rippled
Loading...
Searching...
No Matches
MPTokenIssuanceDestroy.cpp
1#include <xrpld/app/tx/detail/MPTokenIssuanceDestroy.h>
2
3#include <xrpl/ledger/View.h>
4#include <xrpl/protocol/Feature.h>
5#include <xrpl/protocol/TxFlags.h>
6
7namespace xrpl {
8
14
20
21TER
23{
24 // ensure that issuance exists
25 auto const sleMPT = ctx.view.read(keylet::mptIssuance(ctx.tx[sfMPTokenIssuanceID]));
26 if (!sleMPT)
28
29 // ensure it is issued by the tx submitter
30 if ((*sleMPT)[sfIssuer] != ctx.tx[sfAccount])
31 return tecNO_PERMISSION;
32
33 // ensure it has no outstanding balances
34 if ((*sleMPT)[sfOutstandingAmount] != 0)
35 return tecHAS_OBLIGATIONS;
36
37 if ((*sleMPT)[~sfLockedAmount].value_or(0) != 0)
38 return tecHAS_OBLIGATIONS; // LCOV_EXCL_LINE
39
40 return tesSUCCESS;
41}
42
43TER
45{
46 auto const mpt = view().peek(keylet::mptIssuance(ctx_.tx[sfMPTokenIssuanceID]));
47 if (account_ != mpt->getAccountID(sfIssuer))
48 return tecINTERNAL; // LCOV_EXCL_LINE
49
50 if (!view().dirRemove(keylet::ownerDir(account_), (*mpt)[sfOwnerNode], mpt->key(), false))
51 return tefBAD_LEDGER; // LCOV_EXCL_LINE
52
53 view().erase(mpt);
54
56
57 return tesSUCCESS;
58}
59
60} // namespace xrpl
STTx const & tx
virtual void erase(std::shared_ptr< SLE > const &sle)=0
Remove a peeked SLE.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
static std::uint32_t getFlagsMask(PreflightContext const &ctx)
static TER preclaim(PreclaimContext const &ctx)
static NotTEC preflight(PreflightContext const &ctx)
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
AccountID const account_
Definition Transactor.h:113
beast::Journal const j_
Definition Transactor.h:111
ApplyView & view()
Definition Transactor.h:129
ApplyContext & ctx_
Definition Transactor.h:109
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition Indexes.cpp:325
Keylet mptIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Definition Indexes.cpp:462
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:160
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
@ tefBAD_LEDGER
Definition TER.h:151
void adjustOwnerCount(ApplyView &view, std::shared_ptr< SLE > const &sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
Definition View.cpp:941
constexpr std::uint32_t const tfMPTokenIssuanceDestroyMask
Definition TxFlags.h:182
@ tecOBJECT_NOT_FOUND
Definition TER.h:308
@ tecINTERNAL
Definition TER.h:292
@ tecNO_PERMISSION
Definition TER.h:287
@ tecHAS_OBLIGATIONS
Definition TER.h:299
@ tesSUCCESS
Definition TER.h:226
uint256 key
Definition Keylet.h:21
State information when determining if a tx is likely to claim a fee.
Definition Transactor.h:54
ReadView const & view
Definition Transactor.h:57
State information when preflighting a tx.
Definition Transactor.h:16