1#include <xrpl/tx/transactors/vault/VaultDelete.h>
3#include <xrpl/basics/Log.h>
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/beast/utility/Zero.h>
6#include <xrpl/ledger/helpers/AccountRootHelpers.h>
7#include <xrpl/ledger/helpers/MPTokenHelpers.h>
8#include <xrpl/ledger/helpers/TokenHelpers.h>
9#include <xrpl/protocol/AccountID.h>
10#include <xrpl/protocol/Indexes.h>
11#include <xrpl/protocol/MPTIssue.h>
12#include <xrpl/protocol/SField.h>
13#include <xrpl/protocol/STLedgerEntry.h>
14#include <xrpl/protocol/STNumber.h>
15#include <xrpl/protocol/STTx.h>
16#include <xrpl/protocol/TER.h>
17#include <xrpl/protocol/XRPAmount.h>
18#include <xrpl/tx/Transactor.h>
25 if (ctx.
tx[sfVaultID] == beast::kZero)
27 JLOG(ctx.
j.
debug()) <<
"VaultDelete: zero/empty vault ID.";
41 if (vault->at(sfOwner) != ctx.
tx[sfAccount])
43 JLOG(ctx.
j.
debug()) <<
"VaultDelete: account is not an owner.";
47 if (vault->at(sfAssetsAvailable) != 0)
49 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero assets available.";
53 if (vault->at(sfAssetsTotal) != 0)
55 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero assets total.";
65 JLOG(ctx.
j.
error()) <<
"VaultDelete: missing issuance of vault shares.";
70 if (sleMPT->at(sfIssuer) != vault->getAccountID(sfAccount))
73 JLOG(ctx.
j.
error()) <<
"VaultDelete: invalid owner of vault shares.";
78 if (sleMPT->at(sfOutstandingAmount) != 0)
80 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero outstanding shares.";
95 auto asset = vault->at(sfAsset);
100 auto const& pseudoID = vault->at(sfAccount);
105 JLOG(
j_.error()) <<
"VaultDelete: missing vault pseudo-account.";
112 auto const shareMPTID = *vault->at(sfShareMPTID);
117 JLOG(
j_.error()) <<
"VaultDelete: missing issuance of vault shares.";
130 <<
"VaultDelete: failed to remove vault owner's MPToken"
142 JLOG(
j_.error()) <<
"VaultDelete: failed to delete issuance object.";
156 if (!vaultPseudoSLE || vaultPseudoSLE->at(~sfVaultID) != vault->
key())
161 if (*vaultPseudoSLE->at(sfBalance))
164 JLOG(
j_.error()) <<
"VaultDelete: pseudo-account has a balance";
168 if (vaultPseudoSLE->at(sfOwnerCount) != 0)
171 JLOG(
j_.error()) <<
"VaultDelete: pseudo-account still owns objects";
178 JLOG(
j_.error()) <<
"VaultDelete: pseudo-account has a directory";
186 auto const ownerID = vault->at(sfOwner);
190 JLOG(
j_.error()) <<
"VaultDelete: failed to delete vault object.";
199 JLOG(
j_.error()) <<
"VaultDelete: missing vault owner account.";
A generic endpoint for log messages.
virtual SLE::pointer peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
virtual void erase(SLE::ref sle)=0
Remove a peeked SLE.
virtual SLE::const_pointer read(Keylet const &k) const =0
Return the state item associated with a key.
std::shared_ptr< STLedgerEntry const > const & const_ref
AccountID const accountID_
bool finalizeInvariants(STTx const &tx, TER result, XRPAmount fee, ReadView const &view, beast::Journal const &j) override
Check transaction-specific post-conditions after all entries have been visited.
void visitInvariantEntry(bool isDelete, SLE::const_ref before, SLE::const_ref after) override
Inspect a single ledger entry modified by this transaction.
static TER preclaim(PreclaimContext const &ctx)
static NotTEC preflight(PreflightContext const &ctx)
Keylet mptokenIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
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 toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
std::string transToken(TER code)
std::string to_string(BaseUInt< Bits, Tag > const &a)
TERSubset< CanCvtToNotTEC > NotTEC
void adjustOwnerCount(ApplyView &view, SLE::ref sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
bool isTesSuccess(TER x) noexcept
TERSubset< CanCvtToTER > TER
TER removeEmptyHolding(ApplyView &view, AccountID const &accountID, MPTIssue const &mptIssue, beast::Journal journal)
State information when determining if a tx is likely to claim a fee.
State information when preflighting a tx.