3#include <xrpld/rpc/Context.h>
4#include <xrpld/rpc/detail/RPCHelpers.h>
5#include <xrpld/rpc/detail/RPCLedgerHelpers.h>
6#include <xrpld/rpc/detail/Tuning.h>
8#include <xrpl/basics/base_uint.h>
9#include <xrpl/core/ServiceRegistry.h>
10#include <xrpl/json/json_value.h>
11#include <xrpl/ledger/ReadView.h>
12#include <xrpl/ledger/helpers/DirectoryHelpers.h>
13#include <xrpl/protocol/AccountID.h>
14#include <xrpl/protocol/ErrorCodes.h>
15#include <xrpl/protocol/Indexes.h>
16#include <xrpl/protocol/Keylet.h>
17#include <xrpl/protocol/LedgerFormats.h>
18#include <xrpl/protocol/RPCErr.h>
19#include <xrpl/protocol/SField.h>
20#include <xrpl/protocol/jss.h>
21#include <xrpl/resource/Fees.h>
35 obj[jss::flags] = (*offer)[sfFlags];
36 obj[jss::owner] =
toBase58(offer->getAccountID(sfOwner));
38 if (offer->isFieldPresent(sfDestination))
39 obj[jss::destination] =
toBase58(offer->getAccountID(sfDestination));
41 if (offer->isFieldPresent(sfExpiration))
42 obj[jss::expiration] = offer->getFieldU32(sfExpiration);
44 offer->getFieldAmount(sfAmount).setJson(obj[jss::amount]);
57 unsigned int limit = 0;
75 unsigned int reserve(limit);
93 if (!sle || nftId != sle->getFieldH256(sfNFTokenID))
102 auto const offerDir =
107 startHint = sle->getFieldU64(sfNFTokenOfferNode);
119 if (offer->getType() == ltNFTOKEN_OFFER)
131 if (offers.
size() == reserve)
133 result[jss::limit] = limit;
138 for (
auto const& offer : offers)
Value & append(Value const &value)
Append value to array at the end.
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.
std::shared_ptr< STLedgerEntry const > const & ConstRef
T emplace_back(T... args)
@ Array
array value (ordered list)
@ Object
object value (collection of name/value pairs).
Keylet nftokenOffer(AccountID const &owner, SeqProxy const &seq)
An offer from an account to buy or sell an NFT.
Keylet nftSells(UInt256 const &id) noexcept
The directory of sell offers for the specified NFT.
Keylet nftBuys(UInt256 const &id) noexcept
The directory of buy offers for the specified NFT.
Charge const kFeeMediumBurdenRpc
static constexpr LimitRange kNftOffers
Limits for the nft_buy_offers & nft_sell_offers commands.
json::Value expectedFieldError(std::string const &name, std::string const &type)
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.
json::Value enumerateNFTOffers(rpc::JsonContext &context, UInt256 const &nftId, Keylet const &directory)
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
std::string to_string(BaseUInt< Bits, Tag > const &a)
json::Value rpcError(ErrorCodeI iError)
bool forEachItemAfter(ReadView const &view, Keylet const &root, UInt256 const &after, std::uint64_t const hint, unsigned int limit, std::function< bool(SLE::ConstRef)> const &f)
Iterate all items after an item in the given directory.
void appendNftOfferJson(Application const &app, SLE::ConstRef offer, json::Value &offers)
A pair of SHAMap key and LedgerEntryType.
resource::Charge & loadType