Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
GatewayBalances.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/gateway_balances/Types.hpp>
11#include <xrpl/protocol/AccountID.h>
12#include <xrpl/protocol/STAmount.h>
13#include <xrpl/protocol/UintTypes.h>
14
15#include <cstdint>
16#include <map>
17#include <memory>
18#include <string>
19#include <utility>
20#include <vector>
21
22namespace rpc {
23
33 : public rpc::HandlerFor<rpc::spec::handlers::gateway_balances::Input> {
34 std::shared_ptr<BackendInterface> sharedPtrBackend_;
35
36public:
40 struct Output {
41 std::string ledgerHash;
42 uint32_t ledgerIndex;
43 std::string accountID;
44 bool overflow = false;
45 std::map<xrpl::Currency, xrpl::STAmount> sums;
46 std::map<xrpl::AccountID, std::vector<xrpl::STAmount>> hotBalances;
47 std::map<xrpl::AccountID, std::vector<xrpl::STAmount>> assets;
48 std::map<xrpl::AccountID, std::vector<xrpl::STAmount>> frozenBalances;
49 std::map<xrpl::Currency, xrpl::STAmount> locked;
50 // validated should be sent via framework
51 bool validated = true;
52 };
53
54 using Result = HandlerReturnType<Output>;
55
61 GatewayBalancesHandler(std::shared_ptr<BackendInterface> sharedPtrBackend)
62 : sharedPtrBackend_(std::move(sharedPtrBackend))
63 {
64 }
65
73 [[nodiscard]] Result
74 process(Input const& input, Context const& ctx) const;
75
76private:
83 friend void
84 tag_invoke(boost::json::value_from_tag, boost::json::value& jv, Output const& output);
85};
86
87} // namespace rpc
GatewayBalancesHandler(std::shared_ptr< BackendInterface > sharedPtrBackend)
Construct a new GatewayBalancesHandler object.
Definition GatewayBalances.hpp:61
friend void tag_invoke(boost::json::value_from_tag, boost::json::value &jv, Output const &output)
Convert the Output to a JSON object.
Definition GatewayBalances.cpp:172
Result process(Input const &input, Context const &ctx) const
Process the GatewayBalances command.
Definition GatewayBalances.cpp:37
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
Context of an RPC call.
Definition Types.hpp:98
A struct to hold the output data of the command.
Definition GatewayBalances.hpp:40
Result type used to return responses or error statuses to the Webserver subsystem.
Definition Types.hpp:109