xrpld
Loading...
Searching...
No Matches
src/xrpld/rpc/handlers/ledger/Ledger.h
1#pragma once
2
3#include <xrpld/app/main/Application.h>
4#include <xrpld/app/misc/TxQ.h> // IWYU pragma: keep
5#include <xrpld/rpc/Context.h>
6#include <xrpld/rpc/MethodNames.h>
7#include <xrpld/rpc/Role.h>
8#include <xrpld/rpc/detail/Handler.h>
9#include <xrpld/rpc/detail/SpecBridge.hpp>
10
11#include <xrpl/json/json_value.h>
12#include <xrpl/ledger/ReadView.h>
13#include <xrpl/protocol/ApiVersion.h>
14
15#include <rpcspec/Errors.hpp>
16#include <rpcspec/handlers/ledger/Types.hpp>
17
18#include <expected>
19#include <functional>
20#include <memory>
21#include <string_view>
22#include <vector>
23
24namespace xrpl::rpc {
25
26struct JsonContext;
27
28// ledger [id|index|current|closed] [full]
29// {
30// ledger: 'current' | 'closed' | <UInt256> | <number>, // optional
31// full: true | false // optional, defaults to false.
32// }
33
34class LedgerHandler : public HandlerFor<::rpc::spec::handlers::ledger::Input>
35{
36public:
43
44 explicit LedgerHandler(JsonContext&);
45
46 [[nodiscard]] std::expected<Output, ::rpc::Status>
47 process(Input const& input);
48
49 void
50 writeResult(json::Value& value, Output const& output) const;
51
52 // NOLINTBEGIN(readability-identifier-naming)
54
55 static constexpr unsigned minApiVer = rpc::kApiMinimumSupportedVersion;
56
57 static constexpr unsigned maxApiVer = rpc::kApiMaximumValidVersion;
58
59 static constexpr Role role = Role::USER;
60
62 // NOLINTEND(readability-identifier-naming)
63
64private:
66};
67
68} // namespace xrpl::rpc
Represents a JSON value.
Definition json_value.h:117
std::expected< Output, ::rpc::Status > process(Input const &input)
static constexpr std::string_view name
void writeResult(json::Value &value, Output const &output) const
std::reference_wrapper< JsonContext > context_
constexpr std::string_view kLedger
Definition MethodNames.h:46
API version numbers used in later API versions.
Definition ApiVersion.h:36
static constexpr auto kApiMaximumValidVersion
Definition ApiVersion.h:47
static constexpr auto kApiMinimumSupportedVersion
Definition ApiVersion.h:42
Role
Indicates the level of administrative permission to grant.
Definition Role.h:27
@ USER
Definition Role.h:27