remove old isPseudoAccount helper

This commit is contained in:
Mayukha Vadari
2026-04-02 18:28:29 -04:00
parent e9287812ef
commit ffd96e354f
6 changed files with 16 additions and 27 deletions

View File

@@ -197,19 +197,6 @@ isPseudoAccount(
std::shared_ptr<SLE const> sleAcct,
std::set<SField const*> const& pseudoFieldFilter = {});
/** Convenience overload that reads the account from the view. */
[[nodiscard]] inline bool
isPseudoAccount(
ReadView const& view,
AccountID const& accountId,
std::set<SField const*> const& pseudoFieldFilter = {})
{
AccountRoot<ReadView> const acct(accountId, view);
if (!acct)
return false;
return acct.isPseudoAccount(pseudoFieldFilter);
}
/**
* Create pseudo-account, storing pseudoOwnerKey into ownerField.
*

View File

@@ -351,7 +351,8 @@ requireAuth(
if (featureSAVEnabled)
{
// Implicitly authorize Vault and LoanBroker pseudo-accounts
if (isPseudoAccount(view, account, {&sfVaultID, &sfLoanBrokerID}))
AccountRoot const accountRoot(account, view);
if (accountRoot.isPseudoAccount({&sfVaultID, &sfLoanBrokerID}))
return tesSUCCESS;
}

View File

@@ -48,9 +48,9 @@ LoanBrokerCoverWithdraw::preclaim(PreclaimContext const& ctx)
auto const brokerID = tx[sfLoanBrokerID];
auto const amount = tx[sfAmount];
auto const dstAcct = tx[~sfDestination].value_or(account);
auto const dstAcct = AccountRoot(tx[~sfDestination].value_or(account), ctx.view);
if (isPseudoAccount(ctx.view, dstAcct))
if (dstAcct.isPseudoAccount())
{
JLOG(ctx.j.warn()) << "Trying to withdraw into a pseudo-account.";
return tecPSEUDO_ACCOUNT;
@@ -82,13 +82,14 @@ LoanBrokerCoverWithdraw::preclaim(PreclaimContext const& ctx)
// The broker's pseudo-account is the source of funds.
auto const pseudoAccountID = sleBroker->at(sfAccount);
// Cannot transfer a non-transferable Asset
if (auto const ret = canTransfer(ctx.view, vaultAsset, pseudoAccountID, dstAcct))
if (auto const ret = canTransfer(ctx.view, vaultAsset, pseudoAccountID, dstAcct.id());
!isTesSuccess(ret))
return ret;
// Withdrawal to a 3rd party destination account is essentially a transfer.
// Enforce all the usual asset transfer checks.
AuthType authType = AuthType::WeakAuth;
if (account != dstAcct)
if (account != dstAcct.id())
{
if (auto const ret = canWithdraw(ctx.view, tx))
return ret;
@@ -99,17 +100,17 @@ LoanBrokerCoverWithdraw::preclaim(PreclaimContext const& ctx)
}
// Destination MPToken must exist (if asset is an MPT)
if (auto const ter = requireAuth(ctx.view, vaultAsset, dstAcct, authType))
if (auto const ter = requireAuth(ctx.view, vaultAsset, dstAcct.id(), authType))
return ter;
// Check for freezes, unless sending directly to the issuer
if (dstAcct != vaultAsset.getIssuer())
if (dstAcct.id() != vaultAsset.getIssuer())
{
// Cannot send a frozen Asset
if (auto const ret = checkFrozen(ctx.view, pseudoAccountID, vaultAsset))
return ret;
// Destination account cannot receive if asset is deep frozen
if (auto const ret = checkDeepFrozen(ctx.view, dstAcct, vaultAsset))
if (auto const ret = checkDeepFrozen(ctx.view, dstAcct.id(), vaultAsset))
return ret;
}

View File

@@ -70,8 +70,6 @@ TicketCreate::doApply()
return tecINSUFFICIENT_RESERVE;
}
beast::Journal const viewJ{ctx_.registry.get().getJournal("View")};
// The starting ticket sequence is the same as the current account
// root sequence. Before we got here to doApply(), the transaction
// machinery already incremented the account root sequence if that

View File

@@ -94,7 +94,8 @@ MPTokenAuthorize::preclaim(PreclaimContext const& ctx)
return tesSUCCESS;
}
if (AccountRoot const acctHolder(*holderID, ctx.view); !acctHolder)
AccountRoot const holder(*holderID, ctx.view);
if (!holder)
return tecNO_DST;
auto const sleMptIssuance = ctx.view.read(keylet::mptIssuance(ctx.tx[sfMPTokenIssuanceID]));
@@ -125,7 +126,7 @@ MPTokenAuthorize::preclaim(PreclaimContext const& ctx)
// Can't unauthorize the pseudo-accounts because they are implicitly
// always authorized. No need to amendment gate since Vault and LoanBroker
// can only be created if the Vault amendment is enabled.
if (isPseudoAccount(ctx.view, *holderID, {&sfVaultID, &sfLoanBrokerID}))
if (holder.isPseudoAccount({&sfVaultID, &sfLoanBrokerID}))
return tecNO_PERMISSION;
return tesSUCCESS;

View File

@@ -91,7 +91,8 @@ TER
VaultCreate::preclaim(PreclaimContext const& ctx)
{
auto const vaultAsset = ctx.tx[sfAsset];
auto const account = ctx.tx[sfAccount];
auto const& account = ctx.tx[sfAccount];
auto const issuer = AccountRoot(vaultAsset.getIssuer(), ctx.view);
if (auto const ter = canAddHolding(ctx.view, vaultAsset))
return ter;
@@ -101,7 +102,7 @@ VaultCreate::preclaim(PreclaimContext const& ctx)
// impossible to clawback (should the need arise)
if (!vaultAsset.native())
{
if (isPseudoAccount(ctx.view, vaultAsset.getIssuer()))
if (issuer.isPseudoAccount())
return tecWRONG_ASSET;
}