@stellar/stellar-sdk 12.0.1 → 12.1.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.
@@ -13720,21 +13720,30 @@ exports.extendFootprintTtl = extendFootprintTtl;
13720
13720
  var _xdr = _interopRequireDefault(__webpack_require__(1918));
13721
13721
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
13722
13722
  /**
13723
- * Builds an operation to bump the time-to-live of a footprint (read and written
13724
- * ledger keys). Its only parameter is the new, absolute ledger sequence number
13725
- * at which the entry will expire.
13723
+ * Builds an operation to bump the time-to-live (TTL) of the ledger keys. The
13724
+ * keys for extension have to be provided in the read-only footprint of
13725
+ * the transaction.
13726
13726
  *
13727
- * The footprint itself is derived from the transaction (see
13727
+ * The only parameter of the operation itself is the new minimum TTL for
13728
+ * all the provided entries. If an entry already has a higher TTL, then it
13729
+ * will just be skipped.
13730
+ *
13731
+ * TTL is the number of ledgers from the current ledger (exclusive) until
13732
+ * the last ledger the entry is still considered alive (inclusive). Thus
13733
+ * the exact ledger until the entries will live will only be determined
13734
+ * when transaction has been applied.
13735
+ *
13736
+ * The footprint has to be specified in the transaction. See
13728
13737
  * {@link TransactionBuilder}'s `opts.sorobanData` parameter, which is a
13729
13738
  * {@link xdr.SorobanTransactionData} instance that contains fee data & resource
13730
- * usage as part of {@link xdr.SorobanResources}).
13739
+ * usage as part of {@link xdr.SorobanResources}.
13731
13740
  *
13732
13741
  * @function
13733
13742
  * @alias Operation.extendFootprintTtl
13734
13743
  *
13735
13744
  * @param {object} opts - object holding operation parameters
13736
- * @param {number} opts.extendTo - the absolute ledger sequence number at which
13737
- * the transaction's ledger keys will now expire
13745
+ * @param {number} opts.extendTo - the minimum TTL that all the entries in
13746
+ * the read-only footprint will have
13738
13747
  * @param {string} [opts.source] - an optional source account
13739
13748
  *
13740
13749
  * @returns {xdr.Operation} an Extend Footprint TTL operation
@@ -13743,7 +13752,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default":
13743
13752
  function extendFootprintTtl(opts) {
13744
13753
  var _opts$extendTo;
13745
13754
  if (((_opts$extendTo = opts.extendTo) !== null && _opts$extendTo !== void 0 ? _opts$extendTo : -1) <= 0) {
13746
- throw new RangeError("extendTo isn't a ledger quantity (uint32)");
13755
+ throw new RangeError('extendTo has to be positive');
13747
13756
  }
13748
13757
  var extendFootprintOp = new _xdr["default"].ExtendFootprintTtlOp({
13749
13758
  ext: new _xdr["default"].ExtensionPoint(0),
@@ -14784,14 +14793,18 @@ exports.restoreFootprint = restoreFootprint;
14784
14793
  var _xdr = _interopRequireDefault(__webpack_require__(1918));
14785
14794
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
14786
14795
  /**
14787
- * Builds a footprint restoration operation.
14796
+ * Builds an operation to restore the archived ledger entries specified
14797
+ * by the ledger keys.
14798
+ *
14799
+ * The ledger keys to restore are specified separately from the operation
14800
+ * in read-write footprint of the transaction.
14788
14801
  *
14789
14802
  * It takes no parameters because the relevant footprint is derived from the
14790
- * transaction itself (see {@link TransactionBuilder}'s `opts.sorobanData`
14803
+ * transaction itself. See {@link TransactionBuilder}'s `opts.sorobanData`
14791
14804
  * parameter (or {@link TransactionBuilder.setSorobanData} /
14792
14805
  * {@link TransactionBuilder.setLedgerKeys}), which is a
14793
14806
  * {@link xdr.SorobanTransactionData} instance that contains fee data & resource
14794
- * usage as part of {@link xdr.SorobanTransactionData}).
14807
+ * usage as part of {@link xdr.SorobanTransactionData}.
14795
14808
  *
14796
14809
  * @function
14797
14810
  * @alias Operation.restoreFootprint
@@ -15716,21 +15729,23 @@ function scValToNative(scv) {
15716
15729
  case _xdr["default"].ScValType.scvTimepoint().value:
15717
15730
  case _xdr["default"].ScValType.scvDuration().value:
15718
15731
  return new _xdr["default"].Uint64(scv.value()).toBigInt();
15719
- case _xdr["default"].ScValType.scvStatus().value:
15720
- // TODO: Convert each status type into a human-readable error string?
15721
- switch (scv.value()["switch"]()) {
15722
- case _xdr["default"].ScStatusType.sstOk().value:
15723
- case _xdr["default"].ScStatusType.sstUnknownError().value:
15724
- case _xdr["default"].ScStatusType.sstHostValueError().value:
15725
- case _xdr["default"].ScStatusType.sstHostObjectError().value:
15726
- case _xdr["default"].ScStatusType.sstHostFunctionError().value:
15727
- case _xdr["default"].ScStatusType.sstHostStorageError().value:
15728
- case _xdr["default"].ScStatusType.sstHostContextError().value:
15729
- case _xdr["default"].ScStatusType.sstVmError().value:
15730
- case _xdr["default"].ScStatusType.sstContractError().value:
15731
- case _xdr["default"].ScStatusType.sstHostAuthError().value:
15732
+ case _xdr["default"].ScValType.scvError().value:
15733
+ switch (scv.error()["switch"]().value) {
15734
+ // Distinguish errors from the user contract.
15735
+ case _xdr["default"].ScErrorType.sceContract().value:
15736
+ return {
15737
+ type: 'contract',
15738
+ code: scv.error().contractCode()
15739
+ };
15732
15740
  default:
15733
- break;
15741
+ {
15742
+ var err = scv.error();
15743
+ return {
15744
+ type: 'system',
15745
+ code: err.code().value,
15746
+ value: err.code().name
15747
+ };
15748
+ }
15734
15749
  }
15735
15750
 
15736
15751
  // in the fallthrough case, just return the underlying value directly
@@ -20836,6 +20851,7 @@ __webpack_require__.r(__webpack_exports__);
20836
20851
  __webpack_require__.d(__webpack_exports__, {
20837
20852
  AssembledTransaction: () => (/* reexport */ AssembledTransaction),
20838
20853
  Client: () => (/* reexport */ Client),
20854
+ DEFAULT_TIMEOUT: () => (/* reexport */ DEFAULT_TIMEOUT),
20839
20855
  Err: () => (/* reexport */ Err),
20840
20856
  NULL_ACCOUNT: () => (/* reexport */ NULL_ACCOUNT),
20841
20857
  Ok: () => (/* reexport */ Ok),
@@ -20919,6 +20935,7 @@ function utils_typeof(o) { "@babel/helpers - typeof"; return utils_typeof = "fun
20919
20935
  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); }
20920
20936
  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); }); }; }
20921
20937
 
20938
+
20922
20939
  var DEFAULT_TIMEOUT = 5 * 60;
20923
20940
  function withExponentialBackoff(_x, _x2, _x3) {
20924
20941
  return _withExponentialBackoff.apply(this, arguments);
@@ -21010,6 +21027,36 @@ function processSpecEntryStream(buffer) {
21010
21027
  }
21011
21028
  return res;
21012
21029
  }
