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>
34 if (ctx.
tx[sfVaultID] == beast::zero)
36 JLOG(ctx.
j.
debug()) <<
"VaultDelete: zero/empty vault ID.";
50 if (vault->at(sfOwner) != ctx.
tx[sfAccount])
52 JLOG(ctx.
j.
debug()) <<
"VaultDelete: account is not an owner.";
56 if (vault->at(sfAssetsAvailable) != 0)
58 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero assets available.";
62 if (vault->at(sfAssetsTotal) != 0)
64 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero assets total.";
76 <<
"VaultDeposit: missing issuance of vault shares.";
81 if (sleMPT->at(sfIssuer) != vault->getAccountID(sfAccount))
84 JLOG(ctx.
j.
error()) <<
"VaultDeposit: invalid owner of vault shares.";
89 if (sleMPT->at(sfOutstandingAmount) != 0)
91 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero outstanding shares.";
106 auto asset = vault->at(sfAsset);
111 auto const& pseudoID = vault->at(sfAccount);
116 JLOG(
j_.
error()) <<
"VaultDelete: missing vault pseudo-account.";
123 auto const shareMPTID = *vault->at(sfShareMPTID);
128 JLOG(
j_.
error()) <<
"VaultDelete: missing issuance of vault shares.";
142 <<
"VaultDelete: failed to remove vault owner's MPToken"
151 if (!
view().dirRemove(
155 JLOG(
j_.
error()) <<
"VaultDelete: failed to delete issuance object.";
171 auto const ownerID = vault->at(sfOwner);
172 if (!
view().dirRemove(
174 vault->at(sfOwnerNode),
179 JLOG(
j_.
error()) <<
"VaultDelete: failed to delete vault object.";
188 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.
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.
std::string transToken(TER code)
bool isTesSuccess(TER x) noexcept
std::string to_string(base_uint< Bits, Tag > const &a)
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.