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/SpecBackend.hpp"
6#include "rpc/common/Types.hpp"
7#include "util/log/Logger.hpp"
8
9#include <boost/json/array.hpp>
10#include <boost/json/conversion.hpp>
11#include <boost/json/object.hpp>
12#include <boost/json/value.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::HandlerFor<rpc::spec::handlers::nft_history::Input> {
31 util::Logger log_{"RPC"};
32 std::shared_ptr<BackendInterface> sharedPtrBackend_;
33
34public:
38 static constexpr auto kLimitMin = rpc::spec::handlers::nft_history::kLimitMin;
42 static constexpr auto kLimitMax = rpc::spec::handlers::nft_history::kLimitMax;
46 static constexpr auto kLimitDefault = rpc::spec::handlers::nft_history::kLimitDefault;
47
51 using Marker = rpc::spec::handlers::nft_history::Marker;
52
56 struct Output {
57 std::string nftID;
58 uint32_t ledgerIndexMin{0};
59 uint32_t ledgerIndexMax{0};
60 std::optional<uint32_t> limit;
61 std::optional<Marker> marker;
62 // TODO: use a better type than json
63 boost::json::array transactions;
64 // validated should be sent via framework
65 bool validated = true;
66 };
67
72
78 NFTHistoryHandler(std::shared_ptr<BackendInterface> sharedPtrBackend)
79 : sharedPtrBackend_(std::move(sharedPtrBackend))
80 {
81 }
82
90 [[nodiscard]] Result
91 process(Input const& input, Context const& ctx) const;
92
93private:
100 friend void
101 tag_invoke(boost::json::value_from_tag, boost::json::value& jv, Output const& output);
102};
103
104} // namespace rpc
105
110
117void
118tag_invoke(boost::json::value_from_tag, boost::json::value& jv, Marker const& marker);
119
120} // namespace rpc::spec::handlers::nft_history
HandlerReturnType< Output > Result
The result type of the command: either the Output or an error status.
Definition NFTHistory.hpp:71
static constexpr auto kLimitDefault
Default value of the limit parameter.
Definition NFTHistory.hpp:46
static constexpr auto kLimitMax
Maximum allowed value of the limit parameter.
Definition NFTHistory.hpp:42
NFTHistoryHandler(std::shared_ptr< BackendInterface > sharedPtrBackend)
Construct a new NFTHistoryHandler object.
Definition NFTHistory.hpp:78
static constexpr auto kLimitMin
Minimum allowed value of the limit parameter.
Definition NFTHistory.hpp:38
rpc::spec::handlers::nft_history::Marker Marker
A struct to hold the marker data.
Definition NFTHistory.hpp:51
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:110
JSON conversions for the nft_history spec types used by NFTHistoryHandler.
Definition NFTHistory.cpp:188
void tag_invoke(boost::json::value_from_tag, boost::json::value &jv, Marker const &marker)
Convert the Marker to a JSON object.
Definition NFTHistory.cpp:191
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:63
spec::HandlerFor< InputT, boost::json::value > HandlerFor
The spec-driven base every typed handler inherits.
Definition SpecBackend.hpp:24
Context of an RPC call.
Definition Types.hpp:102
A struct to hold the output data of the command.
Definition NFTHistory.hpp:56
std::optional< Marker > marker
Marker to resume from, if more results remain.
Definition NFTHistory.hpp:61
boost::json::array transactions
Transactions that affected the NFT.
Definition NFTHistory.hpp:63
std::optional< uint32_t > limit
Limit from the request; unset if the default was used.
Definition NFTHistory.hpp:60
uint32_t ledgerIndexMax
Highest ledger sequence searched.
Definition NFTHistory.hpp:59
uint32_t ledgerIndexMin
Lowest ledger sequence searched.
Definition NFTHistory.hpp:58
std::string nftID
ID of the queried NFT.
Definition NFTHistory.hpp:57
bool validated
Whether the ledger is validated.
Definition NFTHistory.hpp:65
Result type used to return responses or error statuses to the Webserver subsystem.
Definition Types.hpp:132