@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
@@ -1473,6 +1473,7 @@ module.exports = $defineProperty;
1473
1473
  "use strict";
1474
1474
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1475
1475
  /* harmony export */ $D: () => (/* binding */ parseRawLedgerEntries),
1476
+ /* harmony export */ $E: () => (/* binding */ parseRawLedger),
1476
1477
  /* harmony export */ Af: () => (/* binding */ parseRawSendTransaction),
1477
1478
  /* harmony export */ WC: () => (/* binding */ parseTransactionInfo),
1478
1479
  /* harmony export */ fG: () => (/* binding */ parseRawEvents),
@@ -1646,6 +1647,28 @@ function parseRawSimulation(sim) {
1646
1647
  }
1647
1648
  return parseSuccessful(sim, base);
1648
1649
  }
1650
+ function parseRawLedger(raw) {
1651
+ if (!raw.metadataXdr || !raw.headerXdr) {
1652
+ var missingFields;
1653
+ if (!raw.metadataXdr && !raw.headerXdr) {
1654
+ missingFields = "metadataXdr and headerXdr";
1655
+ } else if (!raw.metadataXdr) {
1656
+ missingFields = "metadataXdr";
1657
+ } else {
1658
+ missingFields = "headerXdr";
1659
+ }
1660
+ throw new TypeError("invalid ledger missing fields: ".concat(missingFields));
1661
+ }
1662
+ var metadataXdr = _stellar_stellar_base__WEBPACK_IMPORTED_MODULE_0__.xdr.LedgerCloseMeta.fromXDR(raw.metadataXdr, "base64");
1663
+ var headerXdr = _stellar_stellar_base__WEBPACK_IMPORTED_MODULE_0__.xdr.LedgerHeaderHistoryEntry.fromXDR(raw.headerXdr, "base64");
1664
+ return {
1665
+ hash: raw.hash,
1666
+ sequence: raw.sequence,
1667
+ ledgerCloseTime: raw.ledgerCloseTime,
1668
+ metadataXdr: metadataXdr,
1669
+ headerXdr: headerXdr
1670
+ };
1671
+ }
1649
1672
 
1650
1673
  /***/ }),
1651
1674
 
@@ -4889,7 +4912,7 @@ var stellar_base_min = __webpack_require__(8950);
4889
4912
  var http_client = __webpack_require__(9983);
4890
4913
  ;// ./src/rpc/axios.ts
4891
4914
 
4892
- var version = "14.2.0";
4915
+ var version = "14.3.0";
4893
4916
  var AxiosClient = (0,http_client/* create */.vt)({
4894
4917
  headers: {
4895
4918
  "X-Client-Name": "js-soroban-client",
@@ -5880,6 +5903,48 @@ var RpcServer = function () {
5880
5903
  }
5881
5904
  return getSACBalance;
5882
5905
  }())
5906
+ }, {
5907
+ key: "getLedgers",
5908
+ value: (function () {
5909
+ var _getLedgers2 = server_asyncToGenerator(server_regenerator().m(function _callee26(request) {
5910
+ return server_regenerator().w(function (_context26) {
5911
+ while (1) switch (_context26.n) {
5912
+ case 0:
5913
+ return _context26.a(2, this._getLedgers(request).then(function (raw) {
5914
+ var result = {
5915
+ ledgers: (raw.ledgers || []).map(parsers/* parseRawLedger */.$E),
5916
+ latestLedger: raw.latestLedger,
5917
+ latestLedgerCloseTime: raw.latestLedgerCloseTime,
5918
+ oldestLedger: raw.oldestLedger,
5919
+ oldestLedgerCloseTime: raw.oldestLedgerCloseTime,
5920
+ cursor: raw.cursor
5921
+ };
5922
+ return result;
5923
+ }));
5924
+ }
5925
+ }, _callee26, this);
5926
+ }));
5927
+ function getLedgers(_x31) {
5928
+ return _getLedgers2.apply(this, arguments);
5929
+ }
5930
+ return getLedgers;
5931
+ }())
5932
+ }, {
5933
+ key: "_getLedgers",
5934
+ value: function () {
5935
+ var _getLedgers3 = server_asyncToGenerator(server_regenerator().m(function _callee27(request) {
5936
+ return server_regenerator().w(function (_context27) {
5937
+ while (1) switch (_context27.n) {
5938
+ case 0:
5939
+ return _context27.a(2, postObject(this.serverURL.toString(), "getLedgers", request));
5940
+ }
5941
+ }, _callee27, this);
5942
+ }));
5943
+ function _getLedgers(_x32) {
5944
+ return _getLedgers3.apply(this, arguments);
5945
+ }
5946
+ return _getLedgers;
5947
+ }()
5883
5948
  }]);
