Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
TransactionEntry.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/object.hpp>
9#include <boost/json/value.hpp>
10#include <rpcspec/handlers/transaction_entry/Types.hpp>
11#include <xrpl/protocol/LedgerHeader.h>
12
13#include <cstdint>
14#include <memory>
15#include <optional>
16#include <utility>
17
18namespace rpc {
19
27 : public rpc::HandlerFor<rpc::spec::handlers::transaction_entry::Input> {
28 std::shared_ptr<BackendInterface> sharedPtrBackend_;
29
30public:
34 struct Output {
38 std::optional<xrpl::LedgerHeader> ledgerHeader;
39 // TODO: use a better type for this
40 boost::json::object metadata;
41 boost::json::object tx;
42 // validated should be sent via framework
43 bool validated = true;
44 uint32_t apiVersion;
45 };
46
51
57 TransactionEntryHandler(std::shared_ptr<BackendInterface> sharedPtrBackend)
58 : sharedPtrBackend_(std::move(sharedPtrBackend))
59 {
60 }
61
69 [[nodiscard]] Result
70 process(Input const& input, Context const& ctx) const;
71
72private:
79 friend void
80 tag_invoke(boost::json::value_from_tag, boost::json::value& jv, Output const& output);
81};
82
83} // namespace rpc
Result process(Input const &input, Context const &ctx) const
Process the transaction_entry command.
Definition TransactionEntry.cpp:21
friend void tag_invoke(boost::json::value_from_tag, boost::json::value &jv, Output const &output)
Convert the Output to a JSON object.
Definition TransactionEntry.cpp:72
HandlerReturnType< Output > Result
The result type of the command: either the Output or an error status.
Definition TransactionEntry.hpp:50
TransactionEntryHandler(std::shared_ptr< BackendInterface > sharedPtrBackend)
Construct a new Transaction Entry Handler object.
Definition TransactionEntry.hpp:57
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
Result type used to return responses or error statuses to the Webserver subsystem.
Definition Types.hpp:132
A struct to hold the output data of the command.
Definition TransactionEntry.hpp:34
boost::json::object metadata
Transaction metadata as JSON.
Definition TransactionEntry.hpp:40
boost::json::object tx
Transaction as JSON.
Definition TransactionEntry.hpp:41
bool validated
Whether the ledger is validated.
Definition TransactionEntry.hpp:43
std::optional< xrpl::LedgerHeader > ledgerHeader
Header of the ledger containing the transaction.
Definition TransactionEntry.hpp:38
uint32_t apiVersion
API version of the request.
Definition TransactionEntry.hpp:44