js-stellar-sdk icon indicating copy to clipboard operation
js-stellar-sdk copied to clipboard

Type for `rpc.Api.GetTransactionsRequest` is wrong

Open fnando opened this issue 8 months ago • 0 comments

Describe the bug

Type for rpc.Api.GetTransactionsRequest is wrong

export interface GetTransactionsRequest {
  startLedger: number;
  cursor?: string;
  limit?: number;
}

The documentation states that startLedger can be omitted if cursor is present.

Ledger sequence number to start fetching responses from (inclusive). This method will return an error if startLedger is less than the oldest ledger stored in this node, or greater than the latest ledger seen by this node. If a cursor is included in the request, startLedger must be omitted.

What version are you on?

13.0.0

To Reproduce

Doing something like

const params: StellarRpc.Api.GetTransactionsRequest = { cursor: "asdf" };

will fail with this:

error TS2741: Property 'startLedger' is missing in type '{ cursor: string; }' but required in type 'GetTransactionsRequest'.

23       const params: StellarRpc.Api.GetTransactionsRequest = { cursor: "asdf" };
               ~~~~~~

  node_modules/@stellar/stellar-sdk/lib/rpc/api.d.ts:104:9
    104         startLedger: number;
                ~~~~~~~~~~~
    'startLedger' is declared here.

Expected behavior

startLedger should be optional when cursor is present.

fnando avatar Apr 08 '25 19:04 fnando