Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
AccountCurrencies.hpp
1#pragma once
2
3#include "data/BackendInterface.hpp"
4#include "rpc/JS.hpp"
5#include "rpc/common/Checkers.hpp"
6#include "rpc/common/Specs.hpp"
7#include "rpc/common/Types.hpp"
8#include "rpc/common/Validators.hpp"
9
10#include <boost/json/conversion.hpp>
11#include <boost/json/value.hpp>
12#include <xrpl/protocol/jss.h>
13
14#include <cstdint>
15#include <memory>
16#include <optional>
17#include <set>
18#include <string>
19
20namespace rpc {
21
29 // dependencies
30 std::shared_ptr<BackendInterface> sharedPtrBackend_;
31
32public:
36 struct Output {
37 std::string ledgerHash;
38 uint32_t ledgerIndex{};
39 std::set<std::string> receiveCurrencies;
40 std::set<std::string> sendCurrencies;
41 // validated should be sent via framework
42 bool validated = true;
43 };
44
48 struct Input {
49 std::string account;
50 std::optional<std::string> ledgerHash;
51 std::optional<uint32_t> ledgerIndex;
52 };
53
54 using Result = HandlerReturnType<Output>;
55
61 AccountCurrenciesHandler(std::shared_ptr<BackendInterface> sharedPtrBackend)
62 : sharedPtrBackend_(std::move(sharedPtrBackend))
63 {
64 }
65
72 static RpcSpecConstRef
73 spec([[maybe_unused]] uint32_t apiVersion)
74 {
75 static auto const kRPC_SPEC = RpcSpec{
79 {"account_index", check::Deprecated{}},
80 {JS(strict), check::Deprecated{}}
81 };
82
83 return kRPC_SPEC;
84 }
85
93 Result
94 process(Input const& input, Context const& ctx) const;
95
96private:
103 friend void
104 tag_invoke(boost::json::value_from_tag, boost::json::value& jv, Output const& output);
105
112 friend Input
113 tag_invoke(boost::json::value_to_tag<Input>, boost::json::value const& jv);
114};
115
116} // namespace rpc
Result process(Input const &input, Context const &ctx) const
Process the AccountCurrencies command.
Definition AccountCurrencies.cpp:28
friend void tag_invoke(boost::json::value_from_tag, boost::json::value &jv, Output const &output)
Convert the Output to a JSON object.
Definition AccountCurrencies.cpp:92
AccountCurrenciesHandler(std::shared_ptr< BackendInterface > sharedPtrBackend)
Construct a new AccountCurrenciesHandler object.
Definition AccountCurrencies.hpp:61
static RpcSpecConstRef spec(uint32_t apiVersion)
Returns the API specification for the command.
Definition AccountCurrencies.hpp:73
Check for a deprecated fields.
Definition Checkers.hpp:44
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:18
RpcSpec const & RpcSpecConstRef
An alias for a const reference to RpcSpec.
Definition Specs.hpp:130
std::expected< OutputType, Status > HandlerReturnType
Return type for each individual handler.
Definition Types.hpp:62
A struct to hold the input data for the command.
Definition AccountCurrencies.hpp:48
A struct to hold the output data of the command.
Definition AccountCurrencies.hpp:36
Context of an RPC call.
Definition Types.hpp:99
Result type used to return responses or error statuses to the Webserver subsystem.
Definition Types.hpp:110
Represents a Specification of an entire RPC command.
Definition Specs.hpp:82
static CustomValidator accountValidator
Provides a commonly used validator for accounts.
Definition Validators.hpp:504
static CustomValidator ledgerIndexValidator
Provides a commonly used validator for ledger index.
Definition Validators.hpp:489
static CustomValidator uint256HexStringValidator
Provides a commonly used validator for uint256 hex string.
Definition Validators.hpp:551
A validator that simply requires a field to be present.
Definition Validators.hpp:28