@stellar/stellar-sdk 14.2.0 → 14.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/stellar-sdk-minimal.js +85 -43
  3. package/dist/stellar-sdk-minimal.min.js +1 -1
  4. package/dist/stellar-sdk-no-axios.js +85 -43
  5. package/dist/stellar-sdk-no-axios.min.js +1 -1
  6. package/dist/stellar-sdk-no-eventsource.js +85 -43
  7. package/dist/stellar-sdk-no-eventsource.min.js +1 -1
  8. package/dist/stellar-sdk.js +85 -43
  9. package/dist/stellar-sdk.min.js +1 -1
  10. package/lib/contract/spec.js +10 -2
  11. package/lib/errors/account_requires_memo.d.ts +0 -1
  12. package/lib/errors/account_requires_memo.js +0 -4
  13. package/lib/errors/bad_request.d.ts +0 -1
  14. package/lib/errors/bad_request.js +2 -8
  15. package/lib/errors/bad_response.d.ts +0 -1
  16. package/lib/errors/bad_response.js +2 -8
  17. package/lib/errors/network.d.ts +0 -1
  18. package/lib/errors/network.js +0 -3
  19. package/lib/errors/not_found.d.ts +0 -1
  20. package/lib/errors/not_found.js +2 -8
  21. package/lib/horizon/horizon_axios_client.js +1 -1
  22. package/lib/minimal/contract/spec.js +10 -2
  23. package/lib/minimal/errors/account_requires_memo.d.ts +0 -1
  24. package/lib/minimal/errors/account_requires_memo.js +0 -4
  25. package/lib/minimal/errors/bad_request.d.ts +0 -1
  26. package/lib/minimal/errors/bad_request.js +2 -8
  27. package/lib/minimal/errors/bad_response.d.ts +0 -1
  28. package/lib/minimal/errors/bad_response.js +2 -8
  29. package/lib/minimal/errors/network.d.ts +0 -1
  30. package/lib/minimal/errors/network.js +0 -3
  31. package/lib/minimal/errors/not_found.d.ts +0 -1
  32. package/lib/minimal/errors/not_found.js +2 -8
  33. package/lib/minimal/horizon/horizon_axios_client.js +1 -1
  34. package/lib/minimal/rpc/api.d.ts +132 -0
  35. package/lib/minimal/rpc/axios.js +1 -1
  36. package/lib/minimal/rpc/parsers.d.ts +1 -0
  37. package/lib/minimal/rpc/parsers.js +23 -0
  38. package/lib/minimal/rpc/server.d.ts +51 -20
  39. package/lib/minimal/rpc/server.js +42 -0
  40. package/lib/minimal/webauth/errors.d.ts +0 -2
  41. package/lib/minimal/webauth/errors.js +2 -8
  42. package/lib/no-axios/contract/spec.js +10 -2
  43. package/lib/no-axios/errors/account_requires_memo.d.ts +0 -1
  44. package/lib/no-axios/errors/account_requires_memo.js +0 -4
  45. package/lib/no-axios/errors/bad_request.d.ts +0 -1
  46. package/lib/no-axios/errors/bad_request.js +2 -8
  47. package/lib/no-axios/errors/bad_response.d.ts +0 -1
  48. package/lib/no-axios/errors/bad_response.js +2 -8
  49. package/lib/no-axios/errors/network.d.ts +0 -1
  50. package/lib/no-axios/errors/network.js +0 -3
  51. package/lib/no-axios/errors/not_found.d.ts +0 -1
  52. package/lib/no-axios/errors/not_found.js +2 -8
  53. package/lib/no-axios/horizon/horizon_axios_client.js +1 -1
  54. package/lib/no-axios/rpc/api.d.ts +132 -0
  55. package/lib/no-axios/rpc/axios.js +1 -1
  56. package/lib/no-axios/rpc/parsers.d.ts +1 -0
  57. package/lib/no-axios/rpc/parsers.js +23 -0
  58. package/lib/no-axios/rpc/server.d.ts +51 -20
  59. package/lib/no-axios/rpc/server.js +42 -0
  60. package/lib/no-axios/webauth/errors.d.ts +0 -2
  61. package/lib/no-axios/webauth/errors.js +2 -8
  62. package/lib/no-eventsource/contract/spec.js +10 -2
  63. package/lib/no-eventsource/errors/account_requires_memo.d.ts +0 -1
  64. package/lib/no-eventsource/errors/account_requires_memo.js +0 -4
  65. package/lib/no-eventsource/errors/bad_request.d.ts +0 -1
  66. package/lib/no-eventsource/errors/bad_request.js +2 -8
  67. package/lib/no-eventsource/errors/bad_response.d.ts +0 -1
  68. package/lib/no-eventsource/errors/bad_response.js +2 -8
  69. package/lib/no-eventsource/errors/network.d.ts +0 -1
  70. package/lib/no-eventsource/errors/network.js +0 -3
  71. package/lib/no-eventsource/errors/not_found.d.ts +0 -1
  72. package/lib/no-eventsource/errors/not_found.js +2 -8
  73. package/lib/no-eventsource/horizon/horizon_axios_client.js +1 -1
  74. package/lib/no-eventsource/rpc/api.d.ts +132 -0
  75. package/lib/no-eventsource/rpc/axios.js +1 -1
  76. package/lib/no-eventsource/rpc/parsers.d.ts +1 -0
  77. package/lib/no-eventsource/rpc/parsers.js +23 -0
  78. package/lib/no-eventsource/rpc/server.d.ts +51 -20
  79. package/lib/no-eventsource/rpc/server.js +42 -0
  80. package/lib/no-eventsource/webauth/errors.d.ts +0 -2
  81. package/lib/no-eventsource/webauth/errors.js +2 -8
  82. package/lib/rpc/api.d.ts +132 -0
  83. package/lib/rpc/axios.js +1 -1
  84. package/lib/rpc/parsers.d.ts +1 -0
  85. package/lib/rpc/parsers.js +23 -0
  86. package/lib/rpc/server.d.ts +51 -20
  87. package/lib/rpc/server.js +42 -0
  88. package/lib/webauth/errors.d.ts +0 -2
  89. package/lib/webauth/errors.js +2 -8
  90. package/package.json +3 -3
