Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
AccountTx.hpp
1#pragma once
2
3#include "data/BackendInterface.hpp"
4#include "etl/ETLServiceInterface.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/account_tx/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 AccountTxHandler : public rpc::HandlerFor<rpc::spec::handlers::account_tx::Input> {
31 util::Logger log_{"RPC"};
32 std::shared_ptr<BackendInterface> sharedPtrBackend_;
33 std::shared_ptr<etl::ETLServiceInterface const> etl_;
34
35public:
36 static constexpr auto kLimitMin = rpc::spec::handlers::account_tx::kLimitMin;
37 static constexpr auto kLimitMax = rpc::spec::handlers::account_tx::kLimitMax;
38 static constexpr auto kLimitDefault = rpc::spec::handlers::account_tx::kLimitDefault;
39
40 using Marker = rpc::spec::handlers::account_tx::Marker;
41
45 struct Output {
46 std::string account;
47 uint32_t ledgerIndexMin{0};
48 uint32_t ledgerIndexMax{0};
49 std::optional<uint32_t> limit;
50 std::optional<Marker> marker;
51 // TODO: use a better type than json
52 boost::json::array transactions;
53 // validated should be sent via framework
54 bool validated = true;
55 };
56
57 using Result = HandlerReturnType<Output>;
58
66 std::shared_ptr<BackendInterface> sharedPtrBackend,
67 std::shared_ptr<etl::ETLServiceInterface const> const& etl
68 )
69 : sharedPtrBackend_(std::move(sharedPtrBackend)), etl_{etl}
70 {
71 }
72
80 [[nodiscard]] Result
81 process(Input const& input, Context const& ctx) const;
82
83private:
90 friend void
91 tag_invoke(boost::json::value_from_tag, boost::json::value& jv, Output const& output);
92};
93
94} // namespace rpc
95
96namespace rpc::spec::handlers::account_tx {
97
98void
99tag_invoke(boost::json::value_from_tag, boost::json::value& jv, Marker const& marker);
100
101} // namespace rpc::spec::handlers::account_tx
Result process(Input const &input, Context const &ctx) const
Process the AccountTx command.
Definition AccountTx.cpp:39
AccountTxHandler(std::shared_ptr< BackendInterface > sharedPtrBackend, std::shared_ptr< etl::ETLServiceInterface const > const &etl)
Construct a new AccountTxHandler object.
Definition AccountTx.hpp:65
friend void tag_invoke(boost::json::value_from_tag, boost::json::value &jv, Output const &output)
Convert the Output to a JSON object.
Definition AccountTx.cpp:244
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
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 AccountTx.hpp:45
Context of an RPC call.
Definition Types.hpp:98
Result type used to return responses or error statuses to the Webserver subsystem.
Definition Types.hpp:109