20#include <xrpld/app/main/Application.h>
21#include <xrpld/app/tx/detail/NFTokenUtils.h>
22#include <xrpld/ledger/ReadView.h>
23#include <xrpld/rpc/Context.h>
24#include <xrpld/rpc/detail/RPCHelpers.h>
25#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>
53 auto const& params = context.
params;
54 if (!params.isMember(jss::account))
57 if (!params[jss::account].isString())
60 auto id = parseBase58<AccountID>(params[jss::account].asString());
68 if (ledger ==
nullptr)
70 auto const accountID{
id.value()};
80 bool const markerSet = params.isMember(jss::marker);
84 auto const& m = params[jss::marker];
95 auto cp = ledger->read(
Keylet(
97 ledger->succ(first.key, last.key.next()).value_or(last.key)));
103 bool pastMarker = marker.
isZero();
104 bool markerFound =
false;
108 auto arr = cp->getFieldArray(sfNFTokens);
110 for (
auto const& o : arr)
123 uint256 const nftokenID = o[sfNFTokenID];
128 if (maskedNftokenID < maskedMarker)
131 if (maskedNftokenID == maskedMarker && nftokenID < marker)
134 if (nftokenID == marker)
141 if (markerSet && !markerFound)
152 obj[sfNFTokenTaxon.jsonName] =
156 obj[sfTransferFee.jsonName] = xferFee;
161 result[jss::limit] = limit;
162 result[jss::marker] =
to_string(o.getFieldH256(sfNFTokenID));
167 if (
auto npm = (*cp)[~sfNextPageMin])
168 cp = ledger->read(
Keylet(ltNFTOKEN_PAGE, *npm));
173 if (markerSet && !markerFound)
176 result[jss::account] =
toBase58(accountID);
184 auto const& params = context.
params;
185 if (!params.isMember(jss::account))
188 if (!params[jss::account].isString())
193 if (ledger ==
nullptr)
196 auto const id = parseBase58<AccountID>(params[jss::account].asString());
202 auto const accountID{
id.value()};
209 if (params.isMember(jss::deletion_blockers_only) &&
210 params[jss::deletion_blockers_only].asBool())
216 }
static constexpr deletionBlockers[] = {
217 {jss::check, ltCHECK},
218 {jss::escrow, ltESCROW},
219 {jss::nft_page, ltNFTOKEN_PAGE},
220 {jss::payment_channel, ltPAYCHAN},
221 {jss::state, ltRIPPLE_STATE},
222 {jss::xchain_owned_claim_id, ltXCHAIN_OWNED_CLAIM_ID},
223 {jss::xchain_owned_create_account_claim_id,
224 ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID},
225 {jss::bridge, ltBRIDGE},
226 {jss::mpt_issuance, ltMPTOKEN_ISSUANCE},
227 {jss::mptoken, ltMPTOKEN},
228 {jss::permissioned_domain, ltPERMISSIONED_DOMAIN}};
231 typeFilter->reserve(
std::size(deletionBlockers));
233 for (
auto [name, type] : deletionBlockers)
235 if (params.isMember(jss::type) && name != params[jss::type])
240 typeFilter->push_back(type);
253 rpcStatus.inject(result);
256 else if (type !=
ltANY)
268 if (params.isMember(jss::marker))
270 auto const& marker = params[jss::marker];
271 if (!marker.isString())
274 auto const& markerStr = marker.asString();
275 auto const& idx = markerStr.find(
',');
276 if (idx == std::string::npos)
279 if (!dirIndex.
parseHex(markerStr.substr(0, idx)))
282 if (!entryIndex.
parseHex(markerStr.substr(idx + 1)))
296 result[jss::account] =
toBase58(accountID);
Lightweight wrapper to tag static string.
Value & append(const Value &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