20#include <xrpld/app/tx/detail/MPTokenAuthorize.h>
21#include <xrpld/ledger/View.h>
23#include <xrpl/protocol/Feature.h>
24#include <xrpl/protocol/TxFlags.h>
25#include <xrpl/protocol/st.h>
41 if (ctx.
tx[sfAccount] == ctx.
tx[~sfHolder])
50 auto const accountID = ctx.
tx[sfAccount];
51 auto const holderID = ctx.
tx[~sfHolder];
76 if ((*sleMpt)[sfMPTAmount] != 0)
78 auto const sleMptIssuance = ctx.
view.
read(
94 auto const sleMptIssuance =
100 if (accountID == (*sleMptIssuance)[sfIssuer])
113 auto const sleMptIssuance =
118 std::uint32_t const mptIssuanceFlags = sleMptIssuance->getFieldU32(sfFlags);
127 if (accountID != (*sleMptIssuance)[sfIssuer])
163 auto const mptokenKey =
165 auto const sleMpt =
view.
peek(mptokenKey);
166 if (!sleMpt || (*sleMpt)[sfMPTAmount] != 0)
171 (*sleMpt)[sfOwnerNode],
191 std::uint32_t const uOwnerCount = sleAcct->getFieldU32(sfOwnerCount);
193 (uOwnerCount < 2) ?
XRPAmount(beast::zero)
199 auto const mptokenKey =
201 auto mptoken = std::make_shared<SLE>(mptokenKey);
205 (*mptoken)[sfAccount] = args.
account;
207 (*mptoken)[sfFlags] = 0;
216 auto const sleMptIssuance =
224 if (args.
account != (*sleMptIssuance)[sfIssuer])
238 flagsOut &= ~lsfMPTAuthorized;
244 if (flagsIn != flagsOut)
245 sleMpt->setFieldU32(sfFlags, flagsOut);
258 {.priorBalance = mPriorBalance,
259 .mptIssuanceID = tx[sfMPTokenIssuanceID],
261 .flags = tx.getFlags(),
262 .holderID = tx[~sfHolder]});
A generic endpoint for log messages.
beast::Journal const journal
Writeable view to a ledger, for applying a transaction.
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to a peeked SLE.
bool dirRemove(Keylet const &directory, std::uint64_t page, uint256 const &key, bool keepRoot)
Remove an entry from a directory.
virtual void insert(std::shared_ptr< SLE > const &sle)=0
Insert a new state SLE.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
virtual void erase(std::shared_ptr< SLE > const &sle)=0
Remove a peeked SLE.
static NotTEC preflight(PreflightContext const &ctx)
static TER preclaim(PreclaimContext const &ctx)
static TER authorize(ApplyView &view, beast::Journal journal, MPTAuthorizeArgs const &args)
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
virtual Fees const & fees() const =0
Returns the fees for the base ledger.
virtual bool exists(Keylet const &k) const =0
Determine if a state item exists.
virtual Rules const & rules() const =0
Returns the tx processing rules.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
std::uint32_t getFlags() const
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Keylet mptIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Keylet account(AccountID const &id) noexcept
AccountID root.
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
constexpr std::uint32_t const tfMPTokenAuthorizeMask
NotTEC preflight1(PreflightContext const &ctx)
Performs early sanity checks on the account and fee fields.
static bool adjustOwnerCount(ApplyContext &ctx, int count)
constexpr std::uint32_t const tfMPTUnauthorize
NotTEC preflight2(PreflightContext const &ctx)
Checks whether the signature appears valid.
@ tecINSUFFICIENT_RESERVE
bool isTesSuccess(TER x) noexcept
TERSubset< CanCvtToNotTEC > NotTEC
TER dirLink(ApplyView &view, AccountID const &owner, std::shared_ptr< SLE > &object)
XRPAmount accountReserve(std::size_t ownerCount) const
Returns the account reserve given the owner count, in drops.
AccountID const & account
std::optional< AccountID > holderID
MPTID const & mptIssuanceID
XRPAmount const & priorBalance
State information when determining if a tx is likely to claim a fee.
State information when preflighting a tx.