Clio
develop
The XRP Ledger API server.
Theme:
Default
Round
Robot
Toggle main menu visibility
Loading...
Searching...
No Matches
AccountOffers.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_offers/Types.hpp>
10
#include <xrpl/protocol/STAmount.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
27
class
AccountOffersHandler
:
public
rpc::HandlerFor
<rpc::spec::handlers::account_offers::Input> {
28
std::shared_ptr<BackendInterface> sharedPtrBackend_;
29
30
public
:
31
static
constexpr
auto
kLimitMin = rpc::spec::handlers::account_offers::kLimitMin;
32
static
constexpr
auto
kLimitMax = rpc::spec::handlers::account_offers::kLimitMax;
33
static
constexpr
auto
kLimitDefault = rpc::spec::handlers::account_offers::kLimitDefault;
34
38
struct
Offer
{
39
uint32_t flags{};
40
uint32_t seq{};
41
xrpl::STAmount takerGets;
42
xrpl::STAmount takerPays;
43
std::string quality;
44
std::optional<uint32_t> expiration;
45
};
46
50
struct
Output
{
51
std::string account;
52
std::string ledgerHash;
53
uint32_t ledgerIndex{};
54
std::vector<Offer> offers;
55
std::optional<std::string> marker;
56
// validated should be sent via framework
57
bool
validated =
true
;
58
};
59
60
using
Result =
HandlerReturnType<Output>
;
61
67
AccountOffersHandler
(std::shared_ptr<BackendInterface> sharedPtrBackend)
68
: sharedPtrBackend_(std::move(sharedPtrBackend))
69
{
70
}
71
79
[[nodiscard]]
Result
80
process
(Input
const
& input,
Context
const
& ctx)
const
;
81
82
private
:
83
static
void
84
addOffer(std::vector<Offer>& offers, xrpl::SLE
const
& offerSle);
85
92
friend
void
93
tag_invoke
(boost::json::value_from_tag, boost::json::value& jv, Output
const
& output);
94
101
friend
void
102
tag_invoke
(boost::json::value_from_tag, boost::json::value& jv, Offer
const
& offer);
103
};
104
}
// namespace rpc
rpc::AccountOffersHandler::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
AccountOffers.cpp:105
rpc::AccountOffersHandler::process
Result process(Input const &input, Context const &ctx) const
Process the AccountOffers command.
Definition
AccountOffers.cpp:48
rpc::AccountOffersHandler::AccountOffersHandler
AccountOffersHandler(std::shared_ptr< BackendInterface > sharedPtrBackend)
Construct a new AccountOffersHandler object.
Definition
AccountOffers.hpp:67
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::AccountOffersHandler::Offer
A struct to hold data for one offer response.
Definition
AccountOffers.hpp:38
rpc::AccountOffersHandler::Output
A struct to hold the output data of the command.
Definition
AccountOffers.hpp:50
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
AccountOffers.hpp
Generated by
1.17.0