Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
DepositAuthorized.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/deposit_authorized/Types.hpp>
11#include <xrpl/basics/base_uint.h>
12#include <xrpl/protocol/STArray.h>
13
14#include <cstdint>
15#include <expected>
16#include <memory>
17#include <optional>
18#include <string>
19#include <utility>
20#include <vector>
21
22namespace rpc {
23
34 : public rpc::HandlerFor<rpc::spec::handlers::deposit_authorized::Input> {
35 // dependencies
36 std::shared_ptr<BackendInterface> const sharedPtrBackend_;
37
38public:
39 // Note: `ledger_current_index` is omitted because it only makes sense for rippled
43 struct Output {
44 bool depositAuthorized = true;
45 std::string sourceAccount;
46 std::string destinationAccount;
47 std::string ledgerHash;
48 uint32_t ledgerIndex{};
52 std::optional<std::vector<xrpl::uint256>> credentials;
53
54 // validated should be sent via framework
55 bool validated = true;
56 };
57
62
68 DepositAuthorizedHandler(std::shared_ptr<BackendInterface> sharedPtrBackend)
69 : sharedPtrBackend_(std::move(sharedPtrBackend))
70 {
71 }
72
80 [[nodiscard]] Result
81 process(Input const& input, Context const& ctx) const;
82
83private:
90 friend void
91 tag_invoke(boost::json::value_from_tag, boost::json::value& jv, Output const& output);
92};
93
94} // namespace rpc
friend void tag_invoke(boost::json::value_from_tag, boost::json::value &jv, Output const &output)
Convert the Output to a JSON object.
Definition DepositAuthorized.cpp:130
DepositAuthorizedHandler(std::shared_ptr< BackendInterface > sharedPtrBackend)
Construct a new DepositAuthorizedHandler object.
Definition DepositAuthorized.hpp:68
HandlerReturnType< Output > Result
The result type of the command: either the Output or an error status.
Definition DepositAuthorized.hpp:61
Result process(Input const &input, Context const &ctx) const
Process the DepositAuthorized command.
Definition DepositAuthorized.cpp:35
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 DepositAuthorized.hpp:43
std::string sourceAccount
Address of the sending account.
Definition DepositAuthorized.hpp:45
uint32_t ledgerIndex
Sequence of the ledger used.
Definition DepositAuthorized.hpp:48
bool depositAuthorized
Whether the source may pay the destination.
Definition DepositAuthorized.hpp:44
std::string ledgerHash
Hash of the ledger used.
Definition DepositAuthorized.hpp:47
bool validated
Whether the ledger is validated.
Definition DepositAuthorized.hpp:55
std::string destinationAccount
Address of the receiving account.
Definition DepositAuthorized.hpp:46
std::optional< std::vector< xrpl::uint256 > > credentials
Credentials from the request, if any.
Definition DepositAuthorized.hpp:52
Result type used to return responses or error statuses to the Webserver subsystem.
Definition Types.hpp:132