20#include <xrpld/app/tx/detail/DID.h>
22#include <xrpld/ledger/ApplyView.h>
23#include <xrpld/ledger/View.h>
24#include <xrpl/basics/Log.h>
25#include <xrpl/protocol/Feature.h>
26#include <xrpl/protocol/Indexes.h>
27#include <xrpl/protocol/TxFlags.h>
28#include <xrpl/protocol/st.h>
67 auto isTooLong = [&](
auto const& sField,
std::size_t length) ->
bool {
68 if (
auto field = ctx.
tx[~sField])
69 return field->length() > length;
93 auto const balance =
STAmount((*sleAccount)[sfBalance]).
xrp();
97 if (balance < reserve)
110 (*sle)[sfOwnerNode] = *page;
125 auto update = [&](
auto const& sField) {
126 if (
auto const field =
ctx_.
tx[~sField])
130 sleDID->makeFieldAbsent(sField);
134 (*sleDID)[sField] = *field;
139 update(sfDIDDocument);
142 if (!sleDID->isFieldPresent(sfURI) &&
143 !sleDID->isFieldPresent(sfDIDDocument) &&
144 !sleDID->isFieldPresent(sfData))
153 auto const sleDID = std::make_shared<SLE>(didKeylet);
156 auto set = [&](
auto const& sField) {
157 if (
auto const field =
ctx_.
tx[~sField]; field && !field->empty())
158 (*sleDID)[sField] = *field;
165 !sleDID->isFieldPresent(sfURI) &&
166 !sleDID->isFieldPresent(sfDIDDocument) &&
167 !sleDID->isFieldPresent(sfData))
193 auto const sle = ctx.
view().
peek(sleKeylet);
211 JLOG(j.
fatal()) <<
"Unable to delete DID Token from owner.";
A generic endpoint for log messages.
State information when applying a tx.
beast::Journal const journal
Writeable view to a ledger, for applying a transaction.
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to a peeked SLE.
bool dirRemove(Keylet const &directory, std::uint64_t page, uint256 const &key, bool keepRoot)
Remove an entry from a directory.
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.
virtual void erase(std::shared_ptr< SLE > const &sle)=0
Remove a peeked SLE.
static NotTEC preflight(PreflightContext const &ctx)
static TER deleteSLE(ApplyContext &ctx, Keylet sleKeylet, AccountID const owner)
static NotTEC preflight(PreflightContext const &ctx)
virtual Fees const & fees() const =0
Returns the fees for the base ledger.
virtual Rules const & rules() const =0
Returns the tx processing rules.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
bool isFieldPresent(SField const &field) const
std::uint32_t getFlags() const
Keylet did(AccountID const &account) noexcept
Keylet account(AccountID const &id) noexcept
AccountID root.
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::size_t constexpr maxDIDURILength
The maximum length of a URI inside a DID.
std::size_t constexpr maxDIDAttestationLength
The maximum length of an Attestation inside a DID.
TER addSLE(ApplyContext &ctx, std::shared_ptr< SLE > const &sle, AccountID const &owner)
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::function< void(SLE::ref)> describeOwnerDir(AccountID const &account)
NotTEC preflight1(PreflightContext const &ctx)
Performs early sanity checks on the account and fee fields.
static bool adjustOwnerCount(ApplyContext &ctx, int count)
NotTEC preflight2(PreflightContext const &ctx)
Checks whether the signature appears valid.
@ tecINSUFFICIENT_RESERVE
constexpr std::uint32_t tfUniversalMask
TERSubset< CanCvtToTER > TER
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.