1#include <xrpld/rpc/detail/Handler.h>
2#include <xrpld/rpc/handlers/Handlers.h>
3#include <xrpld/rpc/handlers/Version.h>
5#include <xrpl/basics/contract.h>
6#include <xrpl/protocol/ApiVersion.h>
15template <
typename Function>
16Handler::Method<Json::Value>
17byRef(Function
const& f)
19 return [f](JsonContext& context,
Json::Value& result) {
24 UNREACHABLE(
"xrpl::RPC::byRef : result is object");
33template <
class Object,
class HandlerImpl>
35handle(JsonContext& context, Object&
object)
38 context.apiVersion >= HandlerImpl::minApiVer &&
39 context.apiVersion <= HandlerImpl::maxApiVer,
40 "xrpl::RPC::handle : valid API version");
41 HandlerImpl handler(context);
43 auto status = handler.check();
47 handler.writeResult(
object);
51template <
typename HandlerImpl>
57 &handle<Json::Value, HandlerImpl>,
59 HandlerImpl::condition,
60 HandlerImpl::minApiVer,
61 HandlerImpl::maxApiVer};
64Handler
const handlerArray[]{
68 {
"account_currencies",
87 {
"deposit_authorized",
96 {
"get_aggregate_price",
131 {
"peer_reservations_add",
135 {
"peer_reservations_del",
139 {
"peer_reservations_list",
144 {
"server_definitions",
155 {
"submit_multisigned",
164 {
"validation_create",
169 {
"validator_list_sites",
189 overlappingApiVersion(
196 "xrpl::RPC::HandlerTable : valid API version range");
199 "xrpl::RPC::HandlerTable : valid max API version");
204 [minVer, maxVer](
auto const& item) {
205 return item.second.minApiVer_ <= maxVer &&
206 item.second.maxApiVer_ >= minVer;
210 template <std::
size_t N>
211 explicit HandlerTable(Handler
const (&entries)[N])
213 for (
auto const& entry : entries)
215 if (overlappingApiVersion(
221 " overlaps with an existing handler");
227 addHandler<LedgerHandler>();
228 addHandler<VersionHandler>();
232 static HandlerTable
const&
235 static HandlerTable
const handlerTable(handlerArray);
239 [[nodiscard]] Handler
const*
250 range.first,
range.second, [version](
auto const& entry) {
251 return entry.second.minApiVer_ <= version &&
252 version <= entry.second.maxApiVer_;
255 return i ==
range.second ? nullptr : &i->second;
262 for (
auto const& i : table_)
263 ret.insert(i.second.name_);
269 handler_table_t table_;
271 template <
class HandlerImpl>
275 static_assert(HandlerImpl::minApiVer <= HandlerImpl::maxApiVer);
280 if (overlappingApiVersion(
282 HandlerImpl::minApiVer,
283 HandlerImpl::maxApiVer))
286 " overlaps with an existing handler");
288 table_.
insert({HandlerImpl::name, handlerFrom<HandlerImpl>()});
297 return HandlerTable::instance().getHandler(version, betaEnabled, name);
303 return HandlerTable::instance().getHandlerNames();
@ objectValue
object value (collection of name/value pairs).
Status
Return codes from Backend operations.
Json::Value makeObjectValue(Value const &value, Json::StaticString const &field=jss::message)
Return a Json::objectValue with a single entry.
static constexpr auto apiBetaVersion
@ NEEDS_NETWORK_CONNECTION
std::set< char const * > getHandlerNames()
Return names of all methods.
Handler const * getHandler(unsigned version, bool betaEnabled, std::string const &name)
static constexpr auto apiMinimumSupportedVersion
static constexpr auto apiMaximumValidVersion
static constexpr auto apiMaximumSupportedVersion
Json::Value entry(jtx::Env &env, jtx::Account const &account, jtx::Account const &authorize)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Json::Value doDepositAuthorized(RPC::JsonContext &context)
Json::Value doAMMInfo(RPC::JsonContext &context)
Json::Value doOwnerInfo(RPC::JsonContext &)
Json::Value doSignFor(RPC::JsonContext &)
Json::Value doLedgerData(RPC::JsonContext &)
Json::Value doValidatorListSites(RPC::JsonContext &)
void LogicError(std::string const &how) noexcept
Called when faulty logic causes a broken invariant.
Json::Value doLedgerAccept(RPC::JsonContext &)
Json::Value doValidationCreate(RPC::JsonContext &)
Json::Value doAccountChannels(RPC::JsonContext &context)
Json::Value doNFTSellOffers(RPC::JsonContext &)
Json::Value doServerInfo(RPC::JsonContext &)
Json::Value doRipplePathFind(RPC::JsonContext &)
Json::Value doConsensusInfo(RPC::JsonContext &context)
Json::Value doVaultInfo(RPC::JsonContext &)
Json::Value doFetchInfo(RPC::JsonContext &context)
Json::Value doRandom(RPC::JsonContext &)
ClosedInterval< T > range(T low, T high)
Create a closed range interval.
Json::Value doTxHistory(RPC::JsonContext &)
Json::Value doTxJson(RPC::JsonContext &)
Json::Value doPeerReservationsList(RPC::JsonContext &)
Json::Value doAccountOffers(RPC::JsonContext &context)
Json::Value doSubscribe(RPC::JsonContext &)
Json::Value doLogLevel(RPC::JsonContext &)
Json::Value doValidators(RPC::JsonContext &)
Json::Value doAccountNFTs(RPC::JsonContext &context)
General RPC command that can retrieve objects in the account root.
Json::Value doLedgerHeader(RPC::JsonContext &)
Json::Value doChannelAuthorize(RPC::JsonContext &)
Json::Value doPing(RPC::JsonContext &)
Json::Value doLedgerRequest(RPC::JsonContext &)
Json::Value doSign(RPC::JsonContext &)
Json::Value doLedgerCurrent(RPC::JsonContext &)
Json::Value doStop(RPC::JsonContext &)
Json::Value doPeers(RPC::JsonContext &)
Json::Value doLogRotate(RPC::JsonContext &)
Json::Value doServerDefinitions(RPC::JsonContext &)
Json::Value doPathFind(RPC::JsonContext &)
Json::Value doUnlList(RPC::JsonContext &)
Json::Value doFee(RPC::JsonContext &context)
Json::Value doPeerReservationsDel(RPC::JsonContext &)
Json::Value doAccountCurrencies(RPC::JsonContext &context)
Json::Value doSubmitMultiSigned(RPC::JsonContext &)
Json::Value doBookChanges(RPC::JsonContext &context)
Json::Value doAccountTxJson(RPC::JsonContext &context)
Json::Value doTransactionEntry(RPC::JsonContext &)
Json::Value doManifest(RPC::JsonContext &context)
Json::Value doBookOffers(RPC::JsonContext &context)
Json::Value doGetCounts(RPC::JsonContext &context)
Json::Value doPrint(RPC::JsonContext &)
Json::Value doChannelVerify(RPC::JsonContext &)
Json::Value doUnsubscribe(RPC::JsonContext &)
Json::Value doAccountLines(RPC::JsonContext &context)
Json::Value doCanDelete(RPC::JsonContext &context)
Json::Value doAccountObjects(RPC::JsonContext &context)
Json::Value doLedgerCleaner(RPC::JsonContext &)
Json::Value doPeerReservationsAdd(RPC::JsonContext &)
Json::Value doConnect(RPC::JsonContext &context)
Json::Value doGetAggregatePrice(RPC::JsonContext &context)
oracles: array of {account, oracle_document_id} base_asset: is the asset to be priced quote_asset: is...
Json::Value doNFTBuyOffers(RPC::JsonContext &)
Json::Value doValidatorInfo(RPC::JsonContext &)
Json::Value doFeature(RPC::JsonContext &context)
Json::Value doSimulate(RPC::JsonContext &)
Json::Value doAccountInfo(RPC::JsonContext &context)
Json::Value doWalletPropose(RPC::JsonContext &)
Json::Value doLedgerClosed(RPC::JsonContext &)
Json::Value doSubmit(RPC::JsonContext &)
Json::Value doBlackList(RPC::JsonContext &context)
Json::Value doTxReduceRelay(RPC::JsonContext &)
Json::Value doNoRippleCheck(RPC::JsonContext &)
Json::Value doServerState(RPC::JsonContext &)
Json::Value doGatewayBalances(RPC::JsonContext &context)
Json::Value doLedgerEntry(RPC::JsonContext &)