Clio
develop
The XRP Ledger API server.
Theme:
Default
Round
Robot
Toggle main menu visibility
Loading...
Searching...
No Matches
AccountLines.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_lines/Types.hpp>
10
#include <xrpl/protocol/AccountID.h>
11
#include <xrpl/protocol/STLedgerEntry.h>
12
13
#include <cstdint>
14
#include <memory>
15
#include <optional>
16
#include <string>
17
#include <utility>
18
#include <vector>
19
20
namespace
rpc
{
21
28
class
AccountLinesHandler
:
public
rpc::HandlerFor
<rpc::spec::handlers::account_lines::Input> {
29
// dependencies
30
std::shared_ptr<BackendInterface>
const
sharedPtrBackend_;
31
32
public
:
33
static
constexpr
auto
kLimitMin = rpc::spec::handlers::account_lines::kLimitMin;
34
static
constexpr
auto
kLimitMax = rpc::spec::handlers::account_lines::kLimitMax;
35
static
constexpr
auto
kLimitDefault = rpc::spec::handlers::account_lines::kLimitDefault;
36
40
struct
LineResponse
{
41
std::string account;
42
std::string balance;
43
std::string currency;
44
std::string limit;
45
std::string limitPeer;
46
uint32_t qualityIn{};
47
uint32_t qualityOut{};
48
std::optional<bool> noRipple;
49
std::optional<bool> noRipplePeer;
50
std::optional<bool> authorized;
51
std::optional<bool> peerAuthorized;
52
std::optional<bool> freeze;
53
std::optional<bool> freezePeer;
54
std::optional<bool> deepFreeze;
55
std::optional<bool> deepFreezePeer;
56
};
57
61
struct
Output
{
62
std::string account;
63
std::vector<LineResponse> lines;
64
std::string ledgerHash;
65
uint32_t ledgerIndex{};
66
bool
validated =
true
;
// should be sent via framework
67
std::optional<std::string> marker;
68
uint32_t limit{};
69
};
70
71
using
Result =
HandlerReturnType<Output>
;
72
78
AccountLinesHandler
(std::shared_ptr<BackendInterface> sharedPtrBackend)
79
: sharedPtrBackend_(std::move(sharedPtrBackend))
80
{
81
}
82
90
[[nodiscard]]
Result
91
process
(Input
const
& input,
Context
const
& ctx)
const
;
92
93
private
:
94
static
void
95
addLine(
96
std::vector<LineResponse>& lines,
97
xrpl::SLE
const
& lineSle,
98
xrpl::AccountID
const
& account,
99
std::optional<xrpl::AccountID>
const
& peerAccount
100
);
101
102
private
:
109
friend
void
110
tag_invoke
(boost::json::value_from_tag, boost::json::value& jv, Output
const
& output);
111
118
friend
void
119
tag_invoke
(boost::json::value_from_tag, boost::json::value& jv, LineResponse
const
& line);
120
};
121
122
}
// namespace rpc
rpc::AccountLinesHandler::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
AccountLines.cpp:191
rpc::AccountLinesHandler::AccountLinesHandler
AccountLinesHandler(std::shared_ptr< BackendInterface > sharedPtrBackend)
Construct a new AccountLinesHandler object.
Definition
AccountLines.hpp:78
rpc::AccountLinesHandler::process
Result process(Input const &input, Context const &ctx) const
Process the AccountLines command.
Definition
AccountLines.cpp:118
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::AccountLinesHandler::LineResponse
A struct to hold data for one line response.
Definition
AccountLines.hpp:40
rpc::AccountLinesHandler::Output
A struct to hold the output data of the command.
Definition
AccountLines.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
AccountLines.hpp
Generated by
1.17.0