20#include <xrpld/rpc/Context.h>
21#include <xrpld/rpc/detail/RPCHelpers.h>
22#include <xrpld/rpc/detail/Tuning.h>
24#include <xrpl/json/json_value.h>
25#include <xrpl/ledger/ReadView.h>
26#include <xrpl/ledger/View.h>
27#include <xrpl/protocol/ErrorCodes.h>
28#include <xrpl/protocol/RPCErr.h>
29#include <xrpl/protocol/jss.h>
30#include <xrpl/resource/Fees.h>
43 obj[jss::flags] = (*offer)[sfFlags];
44 obj[jss::owner] =
toBase58(offer->getAccountID(sfOwner));
46 if (offer->isFieldPresent(sfDestination))
47 obj[jss::destination] =
toBase58(offer->getAccountID(sfDestination));
49 if (offer->isFieldPresent(sfExpiration))
50 obj[jss::expiration] = offer->getFieldU32(sfExpiration);
52 offer->getFieldAmount(sfAmount).setJson(obj[jss::amount]);
77 if (!ledger->exists(directory))
86 unsigned int reserve(limit);
104 if (!sle || nftId != sle->getFieldH256(sfNFTokenID))
107 startHint = sle->getFieldU64(sfNFTokenOfferNode);
109 offers.reserve(reserve);
114 offers.reserve(++reserve);
124 if (offer->getType() == ltNFTOKEN_OFFER)
126 offers.emplace_back(offer);
136 if (offers.size() == reserve)
138 result[jss::limit] = limit;
139 result[jss::marker] =
to_string(offers.back()->key());
143 for (
auto const& offer : offers)
std::string asString() const
Returns the unquoted string value.
bool isMember(char const *key) const
Return true if the object has a member named key.
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
@ arrayValue
array value (ordered list)
@ objectValue
object value (collection of name/value pairs).
static LimitRange constexpr nftOffers
Limits for the nft_buy_offers & nft_sell_offers commands.
Json::Value invalid_field_error(std::string const &name)
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 nft_buys(uint256 const &id) noexcept
The directory of buy offers for the specified NFT.
Keylet nft_sells(uint256 const &id) noexcept
The directory of sell offers for the specified NFT.
Keylet nftoffer(AccountID const &owner, std::uint32_t seq)
An offer from an account to buy or sell an NFT.
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.
static Json::Value enumerateNFTOffers(RPC::JsonContext &context, uint256 const &nftId, Keylet const &directory)
Json::Value doNFTBuyOffers(RPC::JsonContext &)
Json::Value rpcError(int iError)
Json::Value doNFTSellOffers(RPC::JsonContext &)
static void appendNftOfferJson(Application const &app, std::shared_ptr< SLE const > const &offer, Json::Value &offers)
bool forEachItemAfter(ReadView const &view, Keylet const &root, uint256 const &after, std::uint64_t const hint, unsigned int limit, std::function< bool(std::shared_ptr< SLE const > const &)> const &f)
Iterate all items after an item in the given directory.
std::string to_string(base_uint< Bits, Tag > const &a)
A pair of SHAMap key and LedgerEntryType.
Resource::Charge & loadType