1#include <xrpld/app/tx/detail/NFTokenUtils.h>
2#include <xrpld/rpc/Context.h>
3#include <xrpld/rpc/detail/RPCHelpers.h>
4#include <xrpld/rpc/detail/Tuning.h>
6#include <xrpl/ledger/ReadView.h>
7#include <xrpl/protocol/ErrorCodes.h>
8#include <xrpl/protocol/Indexes.h>
9#include <xrpl/protocol/LedgerFormats.h>
10#include <xrpl/protocol/RPCErr.h>
11#include <xrpl/protocol/jss.h>
12#include <xrpl/protocol/nftPageMask.h>
13#include <xrpl/resource/Fees.h>
33 auto const& params = context.
params;
34 if (!params.isMember(jss::account))
37 if (!params[jss::account].isString())
40 auto id = parseBase58<AccountID>(params[jss::account].asString());
48 if (ledger ==
nullptr)
50 auto const accountID{
id.value()};
60 bool const markerSet = params.isMember(jss::marker);
64 auto const& m = params[jss::marker];
75 auto cp = ledger->read(
Keylet(
77 ledger->succ(first.key, last.key.next()).value_or(last.key)));
83 bool pastMarker = marker.
isZero();
84 bool markerFound =
false;
88 auto arr = cp->getFieldArray(sfNFTokens);
90 for (
auto const& o : arr)
103 uint256 const nftokenID = o[sfNFTokenID];
108 if (maskedNftokenID < maskedMarker)
111 if (maskedNftokenID == maskedMarker && nftokenID < marker)
114 if (nftokenID == marker)
121 if (markerSet && !markerFound)
132 obj[sfNFTokenTaxon.jsonName] =
136 obj[sfTransferFee.jsonName] = xferFee;
141 result[jss::limit] = limit;
142 result[jss::marker] =
to_string(o.getFieldH256(sfNFTokenID));
147 if (
auto npm = (*cp)[~sfNextPageMin])
148 cp = ledger->read(
Keylet(ltNFTOKEN_PAGE, *npm));
153 if (markerSet && !markerFound)
156 result[jss::account] =
toBase58(accountID);
164 auto const& params = context.
params;
165 if (!params.isMember(jss::account))
168 if (!params[jss::account].isString())
173 if (ledger ==
nullptr)
176 auto const id = parseBase58<AccountID>(params[jss::account].asString());
182 auto const accountID{
id.value()};
189 if (params.isMember(jss::deletion_blockers_only) &&
190 params[jss::deletion_blockers_only].asBool())
196 }
static constexpr deletionBlockers[] = {
197 {jss::check, ltCHECK},
198 {jss::escrow, ltESCROW},
199 {jss::nft_page, ltNFTOKEN_PAGE},
200 {jss::payment_channel, ltPAYCHAN},
201 {jss::state, ltRIPPLE_STATE},
202 {jss::xchain_owned_claim_id, ltXCHAIN_OWNED_CLAIM_ID},
203 {jss::xchain_owned_create_account_claim_id,
204 ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID},
205 {jss::bridge, ltBRIDGE},
206 {jss::mpt_issuance, ltMPTOKEN_ISSUANCE},
207 {jss::mptoken, ltMPTOKEN},
208 {jss::permissioned_domain, ltPERMISSIONED_DOMAIN},
209 {jss::vault, ltVAULT},
213 typeFilter->reserve(
std::size(deletionBlockers));
215 for (
auto [name, type] : deletionBlockers)
217 if (params.isMember(jss::type) && name != params[jss::type])
222 typeFilter->push_back(type);
235 rpcStatus.inject(result);
238 else if (type !=
ltANY)
250 if (params.isMember(jss::marker))
252 auto const& marker = params[jss::marker];
253 if (!marker.isString())
256 auto const& markerStr = marker.asString();
257 auto const& idx = markerStr.find(
',');
258 if (idx == std::string::npos)
261 if (!dirIndex.
parseHex(markerStr.substr(0, idx)))
264 if (!entryIndex.
parseHex(markerStr.substr(idx + 1)))
278 result[jss::account] =
toBase58(accountID);
Lightweight wrapper to tag static string.
Value & append(Value const &value)
Append value to array at the end.
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
@ arrayValue
array value (ordered list)
static LimitRange constexpr accountNFTokens
Limits for the account_nftokens command, in pages.
static LimitRange constexpr accountObjects
Limits for the account_objects command.
Json::Value invalid_field_error(std::string const &name)
bool isAccountObjectsValidType(LedgerEntryType const &type)
Check if the type is a valid filtering type for account_objects method.
void inject_error(error_code_i code, JsonValue &json)
Add or update the json update to reflect the error code.
std::pair< RPC::Status, LedgerEntryType > chooseLedgerEntryType(Json::Value const ¶ms)
bool getAccountObjects(ReadView const &ledger, AccountID const &account, std::optional< std::vector< LedgerEntryType > > const &typeFilter, uint256 dirIndex, uint256 entryIndex, std::uint32_t const limit, Json::Value &jvResult)
Gathers all objects for an account in a ledger.
Json::Value expected_field_error(std::string const &name, std::string const &type)
Status lookupLedger(std::shared_ptr< ReadView const > &ledger, JsonContext &context, Json::Value &result)
Look up a ledger from a request and fill a Json::Result with the data representing a ledger.
Json::Value missing_field_error(std::string const &name)
Charge const feeMediumBurdenRPC
Keylet nftpage(Keylet const &k, uint256 const &token)
Keylet account(AccountID const &id) noexcept
AccountID root.
Keylet nftpage_min(AccountID const &owner)
NFT page keylets.
Keylet nftpage_max(AccountID const &owner)
A keylet for the owner's last possible NFT page.
std::uint16_t getTransferFee(uint256 const &id)
std::uint16_t getFlags(uint256 const &id)
std::uint32_t toUInt32(Taxon t)
Taxon getTaxon(uint256 const &id)
AccountID getIssuer(uint256 const &id)
std::uint32_t getSerial(uint256 const &id)
uint256 constexpr pageMask(std::string_view("0000000000000000000000000000000000000000ffffffffffffffffffffffff"))
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Json::Value rpcError(int iError)
Json::Value doAccountObjects(RPC::JsonContext &context)
Json::Value doAccountNFTs(RPC::JsonContext &context)
General RPC command that can retrieve objects in the account root.
std::string to_string(base_uint< Bits, Tag > const &a)
LedgerEntryType
Identifiers for on-ledger objects.
@ ltANY
A special type, matching any ledger entry type.
A pair of SHAMap key and LedgerEntryType.
Resource::Charge & loadType