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/TER.h>
8#include <xrpl/protocol/TxFlags.h>
15 if (ctx.
tx[sfVaultID] == beast::zero)
17 JLOG(ctx.
j.
debug()) <<
"VaultDelete: zero/empty vault ID.";
31 if (vault->at(sfOwner) != ctx.
tx[sfAccount])
33 JLOG(ctx.
j.
debug()) <<
"VaultDelete: account is not an owner.";
37 if (vault->at(sfAssetsAvailable) != 0)
39 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero assets available.";
43 if (vault->at(sfAssetsTotal) != 0)
45 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero assets total.";
57 <<
"VaultDeposit: missing issuance of vault shares.";
62 if (sleMPT->at(sfIssuer) != vault->getAccountID(sfAccount))
65 JLOG(ctx.
j.
error()) <<
"VaultDeposit: invalid owner of vault shares.";
70 if (sleMPT->at(sfOutstandingAmount) != 0)
72 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero outstanding shares.";
87 auto asset = vault->at(sfAsset);
92 auto const& pseudoID = vault->at(sfAccount);
97 JLOG(
j_.
error()) <<
"VaultDelete: missing vault pseudo-account.";
104 auto const shareMPTID = *vault->at(sfShareMPTID);
109 JLOG(
j_.
error()) <<
"VaultDelete: missing issuance of vault shares.";
123 <<
"VaultDelete: failed to remove vault owner's MPToken"
132 if (!
view().dirRemove(
136 JLOG(
j_.
error()) <<
"VaultDelete: failed to delete issuance object.";
150 if (!vaultPseudoSLE || vaultPseudoSLE->at(~sfVaultID) != vault->
key())
155 if (*vaultPseudoSLE->at(sfBalance))
158 JLOG(
j_.
error()) <<
"VaultDelete: pseudo-account has a balance";
162 if (vaultPseudoSLE->at(sfOwnerCount) != 0)
165 JLOG(
j_.
error()) <<
"VaultDelete: pseudo-account still owns objects";
172 JLOG(
j_.
error()) <<
"VaultDelete: pseudo-account has a directory";
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.
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.