Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
AccountObjects.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/conversion.hpp>
8#include <boost/json/value.hpp>
9#include <rpcspec/handlers/account_objects/Types.hpp>
10#include <xrpl/protocol/STLedgerEntry.h>
11
12#include <cstdint>
13#include <memory>
14#include <optional>
15#include <string>
16#include <utility>
17#include <vector>
18
19namespace rpc {
20
28class AccountObjectsHandler : public rpc::HandlerFor<rpc::spec::handlers::account_objects::Input> {
29 // dependencies
30 std::shared_ptr<BackendInterface> sharedPtrBackend_;
31
32public:
36 static constexpr auto kLimitMin = rpc::spec::handlers::account_objects::kLimitMin;
40 static constexpr auto kLimitMax = rpc::spec::handlers::account_objects::kLimitMax;
44 static constexpr auto kLimitDefault = rpc::spec::handlers::account_objects::kLimitDefault;
45
49 struct Output {
50 std::string account;
51 std::string ledgerHash;
52 uint32_t ledgerIndex{};
53 std::optional<std::string> marker;
54 uint32_t limit{};
55 std::vector<xrpl::SLE> accountObjects;
56 bool validated = true;
57 };
58
63
69 AccountObjectsHandler(std::shared_ptr<BackendInterface> sharedPtrBackend)
70 : sharedPtrBackend_(std::move(sharedPtrBackend))
71 {
72 }
73
81 [[nodiscard]] Result
82 process(Input const& input, Context const& ctx) const;
83
84private:
91 friend void
92 tag_invoke(boost::json::value_from_tag, boost::json::value& jv, Output const& output);
93};
94
95} // namespace rpc
static constexpr auto kLimitDefault
Value of limit used when the request does not specify one.
Definition AccountObjects.hpp:44
AccountObjectsHandler(std::shared_ptr< BackendInterface > sharedPtrBackend)
Construct a new AccountObjectsHandler object.
Definition AccountObjects.hpp:69
Result process(Input const &input, Context const &ctx) const
Process the AccountObjects command.
Definition AccountObjects.cpp:35
static constexpr auto kLimitMin
Minimum accepted value for the limit request field.
Definition AccountObjects.hpp:36
friend void tag_invoke(boost::json::value_from_tag, boost::json::value &jv, Output const &output)
Convert the Output to a JSON object.
Definition AccountObjects.cpp:149
static constexpr auto kLimitMax
Maximum accepted value for the limit request field.
Definition AccountObjects.hpp:40
HandlerReturnType< Output > Result
The result type of the command: the Output on success or an error Status.
Definition AccountObjects.hpp:62
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 AccountObjects.hpp:49
uint32_t ledgerIndex
Sequence of the ledger used for the request.
Definition AccountObjects.hpp:52
std::vector< xrpl::SLE > accountObjects
Ledger objects owned by the account.
Definition AccountObjects.hpp:55
std::string ledgerHash
Hash of the ledger used for the request.
Definition AccountObjects.hpp:51
std::string account
The account whose objects are returned.
Definition AccountObjects.hpp:50
std::optional< std::string > marker
Pagination marker to resume from, if more results.
Definition AccountObjects.hpp:53
uint32_t limit
Maximum number of objects requested.
Definition AccountObjects.hpp:54
bool validated
Whether the ledger is validated.
Definition AccountObjects.hpp:56
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