@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
@@ -11255,7 +11255,7 @@ var Spec = function () {
11255
11255
  }
11256
11256
  if (value === stellar_base_min.xdr.ScSpecType.scSpecTypeOption().value) {
11257
11257
  var opt = ty.option();
11258
- if (val === undefined) {
11258
+ if (val === null || val === undefined) {
11259
11259
  return stellar_base_min.xdr.ScVal.scvVoid();
11260
11260
  }
11261
11261
  return this.nativeToScVal(val, opt.valueType());
@@ -11519,12 +11519,20 @@ var Spec = function () {
11519
11519
  var _this5 = this;
11520
11520
  var t = typeDef.switch();
11521
11521
  var value = t.value;
11522
+ if (value === stellar_base_min.xdr.ScSpecType.scSpecTypeOption().value) {
11523
+ switch (scv.switch().value) {
11524
+ case stellar_base_min.xdr.ScValType.scvVoid().value:
11525
+ return null;
11526
+ default:
11527
+ return this.scValToNative(scv, typeDef.option().valueType());
11528
+ }
11529
+ }
11522
11530
  if (value === stellar_base_min.xdr.ScSpecType.scSpecTypeUdt().value) {
11523
11531
  return this.scValUdtToNative(scv, typeDef.udt());
11524
11532
  }
11525
11533
  switch (scv.switch().value) {
11526
11534
  case stellar_base_min.xdr.ScValType.scvVoid().value:
11527
- return undefined;
11535
+ return null;
11528
11536
  case stellar_base_min.xdr.ScValType.scvU64().value:
11529
11537
  case stellar_base_min.xdr.ScValType.scvI64().value:
11530
11538
  case stellar_base_min.xdr.ScValType.scvU128().value:
@@ -12825,15 +12833,9 @@ function _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).in
12825
12833
  function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
12826
12834
  function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
12827
12835
  var InvalidChallengeError = function (_Error) {
12828
- function InvalidChallengeError(message) {
12829
- var _this;
12836
+ function InvalidChallengeError() {
12830
12837
  _classCallCheck(this, InvalidChallengeError);
12831
- var trueProto = (this instanceof InvalidChallengeError ? this.constructor : void 0).prototype;
12832
- _this = _callSuper(this, InvalidChallengeError, [message]);
12833
- _this.__proto__ = trueProto;
12834
- _this.constructor = InvalidChallengeError;
12835
- _this.name = "InvalidChallengeError";
12836
- return _this;
12838
+ return _callSuper(this, InvalidChallengeError, arguments);
12837
12839
  }
12838
12840
  _inherits(InvalidChallengeError, _Error);
12839
12841
  return _createClass(InvalidChallengeError);
@@ -13198,7 +13200,7 @@ var stellar_base_min = __webpack_require__(950);
13198
13200
  var http_client = __webpack_require__(983);
13199
13201
  ;// ./src/rpc/axios.ts
13200
13202
 
13201
- var version = "14.2.0";
13203
+ var version = "14.3.0";
13202
13204
  var AxiosClient = (0,http_client/* create */.vt)({
13203
13205
  headers: {
13204
13206
  "X-Client-Name": "js-soroban-client",
@@ -14189,6 +14191,48 @@ var RpcServer = function () {
14189
14191
  }
14190
14192
  return getSACBalance;
14191
14193
  }())
14194
+ }, {
14195
+ key: "getLedgers",
14196
+ value: (function () {
14197
+ var _getLedgers2 = server_asyncToGenerator(server_regenerator().m(function _callee26(request) {
14198
+ return server_regenerator().w(function (_context26) {
14199
+ while (1) switch (_context26.n) {
14200
+ case 0:
14201
+ return _context26.a(2, this._getLedgers(request).then(function (raw) {
14202
+ var result = {
14203
+ ledgers: (raw.ledgers || []).map(parsers/* parseRawLedger */.$E),
14204
+ latestLedger: raw.latestLedger,
14205
+ latestLedgerCloseTime: raw.latestLedgerCloseTime,
14206
+ oldestLedger: raw.oldestLedger,
14207
+ oldestLedgerCloseTime: raw.oldestLedgerCloseTime,
14208
+ cursor: raw.cursor
14209
+ };
14210
+ return result;
14211
+ }));
14212
+ }
14213
+ }, _callee26, this);
14214
+ }));
14215
+ function getLedgers(_x31) {
14216
+ return _getLedgers2.apply(this, arguments);
14217
+ }
14218
+ return getLedgers;
14219
+ }())
14220
+ }, {
14221
+ key: "_getLedgers",
14222
+ value: function () {
14223
+ var _getLedgers3 = server_asyncToGenerator(server_regenerator().m(function _callee27(request) {
14224
+ return server_regenerator().w(function (_context27) {
14225
+ while (1) switch (_context27.n) {
14226
+ case 0:
14227
+ return _context27.a(2, postObject(this.serverURL.toString(), "getLedgers", request));
14228
+ }
14229
+ }, _callee27, this);
14230
+ }));
14231
+ function _getLedgers(_x32) {
14232
+ return _getLedgers3.apply(this, arguments);
14233
+ }
14234
+ return _getLedgers;
14235
+ }()
14192
14236
  }]);
14193
14237
  }();
14194
14238
  ;// ./src/rpc/index.ts
@@ -22239,7 +22283,7 @@ var http_client = __webpack_require__(983);
22239
22283
  function horizon_axios_client_typeof(o) { "@babel/helpers - typeof"; return horizon_axios_client_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; }, horizon_axios_client_typeof(o); }
22240
22284
 
22241
22285
 
22242
- var version = "14.2.0";
22286
+ var version = "14.3.0";
22243
22287
  var SERVER_TIME_MAP = {};
22244
22288
  var AxiosClient = (0,http_client/* create */.vt)({
22245
22289
  headers: {
@@ -24017,6 +24061,7 @@ var HorizonServer = function () {
24017
24061
  "use strict";
24018
24062
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
24019
24063
  /* harmony export */ $D: () => (/* binding */ parseRawLedgerEntries),
24064
+ /* harmony export */ $E: () => (/* binding */ parseRawLedger),
24020
24065
  /* harmony export */ Af: () => (/* binding */ parseRawSendTransaction),
24021
24066
  /* harmony export */ WC: () => (/* binding */ parseTransactionInfo),
24022
24067
  /* harmony export */ fG: () => (/* binding */ parseRawEvents),
@@ -24190,6 +24235,28 @@ function parseRawSimulation(sim) {
24190
24235
  }
24191
24236
  return parseSuccessful(sim, base);
24192
24237
  }
24238
+ function parseRawLedger(raw) {
24239
+ if (!raw.metadataXdr || !raw.headerXdr) {
24240
+ var missingFields;
24241
+ if (!raw.metadataXdr && !raw.headerXdr) {
24242
+ missingFields = "metadataXdr and headerXdr";
24243
+ } else if (!raw.metadataXdr) {
24244
+ missingFields = "metadataXdr";
24245
+ } else {
24246
+ missingFields = "headerXdr";
24247
+ }
24248
+ throw new TypeError("invalid ledger missing fields: ".concat(missingFields));
24249
+ }
24250
+ var metadataXdr = _stellar_stellar_base__WEBPACK_IMPORTED_MODULE_0__.xdr.LedgerCloseMeta.fromXDR(raw.metadataXdr, "base64");
24251
+ var headerXdr = _stellar_stellar_base__WEBPACK_IMPORTED_MODULE_0__.xdr.LedgerHeaderHistoryEntry.fromXDR(raw.headerXdr, "base64");
24252
+ return {
24253
+ hash: raw.hash,
24254
+ sequence: raw.sequence,
24255
+ ledgerCloseTime: raw.ledgerCloseTime,
24256
+ metadataXdr: metadataXdr,
24257
+ headerXdr: headerXdr
24258
+ };
24259
+ }
24193
24260
 
24194
24261
  /***/ }),
24195
24262
 
@@ -24423,10 +24490,7 @@ var NetworkError = function (_Error) {
24423
24490
  function NetworkError(message, response) {
24424
24491
  var _this;
24425
24492
  _classCallCheck(this, NetworkError);
24426
- var trueProto = (this instanceof NetworkError ? this.constructor : void 0).prototype;
24427
24493
  _this = _callSuper(this, NetworkError, [message]);
24428
- _this.__proto__ = trueProto;
24429
- _this.constructor = NetworkError;
24430
24494
  _this.response = response;
24431
24495
  return _this;
24432
24496
  }
@@ -24454,15 +24518,9 @@ function not_found_inherits(t, e) { if ("function" != typeof e && null !== e) th
24454
24518
  function not_found_setPrototypeOf(t, e) { return not_found_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, not_found_setPrototypeOf(t, e); }
24455
24519
 
24456
24520
  var NotFoundError = function (_NetworkError) {
24457
- function NotFoundError(message, response) {
24458
- var _this;
24521
+ function NotFoundError() {
24459
24522
  not_found_classCallCheck(this, NotFoundError);
24460
- var trueProto = (this instanceof NotFoundError ? this.constructor : void 0).prototype;
24461
- _this = not_found_callSuper(this, NotFoundError, [message, response]);
24462
- _this.__proto__ = trueProto;
24463
- _this.constructor = NotFoundError;
24464
- _this.name = "NotFoundError";
24465
- return _this;
24523
+ return not_found_callSuper(this, NotFoundError, arguments);
24466
24524
  }
24467
24525
  not_found_inherits(NotFoundError, _NetworkError);
24468
24526
  return not_found_createClass(NotFoundError);
@@ -24483,15 +24541,9 @@ function bad_request_inherits(t, e) { if ("function" != typeof e && null !== e)
24483
24541
  function bad_request_setPrototypeOf(t, e) { return bad_request_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, bad_request_setPrototypeOf(t, e); }
24484
24542
 
24485
24543
  var BadRequestError = function (_NetworkError) {
24486
- function BadRequestError(message, response) {
24487
- var _this;
24544
+ function BadRequestError() {
24488
24545
  bad_request_classCallCheck(this, BadRequestError);
24489
- var trueProto = (this instanceof BadRequestError ? this.constructor : void 0).prototype;
24490
- _this = bad_request_callSuper(this, BadRequestError, [message, response]);
24491
- _this.__proto__ = trueProto;
24492
- _this.constructor = BadRequestError;
24493
- _this.name = "BadRequestError";
24494
- return _this;
24546
+ return bad_request_callSuper(this, BadRequestError, arguments);
24495
24547
  }
24496
24548
  bad_request_inherits(BadRequestError, _NetworkError);
24497
24549
  return bad_request_createClass(BadRequestError);
@@ -24512,15 +24564,9 @@ function bad_response_inherits(t, e) { if ("function" != typeof e && null !== e)
24512
24564
  function bad_response_setPrototypeOf(t, e) { return bad_response_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, bad_response_setPrototypeOf(t, e); }
24513
24565
 
24514
24566
  var BadResponseError = function (_NetworkError) {
24515
- function BadResponseError(message, response) {
24516
- var _this;
24567
+ function BadResponseError() {
24517
24568
  bad_response_classCallCheck(this, BadResponseError);
24518
- var trueProto = (this instanceof BadResponseError ? this.constructor : void 0).prototype;
24519
- _this = bad_response_callSuper(this, BadResponseError, [message, response]);
24520
- _this.__proto__ = trueProto;
24521
- _this.constructor = BadResponseError;
24522
- _this.name = "BadResponseError";
24523
- return _this;
24569
+ return bad_response_callSuper(this, BadResponseError, arguments);
24524
24570
  }
24525
24571
  bad_response_inherits(BadResponseError, _NetworkError);
24526
24572
  return bad_response_createClass(BadResponseError);
@@ -24546,11 +24592,7 @@ var AccountRequiresMemoError = function (_Error) {
24546
24592
  function AccountRequiresMemoError(message, accountId, operationIndex) {
24547
24593
  var _this;
24548
24594
  account_requires_memo_classCallCheck(this, AccountRequiresMemoError);
24549
- var trueProto = (this instanceof AccountRequiresMemoError ? this.constructor : void 0).prototype;
24550
24595
  _this = account_requires_memo_callSuper(this, AccountRequiresMemoError, [message]);
24551
- _this.__proto__ = trueProto;
24552
- _this.constructor = AccountRequiresMemoError;
24553
- _this.name = "AccountRequiresMemoError";
24554
24596
  _this.accountId = accountId;
24555
24597
  _this.operationIndex = operationIndex;
24556
24598
  return _this;