@stellar/stellar-sdk 14.0.0-rc.3 → 14.0.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 (98) hide show
  1. package/CHANGELOG.md +136 -0
  2. package/dist/stellar-sdk-minimal.js +196 -109
  3. package/dist/stellar-sdk-minimal.min.js +1 -1
  4. package/dist/stellar-sdk-no-axios.js +196 -109
  5. package/dist/stellar-sdk-no-axios.min.js +1 -1
  6. package/dist/stellar-sdk-no-eventsource.js +241 -117
  7. package/dist/stellar-sdk-no-eventsource.min.js +1 -1
  8. package/dist/stellar-sdk.js +241 -117
  9. package/dist/stellar-sdk.min.js +1 -1
  10. package/lib/contract/assembled_transaction.d.ts +15 -5
  11. package/lib/contract/assembled_transaction.js +25 -26
  12. package/lib/contract/basic_node_signer.js +1 -1
  13. package/lib/contract/client.d.ts +2 -0
  14. package/lib/contract/client.js +69 -8
  15. package/lib/contract/sent_transaction.d.ts +16 -3
  16. package/lib/contract/sent_transaction.js +70 -50
  17. package/lib/contract/spec.js +1 -4
  18. package/lib/contract/utils.js +5 -9
  19. package/lib/federation/server.js +1 -1
  20. package/lib/horizon/account_response.d.ts +3 -0
  21. package/lib/horizon/call_builder.js +1 -1
  22. package/lib/horizon/horizon_api.d.ts +0 -2
  23. package/lib/horizon/horizon_axios_client.js +1 -1
  24. package/lib/horizon/payment_call_builder.d.ts +8 -0
  25. package/lib/horizon/payment_call_builder.js +6 -0
  26. package/lib/horizon/server.js +10 -3
  27. package/lib/minimal/contract/assembled_transaction.d.ts +15 -5
  28. package/lib/minimal/contract/assembled_transaction.js +25 -26
  29. package/lib/minimal/contract/basic_node_signer.js +1 -1
  30. package/lib/minimal/contract/client.d.ts +2 -0
  31. package/lib/minimal/contract/client.js +69 -8
  32. package/lib/minimal/contract/sent_transaction.d.ts +16 -3
  33. package/lib/minimal/contract/sent_transaction.js +70 -50
  34. package/lib/minimal/contract/spec.js +1 -4
  35. package/lib/minimal/contract/utils.js +5 -9
  36. package/lib/minimal/federation/server.js +1 -1
  37. package/lib/minimal/horizon/account_response.d.ts +3 -0
  38. package/lib/minimal/horizon/call_builder.js +1 -1
  39. package/lib/minimal/horizon/horizon_api.d.ts +0 -2
  40. package/lib/minimal/horizon/horizon_axios_client.js +1 -1
  41. package/lib/minimal/horizon/payment_call_builder.d.ts +8 -0
  42. package/lib/minimal/horizon/payment_call_builder.js +6 -0
  43. package/lib/minimal/horizon/server.js +10 -3
  44. package/lib/minimal/rpc/api.d.ts +1 -1
  45. package/lib/minimal/rpc/axios.js +1 -1
  46. package/lib/minimal/rpc/jsonrpc.js +1 -1
  47. package/lib/minimal/rpc/server.js +2 -2
  48. package/lib/minimal/stellartoml/index.js +1 -1
  49. package/lib/no-axios/contract/assembled_transaction.d.ts +15 -5
  50. package/lib/no-axios/contract/assembled_transaction.js +25 -26
  51. package/lib/no-axios/contract/basic_node_signer.js +1 -1
  52. package/lib/no-axios/contract/client.d.ts +2 -0
  53. package/lib/no-axios/contract/client.js +69 -8
  54. package/lib/no-axios/contract/sent_transaction.d.ts +16 -3
  55. package/lib/no-axios/contract/sent_transaction.js +70 -50
  56. package/lib/no-axios/contract/spec.js +1 -4
  57. package/lib/no-axios/contract/utils.js +5 -9
  58. package/lib/no-axios/federation/server.js +1 -1
  59. package/lib/no-axios/horizon/account_response.d.ts +3 -0
  60. package/lib/no-axios/horizon/call_builder.js +1 -1
  61. package/lib/no-axios/horizon/horizon_api.d.ts +0 -2
  62. package/lib/no-axios/horizon/horizon_axios_client.js +1 -1
  63. package/lib/no-axios/horizon/payment_call_builder.d.ts +8 -0
  64. package/lib/no-axios/horizon/payment_call_builder.js +6 -0
  65. package/lib/no-axios/horizon/server.js +10 -3
  66. package/lib/no-axios/rpc/api.d.ts +1 -1
  67. package/lib/no-axios/rpc/axios.js +1 -1
  68. package/lib/no-axios/rpc/jsonrpc.js +1 -1
  69. package/lib/no-axios/rpc/server.js +2 -2
  70. package/lib/no-axios/stellartoml/index.js +1 -1
  71. package/lib/no-eventsource/contract/assembled_transaction.d.ts +15 -5
  72. package/lib/no-eventsource/contract/assembled_transaction.js +25 -26
  73. package/lib/no-eventsource/contract/basic_node_signer.js +1 -1
  74. package/lib/no-eventsource/contract/client.d.ts +2 -0
  75. package/lib/no-eventsource/contract/client.js +69 -8
  76. package/lib/no-eventsource/contract/sent_transaction.d.ts +16 -3
  77. package/lib/no-eventsource/contract/sent_transaction.js +70 -50
  78. package/lib/no-eventsource/contract/spec.js +1 -4
  79. package/lib/no-eventsource/contract/utils.js +5 -9
  80. package/lib/no-eventsource/federation/server.js +1 -1
  81. package/lib/no-eventsource/horizon/account_response.d.ts +3 -0
  82. package/lib/no-eventsource/horizon/call_builder.js +1 -1
  83. package/lib/no-eventsource/horizon/horizon_api.d.ts +0 -2
  84. package/lib/no-eventsource/horizon/horizon_axios_client.js +1 -1
  85. package/lib/no-eventsource/horizon/payment_call_builder.d.ts +8 -0
  86. package/lib/no-eventsource/horizon/payment_call_builder.js +6 -0
  87. package/lib/no-eventsource/horizon/server.js +10 -3
  88. package/lib/no-eventsource/rpc/api.d.ts +1 -1
  89. package/lib/no-eventsource/rpc/axios.js +1 -1
  90. package/lib/no-eventsource/rpc/jsonrpc.js +1 -1
  91. package/lib/no-eventsource/rpc/server.js +2 -2
  92. package/lib/no-eventsource/stellartoml/index.js +1 -1
  93. package/lib/rpc/api.d.ts +1 -1
  94. package/lib/rpc/axios.js +1 -1
  95. package/lib/rpc/jsonrpc.js +1 -1
  96. package/lib/rpc/server.js +2 -2
  97. package/lib/stellartoml/index.js +1 -1
  98. package/package.json +5 -4
