Skip to content

Commit

Permalink
RPC Methods: Add getLedgers (#1221)
Browse files Browse the repository at this point in the history
  • Loading branch information
quietbits authored Jan 8, 2025
1 parent 8f1546e commit deae27d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/app/(sidebar)/endpoints/[[...pages]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
);
Expand Down
14 changes: 14 additions & 0 deletions src/constants/endpointsPages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit deae27d

Please sign in to comment.