rippled
Loading...
Searching...
No Matches
MPTokenIssuanceDestroy.cpp
1#include <xrpl/ledger/View.h>
2#include <xrpl/ledger/helpers/AccountRootHelpers.h>
3#include <xrpl/protocol/Feature.h>
4#include <xrpl/protocol/TxFlags.h>
5#include <xrpl/tx/transactors/token/MPTokenIssuanceDestroy.h>
6
7namespace xrpl {
8
14
15TER
17{
18 // ensure that issuance exists
19 auto const sleMPT = ctx.view.read(keylet::mptIssuance(ctx.tx[sfMPTokenIssuanceID]));
20 if (!sleMPT)
22
23 // ensure it is issued by the tx submitter
24 if ((*sleMPT)[sfIssuer] != ctx.tx[sfAccount])
25 return tecNO_PERMISSION;
26
27 // ensure it has no outstanding balances
28 if ((*sleMPT)[sfOutstandingAmount] != 0)
29 return tecHAS_OBLIGATIONS;
30
31 if ((*sleMPT)[~sfLockedAmount].value_or(0) != 0)
32 return tecHAS_OBLIGATIONS; // LCOV_EXCL_LINE
33
34 return tesSUCCESS;
35}
36
37TER
39{
40 auto const mpt = view().peek(keylet::mptIssuance(ctx_.tx[sfMPTokenIssuanceID]));
41 if (account_ != mpt->getAccountID(sfIssuer))
42 return tecINTERNAL; // LCOV_EXCL_LINE
43
44 if (!view().dirRemove(keylet::ownerDir(account_), (*mpt)[sfOwnerNode], mpt->key(), false))
45 return tefBAD_LEDGER; // LCOV_EXCL_LINE
46
47 view().erase(mpt);
48
50
51 return tesSUCCESS;
52}
53
54} // 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 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:116
beast::Journal const j_
Definition Transactor.h:114
ApplyView & view()
Definition Transactor.h:132
ApplyContext & ctx_
Definition Transactor.h:112
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition Indexes.cpp:336
Keylet mptIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Definition Indexes.cpp:474
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:165
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
@ tefBAD_LEDGER
Definition TER.h:150
void adjustOwnerCount(ApplyView &view, std::shared_ptr< SLE > const &sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
@ tecOBJECT_NOT_FOUND
Definition TER.h:307
@ tecINTERNAL
Definition TER.h:291
@ tecNO_PERMISSION
Definition TER.h:286
@ tecHAS_OBLIGATIONS
Definition TER.h:298
TERSubset< CanCvtToNotTEC > NotTEC
Definition TER.h:582
@ tesSUCCESS
Definition TER.h:225
uint256 key
Definition Keylet.h:20
State information when determining if a tx is likely to claim a fee.
Definition Transactor.h:57
ReadView const & view
Definition Transactor.h:60
State information when preflighting a tx.
Definition Transactor.h:14