1#include <xrpl/ledger/View.h>
2#include <xrpl/ledger/helpers/AccountRootHelpers.h>
3#include <xrpl/ledger/helpers/MPTokenHelpers.h>
4#include <xrpl/ledger/helpers/TokenHelpers.h>
5#include <xrpl/protocol/Feature.h>
6#include <xrpl/protocol/MPTIssue.h>
7#include <xrpl/protocol/STNumber.h>
8#include <xrpl/protocol/STTakesAsset.h>
9#include <xrpl/protocol/TER.h>
10#include <xrpl/protocol/TxFlags.h>
11#include <xrpl/tx/transactors/vault/VaultDelete.h>
18 if (ctx.
tx[sfVaultID] == beast::zero)
20 JLOG(ctx.
j.
debug()) <<
"VaultDelete: zero/empty vault ID.";
34 if (vault->at(sfOwner) != ctx.
tx[sfAccount])
36 JLOG(ctx.
j.
debug()) <<
"VaultDelete: account is not an owner.";
40 if (vault->at(sfAssetsAvailable) != 0)
42 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero assets available.";
46 if (vault->at(sfAssetsTotal) != 0)
48 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero assets total.";
58 JLOG(ctx.
j.
error()) <<
"VaultDelete: missing issuance of vault shares.";
63 if (sleMPT->at(sfIssuer) != vault->getAccountID(sfAccount))
66 JLOG(ctx.
j.
error()) <<
"VaultDelete: invalid owner of vault shares.";
71 if (sleMPT->at(sfOutstandingAmount) != 0)
73 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero outstanding shares.";
88 auto asset = vault->at(sfAsset);
93 auto const& pseudoID = vault->at(sfAccount);
98 JLOG(
j_.
error()) <<
"VaultDelete: missing vault pseudo-account.";
105 auto const shareMPTID = *vault->at(sfShareMPTID);
110 JLOG(
j_.
error()) <<
"VaultDelete: missing issuance of vault shares.";
123 <<
"VaultDelete: failed to remove vault owner's MPToken"
135 JLOG(
j_.
error()) <<
"VaultDelete: failed to delete issuance object.";
149 if (!vaultPseudoSLE || vaultPseudoSLE->at(~sfVaultID) != vault->
key())
154 if (*vaultPseudoSLE->at(sfBalance))
157 JLOG(
j_.
error()) <<
"VaultDelete: pseudo-account has a balance";
161 if (vaultPseudoSLE->at(sfOwnerCount) != 0)
164 JLOG(
j_.
error()) <<
"VaultDelete: pseudo-account still owns objects";
171 JLOG(
j_.
error()) <<
"VaultDelete: pseudo-account has a directory";
179 auto const ownerID = vault->at(sfOwner);
183 JLOG(
j_.
error()) <<
"VaultDelete: failed to delete vault object.";
192 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.
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
TER removeEmptyHolding(ApplyView &view, AccountID const &accountID, MPTIssue const &mptIssue, 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.