20 #include <ripple/app/main/Application.h>
21 #include <ripple/json/json_value.h>
22 #include <ripple/ledger/ReadView.h>
23 #include <ripple/ledger/View.h>
24 #include <ripple/net/RPCErr.h>
25 #include <ripple/protocol/ErrorCodes.h>
26 #include <ripple/protocol/jss.h>
27 #include <ripple/resource/Fees.h>
28 #include <ripple/rpc/Context.h>
29 #include <ripple/rpc/impl/RPCHelpers.h>
30 #include <ripple/rpc/impl/Tuning.h>
43 obj[jss::flags] = (*offer)[
sfFlags];
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))
109 offers.reserve(reserve);
114 offers.reserve(++reserve);
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)
static Json::Value enumerateNFTOffers(RPC::JsonContext &context, uint256 const &nftId, Keylet const &directory)
A pair of SHAMap key and LedgerEntryType.
Json::Value rpcError(int iError)
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.
const SF_ACCOUNT sfDestination
const Charge feeMediumBurdenRPC
const SF_UINT256 sfNFTokenID
@ arrayValue
array value (ordered list)
Resource::Charge & loadType
Keylet nftoffer(AccountID const &owner, std::uint32_t seq)
An offer from an account to buy or sell an NFT.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
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.
const SF_UINT64 sfNFTokenOfferNode
Json::Value expected_field_error(std::string const &name, std::string const &type)
const SF_UINT32 sfExpiration
Json::Value missing_field_error(std::string const &name)
Json::Value doNFTBuyOffers(RPC::JsonContext &)
@ objectValue
object value (collection of name/value pairs).
static constexpr LimitRange nftOffers
Limits for the nft_buy_offers & nft_sell_offers commands.
Json::Value doNFTSellOffers(RPC::JsonContext &)
static void appendNftOfferJson(Application const &app, std::shared_ptr< SLE const > const &offer, Json::Value &offers)
@ ltNFTOKEN_OFFER
A ledger object which identifies an offer to buy or sell an NFT.
Keylet nft_sells(uint256 const &id) noexcept
The directory of sell offers for the specified NFT.
virtual bool exists(Keylet const &k) const =0
Determine if a state item exists.
bool isMember(const char *key) const
Return true if the object has a member named key.
Keylet nft_buys(uint256 const &id) noexcept
The directory of buy offers for the specified NFT.
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::string to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
Json::Value invalid_field_error(std::string const &name)
std::string asString() const
Returns the unquoted string value.