1#include <xrpld/app/tx/detail/VaultDelete.h>
3#include <xrpl/ledger/View.h>
4#include <xrpl/protocol/Feature.h>
5#include <xrpl/protocol/MPTIssue.h>
6#include <xrpl/protocol/STNumber.h>
7#include <xrpl/protocol/STTakesAsset.h>
8#include <xrpl/protocol/TER.h>
9#include <xrpl/protocol/TxFlags.h>
16 if (ctx.
tx[sfVaultID] == beast::zero)
18 JLOG(ctx.
j.
debug()) <<
"VaultDelete: zero/empty vault ID.";
32 if (vault->at(sfOwner) != ctx.
tx[sfAccount])
34 JLOG(ctx.
j.
debug()) <<
"VaultDelete: account is not an owner.";
38 if (vault->at(sfAssetsAvailable) != 0)
40 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero assets available.";
44 if (vault->at(sfAssetsTotal) != 0)
46 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero assets total.";
56 JLOG(ctx.
j.
error()) <<
"VaultDeposit: missing issuance of vault shares.";
61 if (sleMPT->at(sfIssuer) != vault->getAccountID(sfAccount))
64 JLOG(ctx.
j.
error()) <<
"VaultDeposit: invalid owner of vault shares.";
69 if (sleMPT->at(sfOutstandingAmount) != 0)
71 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero outstanding shares.";
86 auto asset = vault->at(sfAsset);
91 auto const& pseudoID = vault->at(sfAccount);
96 JLOG(
j_.
error()) <<
"VaultDelete: missing vault pseudo-account.";
103 auto const shareMPTID = *vault->at(sfShareMPTID);
108 JLOG(
j_.
error()) <<
"VaultDelete: missing issuance of vault shares.";
120 <<
"VaultDelete: failed to remove vault owner's MPToken"
132 JLOG(
j_.
error()) <<
"VaultDelete: failed to delete issuance object.";
146 if (!vaultPseudoSLE || vaultPseudoSLE->at(~sfVaultID) != vault->
key())
151 if (*vaultPseudoSLE->at(sfBalance))
154 JLOG(
j_.
error()) <<
"VaultDelete: pseudo-account has a balance";
158 if (vaultPseudoSLE->at(sfOwnerCount) != 0)
161 JLOG(
j_.
error()) <<
"VaultDelete: pseudo-account still owns objects";
168 JLOG(
j_.
error()) <<
"VaultDelete: pseudo-account has a directory";
176 auto const ownerID = vault->at(sfOwner);
180 JLOG(
j_.
error()) <<
"VaultDelete: failed to delete vault object.";
189 JLOG(
j_.
error()) <<
"VaultDelete: missing vault owner account.";
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.
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
static TER preclaim(PreclaimContext const &ctx)
static NotTEC preflight(PreflightContext const &ctx)
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Keylet mptIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Keylet vault(AccountID const &owner, std::uint32_t seq) noexcept
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Keylet account(AccountID const &id) noexcept
AccountID root.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
TER removeEmptyHolding(ApplyView &view, AccountID const &accountID, Issue const &issue, beast::Journal journal)
std::string to_string(base_uint< Bits, Tag > const &a)
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
std::string transToken(TER code)
void adjustOwnerCount(ApplyView &view, std::shared_ptr< SLE > const &sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
bool isTesSuccess(TER x) noexcept
void associateAsset(STLedgerEntry &sle, Asset const &asset)
Associate an Asset with all sMD_NeedsAsset fields in a ledger entry.
TERSubset< CanCvtToNotTEC > NotTEC
State information when determining if a tx is likely to claim a fee.
State information when preflighting a tx.