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();
77 if (balance < reserve)
90 (*sle)[sfOwnerNode] = *page;
103 if (
auto const sleDID =
ctx_.view().peek(didKeylet))
105 auto update = [&](
auto const& sField) {
106 if (
auto const field =
ctx_.tx[~sField])
110 sleDID->makeFieldAbsent(sField);
114 (*sleDID)[sField] = *field;
119 update(sfDIDDocument);
122 if (!sleDID->isFieldPresent(sfURI) && !sleDID->isFieldPresent(sfDIDDocument) &&
123 !sleDID->isFieldPresent(sfData))
127 ctx_.view().update(sleDID);
135 auto set = [&](
auto const& sField) {
136 if (
auto const field =
ctx_.tx[~sField]; field && !field->empty())
137 (*sleDID)[sField] = *field;
143 if (
ctx_.view().rules().enabled(fixEmptyDID) && !sleDID->isFieldPresent(sfURI) &&
144 !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)
virtual Fees const & fees() const =0
Returns the fees for the base ledger.
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,...
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.
void adjustOwnerCount(ApplyView &view, SLE::ref 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.
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
TERSubset< CanCvtToTER > TER
@ tecINSUFFICIENT_RESERVE
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.