1#include <xrpl/ledger/helpers/PermissionedDEXHelpers.h>
3#include <xrpl/basics/Log.h>
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/beast/utility/Journal.h>
6#include <xrpl/beast/utility/Zero.h>
7#include <xrpl/beast/utility/instrumentation.h>
8#include <xrpl/ledger/ReadView.h>
9#include <xrpl/ledger/helpers/CredentialHelpers.h>
10#include <xrpl/protocol/AccountID.h>
11#include <xrpl/protocol/Feature.h>
12#include <xrpl/protocol/Indexes.h>
13#include <xrpl/protocol/LedgerFormats.h>
14#include <xrpl/protocol/SField.h>
15#include <xrpl/protocol/UintTypes.h>
26 if (view.
rules().
enabled(fixCleanup3_2_0) && domainID == beast::kZero)
29 UNREACHABLE(
"xrpl::permissioned_dex::accountInDomain : domainID is zero");
39 if (sleDomain->getAccountID(sfOwner) == account)
42 auto const&
credentials = sleDomain->getFieldArray(sfAcceptedCredentials);
45 auto const sleCred = view.
read(
47 if (!sleCred || !sleCred->isFlag(lsfAccepted))
70 if (!sleOffer->isFieldPresent(sfDomainID))
72 if (sleOffer->getFieldH256(sfDomainID) != domainID)
79 if (sleOffer->isFlag(lsfHybrid) &&
80 (!sleOffer->isFieldPresent(sfAdditionalBooks) ||
81 sleOffer->getFieldArray(sfAdditionalBooks).size() != 1))
83 JLOG(j.
error()) <<
"Hybrid offer " << offerID
84 <<
" missing or malformed AdditionalBooks field";
92 if (sleOffer->isFlag(lsfHybrid) && !sleOffer->isFieldPresent(sfAdditionalBooks))
94 JLOG(j.
error()) <<
"Hybrid offer " << offerID <<
" missing AdditionalBooks field";
99 return accountInDomain(view, sleOffer->getAccountID(sfAccount), domainID);
A generic endpoint for log messages.
virtual Rules const & rules() const =0
Returns the tx processing rules.
virtual SLE::const_pointer read(Keylet const &k) const =0
Return the state item associated with a key.
virtual LedgerHeader const & header() const =0
Returns information about the ledger.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
bool checkExpired(SLE const &sleCredential, NetClock::time_point const &closed)
Keylet offer(AccountID const &id, std::uint32_t seq) noexcept
An offer from an account.
Keylet permissionedDomain(AccountID const &account, std::uint32_t seq) noexcept
Keylet credential(AccountID const &subject, AccountID const &issuer, Slice const &credType) noexcept
bool offerInDomain(ReadView const &view, uint256 const &offerID, Domain const &domainID, beast::Journal j)
bool accountInDomain(ReadView const &view, AccountID const &account, Domain const &domainID)
BaseUInt< 256 > Domain
Domain is a 256-bit hash representing a specific domain.
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.