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 ripple {
8
14
20
21TER
23{
24 // ensure that issuance exists
25 auto const sleMPT =
26 ctx.view.read(keylet::mptIssuance(ctx.tx[sfMPTokenIssuanceID]));
27 if (!sleMPT)
29
30 // ensure it is issued by the tx submitter
31 if ((*sleMPT)[sfIssuer] != ctx.tx[sfAccount])
32 return tecNO_PERMISSION;
33
34 // ensure it has no outstanding balances
35 if ((*sleMPT)[sfOutstandingAmount] != 0)
36 return tecHAS_OBLIGATIONS;
37
38 if ((*sleMPT)[~sfLockedAmount].value_or(0) != 0)
39 return tecHAS_OBLIGATIONS; // LCOV_EXCL_LINE
40
41 return tesSUCCESS;
42}
43
44TER
46{
47 auto const mpt =
48 view().peek(keylet::mptIssuance(ctx_.tx[sfMPTokenIssuanceID]));
49 if (account_ != mpt->getAccountID(sfIssuer))
50 return tecINTERNAL; // LCOV_EXCL_LINE
51
52 if (!view().dirRemove(
53 keylet::ownerDir(account_), (*mpt)[sfOwnerNode], mpt->key(), false))
54 return tefBAD_LEDGER; // LCOV_EXCL_LINE
55
56 view().erase(mpt);
57
59
60 return tesSUCCESS;
61}
62
63} // namespace ripple
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 std::uint32_t getFlagsMask(PreflightContext const &ctx)
static NotTEC preflight(PreflightContext const &ctx)
static TER preclaim(PreclaimContext 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:128
ApplyView & view()
Definition Transactor.h:144
beast::Journal const j_
Definition Transactor.h:126
ApplyContext & ctx_
Definition Transactor.h:124
Keylet mptIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Definition Indexes.cpp:507
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:165
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition Indexes.cpp:355
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
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:1013
@ tefBAD_LEDGER
Definition TER.h:151
@ 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
constexpr std::uint32_t const tfMPTokenIssuanceDestroyMask
Definition TxFlags.h:182
uint256 key
Definition Keylet.h:21
State information when determining if a tx is likely to claim a fee.
Definition Transactor.h:61
ReadView const & view
Definition Transactor.h:64
State information when preflighting a tx.
Definition Transactor.h:16