@@ -32,7 +32,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
32
32
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
33
33
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
34
34
  function _regenerator() { var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
35
- function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { if (r) i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n;else { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } o("next", 0), o("throw", 1), o("return", 2); } }, _regeneratorDefine2(e, r, n, t); }
35
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
36
36
  function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
37
37
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
38
38
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
@@ -158,7 +158,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
158
158
  throw new AssembledTransaction.Errors.NoSigner("You must provide a signTransaction function, either when calling " + "`signAndSend` or when initializing your Client");
159
159
  case 3:
160
160
  sigsNeeded = _this.needsNonInvokerSigningBy().filter(function (id) {
161
- return !id.startsWith('C');
161
+ return !id.startsWith("C");
162
162
  });
163
163
  if (!sigsNeeded.length) {
164
164
  _context2.n = 4;
@@ -197,12 +197,13 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
197
197
  force,
198
198
  _ref6$signTransaction,
199
199
  signTransaction,
200
+ watcher,
200
201
  originalSubmit,
201
202
  _args3 = arguments;
202
203
  return _regenerator().w(function (_context3) {
203
204
  while (1) switch (_context3.p = _context3.n) {
204
205
  case 0:
205
- _ref6 = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {}, _ref6$force = _ref6.force, force = _ref6$force === void 0 ? false : _ref6$force, _ref6$signTransaction = _ref6.signTransaction, signTransaction = _ref6$signTransaction === void 0 ? _this.options.signTransaction : _ref6$signTransaction;
206
+ _ref6 = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {}, _ref6$force = _ref6.force, force = _ref6$force === void 0 ? false : _ref6$force, _ref6$signTransaction = _ref6.signTransaction, signTransaction = _ref6$signTransaction === void 0 ? _this.options.signTransaction : _ref6$signTransaction, watcher = _ref6.watcher;
206
207
  if (_this.signed) {
207
208
  _context3.n = 3;
208
209
  break;
@@ -222,7 +223,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
222
223
  _this.options.submit = originalSubmit;
223
224
  return _context3.f(2);
224
225
  case 3:
225
- return _context3.a(2, _this.send());
226
+ return _context3.a(2, _this.send(watcher));
226
227
  }
227
228
  }, _callee3, null, [[1,, 2, 3]]);
228
229
  })));
