1#include <xrpl/tx/transactors/did/DIDSet.h>
3#include <xrpl/core/ServiceRegistry.h>
4#include <xrpl/ledger/ApplyView.h>
5#include <xrpl/ledger/ReadView.h>
6#include <xrpl/ledger/helpers/AccountRootHelpers.h>
7#include <xrpl/ledger/helpers/DirectoryHelpers.h>
8#include <xrpl/protocol/AccountID.h>
9#include <xrpl/protocol/Feature.h>
10#include <xrpl/protocol/Indexes.h>
11#include <xrpl/protocol/Keylet.h>
12#include <xrpl/protocol/Protocol.h>
13#include <xrpl/protocol/SField.h>
14#include <xrpl/protocol/STLedgerEntry.h>
15#include <xrpl/protocol/STTx.h>
16#include <xrpl/protocol/TER.h>
17#include <xrpl/protocol/XRPAmount.h>
18#include <xrpl/tx/ApplyContext.h>
19#include <xrpl/tx/Transactor.h>
52 auto isTooLong = [&](
auto const& sField,
std::size_t length) ->
bool {
53 if (
auto field = ctx.
tx[~sField])
54 return field->length() > length;
74 auto const balance =
STAmount((*sleAccount)[sfBalance]).
xrp();
78 if (balance < reserve)
91 (*sle)[sfOwnerNode] = *page;
104 if (
auto const sleDID =
ctx_.view().peek(didKeylet))
106 auto update = [&](
auto const& sField) {
107 if (
auto const field =
ctx_.tx[~sField])
111 sleDID->makeFieldAbsent(sField);
115 (*sleDID)[sField] = *field;
120 update(sfDIDDocument);
123 if (!sleDID->isFieldPresent(sfURI) && !sleDID->isFieldPresent(sfDIDDocument) &&
124 !sleDID->isFieldPresent(sfData))
128 ctx_.view().update(sleDID);
136 auto set = [&](
auto const& sField) {
137 if (
auto const field =
ctx_.tx[~sField]; field && !field->empty())
138 (*sleDID)[sField] = *field;
144 if (
ctx_.view().rules().enabled(fixEmptyDID) && !sleDID->isFieldPresent(sfURI) &&
145 !sleDID->isFieldPresent(sfDIDDocument) && !sleDID->isFieldPresent(sfData))
A generic endpoint for log messages.
State information when applying a tx.
beast::Journal const journal
virtual SLE::pointer peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
virtual void insert(SLE::ref sle)=0
Insert a new state SLE.
std::optional< std::uint64_t > dirInsert(Keylet const &directory, uint256 const &key, std::function< void(SLE::ref)> const &describe)
Insert an entry to a directory.
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.
void visitInvariantEntry(bool isDelete, SLE::const_ref before, SLE::const_ref after) override
Inspect a single ledger entry modified by this transaction.
static NotTEC preflight(PreflightContext const &ctx)
std::shared_ptr< STLedgerEntry > const & ref
std::shared_ptr< STLedgerEntry const > const & const_ref
bool isFieldPresent(SField const &field) const
AccountID const accountID_
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,...
void increaseOwnerCount(ApplyView &view, SLE::ref accountSle, SLE::ref sponsorSle, std::uint32_t count, beast::Journal j)
Increase owner-count fields when the caller supplies the sponsor.
static TER addSLE(ApplyContext &ctx, SLE::ref sle, AccountID const &owner)
constexpr std::size_t kMaxDidDataLength
The maximum length of an Attestation inside a DID.
constexpr std::size_t kMaxDidUriLength
The maximum length of a URI inside a DID.
TERSubset< CanCvtToNotTEC > NotTEC
constexpr std::size_t kMaxDidDocumentLength
The maximum length of a Data element inside a DID.
std::function< void(SLE::ref)> describeOwnerDir(AccountID const &account)
Returns a function that sets the owner on a directory SLE.
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
TERSubset< CanCvtToTER > TER
@ tecINSUFFICIENT_RESERVE
XRPAmount accountReserve(ReadView const &view, SLE::const_ref sle, beast::Journal j, Adjustment adj={})
Returns the account reserve, in drops.
A pair of SHAMap key and LedgerEntryType.
State information when preflighting a tx.