From deae27d5ad97160407e4e7125f30a94d2f17b72f Mon Sep 17 00:00:00 2001 From: Iveta Date: Wed, 8 Jan 2025 13:47:43 -0500 Subject: [PATCH] RPC Methods: Add getLedgers (#1221) --- .../(sidebar)/endpoints/[[...pages]]/page.tsx | 23 +++++++++++++++++++ src/constants/endpointsPages.ts | 14 +++++++++++ src/constants/routes.ts | 1 + 3 files changed, 38 insertions(+) diff --git a/src/app/(sidebar)/endpoints/[[...pages]]/page.tsx b/src/app/(sidebar)/endpoints/[[...pages]]/page.tsx index 4e23c262..49964b87 100644 --- a/src/app/(sidebar)/endpoints/[[...pages]]/page.tsx +++ b/src/app/(sidebar)/endpoints/[[...pages]]/page.tsx @@ -208,6 +208,20 @@ export default function Endpoints() { }; } + case Routes.ENDPOINTS_GET_LEDGERS: { + return { + ...defaultRpcRequestBody, + params: { + startLedger: Number(params.startLedger) || null, + pagination: sanitizeObject({ + cursor: params.cursor, + limit: Number(params.limit) || undefined, + }), + xdrFormat: params.xdrFormat || "base64", + }, + }; + } + case Routes.ENDPOINTS_GET_TRANSACTION: { return { ...defaultRpcRequestBody, @@ -363,6 +377,15 @@ export default function Endpoints() { } }); + // RPC Cursor field can be used instead of the required Start Ledger Sequence + if ( + isRpcEndpoint && + requiredFields.includes("startLedger") && + !params.startLedger + ) { + isValidReqFields = Boolean(params.cursor); + } + return ( isValidReqAssetFields && isValidReqFields && isValid && isAssetMultiValid ); diff --git a/src/constants/endpointsPages.ts b/src/constants/endpointsPages.ts index 2be26424..7fc989a1 100644 --- a/src/constants/endpointsPages.ts +++ b/src/constants/endpointsPages.ts @@ -99,6 +99,20 @@ export const ENDPOINTS_PAGES_RPC: EndpointsPagesProps = { isStreaming: false, }, }, + { + route: Routes.ENDPOINTS_GET_LEDGERS, + label: "getLedgers", + form: { + docsUrl: + "https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgers", + docsLabel: "getLedgers", + endpointUrlTemplate: "{?startLedger,cursor,limit,xdrFormat}", + requestMethod: "POST", + requiredParams: "startLedger", + rpcMethod: "getLedgers", + isStreaming: false, + }, + }, { route: Routes.ENDPOINTS_GET_NETWORK, label: "getNetwork", diff --git a/src/constants/routes.ts b/src/constants/routes.ts index dae40ce9..2ac16c26 100644 --- a/src/constants/routes.ts +++ b/src/constants/routes.ts @@ -64,6 +64,7 @@ export enum Routes { ENDPOINTS_GET_HEALTH = "/endpoints/rpc/get-health", ENDPOINTS_GET_LATEST_LEDGER = "/endpoints/rpc/get-latest-ledger", ENDPOINTS_GET_LEDGER_ENTRIES = "/endpoints/rpc/get-ledger-entries", + ENDPOINTS_GET_LEDGERS = "/endpoints/rpc/get-ledgers", ENDPOINTS_GET_NETWORK = "/endpoints/rpc/get-network", ENDPOINTS_GET_TRANSACTION = "/endpoints/rpc/get-transaction", ENDPOINTS_GET_TRANSACTIONS = "/endpoints/rpc/get-transactions",