Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
NFTOffersCommon.hpp
1#pragma once
2
3#include "data/BackendInterface.hpp"
4#include "rpc/common/SpecBackend.hpp"
5#include "rpc/common/Types.hpp"
6
7#include <boost/asio/spawn.hpp>
8#include <boost/json/conversion.hpp>
9#include <boost/json/value.hpp>
10#include <rpcspec/handlers/nft_offers_common/Types.hpp>
11#include <xrpl/basics/base_uint.h>
12#include <xrpl/protocol/Keylet.h>
13#include <xrpl/protocol/STLedgerEntry.h>
14
15#include <cstdint>
16#include <memory>
17#include <optional>
18#include <string>
19#include <utility>
20#include <vector>
21
22namespace rpc {
23
27class NFTOffersHandlerBase : public rpc::HandlerFor<rpc::spec::handlers::nft_offers_common::Input> {
28 std::shared_ptr<BackendInterface> sharedPtrBackend_;
29
30public:
31 static constexpr auto kLimitMin = rpc::spec::handlers::nft_offers_common::kLimitMin;
32 static constexpr auto kLimitMax = rpc::spec::handlers::nft_offers_common::kLimitMax;
33 static constexpr auto kLimitDefault = rpc::spec::handlers::nft_offers_common::kLimitDefault;
34
38 struct Output {
39 std::string nftID;
40 std::vector<xrpl::SLE> offers;
41
42 // validated should be sent via framework
43 bool validated = true;
44 std::optional<uint32_t> limit;
45 std::optional<std::string> marker;
46 };
47
48 using Result = HandlerReturnType<Output>;
49
55 NFTOffersHandlerBase(std::shared_ptr<BackendInterface> sharedPtrBackend)
56 : sharedPtrBackend_(std::move(sharedPtrBackend))
57 {
58 }
59
60protected:
70 [[nodiscard]] Result
72 Input input,
73 xrpl::uint256 const& tokenID,
74 xrpl::Keylet const& directory,
75 boost::asio::yield_context yield
76 ) const;
77
78private:
85 friend void
86 tag_invoke(boost::json::value_from_tag, boost::json::value& jv, Output const& output);
87};
88
89} // namespace rpc
Result iterateOfferDirectory(Input input, xrpl::uint256 const &tokenID, xrpl::Keylet const &directory, boost::asio::yield_context yield) const
Iterate the NFT offer directory.
Definition NFTOffersCommon.cpp:66
friend void tag_invoke(boost::json::value_from_tag, boost::json::value &jv, Output const &output)
Convert the Output to a JSON object.
Definition NFTOffersCommon.cpp:160
NFTOffersHandlerBase(std::shared_ptr< BackendInterface > sharedPtrBackend)
Construct a new NFTOffersHandlerBase object.
Definition NFTOffersCommon.hpp:55
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:17
std::expected< OutputType, Status > HandlerReturnType
Return type for each individual handler.
Definition Types.hpp:61
spec::HandlerFor< InputT, boost::json::value > HandlerFor
The spec-driven base every typed handler inherits.
Definition SpecBackend.hpp:24
A struct to hold the output data of the command.
Definition NFTOffersCommon.hpp:38
Result type used to return responses or error statuses to the Webserver subsystem.
Definition Types.hpp:109