@@ -263,7 +264,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
263
264
  _loop,
264
265
  _ret,
265
266
  _args7 = arguments,
266
- _t7;
267
+ _t5;
267
268
  return _regenerator().w(function (_context7) {
268
269
  while (1) switch (_context7.p = _context7.n) {
269
270
  case 0:
@@ -314,7 +315,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
314
315
  _iterator = _createForOfIteratorHelper(authEntries.entries());
315
316
  _context7.p = 5;
316
317
  _loop = _regenerator().m(function _loop() {
317
- var _step$value, i, entry, credentials, authEntryAddress, sign, _t2, _t3, _t4, _t5, _t6;
318
+ var _step$value, i, entry, credentials, authEntryAddress, sign, _t2, _t3, _t4;
318
319
  return _regenerator().w(function (_context6) {
319
320
  while (1) switch (_context6.n) {
320
321
  case 0:
@@ -362,10 +363,8 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
362
363
  _context6.n = 3;
363
364
  return expiration;
364
365
  case 3:
365
- _t5 = _context6.v;
366
- _t6 = _this.options.networkPassphrase;
367
366
  _context6.n = 4;
368
- return _t2(_t3, _t4, _t5, _t6);
367
+ return _t2(_t3, _t4, _context6.v, _this.options.networkPassphrase);
369
368
  case 4:
370
369
  authEntries[i] = _context6.v;
371
370
  case 5:
@@ -395,8 +394,8 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
395
394
  break;
396
395
  case 10:
397
396
  _context7.p = 10;
398
- _t7 = _context7.v;
399
- _iterator.e(_t7);
397
+ _t5 = _context7.v;
398
+ _iterator.e(_t5);
400
399
  case 11:
401
400
  _context7.p = 11;
402
401
  _iterator.f();
@@ -433,7 +432,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
433
432
  value: function toXDR() {
434
433
  var _this$built2;
435
434
  if (!this.built) throw new Error("Transaction has not yet been simulated; " + "call `AssembledTransaction.simulate` first.");
436
- return (_this$built2 = this.built) === null || _this$built2 === void 0 ? void 0 : _this$built2.toEnvelope().toXDR('base64');
435
+ return (_this$built2 = this.built) === null || _this$built2 === void 0 ? void 0 : _this$built2.toEnvelope().toXDR("base64");
437
436
  }
438
437
  }, {
439
438
  key: "handleWalletError",
@@ -441,7 +440,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
441
440
  if (!error) return;
442
441
  var message = error.message,
443
442
  code = error.code;
444
- var fullMessage = "".concat(message).concat(error.ext ? " (".concat(error.ext.join(', '), ")") : '');
443
+ var fullMessage = "".concat(message).concat(error.ext ? " (".concat(error.ext.join(", "), ")") : "");
445
444
  switch (code) {
446
445
  case -1:
447
446
  throw new AssembledTransaction.Errors.InternalWalletError(fullMessage);
@@ -473,7 +472,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
473
472
  throw new AssembledTransaction.Errors.SimulationFailed("Transaction simulation failed: \"".concat(simulation.error, "\""));
474
473
  }
475
474
  if (_api.Api.isSimulationRestore(simulation)) {
476
- throw new AssembledTransaction.Errors.ExpiredState("You need to restore some contract state before you can invoke this method.\n" + 'You can set `restore` to true in the method options in order to ' + 'automatically restore the contract state when needed.');
475
+ throw new AssembledTransaction.Errors.ExpiredState("You need to restore some contract state before you can invoke this method.\n" + "You can set `restore` to true in the method options in order to " + "automatically restore the contract state when needed.");
477
476
  }
478
477
  this.simulationResult = (_simulation$result = simulation.result) !== null && _simulation$result !== void 0 ? _simulation$result : {
479
478
  auth: [],
@@ -514,7 +513,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
514
513
  }, {
515
514
  key: "send",
516
515
  value: (function () {
517
- var _send = _asyncToGenerator(_regenerator().m(function _callee7() {
516
+ var _send = _asyncToGenerator(_regenerator().m(function _callee7(watcher) {
518
517
  var sent;
519
518
  return _regenerator().w(function (_context8) {
520
519
  while (1) switch (_context8.n) {
@@ -526,14 +525,14 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
526
525
  throw new Error("The transaction has not yet been signed. Run `sign` first, or use `signAndSend` instead.");
527
526
  case 1:
528
527
  _context8.n = 2;
529
- return _sent_transaction.SentTransaction.init(this);
528
+ return _sent_transaction.SentTransaction.init(this, watcher);
530
529
  case 2:
531
530
  sent = _context8.v;
532
531
  return _context8.a(2, sent);
533
532
  }
534
533
  }, _callee7, this);
535
534
  }));
536
- function send() {
535
+ function send(_x2) {
537
536
  return _send.apply(this, arguments);
538
537
  }
539
538
  return send;
@@ -549,7 +548,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
549
548
  key: "restoreFootprint",
550
549
  value: (function () {
551
550
  var _restoreFootprint = _asyncToGenerator(_regenerator().m(function _callee8(restorePreamble, account) {
552
- var restoreTx, sentTransaction, _t8;
551
+ var restoreTx, sentTransaction, _t6;
553
552
  return _regenerator().w(function (_context9) {
554
553
  while (1) switch (_context9.n) {
555
554
  case 0:
@@ -563,16 +562,16 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
563
562
  _context9.n = 2;
564
563
  break;
565
564
  }
566
- _t8 = account;
565
+ _t6 = account;
567
566
  _context9.n = 4;
568
567
  break;
569
568
  case 2:
570
569
  _context9.n = 3;
571
570
  return (0, _utils.getAccount)(this.options, this.server);
572
571
  case 3:
573
- _t8 = _context9.v;
572
+ _t6 = _context9.v;
574
573
  case 4:
575
- account = _t8;
574
+ account = _t6;
576
575
  _context9.n = 5;
577
576
  return AssembledTransaction.buildFootprintRestoreTransaction(_objectSpread({}, this.options), restorePreamble.transactionData, account, restorePreamble.minResourceFee);
578
577
  case 5:
@@ -591,7 +590,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
591
590
  }
592
591
  }, _callee8, this);
593
592
  }));
594
- function restoreFootprint(_x2, _x3) {
593
+ function restoreFootprint(_x3, _x4) {
595
594
  return _restoreFootprint.apply(this, arguments);
596
595
  }
597
596
  return restoreFootprint;
@@ -620,14 +619,14 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
620
619
  var envelope = _stellarBase.xdr.TransactionEnvelope.fromXDR(encodedXDR, "base64");
621
620
  var built = _stellarBase.TransactionBuilder.fromXDR(envelope, options.networkPassphrase);
622
621
  var operation = built.operations[0];
623
- if (!(operation !== null && operation !== void 0 && (_operation$func = operation.func) !== null && _operation$func !== void 0 && _operation$func.value) || typeof operation.func.value !== 'function') {
622
+ if (!(operation !== null && operation !== void 0 && (_operation$func = operation.func) !== null && _operation$func !== void 0 && _operation$func.value) || typeof operation.func.value !== "function") {
624
623
  throw new Error("Could not extract the method from the transaction envelope.");
625
624
  }
626
625
  var invokeContractArgs = operation.func.value();
627
626
  if (!(invokeContractArgs !== null && invokeContractArgs !== void 0 && invokeContractArgs.functionName)) {
628
627
  throw new Error("Could not extract the method name from the transaction envelope.");
629
628
  }
630
- var method = invokeContractArgs.functionName().toString('utf-8');
629
+ var method = invokeContractArgs.functionName().toString("utf-8");
631
630
  var txn = new AssembledTransaction(_objectSpread(_objectSpread({}, options), {}, {
632
631
  method: method,
633
632
  parseResultXdr: function parseResultXdr(result) {
@@ -673,7 +672,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
673
672
  }
674
673
  }, _callee9);
675
674
  }));
676
- function buildWithOp(_x4, _x5) {
675
+ function buildWithOp(_x5, _x6) {
677
676
  return _buildWithOp.apply(this, arguments);
678
677
  }
679
678
  return buildWithOp;
@@ -701,7 +700,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
701
700
  }
702
701
  }, _callee0);
703
702
  }));
704
- function buildFootprintRestoreTransaction(_x6, _x7, _x8, _x9) {
703
+ function buildFootprintRestoreTransaction(_x7, _x8, _x9, _x0) {
705
704
  return _buildFootprintRestoreTransaction.apply(this, arguments);
706
705
  }
707
706
  return buildFootprintRestoreTransaction;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.basicNodeSigner = void 0;
7
7
  var _stellarBase = require("@stellar/stellar-base");
8
8
  function _regenerator() { var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
9
- function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { if (r) i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n;else { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } o("next", 0), o("throw", 1), o("return", 2); } }, _regeneratorDefine2(e, r, n, t); }
9
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
10
10
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
11
11
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
12
12
  var basicNodeSigner = exports.basicNodeSigner = function basicNodeSigner(keypair, networkPassphrase) {
@@ -29,6 +29,8 @@ export declare class Client {
29
29
  salt?: Buffer | Uint8Array;
30
30
  /** The format used to decode `wasmHash`, if it's provided as a string. */
31
31
  format?: "hex" | "base64";
32
+ /** The address to use to deploy the custom contract */
33
+ address?: string;
32
34
  }): Promise<AssembledTransaction<T>>;
33
35
  constructor(spec: Spec, options: ClientOptions);
34
36
  /**
@@ -13,7 +13,7 @@ var _utils = require("./utils");
13
13
  var _excluded = ["method"],
14
14
  _excluded2 = ["wasmHash", "salt", "format", "fee", "timeoutInSeconds", "simulate"];
15
15
  function _regenerator() { var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
16
- function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { if (r) i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n;else { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } o("next", 0), o("throw", 1), o("return", 2); } }, _regeneratorDefine2(e, r, n, t); }
16
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
17
17
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
18
18
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
19
19
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
@@ -24,6 +24,12 @@ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r),
24
24
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
25
25
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
26
26
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
27
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
28
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
29
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
30
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
31
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
32
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
27
33
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
28
34
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
29
35
  var CONSTRUCTOR_FUNC = "__constructor";
@@ -32,30 +38,85 @@ function specFromWasm(_x) {
32
38
  }
33
39
  function _specFromWasm() {
34
40
  _specFromWasm = _asyncToGenerator(_regenerator().m(function _callee5(wasm) {
35
- var wasmModule, xdrSections, bufferSection, specEntryArray, spec;
41
+ var xdrSections, wasmModule, customData, bufferSection, specEntryArray, spec, _t;
36
42
  return _regenerator().w(function (_context5) {
37
- while (1) switch (_context5.n) {
43
+ while (1) switch (_context5.p = _context5.n) {
38
44
  case 0:
45
+ _context5.p = 0;
39
46
  _context5.n = 1;
40
47
  return WebAssembly.compile(wasm);
41
48
  case 1:
42
49
  wasmModule = _context5.v;
43
50
  xdrSections = WebAssembly.Module.customSections(wasmModule, "contractspecv0");
44
- if (!(xdrSections.length === 0)) {
45
- _context5.n = 2;
51
+ _context5.n = 3;
52
+ break;
53
+ case 2:
54
+ _context5.p = 2;
55
+ _t = _context5.v;
56
+ customData = parseWasmCustomSections(wasm);
57
+ xdrSections = customData.get('contractspecv0');
58
+ case 3:
59
+ if (!(!xdrSections || xdrSections.length === 0)) {
60
+ _context5.n = 4;
46
61
  break;
47
62
  }
48
63
  throw new Error("Could not obtain contract spec from wasm");
49
- case 2:
64
+ case 4:
50
65
  bufferSection = Buffer.from(xdrSections[0]);
51
66
  specEntryArray = (0, _utils.processSpecEntryStream)(bufferSection);
52
67
  spec = new _spec.Spec(specEntryArray);
53
68
  return _context5.a(2, spec);
54
69
  }
55
- }, _callee5);
70
+ }, _callee5, null, [[0, 2]]);
56
71
  }));
57
72
  return _specFromWasm.apply(this, arguments);
58
73
  }
74
+ function parseWasmCustomSections(buffer) {
75
+ var sections = new Map();
76
+ var arrayBuffer = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
77
+ var offset = 0;
78
+ var read = function read(length) {
79
+ if (offset + length > buffer.byteLength) throw new Error('Buffer overflow');
80
+ var bytes = new Uint8Array(arrayBuffer, offset, length);
81
+ offset += length;
82
+ return bytes;
83
+ };
84
+ if (_toConsumableArray(read(4)).join() !== '0,97,115,109') throw new Error('Invalid WASM magic');
85
+ if (_toConsumableArray(read(4)).join() !== '1,0,0,0') throw new Error('Invalid WASM version');
86
+ while (offset < buffer.byteLength) {
87
+ var sectionId = read(1)[0];
88
+ var sectionLength = readVarUint32();
89
+ var start = offset;
90
+ if (sectionId === 0) {
91
+ var nameLen = readVarUint32();
92
+ if (nameLen === 0 || offset + nameLen > start + sectionLength) continue;
93
+ var nameBytes = read(nameLen);
94
+ var payload = read(sectionLength - (offset - start));
95
+ try {
96
+ var name = new TextDecoder('utf-8', {
97
+ fatal: true
98
+ }).decode(nameBytes);
99
+ if (payload.length > 0) {
100
+ sections.set(name, (sections.get(name) || []).concat(payload));
101
+ }
102
+ } catch (_unused) {}
103
+ } else {
104
+ offset += sectionLength;
105
+ }
106
+ }
107
+ function readVarUint32() {
108
+ var value = 0,
109
+ shift = 0;
110
+ while (true) {
111
+ var byte = read(1)[0];
112
+ value |= (byte & 0x7F) << shift;
113
+ if ((byte & 0x80) === 0) break;
114
+ if ((shift += 7) >= 32) throw new Error('Invalid WASM value');
115
+ }
116
+ return value >>> 0;
117
+ }
118
+ return sections;
119
+ }
59
120
  function specFromWasmHash(_x2, _x3) {
60
121
  return _specFromWasmHash.apply(this, arguments);
61
122
  }
@@ -152,7 +213,7 @@ var Client = exports.Client = function () {
152
213
  case 1:
153
214
  spec = _context.v;
154
215
  operation = _stellarBase.Operation.createCustomContract({
155
- address: new _stellarBase.Address(options.publicKey),
216
+ address: new _stellarBase.Address(options.address || options.publicKey),
156
217
  wasmHash: typeof wasmHash === "string" ? Buffer.from(wasmHash, format !== null && format !== void 0 ? format : "hex") : wasmHash,
157
218
  salt: salt,
158
219
  constructorArgs: args ? spec.funcArgsToScVals(CONSTRUCTOR_FUNC, args) : []
@@ -75,10 +75,23 @@ export declare class SentTransaction<T> {
75
75
  };
76
76
  constructor(assembled: AssembledTransaction<T>);
77
77
  /**
78
- * Initialize a `SentTransaction` from `options` and a `signed`
79
- * AssembledTransaction. This will also send the transaction to the network.
78
+ * Initialize a `SentTransaction` from {@link AssembledTransaction}
79
+ * `assembled`, passing an optional {@link Watcher} `watcher`. This will also
80
+ * send the transaction to the network.
80
81
  */
81
- static init: <U>(assembled: AssembledTransaction<U>) => Promise<SentTransaction<U>>;
82
+ static init: <U>(assembled: AssembledTransaction<U>, watcher?: Watcher) => Promise<SentTransaction<U>>;
82
83
  private send;
83
84
  get result(): T;
84
85
  }
86
+ export declare abstract class Watcher {
87
+ /**
88
+ * Function to call after transaction has been submitted successfully to
89
+ * the network for processing
90
+ */
91
+ abstract onSubmitted?(response?: Api.SendTransactionResponse): void;
92
+ /**
93
+ * Function to call every time the submitted transaction's status is
94
+ * checked while awaiting its full inclusion in the ledger
95
+ */
96
+ abstract onProgress?(response?: Api.GetTransactionResponse): void;
97
+ }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.SentTransaction = void 0;
6
+ exports.Watcher = exports.SentTransaction = void 0;
7
7
  var _rpc = require("../rpc");
8
8
  var _api = require("../rpc/api");
9
9
  var _utils = require("./utils");
@@ -21,7 +21,7 @@ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf
21
21
  function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
22
22
  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); }
23
23
  function _regenerator() { var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
24
- function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { if (r) i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n;else { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } o("next", 0), o("throw", 1), o("return", 2); } }, _regeneratorDefine2(e, r, n, t); }
24
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
25
25
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
26
26
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
27
27
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
@@ -35,43 +35,60 @@ var SentTransaction = exports.SentTransaction = function () {
35
35
  var _this = this,
36
36
  _this$assembled$optio2;
37
37
  _classCallCheck(this, SentTransaction);
38
- _defineProperty(this, "send", _asyncToGenerator(_regenerator().m(function _callee() {
39
- var _this$assembled$optio;
40
- var hash, timeoutInSeconds;
41
- return _regenerator().w(function (_context) {
42
- while (1) switch (_context.n) {
43
- case 0:
44
- _context.n = 1;
45
- return _this.server.sendTransaction(_this.assembled.signed);
46
- case 1:
47
- _this.sendTransactionResponse = _context.v;
48
- if (!(_this.sendTransactionResponse.status !== "PENDING")) {
49
- _context.n = 2;
50
- break;
51
- }
52
- throw new SentTransaction.Errors.SendFailed("Sending the transaction to the network failed!\n".concat(JSON.stringify(_this.sendTransactionResponse, null, 2)));
53
- case 2:
54
- hash = _this.sendTransactionResponse.hash;
55
- timeoutInSeconds = (_this$assembled$optio = _this.assembled.options.timeoutInSeconds) !== null && _this$assembled$optio !== void 0 ? _this$assembled$optio : _types.DEFAULT_TIMEOUT;
56
- _context.n = 3;
57
- return (0, _utils.withExponentialBackoff)(function () {
58
- return _this.server.getTransaction(hash);
59
- }, function (resp) {
60
- return resp.status === _api.Api.GetTransactionStatus.NOT_FOUND;
61
- }, timeoutInSeconds);
62
- case 3:
63
- _this.getTransactionResponseAll = _context.v;
64
- _this.getTransactionResponse = _this.getTransactionResponseAll[_this.getTransactionResponseAll.length - 1];
65
- if (!(_this.getTransactionResponse.status === _api.Api.GetTransactionStatus.NOT_FOUND)) {
66
- _context.n = 4;
67
- break;
68
- }
69
- throw new SentTransaction.Errors.TransactionStillPending("Waited ".concat(timeoutInSeconds, " seconds for transaction to complete, but it did not. ") + "Returning anyway. Check the transaction status manually. " + "Sent transaction: ".concat(JSON.stringify(_this.sendTransactionResponse, null, 2), "\n") + "All attempts to get the result: ".concat(JSON.stringify(_this.getTransactionResponseAll, null, 2)));
70
- case 4:
71
- return _context.a(2, _this);
72
- }
73
- }, _callee);
74
- })));
38
+ _defineProperty(this, "send", function () {
39
+ var _ref = _asyncToGenerator(_regenerator().m(function _callee2(watcher) {
40
+ var _this$assembled$optio;
41
+ var hash, timeoutInSeconds;
42
+ return _regenerator().w(function (_context2) {
43
+ while (1) switch (_context2.n) {
44
+ case 0:
45
+ _context2.n = 1;
46
+ return _this.server.sendTransaction(_this.assembled.signed);
47
+ case 1:
48
+ _this.sendTransactionResponse = _context2.v;
49
+ if (!(_this.sendTransactionResponse.status !== "PENDING")) {
50
+ _context2.n = 2;
51
+ break;
52
+ }
53
+ throw new SentTransaction.Errors.SendFailed("Sending the transaction to the network failed!\n".concat(JSON.stringify(_this.sendTransactionResponse, null, 2)));
54
+ case 2:
55
+ if (watcher !== null && watcher !== void 0 && watcher.onSubmitted) watcher.onSubmitted(_this.sendTransactionResponse);
56
+ hash = _this.sendTransactionResponse.hash;
57
+ timeoutInSeconds = (_this$assembled$optio = _this.assembled.options.timeoutInSeconds) !== null && _this$assembled$optio !== void 0 ? _this$assembled$optio : _types.DEFAULT_TIMEOUT;
58
+ _context2.n = 3;
59
+ return (0, _utils.withExponentialBackoff)(_asyncToGenerator(_regenerator().m(function _callee() {
60
+ var tx;
61
+ return _regenerator().w(function (_context) {
62
+ while (1) switch (_context.n) {
63
+ case 0:
64
+ _context.n = 1;
65
+ return _this.server.getTransaction(hash);
66
+ case 1:
67
+ tx = _context.v;
68
+ if (watcher !== null && watcher !== void 0 && watcher.onProgress) watcher.onProgress(tx);
69
+ return _context.a(2, tx);
70
+ }
71
+ }, _callee);
72
+ })), function (resp) {
73
+ return resp.status === _api.Api.GetTransactionStatus.NOT_FOUND;
74
+ }, timeoutInSeconds);
75
+ case 3:
76
+ _this.getTransactionResponseAll = _context2.v;
77
+ _this.getTransactionResponse = _this.getTransactionResponseAll[_this.getTransactionResponseAll.length - 1];
78
+ if (!(_this.getTransactionResponse.status === _api.Api.GetTransactionStatus.NOT_FOUND)) {
79
+ _context2.n = 4;
80
+ break;
81
+ }
82
+ throw new SentTransaction.Errors.TransactionStillPending("Waited ".concat(timeoutInSeconds, " seconds for transaction to complete, but it did not. ") + "Returning anyway. Check the transaction status manually. " + "Sent transaction: ".concat(JSON.stringify(_this.sendTransactionResponse, null, 2), "\n") + "All attempts to get the result: ".concat(JSON.stringify(_this.getTransactionResponseAll, null, 2)));
83
+ case 4:
84
+ return _context2.a(2, _this);
85
+ }
86
+ }, _callee2);
87
+ }));
88
+ return function (_x) {
89
+ return _ref.apply(this, arguments);
90
+ };
91
+ }());
75
92
  this.assembled = assembled;
76
93
  this.server = new _rpc.Server(this.assembled.options.rpcUrl, {
77
94
  allowHttp: (_this$assembled$optio2 = this.assembled.options.allowHttp) !== null && _this$assembled$optio2 !== void 0 ? _this$assembled$optio2 : false
@@ -126,21 +143,24 @@ _defineProperty(SentTransaction, "Errors", {
126
143
  }(_wrapNativeSuper(Error))
127
144
  });
128
145
  _defineProperty(SentTransaction, "init", function () {
129
- var _ref2 = _asyncToGenerator(_regenerator().m(function _callee2(assembled) {
146
+ var _ref3 = _asyncToGenerator(_regenerator().m(function _callee3(assembled, watcher) {
130
147
  var tx, sent;
131
- return _regenerator().w(function (_context2) {
132
- while (1) switch (_context2.n) {
148
+ return _regenerator().w(function (_context3) {
149
+ while (1) switch (_context3.n) {
133
150
  case 0:
134
151
  tx = new _SentTransaction(assembled);
135
- _context2.n = 1;
136
- return tx.send();
152
+ _context3.n = 1;
153
+ return tx.send(watcher);
137
154
  case 1:
138
- sent = _context2.v;
139
- return _context2.a(2, sent);
155
+ sent = _context3.v;
156
+ return _context3.a(2, sent);
140
157
  }
141
- }, _callee2);
158
+ }, _callee3);
142
159
  }));
143
- return function (_x) {
144
- return _ref2.apply(this, arguments);
160
+ return function (_x2, _x3) {
161
+ return _ref3.apply(this, arguments);
145
162
  };
146
- }());
163
+ }());
164
+ var Watcher = exports.Watcher = _createClass(function Watcher() {
165
+ _classCallCheck(this, Watcher);
166
+ });
@@ -83,10 +83,7 @@ function stringToScVal(str, ty) {
83
83
  case _stellarBase.xdr.ScSpecType.scSpecTypeSymbol().value:
84
84
  return _stellarBase.xdr.ScVal.scvSymbol(str);
85
85
  case _stellarBase.xdr.ScSpecType.scSpecTypeAddress().value:
86
- {
87
- var addr = _stellarBase.Address.fromString(str);
88
- return _stellarBase.xdr.ScVal.scvAddress(addr.toScAddress());
89
- }
86
+ return _stellarBase.Address.fromString(str).toScVal();
90
87
  case _stellarBase.xdr.ScSpecType.scSpecTypeU64().value:
91
88
  return new _stellarBase.XdrLargeInt("u64", str).toScVal();
92
89
  case _stellarBase.xdr.ScSpecType.scSpecTypeI64().value:
@@ -11,7 +11,7 @@ exports.withExponentialBackoff = withExponentialBackoff;
11
11
  var _stellarBase = require("@stellar/stellar-base");
12
12
  var _types = require("./types");
13
13
  function _regenerator() { var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
14
- function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { if (r) i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n;else { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } o("next", 0), o("throw", 1), o("return", 2); } }, _regeneratorDefine2(e, r, n, t); }
14
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
15
15
  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); }
16
16
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
17
17
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
@@ -29,9 +29,7 @@ function _withExponentialBackoff() {
29
29
  totalWaitTime,
30
30
  _args = arguments,
31
31
  _t,
32
- _t2,
33
- _t3,
34
- _t4;
32
+ _t2;
35
33
  return _regenerator().w(function (_context) {
36
34
  while (1) switch (_context.n) {
37
35
  case 0:
@@ -43,8 +41,7 @@ function _withExponentialBackoff() {
43
41
  _context.n = 1;
44
42
  return fn();
45
43
  case 1:
46
- _t2 = _context.v;
47
- _t.push.call(_t, _t2);
44
+ _t.push.call(_t, _context.v);
48
45
  if (keepWaitingIf(attempts[attempts.length - 1])) {
49
46
  _context.n = 2;
50
47
  break;
@@ -76,12 +73,11 @@ function _withExponentialBackoff() {
76
73
  }
77
74
  }
78
75
  totalWaitTime = waitTime + totalWaitTime;
79
- _t3 = attempts;
76
+ _t2 = attempts;
80
77
  _context.n = 5;
81
78
  return fn(attempts[attempts.length - 1]);
82
79
  case 5:
83
- _t4 = _context.v;
84
- _t3.push.call(_t3, _t4);
80
+ _t2.push.call(_t2, _context.v);
85
81
  if (verbose && keepWaitingIf(attempts[attempts.length - 1])) {
86
82
  console.info("".concat(count, ". Called ").concat(fn, "; ").concat(attempts.length, " prev attempts. Most recent: ").concat(JSON.stringify(attempts[attempts.length - 1], null, 2)));
87
83
  }