@@ -559,7 +559,7 @@ var Spec = exports.Spec = function () {
559
559
  }
560
560
  if (value === _stellarBase.xdr.ScSpecType.scSpecTypeOption().value) {
561
561
  var opt = ty.option();
562
- if (val === undefined) {
562
+ if (val === null || val === undefined) {
563
563
  return _stellarBase.xdr.ScVal.scvVoid();
564
564
  }
565
565
  return this.nativeToScVal(val, opt.valueType());
@@ -823,12 +823,20 @@ var Spec = exports.Spec = function () {
823
823
  var _this5 = this;
824
824
  var t = typeDef.switch();
825
825
  var value = t.value;
826
+ if (value === _stellarBase.xdr.ScSpecType.scSpecTypeOption().value) {
827
+ switch (scv.switch().value) {
828
+ case _stellarBase.xdr.ScValType.scvVoid().value:
829
+ return null;
830
+ default:
831
+ return this.scValToNative(scv, typeDef.option().valueType());
832
+ }
833
+ }
826
834
  if (value === _stellarBase.xdr.ScSpecType.scSpecTypeUdt().value) {
827
835
  return this.scValUdtToNative(scv, typeDef.udt());
828
836
  }
829
837
  switch (scv.switch().value) {
830
838
  case _stellarBase.xdr.ScValType.scvVoid().value:
831
- return undefined;
839
+ return null;
832
840
  case _stellarBase.xdr.ScValType.scvU64().value:
833
841
  case _stellarBase.xdr.ScValType.scvI64().value:
834
842
  case _stellarBase.xdr.ScValType.scvU128().value:
@@ -17,7 +17,6 @@
17
17
  * console.log('The account is used in operation: ', err.operationIndex)
18
18
  */
19
19
  export declare class AccountRequiresMemoError extends Error {
20
- __proto__: AccountRequiresMemoError;
21
20
  accountId: string;
22
21
  operationIndex: number;
23
22
  constructor(message: string, accountId: string, operationIndex: number);
@@ -24,11 +24,7 @@ var AccountRequiresMemoError = exports.AccountRequiresMemoError = function (_Err
24
24
  function AccountRequiresMemoError(message, accountId, operationIndex) {
25
25
  var _this;
26
26
  _classCallCheck(this, AccountRequiresMemoError);
27
- var trueProto = (this instanceof AccountRequiresMemoError ? this.constructor : void 0).prototype;
28
27
  _this = _callSuper(this, AccountRequiresMemoError, [message]);
29
- _this.__proto__ = trueProto;
30
- _this.constructor = AccountRequiresMemoError;
31
- _this.name = "AccountRequiresMemoError";
32
28
  _this.accountId = accountId;
33
29
  _this.operationIndex = operationIndex;
34
30
  return _this;
@@ -10,5 +10,4 @@ import { NetworkError } from "./network";
10
10
  * @param {any} response Response details, received from the Horizon server
11
11
  */
12
12
  export declare class BadRequestError extends NetworkError {
13
- constructor(message: string, response: any);
14
13
  }
@@ -19,15 +19,9 @@ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? O
19
19
  function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
20
20
  function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
21
21
  var BadRequestError = exports.BadRequestError = function (_NetworkError) {
22
- function BadRequestError(message, response) {
23
- var _this;
22
+ function BadRequestError() {
24
23
  _classCallCheck(this, BadRequestError);
25
- var trueProto = (this instanceof BadRequestError ? this.constructor : void 0).prototype;
26
- _this = _callSuper(this, BadRequestError, [message, response]);
27
- _this.__proto__ = trueProto;
28
- _this.constructor = BadRequestError;
29
- _this.name = "BadRequestError";
30
- return _this;
24
+ return _callSuper(this, BadRequestError, arguments);
31
25
  }
32
26
  _inherits(BadRequestError, _NetworkError);
33
27
  return _createClass(BadRequestError);
@@ -13,5 +13,4 @@ import { NetworkError } from "./network";
13
13
  * @param {any} response Response details, received from the server.
14
14
  */
15
15
  export declare class BadResponseError extends NetworkError {
16
- constructor(message: string, response: any);
17
16
  }
@@ -19,15 +19,9 @@ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? O
19
19
  function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
20
20
  function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
21
21
  var BadResponseError = exports.BadResponseError = function (_NetworkError) {
22
- function BadResponseError(message, response) {
23
- var _this;
22
+ function BadResponseError() {
24
23
  _classCallCheck(this, BadResponseError);
25
- var trueProto = (this instanceof BadResponseError ? this.constructor : void 0).prototype;
26
- _this = _callSuper(this, BadResponseError, [message, response]);
27
- _this.__proto__ = trueProto;
28
- _this.constructor = BadResponseError;
29
- _this.name = "BadResponseError";
30
- return _this;
24
+ return _callSuper(this, BadResponseError, arguments);
31
25
  }
32
26
  _inherits(BadResponseError, _NetworkError);
33
27
  return _createClass(BadResponseError);
@@ -18,7 +18,6 @@ export declare class NetworkError extends Error {
18
18
  statusText?: string;
19
19
  url?: string;
20
20
  };
21
- __proto__: NetworkError;
22
21
  constructor(message: string, response: any);
23
22
  /**
24
23
  * Returns the error response sent by the Horizon server.
@@ -24,10 +24,7 @@ var NetworkError = exports.NetworkError = function (_Error) {
24
24
  function NetworkError(message, response) {
25
25
  var _this;
26
26
  _classCallCheck(this, NetworkError);
27
- var trueProto = (this instanceof NetworkError ? this.constructor : void 0).prototype;
28
27
  _this = _callSuper(this, NetworkError, [message]);
29
- _this.__proto__ = trueProto;
30
- _this.constructor = NetworkError;
31
28
  _this.response = response;
32
29
  return _this;
33
30
  }
@@ -10,5 +10,4 @@ import { NetworkError } from "./network";
10
10
  * @param {any} response Response details, received from the Horizon server
11
11
  */
12
12
  export declare class NotFoundError extends NetworkError {
13
- constructor(message: string, response: any);
14
13
  }
@@ -19,15 +19,9 @@ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? O
19
19
  function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
20
20
  function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
21
21
  var NotFoundError = exports.NotFoundError = function (_NetworkError) {
22
- function NotFoundError(message, response) {
23
- var _this;
22
+ function NotFoundError() {
24
23
  _classCallCheck(this, NotFoundError);
25
- var trueProto = (this instanceof NotFoundError ? this.constructor : void 0).prototype;
26
- _this = _callSuper(this, NotFoundError, [message, response]);
27
- _this.__proto__ = trueProto;
28
- _this.constructor = NotFoundError;
29
- _this.name = "NotFoundError";
30
- return _this;
24
+ return _callSuper(this, NotFoundError, arguments);
31
25
  }
32
26
  _inherits(NotFoundError, _NetworkError);
33
27
  return _createClass(NotFoundError);
@@ -10,7 +10,7 @@ var _urijs = _interopRequireDefault(require("urijs"));
10
10
  var _httpClient = require("../http-client");
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
12
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
13
- var version = exports.version = "14.2.0";
13
+ var version = exports.version = "14.3.0";
14
14
  var SERVER_TIME_MAP = exports.SERVER_TIME_MAP = {};
15
15
  var AxiosClient = exports.AxiosClient = (0, _httpClient.create)({
16
16
  headers: {
@@ -179,6 +179,55 @@ export declare namespace Api {
179
179
  latestLedgerCloseTime: string;
180
180
  oldestLedgerCloseTime: string;
181
181
  }
182
+ /**
183
+ * Request parameters for fetching events from the Stellar network.
184
+ *
185
+ * **Important**: This type enforces mutually exclusive pagination modes:
186
+ * - **Ledger range mode**: Use `startLedger` and `endLedger` (cursor must be omitted)
187
+ * - **Cursor pagination mode**: Use `cursor` (startLedger and endLedger must be omitted)
188
+ *
189
+ * @example
190
+ * // ✅ Correct: Ledger range mode
191
+ * const rangeRequest: GetEventsRequest = {
192
+ * filters: [],
193
+ * startLedger: 1000,
194
+ * endLedger: 2000,
195
+ * limit: 100
196
+ * };
197
+ *
198
+ * @example
199
+ * // ✅ Correct: Cursor pagination mode
200
+ * const cursorRequest: GetEventsRequest = {
201
+ * filters: [],
202
+ * cursor: "some-cursor-value",
203
+ * limit: 100
204
+ * };
205
+ *
206
+ * @example
207
+ * // ❌ Invalid: Cannot mix cursor with ledger range
208
+ * const invalidRequest = {
209
+ * filters: [],
210
+ * startLedger: 1000, // ❌ Cannot use with cursor
211
+ * endLedger: 2000, // ❌ Cannot use with cursor
212
+ * cursor: "cursor", // ❌ Cannot use with ledger range
213
+ * limit: 100
214
+ * };
215
+ *
216
+ * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getEvents | getEvents API reference}
217
+ */
218
+ export type GetEventsRequest = {
219
+ filters: Api.EventFilter[];
220
+ startLedger: number;
221
+ endLedger: number;
222
+ cursor?: never;
223
+ limit?: number;
224
+ } | {
225
+ filters: Api.EventFilter[];
226
+ cursor: string;
227
+ startLedger?: never;
228
+ endLedger?: never;
229
+ limit?: number;
230
+ };
182
231
  export interface GetEventsResponse extends RetentionState {
183
232
  events: EventResponse[];
184
233
  cursor: string;
@@ -386,5 +435,88 @@ export declare namespace Api {
386
435
  liveUntilLedgerSeq?: number;
387
436
  };
388
437
  }
438
+ /**
439
+ * Request parameters for fetching a sequential list of ledgers.
440
+ *
441
+ * This type supports two distinct pagination modes that are mutually exclusive:
442
+ * - **Ledger-based pagination**: Use `startLedger` to begin fetching from a specific ledger sequence
443
+ * - **Cursor-based pagination**: Use `cursor` to continue from a previous response's pagination token
444
+ *
445
+ * @typedef {object} GetLedgersRequest
446
+ * @property {number} [startLedger] - Ledger sequence number to start fetching from (inclusive).
447
+ * Must be omitted if cursor is provided. Cannot be less than the oldest ledger or greater
448
+ * than the latest ledger stored on the RPC node.
449
+ * @property {object} [pagination] - Pagination configuration for the request.
450
+ * @property {string} [pagination.cursor] - Page cursor for continuing pagination from a previous
451
+ * response. Must be omitted if startLedger is provided.
452
+ * @property {number} [pagination.limit=100] - Maximum number of ledgers to return per page.
453
+ * Valid range: 1-10000. Defaults to 100 if not specified.
454
+ *
455
+ * @example
456
+ * // Ledger-based pagination - start from specific ledger
457
+ * const ledgerRequest: GetLedgersRequest = {
458
+ * startLedger: 36233,
459
+ * pagination: {
460
+ * limit: 10
461
+ * }
462
+ * };
463
+ *
464
+ * @example
465
+ * // Cursor-based pagination - continue from previous response
466
+ * const cursorRequest: GetLedgersRequest = {
467
+ * pagination: {
468
+ * cursor: "36234",
469
+ * limit: 5
470
+ * }
471
+ * };
472
+ *
473
+ * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgers | getLedgers API reference}
474
+ */
475
+ export type GetLedgersRequest = {
476
+ startLedger: number;
477
+ pagination?: {
478
+ cursor?: never;
479
+ limit?: number;
480
+ };
481
+ } | {
482
+ startLedger?: never;
483
+ pagination: {
484
+ cursor: string;
485
+ limit?: number;
486
+ };
487
+ };
488
+ /** @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgers */
489
+ export interface GetLedgersResponse {
490
+ ledgers: LedgerResponse[];
491
+ latestLedger: number;
492
+ latestLedgerCloseTime: number;
493
+ oldestLedger: number;
494
+ oldestLedgerCloseTime: number;
495
+ cursor: string;
496
+ }
497
+ export interface RawGetLedgersResponse {
498
+ ledgers: RawLedgerResponse[];
499
+ latestLedger: number;
500
+ latestLedgerCloseTime: number;
501
+ oldestLedger: number;
502
+ oldestLedgerCloseTime: number;
503
+ cursor: string;
504
+ }
505
+ export interface LedgerResponse {
506
+ hash: string;
507
+ sequence: number;
508
+ ledgerCloseTime: string;
509
+ headerXdr: xdr.LedgerHeaderHistoryEntry;
510
+ metadataXdr: xdr.LedgerCloseMeta;
511
+ }
512
+ export interface RawLedgerResponse {
513
+ hash: string;
514
+ sequence: number;
515
+ ledgerCloseTime: string;
516
+ /** a base-64 encoded {@link xdr.LedgerHeaderHistoryEntry} instance */
517
+ headerXdr: string;
518
+ /** a base-64 encoded {@link xdr.LedgerCloseMeta} instance */
519
+ metadataXdr: string;
520
+ }
389
521
  export {};
390
522
  }
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = exports.default = exports.AxiosClient = void 0;
7
7
  var _httpClient = require("../http-client");
8
- var version = exports.version = "14.2.0";
8
+ var version = exports.version = "14.3.0";
9
9
  var AxiosClient = exports.AxiosClient = (0, _httpClient.create)({
10
10
  headers: {
11
11
  "X-Client-Name": "js-soroban-client",
@@ -43,3 +43,4 @@ export declare function parseRawLedgerEntries(raw: Api.RawGetLedgerEntriesRespon
43
43
  * @returns {Api.SimulateTransactionResponse} the original parameter (if already parsed), parsed otherwise
44
44
  */
45
45
  export declare function parseRawSimulation(sim: Api.SimulateTransactionResponse | Api.RawSimulateTransactionResponse): Api.SimulateTransactionResponse;
46
+ export declare function parseRawLedger(raw: Api.RawLedgerResponse): Api.LedgerResponse;
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.parseRawEvents = parseRawEvents;
7
+ exports.parseRawLedger = parseRawLedger;
7
8
  exports.parseRawLedgerEntries = parseRawLedgerEntries;
8
9
  exports.parseRawSendTransaction = parseRawSendTransaction;
9
10
  exports.parseRawSimulation = parseRawSimulation;
@@ -172,4 +173,26 @@ function parseRawSimulation(sim) {
172
173
  });
173
174
  }
174
175
  return parseSuccessful(sim, base);
176
+ }
177
+ function parseRawLedger(raw) {
178
+ if (!raw.metadataXdr || !raw.headerXdr) {
179
+ var missingFields;
180
+ if (!raw.metadataXdr && !raw.headerXdr) {
181
+ missingFields = "metadataXdr and headerXdr";
182
+ } else if (!raw.metadataXdr) {
183
+ missingFields = "metadataXdr";
184
+ } else {
185
+ missingFields = "headerXdr";
186
+ }
187
+ throw new TypeError("invalid ledger missing fields: ".concat(missingFields));
188
+ }
189
+ var metadataXdr = _stellarBase.xdr.LedgerCloseMeta.fromXDR(raw.metadataXdr, "base64");
190
+ var headerXdr = _stellarBase.xdr.LedgerHeaderHistoryEntry.fromXDR(raw.headerXdr, "base64");
191
+ return {
192
+ hash: raw.hash,
193
+ sequence: raw.sequence,
194
+ ledgerCloseTime: raw.ledgerCloseTime,
195
+ metadataXdr: metadataXdr,
196
+ headerXdr: headerXdr
197
+ };
175
198
  }
@@ -20,14 +20,6 @@ export declare enum Durability {
20
20
  Temporary = "temporary",
21
21
  Persistent = "persistent"
22
22
  }
23
- /**
24
- * @typedef {object} GetEventsRequest Describes the complex filter combinations available for event queries.
25
- * @property {Array.<module:rpc.Api.EventFilter>} filters Filters to use when querying events from the RPC server.
26
- * @property {number} [startLedger] Ledger number (inclusive) to begin querying events.
27
- * @property {string} [cursor] Page cursor (exclusive) to begin querying events.
28
- * @property {number} [limit=100] The maximum number of events that should be returned in the RPC response.
29
- * @memberof module:rpc.Server
30
- */
31
23
  /**
32
24
  * @typedef {object} ResourceLeeway Describes additional resource leeways for transaction simulation.
33
25
  * @property {number} cpuInstructions Simulate the transaction with more CPU instructions available.
@@ -41,13 +33,11 @@ export declare enum Durability {
41
33
  * @memberof module:rpc.Server
42
34
  */
43
35
  export declare namespace RpcServer {
44
- interface GetEventsRequest {
45
- filters: Api.EventFilter[];
46
- startLedger?: number;
47
- endLedger?: number;
48
- cursor?: string;
49
- limit?: number;
50
- }
36
+ /**
37
+ * @deprecated Use `Api.GetEventsRequest` instead.
38
+ * @see {@link Api.GetEventsRequest}
39
+ */
40
+ type GetEventsRequest = Api.GetEventsRequest;
51
41
  interface PollingOptions {
52
42
  attempts?: number;
53
43
  sleepStrategy?: SleepStrategy;
@@ -365,20 +355,21 @@ export declare class RpcServer {
365
355
  /**
366
356
  * Fetch all events that match a given set of filters.
367
357
  *
368
- * The given filters (see {@link module:rpc.Api.EventFilter | Api.EventFilter}
358
+ * The given filters (see {@link Api.EventFilter}
369
359
  * for detailed fields) are combined only in a logical OR fashion, and all of
370
360
  * the fields in each filter are optional.
371
361
  *
372
362
  * To page through events, use the `pagingToken` field on the relevant
373
363
  * {@link Api.EventResponse} object to set the `cursor` parameter.
374
364
  *
375
- * @param {module:rpc.Server.GetEventsRequest} request Event filters
365
+ * @param {Api.GetEventsRequest} request Event filters {@link Api.GetEventsRequest},
376
366
  * @returns {Promise<Api.GetEventsResponse>} A paginatable set of the events
377
367
  * matching the given event filters
378
368
  *
379
369
  * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getEvents | getEvents docs}
380
370
  *
381
371
  * @example
372
+ *
382
373
  * server.getEvents({
383
374
  * startLedger: 1000,
384
375
  * endLedger: 2000,
@@ -402,8 +393,8 @@ export declare class RpcServer {
402
393
  * limit: 10,
403
394
  * });
404
395
  */
405
- getEvents(request: RpcServer.GetEventsRequest): Promise<Api.GetEventsResponse>;
406
- _getEvents(request: RpcServer.GetEventsRequest): Promise<Api.RawGetEventsResponse>;
396
+ getEvents(request: Api.GetEventsRequest): Promise<Api.GetEventsResponse>;
397
+ _getEvents(request: Api.GetEventsRequest): Promise<Api.RawGetEventsResponse>;
407
398
  /**
408
399
  * Fetch metadata about the network this Soroban RPC server is connected to.
409
400
  *
@@ -624,7 +615,7 @@ export declare class RpcServer {
624
615
  * off" if it already exists)
625
616
  * @throws If Friendbot is not configured on this network or request failure
626
617
  *
627
- * @see {@link https://developers.stellar.org/docs/learn/networks#friendbot | Friendbot docs}
618
+ * @see {@link https://developers.stellar.org/docs/learn/fundamentals/networks#friendbot | Friendbot docs}
628
619
  * @see {@link module:Friendbot.Api.Response}
629
620
  *
630
621
  * @example
@@ -692,4 +683,44 @@ export declare class RpcServer {
692
683
  * "Address has no XLM");
693
684
  */
694
685
  getSACBalance(address: string | Address, sac: Asset, networkPassphrase?: string): Promise<Api.BalanceResponse>;
686
+ /**
687
+ * Fetch a detailed list of ledgers starting from a specified point.
688
+ *
689
+ * Returns ledger data with support for pagination as long as the requested
690
+ * pages fall within the history retention of the RPC provider.
691
+ *
692
+ * @param {Api.GetLedgersRequest} request - The request parameters for fetching ledgers. {@link Api.GetLedgersRequest}
693
+ * @returns {Promise<Api.GetLedgersResponse>} A promise that resolves to the
694
+ * ledgers response containing an array of ledger data and pagination info. {@link Api.GetLedgersResponse}
695
+ *
696
+ * @throws {Error} If startLedger is less than the oldest ledger stored in this
697
+ * node, or greater than the latest ledger seen by this node.
698
+ *
699
+ * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgers | getLedgers docs}
700
+ *
701
+ * @example
702
+ * // Fetch ledgers starting from a specific sequence number
703
+ * server.getLedgers({
704
+ * startLedger: 36233,
705
+ * limit: 10
706
+ * }).then((response) => {
707
+ * console.log("Ledgers:", response.ledgers);
708
+ * console.log("Latest Ledger:", response.latestLedger);
709
+ * console.log("Cursor:", response.cursor);
710
+ * });
711
+ *
712
+ * @example
713
+ * // Paginate through ledgers using cursor
714
+ * const firstPage = await server.getLedgers({
715
+ * startLedger: 36233,
716
+ * limit: 5
717
+ * });
718
+ *
719
+ * const nextPage = await server.getLedgers({
720
+ * cursor: firstPage.cursor,
721
+ * limit: 5
722
+ * });
723
+ */
724
+ getLedgers(request: Api.GetLedgersRequest): Promise<Api.GetLedgersResponse>;
725
+ _getLedgers(request: Api.GetLedgersRequest): Promise<Api.RawGetLedgersResponse>;
695
726
  }
@@ -936,5 +936,47 @@ var RpcServer = exports.RpcServer = function () {
936
936
  }
937
937
  return getSACBalance;
938
938
  }())
939
+ }, {
940
+ key: "getLedgers",
941
+ value: (function () {
942
+ var _getLedgers2 = _asyncToGenerator(_regenerator().m(function _callee26(request) {
943
+ return _regenerator().w(function (_context26) {
944
+ while (1) switch (_context26.n) {
945
+ case 0:
946
+ return _context26.a(2, this._getLedgers(request).then(function (raw) {
947
+ var result = {
948
+ ledgers: (raw.ledgers || []).map(_parsers.parseRawLedger),
949
+ latestLedger: raw.latestLedger,
950
+ latestLedgerCloseTime: raw.latestLedgerCloseTime,
951
+ oldestLedger: raw.oldestLedger,
952
+ oldestLedgerCloseTime: raw.oldestLedgerCloseTime,
953
+ cursor: raw.cursor
954
+ };
955
+ return result;
956
+ }));
957
+ }
958
+ }, _callee26, this);
959
+ }));
960
+ function getLedgers(_x31) {
961
+ return _getLedgers2.apply(this, arguments);
962
+ }
963
+ return getLedgers;
964
+ }())
965
+ }, {
966
+ key: "_getLedgers",
967
+ value: function () {
968
+ var _getLedgers3 = _asyncToGenerator(_regenerator().m(function _callee27(request) {
969
+ return _regenerator().w(function (_context27) {
970
+ while (1) switch (_context27.n) {
971
+ case 0:
972
+ return _context27.a(2, jsonrpc.postObject(this.serverURL.toString(), "getLedgers", request));
973
+ }
974
+ }, _callee27, this);
975
+ }));
976
+ function _getLedgers(_x32) {
977
+ return _getLedgers3.apply(this, arguments);
978
+ }
979
+ return _getLedgers;
980
+ }()
939
981
  }]);
940
982
  }();
@@ -8,6 +8,4 @@
8
8
  * @param {string} message Human-readable error message.
9
9
  */
10
10
  export declare class InvalidChallengeError extends Error {
11
- __proto__: InvalidChallengeError;
12
- constructor(message: string);
13
11
  }
@@ -21,15 +21,9 @@ function _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).in
21
21
  function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
22
22
  function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
23
23
  var InvalidChallengeError = exports.InvalidChallengeError = function (_Error) {
24
- function InvalidChallengeError(message) {
25
- var _this;
24
+ function InvalidChallengeError() {
26
25
  _classCallCheck(this, InvalidChallengeError);
27
- var trueProto = (this instanceof InvalidChallengeError ? this.constructor : void 0).prototype;
28
- _this = _callSuper(this, InvalidChallengeError, [message]);
29
- _this.__proto__ = trueProto;
30
- _this.constructor = InvalidChallengeError;
31
- _this.name = "InvalidChallengeError";
32
- return _this;
26
+ return _callSuper(this, InvalidChallengeError, arguments);
33
27
  }
34
28
  _inherits(InvalidChallengeError, _Error);
35
29
  return _createClass(InvalidChallengeError);