1#include <xrpld/app/tx/detail/DID.h>
3#include <xrpl/basics/Log.h>
4#include <xrpl/ledger/ApplyView.h>
5#include <xrpl/ledger/View.h>
6#include <xrpl/protocol/Feature.h>
7#include <xrpl/protocol/Indexes.h>
8#include <xrpl/protocol/TxFlags.h>
38 auto isTooLong = [&](
auto const& sField,
std::size_t length) ->
bool {
39 if (
auto field = ctx.
tx[~sField])
40 return field->length() > length;
64 auto const balance =
STAmount((*sleAccount)[sfBalance]).
xrp();
68 if (balance < reserve)
81 (*sle)[sfOwnerNode] = *page;
96 auto update = [&](
auto const& sField) {
97 if (
auto const field =
ctx_.
tx[~sField])
101 sleDID->makeFieldAbsent(sField);
105 (*sleDID)[sField] = *field;
110 update(sfDIDDocument);
113 if (!sleDID->isFieldPresent(sfURI) &&
114 !sleDID->isFieldPresent(sfDIDDocument) &&
115 !sleDID->isFieldPresent(sfData))
127 auto set = [&](
auto const& sField) {
128 if (
auto const field =
ctx_.
tx[~sField]; field && !field->empty())
129 (*sleDID)[sField] = *field;
136 !sleDID->isFieldPresent(sfURI) &&
137 !sleDID->isFieldPresent(sfDIDDocument) &&
138 !sleDID->isFieldPresent(sfData))
155 auto const sle = ctx.
view().
peek(sleKeylet);
174 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
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.
void adjustOwnerCount(ApplyView &view, std::shared_ptr< SLE > const &sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
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)
@ tecINSUFFICIENT_RESERVE
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.