1#include <xrpl/ledger/View.h>
2#include <xrpl/ledger/helpers/AccountRootHelpers.h>
3#include <xrpl/ledger/helpers/DirectoryHelpers.h>
4#include <xrpl/ledger/helpers/MPTokenHelpers.h>
5#include <xrpl/protocol/Feature.h>
6#include <xrpl/protocol/TxFlags.h>
7#include <xrpl/protocol/st.h>
8#include <xrpl/tx/transactors/token/MPTokenAuthorize.h>
15 return tfMPTokenAuthorizeMask;
21 if (ctx.
tx[sfAccount] == ctx.
tx[~sfHolder])
30 auto const accountID = ctx.
tx[sfAccount];
31 auto const holderID = ctx.
tx[~sfHolder];
51 if ((ctx.
tx.
getFlags() & tfMPTUnauthorize) != 0u)
56 if ((*sleMpt)[sfMPTAmount] != 0)
58 auto const sleMptIssuance =
66 if ((*sleMpt)[~sfLockedAmount].value_or(0) != 0)
68 auto const sleMptIssuance =
75 if (ctx.
view.
rules().
enabled(featureSingleAssetVault) && sleMpt->isFlag(lsfMPTLocked))
87 if (accountID == (*sleMptIssuance)[sfIssuer])
105 std::uint32_t const mptIssuanceFlags = sleMptIssuance->getFieldU32(sfFlags);
114 if (accountID != (*sleMptIssuance)[sfIssuer])
119 if ((mptIssuanceFlags & lsfMPTRequireAuth) == 0u)
138 MPTID const& mptIssuanceID,
144 auto const ownerNode =
151 (*mptoken)[sfAccount] = account;
152 (*mptoken)[sfMPTokenIssuanceID] = mptIssuanceID;
153 (*mptoken)[sfFlags] = flags;
154 (*mptoken)[sfOwnerNode] = *ownerNode;
168 tx[sfMPTokenIssuanceID],
beast::Journal const journal
Writeable view to a ledger, for applying a transaction.
virtual void insert(std::shared_ptr< SLE > const &sle)=0
Insert a new state SLE.
std::optional< std::uint64_t > dirInsert(Keylet const &directory, uint256 const &key, std::function< void(std::shared_ptr< SLE > const &)> const &describe)
Insert an entry to a directory.
static std::uint32_t getFlagsMask(PreflightContext const &ctx)
static TER preclaim(PreclaimContext const &ctx)
static NotTEC preflight(PreflightContext const &ctx)
static TER createMPToken(ApplyView &view, MPTID const &mptIssuanceID, AccountID const &account, std::uint32_t const flags)
virtual Rules const & rules() const =0
Returns the tx processing rules.
virtual bool exists(Keylet const &k) const =0
Determine if a state item exists.
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
std::uint32_t getFlags() const
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Keylet mptIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Keylet account(AccountID const &id) noexcept
AccountID root.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
TER authorizeMPToken(ApplyView &view, XRPAmount const &priorBalance, MPTID const &mptIssuanceID, AccountID const &account, beast::Journal journal, std::uint32_t flags=0, std::optional< AccountID > holderID=std::nullopt)
bool isPseudoAccount(std::shared_ptr< SLE const > sleAcct, std::set< SField const * > const &pseudoFieldFilter={})
Returns true if and only if sleAcct is a pseudo-account or specific pseudo-accounts in pseudoFieldFil...
std::function< void(SLE::ref)> describeOwnerDir(AccountID const &account)
Returns a function that sets the owner on a directory SLE.
State information when determining if a tx is likely to claim a fee.
State information when preflighting a tx.