Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
AccountNFTs.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/json/array.hpp>
8#include <boost/json/conversion.hpp>
9#include <boost/json/value.hpp>
10#include <rpcspec/handlers/account_nfts/Types.hpp>
11
12#include <cstdint>
13#include <memory>
14#include <optional>
15#include <string>
16#include <utility>
17
18namespace rpc {
19
25class AccountNFTsHandler : public rpc::HandlerFor<rpc::spec::handlers::account_nfts::Input> {
26 std::shared_ptr<BackendInterface> sharedPtrBackend_;
27
28public:
32 static constexpr auto kLimitMin = rpc::spec::handlers::account_nfts::kLimitMin;
36 static constexpr auto kLimitMax = rpc::spec::handlers::account_nfts::kLimitMax;
40 static constexpr auto kLimitDefault = rpc::spec::handlers::account_nfts::kLimitDefault;
41
45 struct Output {
46 std::string account;
47 std::string ledgerHash;
48 uint32_t ledgerIndex;
49 // TODO: use better type than json
50 boost::json::array nfts;
51 uint32_t limit;
52 std::optional<std::string> marker;
53 bool validated = true;
54 };
55
60
66 AccountNFTsHandler(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
static constexpr auto kLimitDefault
Value of limit used when the request does not specify one.
Definition AccountNFTs.hpp:40
Result process(Input const &input, Context const &ctx) const
Process the AccountNFTs command.
Definition AccountNFTs.cpp:32
static constexpr auto kLimitMin
Minimum accepted value for the limit request field.
Definition AccountNFTs.hpp:32
friend void tag_invoke(boost::json::value_from_tag, boost::json::value &jv, Output const &output)
Convert the Output to a JSON object.
Definition AccountNFTs.cpp:128
AccountNFTsHandler(std::shared_ptr< BackendInterface > sharedPtrBackend)
Construct a new AccountNFTsHandler object.
Definition AccountNFTs.hpp:66
static constexpr auto kLimitMax
Maximum accepted value for the limit request field.
Definition AccountNFTs.hpp:36
HandlerReturnType< Output > Result
The result type of the command: the Output on success or an error Status.
Definition AccountNFTs.hpp:59
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
A struct to hold the output data of the command.
Definition AccountNFTs.hpp:45
std::optional< std::string > marker
Key of the next NFT page, if more results.
Definition AccountNFTs.hpp:52
boost::json::array nfts
NFTokens owned by the account.
Definition AccountNFTs.hpp:50
uint32_t limit
The limit used for the request.
Definition AccountNFTs.hpp:51
std::string account
The account whose NFTs are returned.
Definition AccountNFTs.hpp:46
std::string ledgerHash
Hash of the ledger used for the request.
Definition AccountNFTs.hpp:47
uint32_t ledgerIndex
Sequence of the ledger used for the request.
Definition AccountNFTs.hpp:48
bool validated
Whether the ledger is validated.
Definition AccountNFTs.hpp:53
Context of an RPC call.
Definition Types.hpp:102
Result type used to return responses or error statuses to the Webserver subsystem.
Definition Types.hpp:132