1#include <xrpl/tx/invariants/MPTInvariant.h>
3#include <xrpl/basics/Log.h>
4#include <xrpl/beast/utility/instrumentation.h>
5#include <xrpl/protocol/Feature.h>
6#include <xrpl/protocol/Indexes.h>
7#include <xrpl/protocol/MPTIssue.h>
8#include <xrpl/protocol/TxFormats.h>
9#include <xrpl/tx/invariants/InvariantCheckPrivilege.h>
19 if (
after &&
after->getType() == ltMPTOKEN_ISSUANCE)
41 if (mptIssue.getIssuer() ==
after->at(sfAccount))
57 auto const& rules = view.
rules();
59 bool const enforceCreatedByIssuer =
60 rules.
enabled(featureSingleAssetVault) || rules.enabled(featureLendingProtocol);
63 JLOG(j.
fatal()) <<
"Invariant failed: MPToken created for the MPT issuer";
67 enforceCreatedByIssuer,
"xrpl::ValidMPTIssuance::finalize",
"no issuer MPToken");
68 if (enforceCreatedByIssuer)
77 JLOG(j.
fatal()) <<
"Invariant failed: transaction "
78 "succeeded without creating a MPT issuance";
82 JLOG(j.
fatal()) <<
"Invariant failed: transaction "
83 "succeeded while removing MPT issuances";
87 JLOG(j.
fatal()) <<
"Invariant failed: transaction "
88 "succeeded but created multiple issuances";
98 JLOG(j.
fatal()) <<
"Invariant failed: MPT issuance deletion "
99 "succeeded without removing a MPT issuance";
103 JLOG(j.
fatal()) <<
"Invariant failed: MPT issuance deletion "
104 "succeeded while creating MPT issuances";
108 JLOG(j.
fatal()) <<
"Invariant failed: MPT issuance deletion "
109 "succeeded but deleted multiple issuances";
115 bool const lendingProtocolEnabled = view.
rules().
enabled(featureLendingProtocol);
119 bool const enforceEscrowFinish = (txnType == ttESCROW_FINISH) &&
120 (view.
rules().
enabled(featureSingleAssetVault) || lendingProtocolEnabled);
127 JLOG(j.
fatal()) <<
"Invariant failed: MPT authorize "
128 "succeeded but created MPT issuances";
133 JLOG(j.
fatal()) <<
"Invariant failed: MPT authorize "
134 "succeeded but deleted issuances";
139 JLOG(j.
fatal()) <<
"Invariant failed: MPT authorize succeeded "
140 "but created/deleted bad number mptokens";
145 JLOG(j.
fatal()) <<
"Invariant failed: MPT authorize submitted by issuer "
146 "succeeded but created/deleted mptokens";
154 JLOG(j.
fatal()) <<
"Invariant failed: MPT authorize submitted by holder "
155 "succeeded but created/deleted bad number of mptokens";
161 if (txnType == ttESCROW_FINISH)
167 !enforceEscrowFinish,
"xrpl::ValidMPTIssuance::finalize",
"not escrow finish tx");
178 JLOG(j.
fatal()) <<
"Invariant failed: a MPT issuance was created";
182 JLOG(j.
fatal()) <<
"Invariant failed: a MPT issuance was deleted";
186 JLOG(j.
fatal()) <<
"Invariant failed: a MPToken was created";
190 JLOG(j.
fatal()) <<
"Invariant failed: a MPToken was deleted";
A generic endpoint for log messages.
virtual Rules const & rules() const =0
Returns the tx processing rules.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
bool isFieldPresent(SField const &field) const
TxType getTxnType() const
std::uint32_t mptokensCreated_
void visitEntry(bool, std::shared_ptr< SLE const > const &, std::shared_ptr< SLE const > const &)
std::uint32_t mptokensDeleted_
std::uint32_t mptIssuancesCreated_
bool finalize(STTx const &, TER const, XRPAmount const, ReadView const &, beast::Journal const &) const
std::uint32_t mptIssuancesDeleted_
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
bool hasPrivilege(STTx const &tx, Privilege priv)
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
bool isTesSuccess(TER x) noexcept