1#include <xrpld/rpc/Context.h>
2#include <xrpld/rpc/detail/RPCHelpers.h>
3#include <xrpld/rpc/detail/RPCLedgerHelpers.h>
4#include <xrpld/rpc/detail/Tuning.h>
6#include <xrpl/basics/base_uint.h>
7#include <xrpl/json/json_value.h>
8#include <xrpl/ledger/ReadView.h>
9#include <xrpl/protocol/AccountID.h>
10#include <xrpl/protocol/ErrorCodes.h>
11#include <xrpl/protocol/Indexes.h>
12#include <xrpl/protocol/LedgerFormats.h>
13#include <xrpl/protocol/RPCErr.h>
14#include <xrpl/protocol/SField.h>
15#include <xrpl/protocol/jss.h>
16#include <xrpl/protocol/nft.h>
17#include <xrpl/protocol/nftPageMask.h>
18#include <xrpl/resource/Fees.h>
38 auto const& params = context.
params;
39 if (!params.isMember(jss::account))
42 if (!params[jss::account].isString())
53 if (ledger ==
nullptr)
55 auto const accountID{
id.value()};
60 unsigned int limit = 0;
65 bool const markerSet = params.isMember(jss::marker);
69 auto const& m = params[jss::marker];
80 auto cp = ledger->read(
81 Keylet(ltNFTOKEN_PAGE, ledger->succ(first.key, last.key.next()).value_or(last.key)));
87 bool pastMarker = marker.
isZero();
88 bool markerFound =
false;
92 auto arr = cp->getFieldArray(sfNFTokens);
94 for (
auto const& o : arr)
107 uint256 const nftokenID = o[sfNFTokenID];
112 if (maskedNftokenID < maskedMarker)
115 if (maskedNftokenID == maskedMarker && nftokenID < marker)
118 if (nftokenID == marker)
125 if (markerSet && !markerFound)
139 obj[sfTransferFee.jsonName] = xferFee;
144 result[jss::limit] = limit;
145 result[jss::marker] =
to_string(o.getFieldH256(sfNFTokenID));
150 if (
auto npm = (*cp)[~sfNextPageMin])
152 cp = ledger->read(
Keylet(ltNFTOKEN_PAGE, *npm));
160 if (markerSet && !markerFound)
163 result[jss::account] =
toBase58(accountID);
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.
@ Array
array value (ordered list)
static constexpr LimitRange kAccountNfTokens
Limits for the account_nftokens command, in pages.
Status lookupLedger(std::shared_ptr< ReadView const > &ledger, JsonContext const &context, json::Value &result)
Looks up a ledger from a request and fills a json::Value with ledger data.
json::Value invalidFieldError(std::string const &name)
json::Value missingFieldError(std::string const &name)
json::Value expectedFieldError(std::string const &name, std::string const &type)
Charge const kFeeMediumBurdenRpc
Keylet nftokenPageMin(AccountID const &owner)
NFT page keylets.
Keylet nftokenPage(Keylet const &k, uint256 const &token)
Keylet nftokenPageMax(AccountID const &owner)
A keylet for the owner's last possible NFT page.
Keylet account(AccountID const &id) noexcept
AccountID root.
std::uint32_t toUInt32(Taxon t)
Taxon getTaxon(uint256 const &id)
constexpr uint256 kPageMask(std::string_view("0000000000000000000000000000000000000000ffffffffffffffffffffffff"))
std::uint32_t getSequence(uint256 const &id)
AccountID getIssuer(uint256 const &id)
std::uint16_t getTransferFee(uint256 const &id)
std::uint16_t getFlags(uint256 const &id)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::optional< AccountID > parseBase58(std::string const &s)
Parse AccountID from checked, base58 string.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
json::Value doAccountNFTs(RPC::JsonContext &context)
General RPC command that can retrieve objects in the account root.
std::string to_string(BaseUInt< Bits, Tag > const &a)
json::Value rpcError(ErrorCodeI iError)
A pair of SHAMap key and LedgerEntryType.
Resource::Charge & loadType