20#include <xrpld/app/tx/detail/VaultDelete.h>
22#include <xrpl/ledger/View.h>
23#include <xrpl/protocol/Feature.h>
24#include <xrpl/protocol/MPTIssue.h>
25#include <xrpl/protocol/STNumber.h>
26#include <xrpl/protocol/TER.h>
27#include <xrpl/protocol/TxFlags.h>
43 if (ctx.
tx[sfVaultID] == beast::zero)
45 JLOG(ctx.
j.
debug()) <<
"VaultDelete: zero/empty vault ID.";
59 if (vault->at(sfOwner) != ctx.
tx[sfAccount])
61 JLOG(ctx.
j.
debug()) <<
"VaultDelete: account is not an owner.";
65 if (vault->at(sfAssetsAvailable) != 0)
67 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero assets available.";
71 if (vault->at(sfAssetsTotal) != 0)
73 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero assets total.";
85 <<
"VaultDeposit: missing issuance of vault shares.";
90 if (sleMPT->at(sfIssuer) != vault->getAccountID(sfAccount))
93 JLOG(ctx.
j.
error()) <<
"VaultDeposit: invalid owner of vault shares.";
98 if (sleMPT->at(sfOutstandingAmount) != 0)
100 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero outstanding shares.";
115 auto asset = vault->at(sfAsset);
120 auto const& pseudoID = vault->at(sfAccount);
125 JLOG(
j_.
error()) <<
"VaultDelete: missing vault pseudo-account.";
132 auto const shareMPTID = *vault->at(sfShareMPTID);
137 JLOG(
j_.
error()) <<
"VaultDelete: missing issuance of vault shares.";
151 <<
"VaultDelete: failed to remove vault owner's MPToken"
160 if (!
view().dirRemove(
164 JLOG(
j_.
error()) <<
"VaultDelete: failed to delete issuance object.";
180 auto const ownerID = vault->at(sfOwner);
181 if (!
view().dirRemove(
183 vault->at(sfOwnerNode),
188 JLOG(
j_.
error()) <<
"VaultDelete: failed to delete vault object.";
197 JLOG(
j_.
error()) <<
"VaultDelete: missing vault owner account.";
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.
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
std::uint32_t getFlags() const
static NotTEC preflight(PreflightContext const &ctx)
static TER preclaim(PreclaimContext const &ctx)
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Keylet mptIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Keylet vault(AccountID const &owner, std::uint32_t seq) noexcept
Keylet account(AccountID const &id) noexcept
AccountID root.
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
void adjustOwnerCount(ApplyView &view, std::shared_ptr< SLE > const &sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
NotTEC preflight1(PreflightContext const &ctx)
Performs early sanity checks on the account and fee fields.
std::string transToken(TER code)
NotTEC preflight2(PreflightContext const &ctx)
Checks whether the signature appears valid.
bool isTesSuccess(TER x) noexcept
std::string to_string(base_uint< Bits, Tag > const &a)
constexpr std::uint32_t tfUniversalMask
TER removeEmptyHolding(ApplyView &view, AccountID const &accountID, Issue const &issue, beast::Journal journal)
TERSubset< CanCvtToNotTEC > NotTEC
State information when determining if a tx is likely to claim a fee.
State information when preflighting a tx.