Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
NFTHistory.hpp
1#pragma once
2
3#include "data/BackendInterface.hpp"
4#include "rpc/Errors.hpp"
5#include "rpc/common/Types.hpp"
6#include "util/log/Logger.hpp"
7
8#include <boost/json/array.hpp>
9#include <boost/json/conversion.hpp>
10#include <boost/json/object.hpp>
11#include <boost/json/value.hpp>
12#include <rpcspec/HandlerFor.hpp>
13#include <rpcspec/handlers/nft_history/Types.hpp>
14
15#include <cstdint>
16#include <expected>
17#include <memory>
18#include <optional>
19#include <string>
20#include <utility>
21
22namespace rpc {
23
30class NFTHistoryHandler : public rpc::spec::HandlerFor<rpc::spec::handlers::nft_history::Input> {
31 util::Logger log_{"RPC"};
32 std::shared_ptr<BackendInterface> sharedPtrBackend_;
33
34public:
35 static constexpr auto kLimitMin = rpc::spec::handlers::nft_history::kLimitMin;
36 static constexpr auto kLimitMax = rpc::spec::handlers::nft_history::kLimitMax;
37 static constexpr auto kLimitDefault = rpc::spec::handlers::nft_history::kLimitDefault;
38
42 using Marker = rpc::spec::handlers::nft_history::Marker;
43
47 struct Output {
48 std::string nftID;
49 uint32_t ledgerIndexMin{0};
50 uint32_t ledgerIndexMax{0};
51 std::optional<uint32_t> limit;
52 std::optional<Marker> marker;
53 // TODO: use a better type than json
54 boost::json::array transactions;
55 // validated should be sent via framework
56 bool validated = true;
57 };
58
59 using Result = HandlerReturnType<Output>;
60
66 NFTHistoryHandler(std::shared_ptr<BackendInterface> sharedPtrBackend)
67 : sharedPtrBackend_(std::move(sharedPtrBackend))
68 {
69 }
70
78 [[nodiscard]] Result
79 process(Input const& input, Context const& ctx) const;
80
81private:
88 friend void
89 tag_invoke(boost::json::value_from_tag, boost::json::value& jv, Output const& output);
90};
91
92} // namespace rpc
93
94namespace rpc::spec::handlers::nft_history {
95
96void
97tag_invoke(boost::json::value_from_tag, boost::json::value& jv, Marker const& marker);
98
99} // namespace rpc::spec::handlers::nft_history
NFTHistoryHandler(std::shared_ptr< BackendInterface > sharedPtrBackend)
Construct a new NFTHistoryHandler object.
Definition NFTHistory.hpp:66
rpc::spec::handlers::nft_history::Marker Marker
A struct to hold the marker data.
Definition NFTHistory.hpp:42
friend void tag_invoke(boost::json::value_from_tag, boost::json::value &jv, Output const &output)
Convert the Output to a JSON object.
Definition NFTHistory.cpp:165
Result process(Input const &input, Context const &ctx) const
Process the NFTHistory command.
Definition NFTHistory.cpp:34
A simple thread-safe logger for the channel specified in the constructor.
Definition Logger.hpp:78
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
Context of an RPC call.
Definition Types.hpp:98
A struct to hold the output data of the command.
Definition NFTHistory.hpp:47
Result type used to return responses or error statuses to the Webserver subsystem.
Definition Types.hpp:109