1#include <xrpl/ledger/View.h>
2#include <xrpl/protocol/Asset.h>
3#include <xrpl/protocol/Feature.h>
4#include <xrpl/protocol/Indexes.h>
5#include <xrpl/protocol/SField.h>
6#include <xrpl/protocol/STNumber.h>
7#include <xrpl/protocol/STTakesAsset.h>
8#include <xrpl/protocol/TER.h>
9#include <xrpl/protocol/TxFlags.h>
10#include <xrpl/tx/transactors/vault/VaultSet.h>
23 if (ctx.
tx[sfVaultID] == beast::zero)
25 JLOG(ctx.
j.
debug()) <<
"VaultSet: zero/empty vault ID.";
29 if (
auto const data = ctx.
tx[~sfData])
33 JLOG(ctx.
j.
debug()) <<
"VaultSet: invalid data payload size.";
38 if (
auto const assetMax = ctx.
tx[~sfAssetsMaximum])
40 if (*assetMax < beast::zero)
42 JLOG(ctx.
j.
debug()) <<
"VaultSet: invalid max assets.";
50 JLOG(ctx.
j.
debug()) <<
"VaultSet: nothing is being updated.";
65 if (ctx.
tx[sfAccount] != vault->at(sfOwner))
67 JLOG(ctx.
j.
debug()) <<
"VaultSet: account is not an owner.";
71 auto const mptIssuanceID = (*vault)[sfShareMPTID];
76 JLOG(ctx.
j.
error()) <<
"VaultSet: missing issuance of vault shares.";
81 if (
auto const domain = ctx.
tx[~sfDomainID])
84 if (!vault->isFlag(lsfVaultPrivate))
86 JLOG(ctx.
j.
debug()) <<
"VaultSet: vault is not private";
90 if (*domain != beast::zero)
98 if ((sleIssuance->getFlags() & lsfMPTRequireAuth) == 0)
101 JLOG(ctx.
j.
error()) <<
"VaultSet: issuance of vault shares is not private.";
124 auto const vaultAsset = vault->at(sfAsset);
126 auto const mptIssuanceID = (*vault)[sfShareMPTID];
131 JLOG(
j_.
error()) <<
"VaultSet: missing issuance of vault shares.";
137 if (tx.isFieldPresent(sfData))
138 vault->at(sfData) = tx[sfData];
139 if (tx.isFieldPresent(sfAssetsMaximum))
141 if (tx[sfAssetsMaximum] != 0 && tx[sfAssetsMaximum] < *vault->at(sfAssetsTotal))
143 vault->at(sfAssetsMaximum) = tx[sfAssetsMaximum];
146 if (
auto const domainId = tx[~sfDomainID]; domainId)
148 if (*domainId != beast::zero)
155 sleIssuance->setFieldH256(sfDomainID, *domainId);
157 else if (sleIssuance->isFieldPresent(sfDomainID))
159 sleIssuance->makeFieldAbsent(sfDomainID);
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to 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.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
bool isFieldPresent(SField const &field) const
static bool checkExtraFeatures(PreflightContext const &ctx)
static TER preclaim(PreclaimContext const &ctx)
static NotTEC preflight(PreflightContext const &ctx)
Keylet mptIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Keylet vault(AccountID const &owner, std::uint32_t seq) noexcept
Keylet permissionedDomain(AccountID const &account, std::uint32_t seq) noexcept
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::size_t constexpr maxDataPayloadLength
The maximum length of Data payload.
void associateAsset(STLedgerEntry &sle, Asset const &asset)
Associate an Asset with all sMD_NeedsAsset fields in a ledger entry.
State information when determining if a tx is likely to claim a fee.
State information when preflighting a tx.