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(
90 auto const sleMptIssuance =
96 if (accountID == (*sleMptIssuance)[sfIssuer])
109 auto const sleMptIssuance =
114 std::uint32_t const mptIssuanceFlags = sleMptIssuance->getFieldU32(sfFlags);
123 if (accountID != (*sleMptIssuance)[sfIssuer])
159 auto const mptokenKey =
161 auto const sleMpt =
view.
peek(mptokenKey);
162 if (!sleMpt || (*sleMpt)[sfMPTAmount] != 0)
167 (*sleMpt)[sfOwnerNode],
187 std::uint32_t const uOwnerCount = sleAcct->getFieldU32(sfOwnerCount);
189 (uOwnerCount < 2) ?
XRPAmount(beast::zero)
195 auto const mptokenKey =
206 auto mptoken = std::make_shared<SLE>(mptokenKey);
207 (*mptoken)[sfAccount] = args.
account;
209 (*mptoken)[sfFlags] = 0;
210 (*mptoken)[sfOwnerNode] = *ownerNode;
219 auto const sleMptIssuance =
227 if (args.
account != (*sleMptIssuance)[sfIssuer])
241 flagsOut &= ~lsfMPTAuthorized;
247 if (flagsIn != flagsOut)
248 sleMpt->setFieldU32(sfFlags, flagsOut);
261 {.priorBalance = mPriorBalance,
262 .mptIssuanceID = tx[sfMPTokenIssuanceID],
264 .flags = tx.getFlags(),
265 .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.
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.
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.
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
std::function< void(SLE::ref)> describeOwnerDir(AccountID const &account)
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
TERSubset< CanCvtToNotTEC > NotTEC
XRPAmount accountReserve(std::size_t ownerCount) const
Returns the account reserve given the owner count, in drops.
AccountID const & account
std::optional< AccountID > holderID
uint192 const & mptIssuanceID
XRPAmount const & priorBalance
State information when determining if a tx is likely to claim a fee.
State information when preflighting a tx.