@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__(6371);
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);
@@ -15511,10 +15570,7 @@ var NetworkError = function (_Error) {
15511
15570
  function NetworkError(message, response) {
15512
15571
  var _this;
15513
15572
  _classCallCheck(this, NetworkError);
15514
- var trueProto = (this instanceof NetworkError ? this.constructor : void 0).prototype;
15515
15573
  _this = _callSuper(this, NetworkError, [message]);
15516
- _this.__proto__ = trueProto;
15517
- _this.constructor = NetworkError;
15518
15574
  _this.response = response;
15519
15575
  return _this;
15520
15576
  }
@@ -15542,15 +15598,9 @@ function not_found_inherits(t, e) { if ("function" != typeof e && null !== e) th
15542
15598
  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); }
15543
15599
 
15544
15600
  var NotFoundError = function (_NetworkError) {
15545
- function NotFoundError(message, response) {
15546
- var _this;
15601
+ function NotFoundError() {
15547
15602
  not_found_classCallCheck(this, NotFoundError);
15548
- var trueProto = (this instanceof NotFoundError ? this.constructor : void 0).prototype;
15549
- _this = not_found_callSuper(this, NotFoundError, [message, response]);
15550
- _this.__proto__ = trueProto;
15551
- _this.constructor = NotFoundError;
15552
- _this.name = "NotFoundError";
15553
- return _this;
15603
+ return not_found_callSuper(this, NotFoundError, arguments);
15554
15604
  }
15555
15605
  not_found_inherits(NotFoundError, _NetworkError);
15556
15606
  return not_found_createClass(NotFoundError);
@@ -15571,15 +15621,9 @@ function bad_request_inherits(t, e) { if ("function" != typeof e && null !== e)
15571
15621
  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); }
15572
15622
 
15573
15623
  var BadRequestError = function (_NetworkError) {
15574
- function BadRequestError(message, response) {
15575
- var _this;
15624
+ function BadRequestError() {
15576
15625
  bad_request_classCallCheck(this, BadRequestError);
15577
- var trueProto = (this instanceof BadRequestError ? this.constructor : void 0).prototype;
15578
- _this = bad_request_callSuper(this, BadRequestError, [message, response]);
15579
- _this.__proto__ = trueProto;
15580
- _this.constructor = BadRequestError;
15581
- _this.name = "BadRequestError";
15582
- return _this;
15626
+ return bad_request_callSuper(this, BadRequestError, arguments);
15583
15627
  }
15584
15628
  bad_request_inherits(BadRequestError, _NetworkError);
15585
15629
  return bad_request_createClass(BadRequestError);
@@ -15600,15 +15644,9 @@ function bad_response_inherits(t, e) { if ("function" != typeof e && null !== e)
15600
15644
  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); }
15601
15645
 
15602
15646
  var BadResponseError = function (_NetworkError) {
15603
- function BadResponseError(message, response) {
15604
- var _this;
15647
+ function BadResponseError() {
15605
15648
  bad_response_classCallCheck(this, BadResponseError);
15606
- var trueProto = (this instanceof BadResponseError ? this.constructor : void 0).prototype;
15607
- _this = bad_response_callSuper(this, BadResponseError, [message, response]);
15608
- _this.__proto__ = trueProto;
15609
- _this.constructor = BadResponseError;
15610
- _this.name = "BadResponseError";
15611
- return _this;
15649
+ return bad_response_callSuper(this, BadResponseError, arguments);
15612
15650
  }
15613
15651
  bad_response_inherits(BadResponseError, _NetworkError);
15614
15652
  return bad_response_createClass(BadResponseError);
@@ -15634,11 +15672,7 @@ var AccountRequiresMemoError = function (_Error) {
15634
15672
  function AccountRequiresMemoError(message, accountId, operationIndex) {
15635
15673
  var _this;
15636
15674
  account_requires_memo_classCallCheck(this, AccountRequiresMemoError);
15637
- var trueProto = (this instanceof AccountRequiresMemoError ? this.constructor : void 0).prototype;
15638
15675
  _this = account_requires_memo_callSuper(this, AccountRequiresMemoError, [message]);
15639
- _this.__proto__ = trueProto;
15640
- _this.constructor = AccountRequiresMemoError;
15641
- _this.name = "AccountRequiresMemoError";
15642
15676
  _this.accountId = accountId;
15643
15677
  _this.operationIndex = operationIndex;
15644
15678
  return _this;
@@ -17769,7 +17803,7 @@ var Spec = function () {
17769
17803
  }
17770
17804
  if (value === stellar_base_min.xdr.ScSpecType.scSpecTypeOption().value) {
17771
17805
  var opt = ty.option();
17772
- if (val === undefined) {
17806
+ if (val === null || val === undefined) {
17773
17807
  return stellar_base_min.xdr.ScVal.scvVoid();
17774
17808
  }
17775
17809
  return this.nativeToScVal(val, opt.valueType());
@@ -18033,12 +18067,20 @@ var Spec = function () {
18033
18067
  var _this5 = this;
18034
18068
  var t = typeDef.switch();
18035
18069
  var value = t.value;
18070
+ if (value === stellar_base_min.xdr.ScSpecType.scSpecTypeOption().value) {
18071
+ switch (scv.switch().value) {
18072
+ case stellar_base_min.xdr.ScValType.scvVoid().value:
18073
+ return null;
18074
+ default:
18075
+ return this.scValToNative(scv, typeDef.option().valueType());
18076
+ }
18077
+ }
18036
18078
  if (value === stellar_base_min.xdr.ScSpecType.scSpecTypeUdt().value) {
18037
18079
  return this.scValUdtToNative(scv, typeDef.udt());
18038
18080
  }
18039
18081
  switch (scv.switch().value) {
18040
18082
  case stellar_base_min.xdr.ScValType.scvVoid().value:
18041
- return undefined;
18083
+ return null;
18042
18084
  case stellar_base_min.xdr.ScValType.scvU64().value:
18043
18085
  case stellar_base_min.xdr.ScValType.scvI64().value:
18044
18086
  case stellar_base_min.xdr.ScValType.scvU128().value:
@@ -26984,7 +27026,7 @@ var http_client = __webpack_require__(6371);
26984
27026
  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); }
26985
27027
 
26986
27028
 
26987
- var version = "14.2.0";
27029
+ var version = "14.3.0";
26988
27030
  var SERVER_TIME_MAP = {};
26989
27031
  var AxiosClient = (0,http_client/* create */.vt)({
26990
27032
  headers: {