Clio
develop
The XRP Ledger API server.
Theme:
Default
Round
Robot
Toggle main menu visibility
Loading...
Searching...
No Matches
AccountChannels.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_channels/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
19
namespace
rpc
{
20
28
class
AccountChannelsHandler
29
:
public
rpc::HandlerFor
<rpc::spec::handlers::account_channels::Input> {
30
// dependencies
31
std::shared_ptr<BackendInterface>
const
sharedPtrBackend_;
32
33
public
:
34
static
constexpr
auto
kLimitMin = rpc::spec::handlers::account_channels::kLimitMin;
35
static
constexpr
auto
kLimitMax = rpc::spec::handlers::account_channels::kLimitMax;
36
static
constexpr
auto
kLimitDefault = rpc::spec::handlers::account_channels::kLimitDefault;
37
43
struct
ChannelResponse
{
44
std::string channelID;
45
std::string account;
46
std::string accountDestination;
47
std::string amount;
48
std::string balance;
49
std::optional<std::string> publicKey;
50
std::optional<std::string> publicKeyHex;
51
uint32_t settleDelay{};
52
std::optional<uint32_t> expiration;
53
std::optional<uint32_t> cancelAfter;
54
std::optional<uint32_t> sourceTag;
55
std::optional<uint32_t> destinationTag;
56
};
57
61
struct
Output
{
62
std::vector<ChannelResponse> channels;
63
std::string account;
64
std::string ledgerHash;
65
uint32_t ledgerIndex{};
66
// validated should be sent via framework
67
bool
validated =
true
;
68
uint32_t limit{};
69
std::optional<std::string> marker;
70
};
71
72
using
Result =
HandlerReturnType<Output>
;
73
79
AccountChannelsHandler
(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
94
private
:
95
static
void
96
addChannel(std::vector<ChannelResponse>& jsonChannels, xrpl::SLE
const
& channelSle);
97
104
friend
void
105
tag_invoke
(boost::json::value_from_tag, boost::json::value& jv, Output
const
& output);
106
113
friend
void
114
tag_invoke
(boost::json::value_from_tag, boost::json::value& jv, ChannelResponse
const
& channel);
115
};
116
}
// namespace rpc
rpc::AccountChannelsHandler::AccountChannelsHandler
AccountChannelsHandler(std::shared_ptr< BackendInterface > sharedPtrBackend)
Construct a new AccountChannelsHandler object.
Definition
AccountChannels.hpp:79
rpc::AccountChannelsHandler::process
Result process(Input const &input, Context const &ctx) const
Process the AccountChannels command.
Definition
AccountChannels.cpp:67
rpc::AccountChannelsHandler::tag_invoke
friend void tag_invoke(boost::json::value_from_tag, boost::json::value &jv, Output const &output)
Convert the Output to a JSON object.
Definition
AccountChannels.cpp:131
rpc
This namespace contains all the RPC logic and handlers.
Definition
AMMHelpers.cpp:17
rpc::HandlerReturnType
std::expected< OutputType, Status > HandlerReturnType
Return type for each individual handler.
Definition
Types.hpp:61
rpc::HandlerFor
spec::HandlerFor< InputT, boost::json::value > HandlerFor
The spec-driven base every typed handler inherits.
Definition
SpecBackend.hpp:24
rpc::AccountChannelsHandler::ChannelResponse
A struct to hold data for one channel response.
Definition
AccountChannels.hpp:43
rpc::AccountChannelsHandler::Output
A struct to hold the output data of the command.
Definition
AccountChannels.hpp:61
rpc::Context
Context of an RPC call.
Definition
Types.hpp:98
rpc::Result
Result type used to return responses or error statuses to the Webserver subsystem.
Definition
Types.hpp:109
src
rpc
handlers
AccountChannels.hpp
Generated by
1.17.0