1#include <xrpl/tx/transactors/permissioned_domain/PermissionedDomainSet.h>
3#include <xrpl/beast/utility/Zero.h>
4#include <xrpl/core/ServiceRegistry.h>
5#include <xrpl/ledger/helpers/AccountRootHelpers.h>
6#include <xrpl/ledger/helpers/CredentialHelpers.h>
7#include <xrpl/ledger/helpers/DirectoryHelpers.h>
8#include <xrpl/protocol/Feature.h>
9#include <xrpl/protocol/Indexes.h>
10#include <xrpl/protocol/Keylet.h>
11#include <xrpl/protocol/Protocol.h>
12#include <xrpl/protocol/SField.h>
13#include <xrpl/protocol/STLedgerEntry.h>
14#include <xrpl/protocol/STObject.h>
15#include <xrpl/protocol/STTx.h>
16#include <xrpl/protocol/TER.h>
17#include <xrpl/protocol/XRPAmount.h>
18#include <xrpl/tx/Transactor.h>
41 auto const domain = ctx.
tx.
at(~sfDomainID);
42 if (domain && *domain == beast::kZero)
65 auto const sleDomain =
69 if (sleDomain->getAccountID(sfOwner) != account)
84 auto const sortedTxCredentials =
86 STArray sortedLE(sfAcceptedCredentials, sortedTxCredentials.size());
87 for (
auto const& p : sortedTxCredentials)
90 cred.setAccountID(sfIssuer, p.first);
91 cred.setFieldVL(sfCredentialType, p.second);
95 if (
ctx_.tx.isFieldPresent(sfDomainID))
101 slePd->peekFieldArray(sfAcceptedCredentials) = std::move(sortedLE);
108 auto const balance =
STAmount((*ownerSle)[sfBalance]).
xrp();
109 auto const reserve =
ctx_.view().fees().accountReserve((*ownerSle)[sfOwnerCount] + 1);
110 if (balance < reserve)
114 auto const seq = fixEnabled ?
ctx_.tx.getSeqValue() :
ctx_.tx.getFieldU32(sfSequence);
119 slePd->setFieldU32(sfSequence, seq);
120 slePd->peekFieldArray(sfAcceptedCredentials) = std::move(sortedLE);
126 slePd->setFieldU64(sfOwnerNode, *page);
A generic endpoint for log messages.
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.
TER doApply() override
Attempt to create the Permissioned Domain.
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.
static bool checkExtraFeatures(PreflightContext const &ctx)
void visitInvariantEntry(bool isDelete, SLE::const_ref before, SLE::const_ref after) override
Inspect a single ledger entry modified by this transaction.
static TER preclaim(PreclaimContext const &ctx)
static NotTEC preflight(PreflightContext const &ctx)
virtual Rules const & rules() const =0
Returns the tx processing rules.
virtual bool exists(Keylet const &k) const =0
Determine if a state item exists.
virtual SLE::const_pointer read(Keylet const &k) const =0
Return the state item associated with a key.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
void pushBack(STObject const &object)
std::shared_ptr< STLedgerEntry const > const & const_ref
T::value_type at(TypedField< T > const &f) const
Get the value of a field.
STArray const & getFieldArray(SField const &field) const
bool isFieldPresent(SField const &field) const
uint256 getFieldH256(SField const &field) const
static STObject makeInnerObject(SField const &name)
AccountID getAccountID(SField const &field) const
AccountID const accountID_
std::set< std::pair< AccountID, Slice > > makeSorted(STArray const &credentials)
NotTEC checkArray(STArray const &credentials, unsigned maxSize, beast::Journal j)
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Keylet account(AccountID const &id) noexcept
AccountID root.
Keylet permissionedDomain(AccountID const &account, std::uint32_t seq) noexcept
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
TERSubset< CanCvtToNotTEC > NotTEC
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.
bool isTesSuccess(TER x) noexcept
TERSubset< CanCvtToTER > TER
constexpr std::size_t kMaxPermissionedDomainCredentialsArraySize
The maximum number of credentials can be passed in array for permissioned domain.
@ tecINSUFFICIENT_RESERVE
A pair of SHAMap key and LedgerEntryType.
State information when determining if a tx is likely to claim a fee.
State information when preflighting a tx.