1#include <xrpl/tx/transactors/system/LedgerStateFix.h>
3#include <xrpl/beast/utility/Journal.h>
4#include <xrpl/ledger/ReadView.h>
5#include <xrpl/ledger/helpers/NFTokenHelpers.h>
6#include <xrpl/protocol/AccountID.h>
7#include <xrpl/protocol/Feature.h>
8#include <xrpl/protocol/Indexes.h>
9#include <xrpl/protocol/LedgerFormats.h>
10#include <xrpl/protocol/SField.h>
11#include <xrpl/protocol/STLedgerEntry.h>
12#include <xrpl/protocol/STTx.h>
13#include <xrpl/protocol/TER.h>
14#include <xrpl/protocol/XRPAmount.h>
15#include <xrpl/tx/Transactor.h>
27std::array<std::pair<FixType, SField const*>, 2>
const kLedgerFixFields = {{
28 {FixType::NfTokenPageLink, &sfOwner},
29 {FixType::BookExchangeRate, &sfBookDirectory},
33fixField(FixType
const fixType)
36 kLedgerFixFields, [fixType](
auto const& entry) {
return entry.first == fixType; });
38 if (iter == kLedgerFixFields.
end())
45hasUnexpectedFixField(
STTx const& tx,
SField const& expected)
49 return field != &expected && tx.isFieldPresent(*field);
58 auto const fixType =
static_cast<FixType>(ctx.
tx[sfLedgerFixType]);
74 auto const expectedField = fixField(fixType);
75 if (expectedField ==
nullptr)
79 if (!ctx.
tx.
isFieldPresent(*expectedField) || hasUnexpectedFixField(ctx.
tx, *expectedField))
113 if (!sle->isFieldPresent(sfExchangeRate))
117 if (
getQuality(sle->key()) == sle->getFieldU64(sfExchangeRate))
140 auto const dirKey =
ctx_.tx.getFieldH256(sfBookDirectory);
145 sle->setFieldU64(sfExchangeRate,
getQuality(sle->key()));
A generic endpoint for log messages.
virtual SLE::pointer peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
virtual void update(SLE::ref sle)=0
Indicate changes to a peeked SLE.
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 XRPAmount calculateBaseFee(ReadView const &view, STTx const &tx)
static NotTEC preflight(PreflightContext const &ctx)
static TER preclaim(PreclaimContext const &ctx)
void visitInvariantEntry(bool isDelete, SLE::const_ref before, SLE::const_ref after) override
Inspect a single ledger entry modified by this transaction.
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
uint256 getFieldH256(SField const &field) const
static XRPAmount calculateOwnerReserveFee(ReadView const &view, STTx const &tx)
FieldT< CharT, Traits, Allocator > field(std::basic_string< CharT, Traits, Allocator > const &text, int width=8, int pad=0, bool right=false)
Keylet account(AccountID const &id) noexcept
AccountID root.
bool repairNFTokenDirectoryLinks(ApplyView &view, AccountID const &owner)
Repairs the links in an NFTokenPage directory.
json::Value entry(jtx::Env &env, jtx::Account const &account, jtx::Account const &authorize)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
@ tefINVALID_LEDGER_FIX_TYPE
std::uint64_t getQuality(uint256 const &uBase)
TERSubset< CanCvtToNotTEC > NotTEC
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
TERSubset< CanCvtToTER > TER
A pair of SHAMap key and LedgerEntryType.
State information when determining if a tx is likely to claim a fee.
State information when preflighting a tx.