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;
48 std::map<xrpl::Currency, xrpl::STAmount> sums;
52 std::map<xrpl::AccountID, std::vector<xrpl::STAmount>> hotBalances;
56 std::map<xrpl::AccountID, std::vector<xrpl::STAmount>> assets;
60 std::map<xrpl::AccountID, std::vector<xrpl::STAmount>> frozenBalances;
64 std::map<xrpl::Currency, xrpl::STAmount> locked;
65 // validated should be sent via framework
66 bool validated = true;
67 };
68
73
79 GatewayBalancesHandler(std::shared_ptr<BackendInterface> sharedPtrBackend)
80 : sharedPtrBackend_(std::move(sharedPtrBackend))
81 {
82 }
83
91 [[nodiscard]] Result
92 process(Input const& input, Context const& ctx) const;
93
94private:
101 friend void
102 tag_invoke(boost::json::value_from_tag, boost::json::value& jv, Output const& output);
103};
104
105} // namespace rpc
GatewayBalancesHandler(std::shared_ptr< BackendInterface > sharedPtrBackend)
Construct a new GatewayBalancesHandler object.
Definition GatewayBalances.hpp:79
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:178
HandlerReturnType< Output > Result
The result type of the command: either the Output or an error status.
Definition GatewayBalances.hpp:72
Result process(Input const &input, Context const &ctx) const
Process the GatewayBalances command.
Definition GatewayBalances.cpp:38
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 GatewayBalances.hpp:40
std::map< xrpl::Currency, xrpl::STAmount > sums
Total obligations to customers, per currency.
Definition GatewayBalances.hpp:48
bool overflow
Whether a sum overflowed; currently never set (sums saturate).
Definition GatewayBalances.hpp:44
bool validated
Whether the ledger is validated.
Definition GatewayBalances.hpp:66
uint32_t ledgerIndex
Sequence of the ledger used.
Definition GatewayBalances.hpp:42
std::map< xrpl::AccountID, std::vector< xrpl::STAmount > > hotBalances
Balances issued to the requested hot wallets.
Definition GatewayBalances.hpp:52
std::string accountID
Address of the gateway (issuing) account.
Definition GatewayBalances.hpp:43
std::map< xrpl::AccountID, std::vector< xrpl::STAmount > > assets
Positive balances owed to the gateway, per peer.
Definition GatewayBalances.hpp:56
std::map< xrpl::AccountID, std::vector< xrpl::STAmount > > frozenBalances
Obligations frozen by the gateway, per holder.
Definition GatewayBalances.hpp:60
std::string ledgerHash
Hash of the ledger used.
Definition GatewayBalances.hpp:41
std::map< xrpl::Currency, xrpl::STAmount > locked
Amounts locked in escrow, per currency.
Definition GatewayBalances.hpp:64
Result type used to return responses or error statuses to the Webserver subsystem.
Definition Types.hpp:132