21030
+ function getAccount(_x4, _x5) {
21031
+ return _getAccount.apply(this, arguments);
21032
+ }
21033
+ function _getAccount() {
21034
+ _getAccount = _asyncToGenerator(_regeneratorRuntime().mark(function _callee2(options, server) {
21035
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
21036
+ while (1) switch (_context2.prev = _context2.next) {
21037
+ case 0:
21038
+ if (!options.publicKey) {
21039
+ _context2.next = 6;
21040
+ break;
21041
+ }
21042
+ _context2.next = 3;
21043
+ return server.getAccount(options.publicKey);
21044
+ case 3:
21045
+ _context2.t0 = _context2.sent;
21046
+ _context2.next = 7;
21047
+ break;
21048
+ case 6:
21049
+ _context2.t0 = new lib.Account(NULL_ACCOUNT, "0");
21050
+ case 7:
21051
+ return _context2.abrupt("return", _context2.t0);
21052
+ case 8:
21053
+ case "end":
21054
+ return _context2.stop();
21055
+ }
21056
+ }, _callee2);
21057
+ }));
21058
+ return _getAccount.apply(this, arguments);
21059
+ }
21013
21060
  ;// CONCATENATED MODULE: ./src/contract/sent_transaction.ts
21014
21061
  var _SentTransaction;
21015
21062
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
@@ -21035,69 +21082,52 @@ function sent_transaction_toPrimitive(t, r) { if ("object" != sent_transaction_t
21035
21082
 
21036
21083
 
21037
21084
 
21038
-
21039
21085
  var SentTransaction = function () {
21040
- function SentTransaction(signTransaction, assembled) {
21086
+ function SentTransaction(_, assembled) {
21041
21087
  var _this = this,
21042
21088
  _this$assembled$optio2;
21043
21089
  sent_transaction_classCallCheck(this, SentTransaction);
21044
21090
  _defineProperty(this, "send", sent_transaction_asyncToGenerator(sent_transaction_regeneratorRuntime().mark(function _callee() {
21045
21091
  var _this$assembled$optio;
21046
- var timeoutInSeconds, signature, hash;
21092
+ var hash, timeoutInSeconds;
21047
21093
  return sent_transaction_regeneratorRuntime().wrap(function _callee$(_context) {
21048
21094
  while (1) switch (_context.prev = _context.next) {
21049
21095
  case 0:
21050
- timeoutInSeconds = (_this$assembled$optio = _this.assembled.options.timeoutInSeconds) !== null && _this$assembled$optio !== void 0 ? _this$assembled$optio : DEFAULT_TIMEOUT;
21051
- _this.assembled.built = lib.TransactionBuilder.cloneFrom(_this.assembled.built, {
21052
- fee: _this.assembled.built.fee,
21053
- timebounds: undefined,
21054
- sorobanData: new lib.SorobanDataBuilder(_this.assembled.simulationData.transactionData.toXDR()).build()
21055
- }).setTimeout(timeoutInSeconds).build();
21056
- _context.next = 4;
21057
- return _this.signTransaction(_this.assembled.built.toXDR(), {
21058
- networkPassphrase: _this.assembled.options.networkPassphrase
21059
- });
21060
- case 4:
21061
- signature = _context.sent;
21062
- _this.signed = lib.TransactionBuilder.fromXDR(signature, _this.assembled.options.networkPassphrase);
21063
- _context.next = 8;
21064
- return _this.server.sendTransaction(_this.signed);
21065
- case 8:
21096
+ _context.next = 2;
21097
+ return _this.server.sendTransaction(_this.assembled.signed);
21098
+ case 2:
21066
21099
  _this.sendTransactionResponse = _context.sent;
21067
21100
  if (!(_this.sendTransactionResponse.status !== "PENDING")) {
21068
- _context.next = 11;
21101
+ _context.next = 5;
21069
21102
  break;
21070
21103
  }
21071
21104
  throw new SentTransaction.Errors.SendFailed("Sending the transaction to the network failed!\n".concat(JSON.stringify(_this.sendTransactionResponse, null, 2)));
21072
- case 11:
21105
+ case 5:
21073
21106
  hash = _this.sendTransactionResponse.hash;
21074
- _context.next = 14;
21107
+ timeoutInSeconds = (_this$assembled$optio = _this.assembled.options.timeoutInSeconds) !== null && _this$assembled$optio !== void 0 ? _this$assembled$optio : DEFAULT_TIMEOUT;
21108
+ _context.next = 9;
21075
21109
  return withExponentialBackoff(function () {
21076
21110
  return _this.server.getTransaction(hash);
21077
21111
  }, function (resp) {
21078
21112
  return resp.status === api/* Api */.j.GetTransactionStatus.NOT_FOUND;
21079
21113
  }, timeoutInSeconds);
21080
- case 14:
21114
+ case 9:
21081
21115
  _this.getTransactionResponseAll = _context.sent;
21082
21116
  _this.getTransactionResponse = _this.getTransactionResponseAll[_this.getTransactionResponseAll.length - 1];
21083
21117
  if (!(_this.getTransactionResponse.status === api/* Api */.j.GetTransactionStatus.NOT_FOUND)) {
21084
- _context.next = 18;
21118
+ _context.next = 13;
21085
21119
  break;
21086
21120
  }
21087
21121
  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)));
21088
- case 18:
21122
+ case 13:
21089
21123
  return _context.abrupt("return", _this);
21090
- case 19:
21124
+ case 14:
21091
21125
  case "end":
21092
21126
  return _context.stop();
21093
21127
  }
21094
21128
  }, _callee);
21095
21129
  })));
21096
- this.signTransaction = signTransaction;
21097
21130
  this.assembled = assembled;
21098
- if (!signTransaction) {
21099
- throw new Error("You must provide a `signTransaction` function to send a transaction");
21100
- }
21101
21131
  this.server = new server/* Server */.gq(this.assembled.options.rpcUrl, {
21102
21132
  allowHttp: (_this$assembled$optio2 = this.assembled.options.allowHttp) !== null && _this$assembled$optio2 !== void 0 ? _this$assembled$optio2 : false
21103
21133
  });
@@ -21119,7 +21149,7 @@ var SentTransaction = function () {
21119
21149
  }
21120
21150
  throw new SentTransaction.Errors.SendResultOnly("Transaction was sent to the network, but not yet awaited. No result to show. Await transaction completion with `getTransaction(sendTransactionResponse.hash)`");
21121
21151
  }
21122
- throw new Error("Sending transaction failed: ".concat(JSON.stringify(this.assembled)));
21152
+ throw new Error("Sending transaction failed: ".concat(JSON.stringify(this.assembled.signed)));
21123
21153
  }
21124
21154
  }]);
21125
21155
  }();
@@ -21151,12 +21181,12 @@ _defineProperty(SentTransaction, "Errors", {
21151
21181
  }(_wrapNativeSuper(Error))
21152
21182
  });
