20#include <xrpld/app/tx/detail/NFTokenUtils.h>
21#include <xrpld/ledger/ReadView.h>
22#include <xrpld/rpc/Context.h>
23#include <xrpld/rpc/detail/RPCHelpers.h>
24#include <xrpld/rpc/detail/Tuning.h>
26#include <xrpl/protocol/ErrorCodes.h>
27#include <xrpl/protocol/Indexes.h>
28#include <xrpl/protocol/LedgerFormats.h>
29#include <xrpl/protocol/RPCErr.h>
30#include <xrpl/protocol/jss.h>
31#include <xrpl/protocol/nftPageMask.h>
32#include <xrpl/resource/Fees.h>
52 auto const& params = context.
params;
53 if (!params.isMember(jss::account))
56 if (!params[jss::account].isString())
59 auto id = parseBase58<AccountID>(params[jss::account].asString());
67 if (ledger ==
nullptr)
69 auto const accountID{
id.value()};
79 bool const markerSet = params.isMember(jss::marker);
83 auto const& m = params[jss::marker];
94 auto cp = ledger->read(
Keylet(
96 ledger->succ(first.key, last.key.next()).value_or(last.key)));
102 bool pastMarker = marker.
isZero();
103 bool markerFound =
false;
107 auto arr = cp->getFieldArray(sfNFTokens);
109 for (
auto const& o : arr)
122 uint256 const nftokenID = o[sfNFTokenID];
127 if (maskedNftokenID < maskedMarker)
130 if (maskedNftokenID == maskedMarker && nftokenID < marker)
133 if (nftokenID == marker)
140 if (markerSet && !markerFound)
151 obj[sfNFTokenTaxon.jsonName] =
155 obj[sfTransferFee.jsonName] = xferFee;
160 result[jss::limit] = limit;
161 result[jss::marker] =
to_string(o.getFieldH256(sfNFTokenID));
166 if (
auto npm = (*cp)[~sfNextPageMin])
167 cp = ledger->read(
Keylet(ltNFTOKEN_PAGE, *npm));
172 if (markerSet && !markerFound)
175 result[jss::account] =
toBase58(accountID);
183 auto const& params = context.
params;
184 if (!params.isMember(jss::account))
187 if (!params[jss::account].isString())
192 if (ledger ==
nullptr)
195 auto const id = parseBase58<AccountID>(params[jss::account].asString());
201 auto const accountID{
id.value()};
208 if (params.isMember(jss::deletion_blockers_only) &&
209 params[jss::deletion_blockers_only].asBool())
215 }
static constexpr deletionBlockers[] = {
216 {jss::check, ltCHECK},
217 {jss::escrow, ltESCROW},
218 {jss::nft_page, ltNFTOKEN_PAGE},
219 {jss::payment_channel, ltPAYCHAN},
220 {jss::state, ltRIPPLE_STATE},
221 {jss::xchain_owned_claim_id, ltXCHAIN_OWNED_CLAIM_ID},
222 {jss::xchain_owned_create_account_claim_id,
223 ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID},
224 {jss::bridge, ltBRIDGE},
225 {jss::mpt_issuance, ltMPTOKEN_ISSUANCE},
226 {jss::mptoken, ltMPTOKEN},
227 {jss::permissioned_domain, ltPERMISSIONED_DOMAIN}};
230 typeFilter->reserve(
std::size(deletionBlockers));
232 for (
auto [name, type] : deletionBlockers)
234 if (params.isMember(jss::type) && name != params[jss::type])
239 typeFilter->push_back(type);
252 rpcStatus.inject(result);
255 else if (type !=
ltANY)
267 if (params.isMember(jss::marker))
269 auto const& marker = params[jss::marker];
270 if (!marker.isString())
273 auto const& markerStr = marker.asString();
274 auto const& idx = markerStr.find(
',');
275 if (idx == std::string::npos)
278 if (!dirIndex.
parseHex(markerStr.substr(0, idx)))
281 if (!entryIndex.
parseHex(markerStr.substr(idx + 1)))
295 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