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/STArray.h>
16#include <xrpl/protocol/jss.h>
17#include <xrpl/protocol/nft.h>
18#include <xrpl/protocol/nftPageMask.h>
19#include <xrpl/resource/Fees.h>
40 auto const& params = context.
params;
41 if (!params.isMember(jss::account))
44 if (!params[jss::account].isString())
55 if (ledger ==
nullptr)
57 auto const accountID{
id.value()};
62 unsigned int limit = 0;
67 bool const markerSet = params.isMember(jss::marker);
71 auto const& m = params[jss::marker];
82 auto cp = ledger->read(
83 Keylet(ltNFTOKEN_PAGE, ledger->succ(first.key, last.key.next()).value_or(last.key)));
89 bool pastMarker = marker.
isZero();
90 bool markerFound =
false;
94 auto arr = cp->getFieldArray(sfNFTokens);
96 for (
auto const& o : arr)
109 uint256 const nftokenID = o[sfNFTokenID];
114 if (maskedNftokenID < maskedMarker)
117 if (maskedNftokenID == maskedMarker && nftokenID < marker)
120 if (nftokenID == marker)
127 if (markerSet && !markerFound)
141 obj[sfTransferFee.jsonName] = xferFee;
146 result[jss::limit] = limit;
147 result[jss::marker] =
to_string(o.getFieldH256(sfNFTokenID));
152 if (
auto npm = (*cp)[~sfNextPageMin])
154 cp = ledger->read(
Keylet(ltNFTOKEN_PAGE, *npm));
162 if (markerSet && !markerFound)
165 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)
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)
Charge const kFeeMediumBurdenRpc
static constexpr LimitRange kAccountNfTokens
Limits for the account_nftokens command, in pages.
json::Value expectedFieldError(std::string const &name, std::string const &type)
json::Value invalidFieldError(std::string const &name)
json::Value missingFieldError(std::string const &name)
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.
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