5884
5949
  }();
5885
5950
  ;// ./src/rpc/index.ts
@@ -10610,15 +10675,9 @@ function _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).in
10610
10675
  function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
10611
10676
  function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
10612
10677
  var InvalidChallengeError = function (_Error) {
10613
- function InvalidChallengeError(message) {
10614
- var _this;
10678
+ function InvalidChallengeError() {
10615
10679
  _classCallCheck(this, InvalidChallengeError);
10616
- var trueProto = (this instanceof InvalidChallengeError ? this.constructor : void 0).prototype;
10617
- _this = _callSuper(this, InvalidChallengeError, [message]);
10618
- _this.__proto__ = trueProto;
10619
- _this.constructor = InvalidChallengeError;
10620
- _this.name = "InvalidChallengeError";
10621
- return _this;
10680
+ return _callSuper(this, InvalidChallengeError, arguments);
10622
10681
  }
10623
10682
  _inherits(InvalidChallengeError, _Error);
10624
10683
  return _createClass(InvalidChallengeError);
@@ -15473,10 +15532,7 @@ var NetworkError = function (_Error) {
15473
15532
  function NetworkError(message, response) {
15474
15533
  var _this;
15475
15534
  _classCallCheck(this, NetworkError);
15476
- var trueProto = (this instanceof NetworkError ? this.constructor : void 0).prototype;
15477
15535
  _this = _callSuper(this, NetworkError, [message]);
15478
- _this.__proto__ = trueProto;
15479
- _this.constructor = NetworkError;
15480
15536
  _this.response = response;
15481
15537
  return _this;
15482
15538
  }
@@ -15504,15 +15560,9 @@ function not_found_inherits(t, e) { if ("function" != typeof e && null !== e) th
15504
15560
  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); }
15505
15561
 
15506
15562
  var NotFoundError = function (_NetworkError) {
15507
- function NotFoundError(message, response) {
15508
- var _this;
15563
+ function NotFoundError() {
15509
15564
  not_found_classCallCheck(this, NotFoundError);
15510
- var trueProto = (this instanceof NotFoundError ? this.constructor : void 0).prototype;
15511
- _this = not_found_callSuper(this, NotFoundError, [message, response]);
15512
- _this.__proto__ = trueProto;
15513
- _this.constructor = NotFoundError;
15514
- _this.name = "NotFoundError";
15515
- return _this;
15565
+ return not_found_callSuper(this, NotFoundError, arguments);
15516
15566
  }
15517
15567
  not_found_inherits(NotFoundError, _NetworkError);
15518
15568
  return not_found_createClass(NotFoundError);
@@ -15533,15 +15583,9 @@ function bad_request_inherits(t, e) { if ("function" != typeof e && null !== e)
15533
15583
  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); }
15534
15584
 
15535
15585
  var BadRequestError = function (_NetworkError) {
15536
- function BadRequestError(message, response) {
15537
- var _this;
15586
+ function BadRequestError() {
15538
15587
  bad_request_classCallCheck(this, BadRequestError);
15539
- var trueProto = (this instanceof BadRequestError ? this.constructor : void 0).prototype;
15540
- _this = bad_request_callSuper(this, BadRequestError, [message, response]);
15541
- _this.__proto__ = trueProto;
15542
- _this.constructor = BadRequestError;
15543
- _this.name = "BadRequestError";
15544
- return _this;
15588
+ return bad_request_callSuper(this, BadRequestError, arguments);
15545
15589
  }
15546
15590
  bad_request_inherits(BadRequestError, _NetworkError);
15547
15591
  return bad_request_createClass(BadRequestError);
@@ -15562,15 +15606,9 @@ function bad_response_inherits(t, e) { if ("function" != typeof e && null !== e)
15562
15606
  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); }
15563
15607
 
15564
15608
  var BadResponseError = function (_NetworkError) {
15565
- function BadResponseError(message, response) {
15566
- var _this;
15609
+ function BadResponseError() {
15567
15610
  bad_response_classCallCheck(this, BadResponseError);
15568
- var trueProto = (this instanceof BadResponseError ? this.constructor : void 0).prototype;
15569
- _this = bad_response_callSuper(this, BadResponseError, [message, response]);
15570
- _this.__proto__ = trueProto;
15571
- _this.constructor = BadResponseError;
15572
- _this.name = "BadResponseError";
15573
- return _this;
15611
+ return bad_response_callSuper(this, BadResponseError, arguments);
15574
15612
  }
15575
15613
  bad_response_inherits(BadResponseError, _NetworkError);
15576
15614
  return bad_response_createClass(BadResponseError);
@@ -15596,11 +15634,7 @@ var AccountRequiresMemoError = function (_Error) {
15596
15634
  function AccountRequiresMemoError(message, accountId, operationIndex) {
15597
15635
  var _this;
15598
15636
  account_requires_memo_classCallCheck(this, AccountRequiresMemoError);
15599
- var trueProto = (this instanceof AccountRequiresMemoError ? this.constructor : void 0).prototype;
15600
15637
  _this = account_requires_memo_callSuper(this, AccountRequiresMemoError, [message]);
15601
- _this.__proto__ = trueProto;
15602
- _this.constructor = AccountRequiresMemoError;
15603
- _this.name = "AccountRequiresMemoError";
15604
15638
  _this.accountId = accountId;
15605
15639
  _this.operationIndex = operationIndex;
15606
15640
  return _this;
@@ -21877,7 +21911,7 @@ var Spec = function () {
21877
21911
  }
21878
21912
  if (value === stellar_base_min.xdr.ScSpecType.scSpecTypeOption().value) {
21879
21913
  var opt = ty.option();
21880
- if (val === undefined) {
21914
+ if (val === null || val === undefined) {
21881
21915
  return stellar_base_min.xdr.ScVal.scvVoid();
21882
21916
  }
21883
21917
  return this.nativeToScVal(val, opt.valueType());
@@ -22141,12 +22175,20 @@ var Spec = function () {
22141
22175
  var _this5 = this;
22142
22176
  var t = typeDef.switch();
22143
22177
  var value = t.value;
22178
+ if (value === stellar_base_min.xdr.ScSpecType.scSpecTypeOption().value) {
22179
+ switch (scv.switch().value) {
22180
+ case stellar_base_min.xdr.ScValType.scvVoid().value:
22181
+ return null;
22182
+ default:
22183
+ return this.scValToNative(scv, typeDef.option().valueType());
22184
+ }
22185
+ }
22144
22186
  if (value === stellar_base_min.xdr.ScSpecType.scSpecTypeUdt().value) {
22145
22187
  return this.scValUdtToNative(scv, typeDef.udt());
22146
22188
  }
22147
22189
  switch (scv.switch().value) {
22148
22190
  case stellar_base_min.xdr.ScValType.scvVoid().value:
22149
- return undefined;
22191
+ return null;
22150
22192
  case stellar_base_min.xdr.ScValType.scvU64().value:
22151
22193
  case stellar_base_min.xdr.ScValType.scvI64().value:
22152
22194
  case stellar_base_min.xdr.ScValType.scvU128().value:
@@ -31070,7 +31112,7 @@ var http_client = __webpack_require__(9983);
31070
31112
  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); }
31071
31113
 
31072
31114
 
31073
- var version = "14.2.0";
31115
+ var version = "14.3.0";
31074
31116
  var SERVER_TIME_MAP = {};
31075
31117
  var AxiosClient = (0,http_client/* create */.vt)({
31076
31118
  headers: {