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/Feature.h>
11#include <xrpl/protocol/Indexes.h>
12#include <xrpl/protocol/MPTIssue.h>
13#include <xrpl/protocol/Protocol.h>
14#include <xrpl/protocol/SField.h>
15#include <xrpl/protocol/STLedgerEntry.h>
16#include <xrpl/protocol/STNumber.h>
17#include <xrpl/protocol/STTx.h>
18#include <xrpl/protocol/TER.h>
19#include <xrpl/protocol/XRPAmount.h>
20#include <xrpl/tx/Transactor.h>
29 JLOG(ctx.
j.
debug()) <<
"VaultDelete: zero/empty vault ID.";
49 if (vault->at(sfOwner) != ctx.
tx[sfAccount])
51 JLOG(ctx.
j.
debug()) <<
"VaultDelete: account is not an owner.";
55 if (vault->at(sfAssetsAvailable) != 0)
57 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero assets available.";
61 if (vault->at(sfAssetsTotal) != 0)
63 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero assets total.";
73 JLOG(ctx.
j.
error()) <<
"VaultDelete: missing issuance of vault shares.";
78 if (sleMPT->at(sfIssuer) != vault->getAccountID(sfAccount))
81 JLOG(ctx.
j.
error()) <<
"VaultDelete: invalid owner of vault shares.";
86 if (sleMPT->at(sfOutstandingAmount) != 0)
88 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero outstanding shares.";
99 auto applyViewContext =
ctx_.getApplyViewContext();
104 auto asset = vault->at(sfAsset);
110 auto const& pseudoID = vault->at(sfAccount);
115 JLOG(
j_.error()) <<
"VaultDelete: missing vault pseudo-account.";
122 auto const shareMPTID = *vault->at(sfShareMPTID);
127 JLOG(
j_.error()) <<
"VaultDelete: missing issuance of vault shares.";
141 <<
"VaultDelete: failed to remove vault owner's MPToken"
153 JLOG(
j_.error()) <<
"VaultDelete: failed to delete issuance object.";
167 if (!vaultPseudoSLE || vaultPseudoSLE->at(~sfVaultID) != vault->
key())
172 if (*vaultPseudoSLE->at(sfBalance))
175 JLOG(
j_.error()) <<
"VaultDelete: pseudo-account has a balance";
179 if (vaultPseudoSLE->at(sfOwnerCount) != 0)
182 JLOG(
j_.error()) <<
"VaultDelete: pseudo-account still owns objects";
189 JLOG(
j_.error()) <<
"VaultDelete: pseudo-account has a directory";
197 auto const ownerID = vault->at(sfOwner);
201 JLOG(
j_.error()) <<
"VaultDelete: failed to delete vault object.";
210 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.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
std::shared_ptr< STLedgerEntry const > const & const_ref
bool isFieldPresent(SField const &field) const
AccountID const accountID_
static bool validDataLength(std::optional< Slice > const &slice, std::size_t maxLength)
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 ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Keylet vault(AccountID const &owner, SeqProxy const &seq) noexcept
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Keylet account(AccountID const &id) noexcept
AccountID root.
Keylet mptokenIssuance(MPTID const &issuanceID) noexcept
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
void decreaseOwnerCountForObject(ApplyView &view, SLE::ref accountSle, SLE::ref objectSle, std::uint32_t count, beast::Journal j)
Decrease owner-count fields for an existing ledger object.
TER removeEmptyHolding(ApplyViewContext ctx, AccountID const &accountID, MPTIssue const &mptIssue, beast::Journal journal)
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)
constexpr std::size_t kMaxDataPayloadLength
The maximum length of Data payload.
TERSubset< CanCvtToNotTEC > NotTEC
bool isTesSuccess(TER x) noexcept
TERSubset< CanCvtToTER > TER
State information when determining if a tx is likely to claim a fee.
State information when preflighting a tx.