more usage of IOUToken

This commit is contained in:
Mayukha Vadari
2026-03-21 22:43:00 -07:00
parent ad2c359f21
commit 7e62ecb63b
20 changed files with 43 additions and 53 deletions

View File

@@ -3,7 +3,7 @@
#include <xrpl/beast/utility/Journal.h>
#include <xrpl/ledger/ApplyView.h>
#include <xrpl/ledger/ReadView.h>
#include <xrpl/ledger/helpersWrappedSLEBase.h>
#include <xrpl/ledger/helpers/WrappedSLEBase.h>
#include <xrpl/protocol/Asset.h>
#include <xrpl/protocol/MPTIssue.h>
#include <xrpl/protocol/Rate.h>

View File

@@ -1,6 +1,6 @@
#pragma once
#include <xrpl/ledger/entries/MPTokenHelpers.h>
#include <xrpl/ledger/helpers/MPTokenHelpers.h>
#include <xrpl/protocol/STAmount.h>
#include <xrpl/protocol/STLedgerEntry.h>

View File

@@ -1,6 +1,6 @@
#pragma once
#include <xrpl/ledger/entries/MPTokenHelpers.h>
#include <xrpl/ledger/helpers/MPTokenHelpers.h>
#include <xrpl/tx/Transactor.h>
namespace xrpl {

View File

@@ -2,7 +2,7 @@
#include <xrpl/basics/StringUtilities.h>
#include <xrpl/ledger/AcceptedLedgerTx.h>
#include <xrpl/ledger/View.h>
#include <xrpl/ledger/helpersTokenHelpers.h>
#include <xrpl/ledger/helpers/TokenHelpers.h>
#include <xrpl/protocol/UintTypes.h>
#include <xrpl/protocol/jss.h>

View File

@@ -1,9 +1,9 @@
#include <xrpl/ledger/helpersMPTokenHelpers.h>
#include <xrpl/ledger/helpers/MPTokenHelpers.h>
//
#include <xrpl/basics/Log.h>
#include <xrpl/ledger/helpersAccountRootHelpers.h>
#include <xrpl/ledger/helpersCredentialHelpers.h>
#include <xrpl/ledger/helpersDirectoryHelpers.h>
#include <xrpl/ledger/helpers/AccountRootHelpers.h>
#include <xrpl/ledger/helpers/CredentialHelpers.h>
#include <xrpl/ledger/helpers/DirectoryHelpers.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/Indexes.h>
#include <xrpl/protocol/LedgerFormats.h>

View File

@@ -1,11 +1,11 @@
#include <xrpl/ledger/helpersRippleStateHelpers.h>
#include <xrpl/ledger/helpers/RippleStateHelpers.h>
//
#include <xrpl/basics/Log.h>
#include <xrpl/ledger/ApplyView.h>
#include <xrpl/ledger/ReadView.h>
#include <xrpl/ledger/View.h>
#include <xrpl/ledger/helpersAccountRootHelpers.h>
#include <xrpl/ledger/helpersDirectoryHelpers.h>
#include <xrpl/ledger/helpers/AccountRootHelpers.h>
#include <xrpl/ledger/helpers/DirectoryHelpers.h>
#include <xrpl/protocol/AmountConversions.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/Indexes.h>

View File

@@ -3,7 +3,7 @@
#include <xrpl/basics/Log.h>
#include <xrpl/beast/utility/instrumentation.h>
#include <xrpl/ledger/View.h>
#include <xrpl/ledger/helpersTokenHelpers.h>
#include <xrpl/ledger/helpers/TokenHelpers.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/Indexes.h>
#include <xrpl/protocol/LedgerFormats.h>

View File

@@ -1,6 +1,6 @@
#include <xrpl/basics/Log.h>
#include <xrpl/ledger/View.h>
#include <xrpl/ledger/helpersRippleStateHelpers.h>
#include <xrpl/ledger/helpers/RippleStateHelpers.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/LedgerFormats.h>
#include <xrpl/tx/paths/OfferStream.h>

View File

@@ -154,15 +154,15 @@ CheckCash::preclaim(PreclaimContext const& ctx)
// An issuer can always accept their own currency.
if (!value.native() && (value.getIssuer() != dstId))
{
AccountRoot const acctIssuer(issuerId, ctx.view);
if (!acctIssuer)
IOUToken const iouToken(ctx.view, issuerId, currency);
if (!iouToken)
{
JLOG(ctx.j.warn())
<< "Can't receive IOUs from non-existent issuer: " << to_string(issuerId);
return tecNO_ISSUER;
}
if (acctIssuer->at(sfFlags) & lsfRequireAuth)
if (iouToken.requiresAuth())
{
auto const sleTrustLine = ctx.view.read(keylet::line(dstId, issuerId, currency));

View File

@@ -1,6 +1,7 @@
#include <xrpl/basics/Log.h>
#include <xrpl/ledger/View.h>
#include <xrpl/ledger/helpers/AccountRootHelpers.h>
#include <xrpl/ledger/helpers/RippleStateHelpers.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/Indexes.h>
#include <xrpl/protocol/TER.h>
@@ -83,10 +84,10 @@ CheckCreate::preclaim(PreclaimContext const& ctx)
STAmount const sendMax{ctx.tx[sfSendMax]};
if (!sendMax.native())
{
IOUToken const iouToken(ctx.view, sendMax.issue());
// The currency may not be globally frozen
AccountID const issuerId{sendMax.getIssuer()};
AccountRoot wrappedIssuer(issuerId, ctx.view);
if (wrappedIssuer.isGlobalFrozen())
if (iouToken.isGlobalFrozen())
{
JLOG(ctx.j.warn()) << "Creating a check for frozen asset";
return tecFROZEN;
@@ -97,27 +98,15 @@ CheckCreate::preclaim(PreclaimContext const& ctx)
// Note that we DO allow create check for a currency that the
// account does not yet have a trustline to.
AccountID const srcId{ctx.tx.getAccountID(sfAccount)};
if (issuerId != srcId)
if (iouToken.isFrozen(srcId))
{
// Check if the issuer froze the line
auto const sleTrust =
ctx.view.read(keylet::line(srcId, issuerId, sendMax.getCurrency()));
if (sleTrust && sleTrust->isFlag((issuerId > srcId) ? lsfHighFreeze : lsfLowFreeze))
{
JLOG(ctx.j.warn()) << "Creating a check for frozen trustline.";
return tecFROZEN;
}
JLOG(ctx.j.warn()) << "Creating a check for frozen trustline.";
return tecFROZEN;
}
if (issuerId != dstId)
if (iouToken.isFrozen(dstId))
{
// Check if dst froze the line.
auto const sleTrust =
ctx.view.read(keylet::line(issuerId, dstId, sendMax.getCurrency()));
if (sleTrust && sleTrust->isFlag((dstId > issuerId) ? lsfHighFreeze : lsfLowFreeze))
{
JLOG(ctx.j.warn()) << "Creating a check for destination frozen trustline.";
return tecFROZEN;
}
JLOG(ctx.j.warn()) << "Creating a check for destination frozen trustline.";
return tecFROZEN;
}
}
}

View File

@@ -2,7 +2,8 @@
#include <xrpl/beast/utility/WrappedSink.h>
#include <xrpl/ledger/OrderBookDB.h>
#include <xrpl/ledger/PaymentSandbox.h>
#include <xrpl/ledger/helpersTokenHelpers.h>
#include <xrpl/ledger/helpers/RippleStateHelpers.h>
#include <xrpl/ledger/helpers/TokenHelpers.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/STAmount.h>
#include <xrpl/protocol/TER.h>
@@ -214,9 +215,9 @@ OfferCreate::checkAcceptAsset(
// Only valid for custom currencies
XRPL_ASSERT(!isXRP(issue.currency), "xrpl::OfferCreate::checkAcceptAsset : input is not XRP");
AccountRoot const issuerAcct(issue.account, view);
IOUToken const iouToken(view, issue);
if (!issuerAcct)
if (!iouToken)
{
JLOG(j.debug()) << "delay: can't receive IOUs from non-existent issuer: "
<< to_string(issue.account);
@@ -230,7 +231,7 @@ OfferCreate::checkAcceptAsset(
if (issue.account == id)
return tesSUCCESS;
if (issuerAcct->getFlags() & lsfRequireAuth)
if (iouToken.requiresAuth())
{
auto const trustLine = view.read(keylet::line(id, issue.account, issue.currency));

View File

@@ -1,6 +1,6 @@
#include <xrpl/tx/transactors/lending/LoanBrokerSet.h>
//
#include <xrpl/ledger/helpersTokenHelpers.h>
#include <xrpl/ledger/helpers/TokenHelpers.h>
#include <xrpl/protocol/STTakesAsset.h>
#include <xrpl/tx/transactors/lending/LendingHelpers.h>

View File

@@ -1009,8 +1009,8 @@ checkTrustlineAuthorized(
if (view.rules().enabled(fixEnforceNFTokenTrustlineV2))
{
AccountRoot const acctIssuer(issue.account, view);
if (!acctIssuer)
IOUToken const iouToken(view, issue);
if (!iouToken)
{
JLOG(j.debug()) << "xrpl::nft::checkTrustlineAuthorized: can't "
"receive IOUs from non-existent issuer: "
@@ -1027,7 +1027,7 @@ checkTrustlineAuthorized(
return tesSUCCESS;
}
if (acctIssuer->isFlag(lsfRequireAuth))
if (iouToken.requiresAuth())
{
auto const trustLine = view.read(keylet::line(id, issue.account, issue.currency));

View File

@@ -1,5 +1,5 @@
#include <xrpl/ledger/View.h>
#include <xrpl/ledger/entries/MPTokenHelpers.h>
#include <xrpl/ledger/helpers/MPTokenHelpers.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/TxFlags.h>
#include <xrpl/tx/transactors/token/MPTokenIssuanceDestroy.h>

View File

@@ -1,4 +1,4 @@
#include <xrpl/ledger/entries/MPTokenHelpers.h>
#include <xrpl/ledger/helpers/MPTokenHelpers.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/LedgerFormats.h>
#include <xrpl/protocol/TxFlags.h>

View File

@@ -1,6 +1,6 @@
#include <xrpl/ledger/View.h>
#include <xrpl/ledger/helpersMPTokenHelpers.h>
#include <xrpl/ledger/helpersTokenHelpers.h>
#include <xrpl/ledger/helpers/MPTokenHelpers.h>
#include <xrpl/ledger/helpers/TokenHelpers.h>
#include <xrpl/protocol/Asset.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/Indexes.h>

View File

@@ -1,5 +1,5 @@
#include <xrpl/ledger/View.h>
#include <xrpl/ledger/entries/MPTokenHelpers.h>
#include <xrpl/ledger/helpers/MPTokenHelpers.h>
#include <xrpl/protocol/Asset.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/Indexes.h>

View File

@@ -7,7 +7,7 @@
#include <xrpl/ledger/OpenView.h>
#include <xrpl/ledger/PaymentSandbox.h>
#include <xrpl/ledger/Sandbox.h>
#include <xrpl/ledger/helpersTokenHelpers.h>
#include <xrpl/ledger/helpers/TokenHelpers.h>
#include <xrpl/protocol/Feature.h>
#include <type_traits>

View File

@@ -7,7 +7,7 @@
#include <xrpld/rpc/MPTokenIssuanceID.h>
#include <xrpl/basics/base_uint.h>
#include <xrpl/ledger/helpersTokenHelpers.h>
#include <xrpl/ledger/helpers/TokenHelpers.h>
#include <xrpl/protocol/ApiVersion.h>
#include <xrpl/protocol/jss.h>

View File

@@ -43,7 +43,7 @@
#include <xrpl/git/Git.h>
#include <xrpl/ledger/AmendmentTable.h>
#include <xrpl/ledger/OrderBookDB.h>
#include <xrpl/ledger/helpersTokenHelpers.h>
#include <xrpl/ledger/helpers/TokenHelpers.h>
#include <xrpl/protocol/BuildInfo.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/MultiApiJson.h>