21153
21183
  _defineProperty(SentTransaction, "init", function () {
21154
- var _ref2 = sent_transaction_asyncToGenerator(sent_transaction_regeneratorRuntime().mark(function _callee2(signTransaction, assembled) {
21184
+ var _ref2 = sent_transaction_asyncToGenerator(sent_transaction_regeneratorRuntime().mark(function _callee2(_, assembled) {
21155
21185
  var tx, sent;
21156
21186
  return sent_transaction_regeneratorRuntime().wrap(function _callee2$(_context2) {
21157
21187
  while (1) switch (_context2.prev = _context2.next) {
21158
21188
  case 0:
21159
- tx = new _SentTransaction(signTransaction, assembled);
21189
+ tx = new _SentTransaction(undefined, assembled);
21160
21190
  _context2.next = 3;
21161
21191
  return tx.send();
21162
21192
  case 3:
@@ -21185,18 +21215,20 @@ function assembled_transaction_isNativeFunction(t) { try { return -1 !== Functio
21185
21215
  function assembled_transaction_setPrototypeOf(t, e) { return assembled_transaction_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, assembled_transaction_setPrototypeOf(t, e); }
21186
21216
  function assembled_transaction_getPrototypeOf(t) { return assembled_transaction_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, assembled_transaction_getPrototypeOf(t); }
21187
21217
  function assembled_transaction_typeof(o) { "@babel/helpers - typeof"; return assembled_transaction_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; }, assembled_transaction_typeof(o); }
21218
+ 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; }
21219
+ 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) { assembled_transaction_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; }
21188
21220
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
21189
21221
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
21190
21222
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
21191
21223
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
21192
21224
  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; } } }; }
21225
+ function assembled_transaction_regeneratorRuntime() { "use strict"; assembled_transaction_regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == assembled_transaction_typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(assembled_transaction_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
21193
21226
  function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
21194
21227
  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."); }
21195
21228
  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; } }
21196
21229
  function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
21197
21230
  function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
21198
21231
  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; }
21199
- function assembled_transaction_regeneratorRuntime() { "use strict"; assembled_transaction_regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == assembled_transaction_typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(assembled_transaction_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
21200
21232
  function assembled_transaction_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); }
21201
21233
  function assembled_transaction_asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { assembled_transaction_asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { assembled_transaction_asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
21202
21234
  function assembled_transaction_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
@@ -21220,43 +21252,91 @@ var AssembledTransaction = function () {
21220
21252
  _this$options$allowHt;
21221
21253
  assembled_transaction_classCallCheck(this, AssembledTransaction);
21222
21254
  assembled_transaction_defineProperty(this, "simulate", assembled_transaction_asyncToGenerator(assembled_transaction_regeneratorRuntime().mark(function _callee() {
21255
+ var _restore;
21256
+ var _ref2,
21257
+ restore,
21258
+ account,
21259
+ result,
21260
+ _this$options$fee,
21261
+ _this$options$args,
21262
+ _this$options$timeout,
21263
+ contract,
21264
+ _args = arguments;
21223
21265
  return assembled_transaction_regeneratorRuntime().wrap(function _callee$(_context) {
21224
21266
  while (1) switch (_context.prev = _context.next) {
21225
21267
  case 0:
21268
+ _ref2 = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}, restore = _ref2.restore;
21269
+ if (_this.built) {
21270
+ _context.next = 5;
21271
+ break;
21272
+ }
21226
21273
  if (_this.raw) {
21227
- _context.next = 2;
21274
+ _context.next = 4;
21228
21275
  break;
21229
21276
  }
21230
21277
  throw new Error("Transaction has not yet been assembled; " + "call `AssembledTransaction.build` first.");
21231
- case 2:
21278
+ case 4:
21232
21279
  _this.built = _this.raw.build();
21233
- _context.next = 5;
21234
- return _this.server.simulateTransaction(_this.built);
21235
21280
  case 5:
21281
+ restore = (_restore = restore) !== null && _restore !== void 0 ? _restore : _this.options.restore;
21282
+ delete _this.simulationResult;
21283
+ delete _this.simulationTransactionData;
21284
+ _context.next = 10;
21285
+ return _this.server.simulateTransaction(_this.built);
21286
+ case 10:
21236
21287
  _this.simulation = _context.sent;
21288
+ if (!(restore && api/* Api */.j.isSimulationRestore(_this.simulation))) {
21289
+ _context.next = 25;
21290
+ break;
21291
+ }
21292
+ _context.next = 14;
21293
+ return getAccount(_this.options, _this.server);
21294
+ case 14:
21295
+ account = _context.sent;
21296
+ _context.next = 17;
21297
+ return _this.restoreFootprint(_this.simulation.restorePreamble, account);
21298
+ case 17:
21299
+ result = _context.sent;
21300
+ if (!(result.status === api/* Api */.j.GetTransactionStatus.SUCCESS)) {
21301
+ _context.next = 24;
21302
+ break;
21303
+ }
21304
+ contract = new lib.Contract(_this.options.contractId);
21305
+ _this.raw = new lib.TransactionBuilder(account, {
21306
+ fee: (_this$options$fee = _this.options.fee) !== null && _this$options$fee !== void 0 ? _this$options$fee : lib.BASE_FEE,
21307
+ networkPassphrase: _this.options.networkPassphrase
21308
+ }).addOperation(contract.call.apply(contract, [_this.options.method].concat(_toConsumableArray((_this$options$args = _this.options.args) !== null && _this$options$args !== void 0 ? _this$options$args : [])))).setTimeout((_this$options$timeout = _this.options.timeoutInSeconds) !== null && _this$options$timeout !== void 0 ? _this$options$timeout : DEFAULT_TIMEOUT);
21309
+ _context.next = 23;
21310
+ return _this.simulate();
21311
+ case 23:
21312
+ return _context.abrupt("return", _this);
21313
+ case 24:
21314
+ throw new AssembledTransaction.Errors.RestorationFailure("Automatic restore failed! You set 'restore: true' but the attempted restore did not work. Result:\n".concat(JSON.stringify(result)));
21315
+ case 25:
21237
21316
  if (api/* Api */.j.isSimulationSuccess(_this.simulation)) {
21238
21317
  _this.built = (0,transaction/* assembleTransaction */.X)(_this.built, _this.simulation).build();
21239
21318
  }
21240
21319
  return _context.abrupt("return", _this);
21241
- case 8:
21320
+ case 27:
21242
21321
  case "end":
21243
21322
  return _context.stop();
21244
21323
  }
21245
21324
  }, _callee);
21246
21325
  })));
21247
- assembled_transaction_defineProperty(this, "signAndSend", assembled_transaction_asyncToGenerator(assembled_transaction_regeneratorRuntime().mark(function _callee2() {
21248
- var _ref3,
21249
- _ref3$force,
21326
+ assembled_transaction_defineProperty(this, "sign", assembled_transaction_asyncToGenerator(assembled_transaction_regeneratorRuntime().mark(function _callee2() {
21327
+ var _this$options$timeout2;
21328
+ var _ref4,
21329
+ _ref4$force,
21250
21330
  force,
21251
- _ref3$signTransaction,
21331
+ _ref4$signTransaction,
21252
21332
  signTransaction,
21253
- typeChecked,
21254
- sent,
21333
+ timeoutInSeconds,
21334
+ signature,
21255
21335
  _args2 = arguments;
21256
21336
  return assembled_transaction_regeneratorRuntime().wrap(function _callee2$(_context2) {
21257
21337
  while (1) switch (_context2.prev = _context2.next) {
21258
21338
  case 0:
21259
- _ref3 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, _ref3$force = _ref3.force, force = _ref3$force === void 0 ? false : _ref3$force, _ref3$signTransaction = _ref3.signTransaction, signTransaction = _ref3$signTransaction === void 0 ? _this.options.signTransaction : _ref3$signTransaction;
21339
+ _ref4 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, _ref4$force = _ref4.force, force = _ref4$force === void 0 ? false : _ref4$force, _ref4$signTransaction = _ref4.signTransaction, signTransaction = _ref4$signTransaction === void 0 ? _this.options.signTransaction : _ref4$signTransaction;
21260
21340
  if (_this.built) {
21261
21341
  _context2.next = 3;
21262
21342
  break;
@@ -21281,45 +21361,80 @@ var AssembledTransaction = function () {
21281
21361
  }
21282
21362
  throw new AssembledTransaction.Errors.NeedsMoreSignatures("Transaction requires more signatures. " + "See `needsNonInvokerSigningBy` for details.");
21283
21363
  case 9:
21284
- typeChecked = _this;
21285
- _context2.next = 12;
21286
- return SentTransaction.init(signTransaction, typeChecked);
21287
- case 12:
21288
- sent = _context2.sent;
21289
- return _context2.abrupt("return", sent);
21290
- case 14:
21364
+ timeoutInSeconds = (_this$options$timeout2 = _this.options.timeoutInSeconds) !== null && _this$options$timeout2 !== void 0 ? _this$options$timeout2 : DEFAULT_TIMEOUT;
21365
+ _this.built = lib.TransactionBuilder.cloneFrom(_this.built, {
21366
+ fee: _this.built.fee,
21367
+ timebounds: undefined,
21368
+ sorobanData: _this.simulationData.transactionData
21369
+ }).setTimeout(timeoutInSeconds).build();
21370
+ _context2.next = 13;
21371
+ return signTransaction(_this.built.toXDR(), {
21372
+ networkPassphrase: _this.options.networkPassphrase
21373
+ });
21374
+ case 13:
21375
+ signature = _context2.sent;
21376
+ _this.signed = lib.TransactionBuilder.fromXDR(signature, _this.options.networkPassphrase);
21377
+ case 15:
21291
21378
  case "end":
21292
21379
  return _context2.stop();
21293
21380
  }
21294
21381
  }, _callee2);
21295
21382
  })));
21296
- assembled_transaction_defineProperty(this, "getStorageExpiration", assembled_transaction_asyncToGenerator(assembled_transaction_regeneratorRuntime().mark(function _callee3() {
21297
- var entryRes;
21383
+ assembled_transaction_defineProperty(this, "signAndSend", assembled_transaction_asyncToGenerator(assembled_transaction_regeneratorRuntime().mark(function _callee3() {
21384
+ var _ref6,
21385
+ _ref6$force,
21386
+ force,
21387
+ _ref6$signTransaction,
21388
+ signTransaction,
21389
+ _args3 = arguments;
21298
21390
  return assembled_transaction_regeneratorRuntime().wrap(function _callee3$(_context3) {
21299
21391
  while (1) switch (_context3.prev = _context3.next) {
21300
21392
  case 0:
21301
- _context3.next = 2;
21393
+ _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;
21394
+ if (_this.signed) {
21395
+ _context3.next = 4;
21396
+ break;
21397
+ }
21398
+ _context3.next = 4;
21399
+ return _this.sign({
21400
+ force: force,
21401
+ signTransaction: signTransaction
21402
+ });
21403
+ case 4:
21404
+ return _context3.abrupt("return", _this.send());
21405
+ case 5:
21406
+ case "end":
21407
+ return _context3.stop();
21408
+ }
21409
+ }, _callee3);
21410
+ })));
21411
+ assembled_transaction_defineProperty(this, "getStorageExpiration", assembled_transaction_asyncToGenerator(assembled_transaction_regeneratorRuntime().mark(function _callee4() {
21412
+ var entryRes;
21413
+ return assembled_transaction_regeneratorRuntime().wrap(function _callee4$(_context4) {
21414
+ while (1) switch (_context4.prev = _context4.next) {
21415
+ case 0:
21416
+ _context4.next = 2;
21302
21417
  return _this.server.getLedgerEntries(new lib.Contract(_this.options.contractId).getFootprint());
21303
21418
  case 2:
21304
- entryRes = _context3.sent;
21419
+ entryRes = _context4.sent;
21305
21420
  if (!(!entryRes.entries || !entryRes.entries.length || !entryRes.entries[0].liveUntilLedgerSeq)) {
21306
- _context3.next = 5;
21421
+ _context4.next = 5;
21307
21422
  break;
21308
21423
  }
21309
21424
  throw new Error("failed to get ledger entry");
21310
21425
  case 5:
21311
- return _context3.abrupt("return", entryRes.entries[0].liveUntilLedgerSeq);
21426
+ return _context4.abrupt("return", entryRes.entries[0].liveUntilLedgerSeq);
21312
21427
  case 6:
21313
21428
  case "end":
21314
- return _context3.stop();
21429
+ return _context4.stop();
21315
21430
  }
21316
- }, _callee3);
21431
+ }, _callee4);
21317
21432
  })));
21318
21433
  assembled_transaction_defineProperty(this, "needsNonInvokerSigningBy", function () {
21319
21434
  var _rawInvokeHostFunctio;
21320
- var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
21321
- _ref5$includeAlreadyS = _ref5.includeAlreadySigned,
21322
- includeAlreadySigned = _ref5$includeAlreadyS === void 0 ? false : _ref5$includeAlreadyS;
21435
+ var _ref8 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
21436
+ _ref8$includeAlreadyS = _ref8.includeAlreadySigned,
21437
+ includeAlreadySigned = _ref8$includeAlreadyS === void 0 ? false : _ref8$includeAlreadyS;
21323
21438
  if (!_this.built) {
21324
21439
  throw new Error("Transaction has not yet been simulated");
21325
21440
  }
@@ -21333,14 +21448,14 @@ var AssembledTransaction = function () {
21333
21448
  return lib.StrKey.encodeEd25519PublicKey(entry.credentials().address().address().accountId().ed25519());
21334
21449
  })));
21335
21450
  });
21336
- assembled_transaction_defineProperty(this, "signAuthEntries", assembled_transaction_asyncToGenerator(assembled_transaction_regeneratorRuntime().mark(function _callee5() {
21451
+ assembled_transaction_defineProperty(this, "signAuthEntries", assembled_transaction_asyncToGenerator(assembled_transaction_regeneratorRuntime().mark(function _callee6() {
21337
21452
  var _rawInvokeHostFunctio2;
21338
- var _ref7,
21339
- _ref7$expiration,
21453
+ var _ref10,
21454
+ _ref10$expiration,
21340
21455
  expiration,
21341
- _ref7$signAuthEntry,
21456
+ _ref10$signAuthEntry,
21342
21457
  signAuthEntry,
21343
- _ref7$publicKey,
21458
+ _ref10$publicKey,
21344
21459
  publicKey,
21345
21460
  needsNonInvokerSigningBy,
21346
21461
  rawInvokeHostFunctionOp,
@@ -21351,32 +21466,32 @@ var AssembledTransaction = function () {
21351
21466
  i,
21352
21467
  entry,
21353
21468
  pk,
21354
- _args5 = arguments;
21355
- return assembled_transaction_regeneratorRuntime().wrap(function _callee5$(_context5) {
21356
- while (1) switch (_context5.prev = _context5.next) {
21469
+ _args6 = arguments;
21470
+ return assembled_transaction_regeneratorRuntime().wrap(function _callee6$(_context6) {
21471
+ while (1) switch (_context6.prev = _context6.next) {
21357
21472
  case 0:
21358
- _ref7 = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {}, _ref7$expiration = _ref7.expiration, expiration = _ref7$expiration === void 0 ? _this.getStorageExpiration() : _ref7$expiration, _ref7$signAuthEntry = _ref7.signAuthEntry, signAuthEntry = _ref7$signAuthEntry === void 0 ? _this.options.signAuthEntry : _ref7$signAuthEntry, _ref7$publicKey = _ref7.publicKey, publicKey = _ref7$publicKey === void 0 ? _this.options.publicKey : _ref7$publicKey;
21473
+ _ref10 = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {}, _ref10$expiration = _ref10.expiration, expiration = _ref10$expiration === void 0 ? _this.getStorageExpiration() : _ref10$expiration, _ref10$signAuthEntry = _ref10.signAuthEntry, signAuthEntry = _ref10$signAuthEntry === void 0 ? _this.options.signAuthEntry : _ref10$signAuthEntry, _ref10$publicKey = _ref10.publicKey, publicKey = _ref10$publicKey === void 0 ? _this.options.publicKey : _ref10$publicKey;
21359
21474
  if (_this.built) {
21360
- _context5.next = 3;
21475
+ _context6.next = 3;
21361
21476
  break;
21362
21477
  }
21363
21478
  throw new Error("Transaction has not yet been assembled or simulated");
21364
21479
  case 3:
21365
21480
  needsNonInvokerSigningBy = _this.needsNonInvokerSigningBy();
21366
21481
  if (needsNonInvokerSigningBy) {
21367
- _context5.next = 6;
21482
+ _context6.next = 6;
21368
21483
  break;
21369
21484
  }
21370
21485
  throw new AssembledTransaction.Errors.NoUnsignedNonInvokerAuthEntries("No unsigned non-invoker auth entries; maybe you already signed?");
21371
21486
  case 6:
21372
21487
  if (!(needsNonInvokerSigningBy.indexOf(publicKey !== null && publicKey !== void 0 ? publicKey : "") === -1)) {
21373
- _context5.next = 8;
21488
+ _context6.next = 8;
21374
21489
  break;
21375
21490
  }
21376
21491
  throw new AssembledTransaction.Errors.NoSignatureNeeded("No auth entries for public key \"".concat(publicKey, "\""));
21377
21492
  case 8:
21378
21493
  if (signAuthEntry) {
21379
- _context5.next = 10;
21494
+ _context6.next = 10;
21380
21495
  break;
21381
21496
  }
21382
21497
  throw new AssembledTransaction.Errors.NoSigner("You must provide `signAuthEntry` when calling `signAuthEntries`, " + "or when constructing the `Client` or `AssembledTransaction`");
@@ -21384,78 +21499,78 @@ var AssembledTransaction = function () {
21384
21499
  rawInvokeHostFunctionOp = _this.built.operations[0];
21385
21500
  authEntries = (_rawInvokeHostFunctio2 = rawInvokeHostFunctionOp.auth) !== null && _rawInvokeHostFunctio2 !== void 0 ? _rawInvokeHostFunctio2 : [];
21386
21501
  _iterator = _createForOfIteratorHelper(authEntries.entries());
21387
- _context5.prev = 13;
21502
+ _context6.prev = 13;
21388
21503
  _iterator.s();
21389
21504
  case 15:
21390
21505
  if ((_step = _iterator.n()).done) {
21391
- _context5.next = 34;
21506
+ _context6.next = 34;
21392
21507
  break;
21393
21508
  }
21394
21509
  _step$value = _slicedToArray(_step.value, 2), i = _step$value[0], entry = _step$value[1];
21395
21510
  if (!(entry.credentials().switch() !== lib.xdr.SorobanCredentialsType.sorobanCredentialsAddress())) {
21396
- _context5.next = 19;
21511
+ _context6.next = 19;
21397
21512
  break;
21398
21513
  }
21399
- return _context5.abrupt("continue", 32);
21514
+ return _context6.abrupt("continue", 32);
21400
21515
  case 19:
21401
21516
  pk = lib.StrKey.encodeEd25519PublicKey(entry.credentials().address().address().accountId().ed25519());
21402
21517
  if (!(pk !== publicKey)) {
21403
- _context5.next = 22;
21518
+ _context6.next = 22;
21404
21519
  break;
21405
21520
  }
21406
- return _context5.abrupt("continue", 32);
21521
+ return _context6.abrupt("continue", 32);
21407
21522
  case 22:
21408
- _context5.t0 = lib.authorizeEntry;
21409
- _context5.t1 = entry;
21410
- _context5.t2 = function () {
21411
- var _ref8 = assembled_transaction_asyncToGenerator(assembled_transaction_regeneratorRuntime().mark(function _callee4(preimage) {
21412
- return assembled_transaction_regeneratorRuntime().wrap(function _callee4$(_context4) {
21413
- while (1) switch (_context4.prev = _context4.next) {
21523
+ _context6.t0 = lib.authorizeEntry;
21524
+ _context6.t1 = entry;
21525
+ _context6.t2 = function () {
21526
+ var _ref11 = assembled_transaction_asyncToGenerator(assembled_transaction_regeneratorRuntime().mark(function _callee5(preimage) {
21527
+ return assembled_transaction_regeneratorRuntime().wrap(function _callee5$(_context5) {
21528
+ while (1) switch (_context5.prev = _context5.next) {
21414
21529
  case 0:
21415
- _context4.t0 = Buffer;
21416
- _context4.next = 3;
21530
+ _context5.t0 = Buffer;
21531
+ _context5.next = 3;
21417
21532
  return signAuthEntry(preimage.toXDR("base64"));
21418
21533
  case 3:
21419
- _context4.t1 = _context4.sent;
21420
- return _context4.abrupt("return", _context4.t0.from.call(_context4.t0, _context4.t1, "base64"));
21534
+ _context5.t1 = _context5.sent;
21535
+ return _context5.abrupt("return", _context5.t0.from.call(_context5.t0, _context5.t1, "base64"));
21421
21536
  case 5:
21422
21537
  case "end":
21423
- return _context4.stop();
21538
+ return _context5.stop();
21424
21539
  }
21425
- }, _callee4);
21540
+ }, _callee5);
21426
21541
  }));
21427
21542
  return function (_x) {
21428
- return _ref8.apply(this, arguments);
21543
+ return _ref11.apply(this, arguments);
21429
21544
  };
21430
21545
  }();
21431
- _context5.next = 27;
21546
+ _context6.next = 27;
21432
21547
  return expiration;
21433
21548
  case 27:
21434
- _context5.t3 = _context5.sent;
21435
- _context5.t4 = _this.options.networkPassphrase;
21436
- _context5.next = 31;
21437
- return (0, _context5.t0)(_context5.t1, _context5.t2, _context5.t3, _context5.t4);
21549
+ _context6.t3 = _context6.sent;
21550
+ _context6.t4 = _this.options.networkPassphrase;
21551
+ _context6.next = 31;
21552
+ return (0, _context6.t0)(_context6.t1, _context6.t2, _context6.t3, _context6.t4);
21438
21553
  case 31:
21439
- authEntries[i] = _context5.sent;
21554
+ authEntries[i] = _context6.sent;
21440
21555
  case 32:
21441
- _context5.next = 15;
21556
+ _context6.next = 15;
21442
21557
  break;
21443
21558
  case 34:
21444
- _context5.next = 39;
21559
+ _context6.next = 39;
21445
21560
  break;
21446
21561
  case 36:
21447
- _context5.prev = 36;
21448
- _context5.t5 = _context5["catch"](13);
21449
- _iterator.e(_context5.t5);
21562
+ _context6.prev = 36;
21563
+ _context6.t5 = _context6["catch"](13);
21564
+ _iterator.e(_context6.t5);
21450
21565
  case 39:
21451
- _context5.prev = 39;
21566
+ _context6.prev = 39;
21452
21567
  _iterator.f();
21453
- return _context5.finish(39);
21568
+ return _context6.finish(39);
21454
21569
  case 42:
21455
21570
  case "end":
21456
- return _context5.stop();
21571
+ return _context6.stop();
21457
21572
  }
21458
- }, _callee5, null, [[13, 36, 39, 42]]);
21573
+ }, _callee6, null, [[13, 36, 39, 42]]);
21459
21574
  })));
21460
21575
  this.options = options;
21461
21576
  this.options.simulate = (_this$options$simulat = this.options.simulate) !== null && _this$options$simulat !== void 0 ? _this$options$simulat : true;
@@ -21479,9 +21594,17 @@ var AssembledTransaction = function () {
21479
21594
  simulationTransactionData: this.simulationData.transactionData.toXDR("base64")
21480
21595
  });
21481
21596
  }
21597
+ }, {
21598
+ key: "toXDR",
21599
+ value: function toXDR() {
21600
+ var _this$built2;
21601
+ if (!this.built) throw new Error("Transaction has not yet been simulated; " + "call `AssembledTransaction.simulate` first.");
21602
+ return (_this$built2 = this.built) === null || _this$built2 === void 0 ? void 0 : _this$built2.toEnvelope().toXDR('base64');
21603
+ }
21482
21604
  }, {
21483
21605
  key: "simulationData",
21484
21606
  get: function get() {
21607
+ var _simulation$result;
21485
21608
  if (this.simulationResult && this.simulationTransactionData) {
21486
21609
  return {
21487
21610
  result: this.simulationResult,
@@ -21496,12 +21619,12 @@ var AssembledTransaction = function () {
21496
21619
  throw new Error("Transaction simulation failed: \"".concat(simulation.error, "\""));
21497
21620
  }
21498
21621
  if (api/* Api */.j.isSimulationRestore(simulation)) {
21499
- throw new AssembledTransaction.Errors.ExpiredState("You need to restore some contract state before you can invoke this method. ".concat(JSON.stringify(simulation, null, 2)));
21500
- }
21501
- if (!simulation.result) {
21502
- throw new Error("Expected an invocation simulation, but got no 'result' field. Simulation: ".concat(JSON.stringify(simulation, null, 2)));
21622
+ 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.');
21503
21623
  }
21504
- this.simulationResult = simulation.result;
21624
+ this.simulationResult = (_simulation$result = simulation.result) !== null && _simulation$result !== void 0 ? _simulation$result : {
21625
+ auth: [],
21626
+ retval: lib.xdr.ScVal.scvVoid()
21627
+ };
21505
21628
  this.simulationTransactionData = simulation.transactionData.build();
21506
21629
  return {
21507
21630
  result: this.simulationResult,
@@ -21512,6 +21635,9 @@ var AssembledTransaction = function () {
21512
21635
  key: "result",
21513
21636
  get: function get() {
21514
21637
  try {
21638
+ if (!this.simulationData.result) {
21639
+ throw new Error("No simulation result!");
21640
+ }
21515
21641
  return this.options.parseResultXdr(this.simulationData.result.retval);
21516
21642
  } catch (e) {
21517
21643
  if (!implementsToString(e)) throw e;
@@ -21531,6 +21657,36 @@ var AssembledTransaction = function () {
21531
21657
  if (!err) return undefined;
21532
21658
  return new Err(err);
21533
21659
  }
21660
+ }, {
21661
+ key: "send",
21662
+ value: (function () {
21663
+ var _send = assembled_transaction_asyncToGenerator(assembled_transaction_regeneratorRuntime().mark(function _callee7() {
21664
+ var sent;
21665
+ return assembled_transaction_regeneratorRuntime().wrap(function _callee7$(_context7) {
21666
+ while (1) switch (_context7.prev = _context7.next) {
21667
+ case 0:
21668
+ if (this.signed) {
21669
+ _context7.next = 2;
21670
+ break;
21671
+ }
21672
+ throw new Error("The transaction has not yet been signed. Run `sign` first, or use `signAndSend` instead.");
21673
+ case 2:
21674
+ _context7.next = 4;
21675
+ return SentTransaction.init(undefined, this);
21676
+ case 4:
21677
+ sent = _context7.sent;
21678
+ return _context7.abrupt("return", sent);
21679
+ case 6:
21680
+ case "end":
21681
+ return _context7.stop();
21682
+ }
21683
+ }, _callee7, this);
21684
+ }));
21685
+ function send() {
21686
+ return _send.apply(this, arguments);
21687
+ }
21688
+ return send;
21689
+ }())
21534
21690
  }, {
21535
21691
  key: "isReadCall",
21536
21692
  get: function get() {
@@ -21538,12 +21694,67 @@ var AssembledTransaction = function () {
21538
21694
  var writeLength = this.simulationData.transactionData.resources().footprint().readWrite().length;
21539
21695
  return authsCount === 0 && writeLength === 0;
21540
21696
  }
21697
+ }, {
21698
+ key: "restoreFootprint",
21699
+ value: (function () {
21700
+ var _restoreFootprint = assembled_transaction_asyncToGenerator(assembled_transaction_regeneratorRuntime().mark(function _callee8(restorePreamble, account) {
21701
+ var _account;
21702
+ var restoreTx, sentTransaction;
21703
+ return assembled_transaction_regeneratorRuntime().wrap(function _callee8$(_context8) {
21704
+ while (1) switch (_context8.prev = _context8.next) {
21705
+ case 0:
21706
+ if (this.options.signTransaction) {
21707
+ _context8.next = 2;
21708
+ break;
21709
+ }
21710
+ throw new Error("For automatic restore to work you must provide a signTransaction function when initializing your Client");
21711
+ case 2:
21712
+ if (!((_account = account) !== null && _account !== void 0)) {
21713
+ _context8.next = 6;
21714
+ break;
21715
+ }
21716
+ _context8.t0 = _account;
21717
+ _context8.next = 9;
21718
+ break;
21719
+ case 6:
21720
+ _context8.next = 8;
21721
+ return getAccount(this.options, this.server);
21722
+ case 8:
21723
+ _context8.t0 = _context8.sent;
21724
+ case 9:
21725
+ account = _context8.t0;
21726
+ _context8.next = 12;
21727
+ return AssembledTransaction.buildFootprintRestoreTransaction(_objectSpread({}, this.options), restorePreamble.transactionData, account, restorePreamble.minResourceFee);
21728
+ case 12:
21729
+ restoreTx = _context8.sent;
21730
+ _context8.next = 15;
21731
+ return restoreTx.signAndSend();
21732
+ case 15:
21733
+ sentTransaction = _context8.sent;
21734
+ if (sentTransaction.getTransactionResponse) {
21735
+ _context8.next = 18;
21736
+ break;
21737
+ }
21738
+ throw new AssembledTransaction.Errors.RestorationFailure("The attempt at automatic restore failed. \n".concat(JSON.stringify(sentTransaction)));
21739
+ case 18:
21740
+ return _context8.abrupt("return", sentTransaction.getTransactionResponse);
21741
+ case 19:
21742
+ case "end":
21743
+ return _context8.stop();
21744
+ }
21745
+ }, _callee8, this);
21746
+ }));
21747
+ function restoreFootprint(_x2, _x3) {
21748
+ return _restoreFootprint.apply(this, arguments);
21749
+ }
21750
+ return restoreFootprint;
21751
+ }())
21541
21752
  }], [{
21542
21753
  key: "fromJSON",
21543
- value: function fromJSON(options, _ref9) {
21544
- var tx = _ref9.tx,
21545
- simulationResult = _ref9.simulationResult,
21546
- simulationTransactionData = _ref9.simulationTransactionData;
21754
+ value: function fromJSON(options, _ref12) {
21755
+ var tx = _ref12.tx,
21756
+ simulationResult = _ref12.simulationResult,
21757
+ simulationTransactionData = _ref12.simulationTransactionData;
21547
21758
  var txn = new AssembledTransaction(options);
21548
21759
  txn.built = lib.TransactionBuilder.fromXDR(tx, options.networkPassphrase);
21549
21760
  txn.simulationResult = {
@@ -21555,54 +21766,99 @@ var AssembledTransaction = function () {
21555
21766
  txn.simulationTransactionData = lib.xdr.SorobanTransactionData.fromXDR(simulationTransactionData, "base64");
21556
21767
  return txn;
21557
21768
  }
21769
+ }, {
21770
+ key: "fromXDR",
21771
+ value: function fromXDR(options, encodedXDR, spec) {
21772
+ var _operation$func;
21773
+ var envelope = lib.xdr.TransactionEnvelope.fromXDR(encodedXDR, "base64");
21774
+ var built = lib.TransactionBuilder.fromXDR(envelope, options.networkPassphrase);
21775
+ var operation = built.operations[0];
21776
+ if (!(operation !== null && operation !== void 0 && (_operation$func = operation.func) !== null && _operation$func !== void 0 && _operation$func.value) || typeof operation.func.value !== 'function') {
21777
+ throw new Error("Could not extract the method from the transaction envelope.");
21778
+ }
21779
+ var invokeContractArgs = operation.func.value();
21780
+ if (!(invokeContractArgs !== null && invokeContractArgs !== void 0 && invokeContractArgs.functionName)) {
21781
+ throw new Error("Could not extract the method name from the transaction envelope.");
21782
+ }
21783
+ var method = invokeContractArgs.functionName().toString('utf-8');
21784
+ var txn = new AssembledTransaction(_objectSpread(_objectSpread({}, options), {}, {
21785
+ method: method,
21786
+ parseResultXdr: function parseResultXdr(result) {
21787
+ return spec.funcResToNative(method, result);
21788
+ }
21789
+ }));
21790
+ txn.built = built;
21791
+ return txn;
21792
+ }
21558
21793
  }, {
21559
21794
  key: "build",
21560
21795
  value: (function () {
21561
- var _build = assembled_transaction_asyncToGenerator(assembled_transaction_regeneratorRuntime().mark(function _callee6(options) {
21796
+ var _build = assembled_transaction_asyncToGenerator(assembled_transaction_regeneratorRuntime().mark(function _callee9(options) {
21562
21797
  var _options$fee, _options$args, _options$timeoutInSec;
21563
21798
  var tx, contract, account;
21564
- return assembled_transaction_regeneratorRuntime().wrap(function _callee6$(_context6) {
21565
- while (1) switch (_context6.prev = _context6.next) {
21799
+ return assembled_transaction_regeneratorRuntime().wrap(function _callee9$(_context9) {
21800
+ while (1) switch (_context9.prev = _context9.next) {
21566
21801
  case 0:
21567
21802
  tx = new AssembledTransaction(options);
21568
21803
  contract = new lib.Contract(options.contractId);
21569
- if (!options.publicKey) {
21570
- _context6.next = 8;
21571
- break;
21572
- }
21573
- _context6.next = 5;
21574
- return tx.server.getAccount(options.publicKey);
21575
- case 5:
21576
- _context6.t0 = _context6.sent;
21577
- _context6.next = 9;
21578
- break;
21579
- case 8:
21580
- _context6.t0 = new lib.Account(NULL_ACCOUNT, "0");
21581
- case 9:
21582
- account = _context6.t0;
21804
+ _context9.next = 4;
21805
+ return getAccount(options, tx.server);
21806
+ case 4:
21807
+ account = _context9.sent;
21583
21808
  tx.raw = new lib.TransactionBuilder(account, {
21584
21809
  fee: (_options$fee = options.fee) !== null && _options$fee !== void 0 ? _options$fee : lib.BASE_FEE,
21585
21810
  networkPassphrase: options.networkPassphrase
21586
21811
  }).addOperation(contract.call.apply(contract, [options.method].concat(_toConsumableArray((_options$args = options.args) !== null && _options$args !== void 0 ? _options$args : [])))).setTimeout((_options$timeoutInSec = options.timeoutInSeconds) !== null && _options$timeoutInSec !== void 0 ? _options$timeoutInSec : DEFAULT_TIMEOUT);
21587
21812
  if (!options.simulate) {
21588
- _context6.next = 14;
21813
+ _context9.next = 9;
21589
21814
  break;
21590
21815
  }
21591
- _context6.next = 14;
21816
+ _context9.next = 9;
21592
21817
  return tx.simulate();
21593
- case 14:
21594
- return _context6.abrupt("return", tx);
21595
- case 15:
21818
+ case 9:
21819
+ return _context9.abrupt("return", tx);
21820
+ case 10:
21596
21821
  case "end":
21597
- return _context6.stop();
21822
+ return _context9.stop();
21598
21823
  }
21599
- }, _callee6);
21824
+ }, _callee9);
21600
21825
  }));
21601
- function build(_x2) {
21826
+ function build(_x4) {
21602
21827
  return _build.apply(this, arguments);
21603
21828
  }
21604
21829
  return build;
21605
21830
  }())
21831
+ }, {
21832
+ key: "buildFootprintRestoreTransaction",
21833
+ value: function () {
21834
+ var _buildFootprintRestoreTransaction = assembled_transaction_asyncToGenerator(assembled_transaction_regeneratorRuntime().mark(function _callee10(options, sorobanData, account, fee) {
21835
+ var _options$timeoutInSec2;
21836
+ var tx;
21837
+ return assembled_transaction_regeneratorRuntime().wrap(function _callee10$(_context10) {
21838
+ while (1) switch (_context10.prev = _context10.next) {
21839
+ case 0:
21840
+ tx = new AssembledTransaction(options);
21841
+ tx.raw = new lib.TransactionBuilder(account, {
21842
+ fee: fee,
21843
+ networkPassphrase: options.networkPassphrase
21844
+ }).setSorobanData(sorobanData instanceof lib.SorobanDataBuilder ? sorobanData.build() : sorobanData).addOperation(lib.Operation.restoreFootprint({})).setTimeout((_options$timeoutInSec2 = options.timeoutInSeconds) !== null && _options$timeoutInSec2 !== void 0 ? _options$timeoutInSec2 : DEFAULT_TIMEOUT);
21845
+ _context10.next = 4;
21846
+ return tx.simulate({
21847
+ restore: false
21848
+ });
21849
+ case 4:
21850
+ return _context10.abrupt("return", tx);
21851
+ case 5:
21852
+ case "end":
21853
+ return _context10.stop();
21854
+ }
21855
+ }, _callee10);
21856
+ }));
21857
+ function buildFootprintRestoreTransaction(_x5, _x6, _x7, _x8) {
21858
+ return _buildFootprintRestoreTransaction.apply(this, arguments);
21859
+ }
21860
+ return buildFootprintRestoreTransaction;
21861
+ }()
21606
21862
  }]);
21607
21863
  }();
21608
21864
  assembled_transaction_defineProperty(AssembledTransaction, "Errors", {
@@ -21614,52 +21870,60 @@ assembled_transaction_defineProperty(AssembledTransaction, "Errors", {
21614
21870
  assembled_transaction_inherits(ExpiredStateError, _Error);
21615
21871
  return assembled_transaction_createClass(ExpiredStateError);
21616
21872
  }(assembled_transaction_wrapNativeSuper(Error)),
21617
- NeedsMoreSignatures: function (_Error2) {
21873
+ RestorationFailure: function (_Error2) {
21874
+ function RestoreFailureError() {
21875
+ assembled_transaction_classCallCheck(this, RestoreFailureError);
21876
+ return assembled_transaction_callSuper(this, RestoreFailureError, arguments);
21877
+ }
21878
+ assembled_transaction_inherits(RestoreFailureError, _Error2);
21879
+ return assembled_transaction_createClass(RestoreFailureError);
21880
+ }(assembled_transaction_wrapNativeSuper(Error)),
21881
+ NeedsMoreSignatures: function (_Error3) {
21618
21882
  function NeedsMoreSignaturesError() {
21619
21883
  assembled_transaction_classCallCheck(this, NeedsMoreSignaturesError);
21620
21884
  return assembled_transaction_callSuper(this, NeedsMoreSignaturesError, arguments);
21621
21885
  }
21622
- assembled_transaction_inherits(NeedsMoreSignaturesError, _Error2);
21886
+ assembled_transaction_inherits(NeedsMoreSignaturesError, _Error3);
21623
21887
  return assembled_transaction_createClass(NeedsMoreSignaturesError);
21624
21888
  }(assembled_transaction_wrapNativeSuper(Error)),
21625
- NoSignatureNeeded: function (_Error3) {
21889
+ NoSignatureNeeded: function (_Error4) {
21626
21890
  function NoSignatureNeededError() {
21627
21891
  assembled_transaction_classCallCheck(this, NoSignatureNeededError);
21628
21892
  return assembled_transaction_callSuper(this, NoSignatureNeededError, arguments);
21629
21893
  }
21630
- assembled_transaction_inherits(NoSignatureNeededError, _Error3);
21894
+ assembled_transaction_inherits(NoSignatureNeededError, _Error4);
21631
21895
  return assembled_transaction_createClass(NoSignatureNeededError);
21632
21896
  }(assembled_transaction_wrapNativeSuper(Error)),
21633
- NoUnsignedNonInvokerAuthEntries: function (_Error4) {
21897
+ NoUnsignedNonInvokerAuthEntries: function (_Error5) {
21634
21898
  function NoUnsignedNonInvokerAuthEntriesError() {
21635
21899
  assembled_transaction_classCallCheck(this, NoUnsignedNonInvokerAuthEntriesError);
21636
21900
  return assembled_transaction_callSuper(this, NoUnsignedNonInvokerAuthEntriesError, arguments);
21637
21901
  }
21638
- assembled_transaction_inherits(NoUnsignedNonInvokerAuthEntriesError, _Error4);
21902
+ assembled_transaction_inherits(NoUnsignedNonInvokerAuthEntriesError, _Error5);
21639
21903
  return assembled_transaction_createClass(NoUnsignedNonInvokerAuthEntriesError);
21640
21904
  }(assembled_transaction_wrapNativeSuper(Error)),
21641
- NoSigner: function (_Error5) {
21905
+ NoSigner: function (_Error6) {
21642
21906
  function NoSignerError() {
21643
21907
  assembled_transaction_classCallCheck(this, NoSignerError);
21644
21908
  return assembled_transaction_callSuper(this, NoSignerError, arguments);
21645
21909
  }
21646
- assembled_transaction_inherits(NoSignerError, _Error5);
21910
+ assembled_transaction_inherits(NoSignerError, _Error6);
21647
21911
  return assembled_transaction_createClass(NoSignerError);
21648
21912
  }(assembled_transaction_wrapNativeSuper(Error)),
21649
- NotYetSimulated: function (_Error6) {
21913
+ NotYetSimulated: function (_Error7) {
21650
21914
  function NotYetSimulatedError() {
21651
21915
  assembled_transaction_classCallCheck(this, NotYetSimulatedError);
21652
21916
  return assembled_transaction_callSuper(this, NotYetSimulatedError, arguments);
21653
21917
  }
21654
- assembled_transaction_inherits(NotYetSimulatedError, _Error6);
21918
+ assembled_transaction_inherits(NotYetSimulatedError, _Error7);
21655
21919
  return assembled_transaction_createClass(NotYetSimulatedError);
21656
21920
  }(assembled_transaction_wrapNativeSuper(Error)),
21657
- FakeAccount: function (_Error7) {
21921
+ FakeAccount: function (_Error8) {
21658
21922
  function FakeAccountError() {
21659
21923
  assembled_transaction_classCallCheck(this, FakeAccountError);
21660
21924
  return assembled_transaction_callSuper(this, FakeAccountError, arguments);
21661
21925
  }
21662
- assembled_transaction_inherits(FakeAccountError, _Error7);
21926
+ assembled_transaction_inherits(FakeAccountError, _Error8);
21663
21927
  return assembled_transaction_createClass(FakeAccountError);
21664
21928
  }(assembled_transaction_wrapNativeSuper(Error))
21665
21929
  });
@@ -21713,8 +21977,8 @@ var basicNodeSigner = function basicNodeSigner(keypair, networkPassphrase) {
21713
21977
  };
21714
21978
  ;// CONCATENATED MODULE: ./src/contract/spec.ts
21715
21979
  /* provided dependency */ var spec_Buffer = __webpack_require__(8287)["Buffer"];
21716
- 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; }
21717
- 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) { spec_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; }
21980
+ function spec_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; }
21981
+ function spec_objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? spec_ownKeys(Object(t), !0).forEach(function (r) { spec_defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : spec_ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
21718
21982
  function spec_createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = spec_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; } } }; }
21719
21983
  function spec_typeof(o) { "@babel/helpers - typeof"; return spec_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; }, spec_typeof(o); }
21720
21984
  function spec_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
@@ -22296,7 +22560,7 @@ var Spec = function () {
22296
22560
  }
22297
22561
  var res = {
22298
22562
  $schema: "http://json-schema.org/draft-07/schema#",
22299
- definitions: _objectSpread(_objectSpread({}, PRIMITIVE_DEFINITONS), definitions)
22563
+ definitions: spec_objectSpread(spec_objectSpread({}, PRIMITIVE_DEFINITONS), definitions)
22300
22564
  };
22301
22565
  if (funcName) {
22302
22566
  res["$ref"] = "#/definitions/".concat(funcName);
@@ -22800,6 +23064,9 @@ var Client = function () {
22800
23064
  }
22801
23065
  }), tx);
22802
23066
  });
23067
+ client_defineProperty(this, "txFromXDR", function (xdrBase64) {
23068
+ return AssembledTransaction.fromXDR(_this.options, xdrBase64, _this.spec);
23069
+ });
22803
23070
  this.spec = spec;
22804
23071
  this.options = options;
22805
23072
  this.spec.funcs().forEach(function (xdrFn) {
@@ -22946,6 +23213,7 @@ var Client = function () {
22946
23213
 
22947
23214
 
22948
23215
 
23216
+
22949
23217
  /***/ }),
22950
23218
 
22951
23219
  /***/ 5885:
@@ -58906,7 +59174,7 @@ axios.default = axios;
58906
59174
  /***/ ((module) => {
58907
59175
 
58908
59176
  "use strict";
58909
- module.exports = {"rE":"12.0.1"};
59177
+ module.exports = {"rE":"12.1.0"};
58910
59178
 
58911
59179
  /***/ })
58912
59180