xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
libxrpl
tx
transactors
token
MPTokenIssuanceDestroy.cpp
1
#include <xrpl/tx/transactors/token/MPTokenIssuanceDestroy.h>
2
3
#include <xrpl/ledger/helpers/AccountRootHelpers.h>
4
#include <xrpl/protocol/Indexes.h>
5
#include <xrpl/protocol/SField.h>
6
#include <xrpl/protocol/STLedgerEntry.h>
7
#include <xrpl/protocol/STTx.h>
8
#include <xrpl/protocol/TER.h>
9
#include <xrpl/protocol/XRPAmount.h>
10
#include <xrpl/tx/Transactor.h>
11
12
namespace
xrpl
{
13
14
NotTEC
15
MPTokenIssuanceDestroy::preflight
(
PreflightContext
const
& ctx)
16
{
17
return
tesSUCCESS
;
18
}
19
20
TER
21
MPTokenIssuanceDestroy::preclaim
(
PreclaimContext
const
& ctx)
22
{
23
// ensure that issuance exists
24
auto
const
sleMPT = ctx.
view
.
read
(
keylet::mptokenIssuance
(ctx.
tx
[sfMPTokenIssuanceID]));
25
if
(!sleMPT)
26
return
tecOBJECT_NOT_FOUND
;
27
28
// ensure it is issued by the tx submitter
29
if
((*sleMPT)[sfIssuer] != ctx.
tx
[sfAccount])
30
return
tecNO_PERMISSION
;
31
32
// ensure it has no outstanding balances
33
if
((*sleMPT)[sfOutstandingAmount] != 0)
34
return
tecHAS_OBLIGATIONS
;
35
36
if
((*sleMPT)[~sfLockedAmount].value_or(0) != 0)
37
return
tecHAS_OBLIGATIONS
;
// LCOV_EXCL_LINE
38
39
return
tesSUCCESS
;
40
}
41
42
TER
43
MPTokenIssuanceDestroy::doApply
()
44
{
45
auto
const
mpt =
view
().
peek
(
keylet::mptokenIssuance
(
ctx_
.tx[sfMPTokenIssuanceID]));
46
if
(
accountID_
!= mpt->getAccountID(sfIssuer))
47
return
tecINTERNAL
;
// LCOV_EXCL_LINE
48
49
if
(!
view
().dirRemove(
keylet::ownerDir
(
accountID_
), (*mpt)[sfOwnerNode], mpt->key(),
false
))
50
return
tefBAD_LEDGER
;
// LCOV_EXCL_LINE
51
52
decreaseOwnerCountForObject
(
view
(),
accountID_
, mpt, 1,
j_
);
53
view
().
erase
(mpt);
54
55
return
tesSUCCESS
;
56
}
57
58
void
59
MPTokenIssuanceDestroy::visitInvariantEntry
(
bool
,
SLE::ConstRef
,
SLE::ConstRef
)
60
{
61
// No transaction-specific invariants yet (future work).
62
}
63
64
bool
65
MPTokenIssuanceDestroy::finalizeInvariants
(
66
STTx
const
&,
67
TER
,
68
XRPAmount
,
69
ReadView
const
&,
70
beast::Journal
const
&)
71
{
72
// No transaction-specific invariants yet (future work).
73
return
true
;
74
}
75
76
}
// namespace xrpl
beast::Journal
A generic endpoint for log messages.
Definition
Journal.h:44
xrpl::ApplyView::peek
virtual SLE::pointer peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
xrpl::ApplyView::erase
virtual void erase(SLE::Ref sle)=0
Remove a peeked SLE.
xrpl::MPTokenIssuanceDestroy::visitInvariantEntry
void visitInvariantEntry(bool isDelete, SLE::ConstRef before, SLE::ConstRef after) override
Inspect a single ledger entry modified by this transaction.
Definition
MPTokenIssuanceDestroy.cpp:59
xrpl::MPTokenIssuanceDestroy::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition
MPTokenIssuanceDestroy.cpp:21
xrpl::MPTokenIssuanceDestroy::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition
MPTokenIssuanceDestroy.cpp:15
xrpl::MPTokenIssuanceDestroy::finalizeInvariants
bool finalizeInvariants(STTx const &tx, TER result, XRPAmount fee, ReadView const &view, beast::Journal const &j) override
Check transaction-specific post-conditions after all entries have been visited.
Definition
MPTokenIssuanceDestroy.cpp:65
xrpl::MPTokenIssuanceDestroy::doApply
TER doApply() override
Definition
MPTokenIssuanceDestroy.cpp:43
xrpl::ReadView
A view into a ledger.
Definition
ReadView.h:41
xrpl::ReadView::read
virtual SLE::const_pointer read(Keylet const &k) const =0
Return the state item associated with a key.
xrpl::STLedgerEntry::ConstRef
std::shared_ptr< STLedgerEntry const > const & ConstRef
Definition
STLedgerEntry.h:37
xrpl::STTx
Definition
STTx.h:43
xrpl::Transactor::j_
beast::Journal const j_
Definition
Transactor.h:164
xrpl::Transactor::view
ApplyView & view()
Definition
Transactor.h:184
xrpl::Transactor::accountID_
AccountID const accountID_
Definition
Transactor.h:166
xrpl::Transactor::ctx_
ApplyContext & ctx_
Definition
Transactor.h:162
xrpl::XRPAmount
Definition
XRPAmount.h:28
xrpl::keylet::ownerDir
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition
Indexes.cpp:403
xrpl::keylet::mptokenIssuance
Keylet mptokenIssuance(MPTID const &issuanceID) noexcept
Definition
Indexes.cpp:567
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::tefBAD_LEDGER
@ tefBAD_LEDGER
Definition
TER.h:165
xrpl::NotTEC
TERSubset< CanCvtToNotTEC > NotTEC
Definition
TER.h:614
xrpl::decreaseOwnerCountForObject
void decreaseOwnerCountForObject(ApplyView &view, SLE::Ref accountSle, SLE::Ref objectSle, std::uint32_t count, beast::Journal j)
Decrease owner-count fields for an existing ledger object.
Definition
AccountRootHelpers.cpp:359
xrpl::TER
TERSubset< CanCvtToTER > TER
Definition
TER.h:654
xrpl::tecOBJECT_NOT_FOUND
@ tecOBJECT_NOT_FOUND
Definition
TER.h:334
xrpl::tecINTERNAL
@ tecINTERNAL
Definition
TER.h:318
xrpl::tecNO_PERMISSION
@ tecNO_PERMISSION
Definition
TER.h:313
xrpl::tecHAS_OBLIGATIONS
@ tecHAS_OBLIGATIONS
Definition
TER.h:325
xrpl::tesSUCCESS
@ tesSUCCESS
Definition
TER.h:250
xrpl::PreclaimContext
State information when determining if a tx is likely to claim a fee.
Definition
Transactor.h:92
xrpl::PreclaimContext::view
ReadView const & view
Definition
Transactor.h:95
xrpl::PreclaimContext::tx
STTx const & tx
Definition
Transactor.h:98
xrpl::PreflightContext
State information when preflighting a tx.
Definition
Transactor.h:39
Generated by
1.17.0