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.";
50 if (vault->at(sfOwner) != ctx.
tx[sfAccount])
52 JLOG(ctx.
j.
debug()) <<
"VaultDelete: account is not an owner.";
56 if (vault->at(sfAssetsAvailable) != 0)
58 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero assets available.";
62 if (vault->at(sfAssetsTotal) != 0)
64 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero assets total.";
74 JLOG(ctx.
j.
error()) <<
"VaultDelete: missing issuance of vault shares.";
79 if (sleMPT->at(sfIssuer) != vault->getAccountID(sfAccount))
82 JLOG(ctx.
j.
error()) <<
"VaultDelete: invalid owner of vault shares.";
87 if (sleMPT->at(sfOutstandingAmount) != 0)
89 JLOG(ctx.
j.
debug()) <<
"VaultDelete: nonzero outstanding shares.";
100 auto applyViewContext =
ctx_.getApplyViewContext();
105 auto asset = vault->at(sfAsset);
111 auto const& pseudoID = vault->at(sfAccount);
116 JLOG(
j_.error()) <<
"VaultDelete: missing vault pseudo-account.";
123 auto const shareMPTID = *vault->at(sfShareMPTID);
128 JLOG(
j_.error()) <<
"VaultDelete: missing issuance of vault shares.";
142 <<
"VaultDelete: failed to remove vault owner's MPToken"
154 JLOG(
j_.error()) <<
"VaultDelete: failed to delete issuance object.";
168 if (!vaultPseudoSLE || vaultPseudoSLE->at(~sfVaultID) != vault->
key())
173 if (*vaultPseudoSLE->at(sfBalance))
176 JLOG(
j_.error()) <<
"VaultDelete: pseudo-account has a balance";
180 if (vaultPseudoSLE->at(sfOwnerCount) != 0)
183 JLOG(
j_.error()) <<
"VaultDelete: pseudo-account still owns objects";
190 JLOG(
j_.error()) <<
"VaultDelete: pseudo-account has a directory";
198 auto const ownerID = vault->at(sfOwner);
202 JLOG(
j_.error()) <<
"VaultDelete: failed to delete vault object.";
211 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 & ConstRef
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.
static TER preclaim(PreclaimContext const &ctx)
void visitInvariantEntry(bool isDelete, SLE::ConstRef before, SLE::ConstRef after) override
Inspect a single ledger entry modified by this transaction.
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.
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
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.
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.