1#include <xrpl/basics/Log.h>
2#include <xrpl/ledger/ApplyView.h>
3#include <xrpl/ledger/helpers/AccountRootHelpers.h>
4#include <xrpl/ledger/helpers/DirectoryHelpers.h>
5#include <xrpl/protocol/Feature.h>
6#include <xrpl/protocol/Indexes.h>
7#include <xrpl/protocol/TxFlags.h>
8#include <xrpl/tx/transactors/did/DIDSet.h>
38 auto isTooLong = [&](
auto const& sField,
std::size_t length) ->
bool {
39 if (
auto field = ctx.
tx[~sField])
40 return field->length() > length;
60 auto const balance =
STAmount((*sleAccount)[sfBalance]).
xrp();
63 if (balance < reserve)
76 (*sle)[sfOwnerNode] = *page;
91 auto update = [&](
auto const& sField) {
92 if (
auto const field =
ctx_.
tx[~sField])
96 sleDID->makeFieldAbsent(sField);
100 (*sleDID)[sField] = *field;
105 update(sfDIDDocument);
108 if (!sleDID->isFieldPresent(sfURI) && !sleDID->isFieldPresent(sfDIDDocument) &&
109 !sleDID->isFieldPresent(sfData))
121 auto set = [&](
auto const& sField) {
122 if (
auto const field =
ctx_.
tx[~sField]; field && !field->empty())
123 (*sleDID)[sField] = *field;
130 !sleDID->isFieldPresent(sfDIDDocument) && !sleDID->isFieldPresent(sfData))
State information when applying a tx.
beast::Journal const journal
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to a peeked SLE.
virtual void insert(std::shared_ptr< SLE > const &sle)=0
Insert a new state SLE.
std::optional< std::uint64_t > dirInsert(Keylet const &directory, uint256 const &key, std::function< void(std::shared_ptr< SLE > const &)> const &describe)
Insert an entry to a directory.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
static NotTEC preflight(PreflightContext const &ctx)
virtual Rules const & rules() const =0
Returns the tx processing rules.
virtual Fees const & fees() const =0
Returns the fees for the base ledger.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
bool isFieldPresent(SField const &field) const
Keylet did(AccountID const &account) noexcept
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Keylet account(AccountID const &id) noexcept
AccountID root.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
bool set(T &target, std::string const &name, Section const §ion)
Set a value from a configuration Section If the named value is not found or doesn't parse as a T,...
std::size_t constexpr maxDIDDocumentLength
The maximum length of a Data element inside a DID.
std::size_t constexpr maxDIDURILength
The maximum length of a URI inside a DID.
std::size_t constexpr maxDIDDataLength
The maximum length of an Attestation inside a DID.
TERSubset< CanCvtToTER > TER
void adjustOwnerCount(ApplyView &view, std::shared_ptr< SLE > const &sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
std::function< void(SLE::ref)> describeOwnerDir(AccountID const &account)
Returns a function that sets the owner on a directory SLE.
static TER addSLE(ApplyContext &ctx, std::shared_ptr< SLE > const &sle, AccountID const &owner)
@ tecINSUFFICIENT_RESERVE
TERSubset< CanCvtToNotTEC > NotTEC
XRPAmount accountReserve(std::size_t ownerCount) const
Returns the account reserve given the owner count, in drops.
A pair of SHAMap key and LedgerEntryType.
State information when preflighting a tx.