@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.
- package/CHANGELOG.md +18 -0
- package/dist/stellar-sdk.js +454 -186
- package/dist/stellar-sdk.min.js +1 -1
- package/lib/contract/assembled_transaction.d.ts +81 -6
- package/lib/contract/assembled_transaction.js +358 -124
- package/lib/contract/client.d.ts +1 -0
- package/lib/contract/client.js +3 -0
- package/lib/contract/index.d.ts +1 -0
- package/lib/contract/index.js +18 -1
- package/lib/contract/sent_transaction.d.ts +5 -8
- package/lib/contract/sent_transaction.js +16 -33
- package/lib/contract/types.d.ts +5 -0
- package/lib/contract/utils.d.ts +4 -1
- package/lib/contract/utils.js +32 -0
- package/package.json +18 -27
|
@@ -22,18 +22,20 @@ function _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).in
|
|
|
22
22
|
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
23
23
|
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
24
24
|
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); }
|
|
25
|
+
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; }
|
|
26
|
+
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; }
|
|
25
27
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
26
28
|
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."); }
|
|
27
29
|
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; } }
|
|
28
30
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
29
31
|
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; } } }; }
|
|
32
|
+
function _regeneratorRuntime() { "use strict"; _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" == _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(_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; }
|
|
30
33
|
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
31
34
|
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."); }
|
|
32
35
|
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; } }
|
|
33
36
|
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
34
37
|
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
35
38
|
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; }
|
|
36
|
-
function _regeneratorRuntime() { "use strict"; _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" == _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(_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; }
|
|
37
39
|
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); }
|
|
38
40
|
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); }); }; }
|
|
39
41
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
@@ -50,43 +52,91 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
50
52
|
_this$options$allowHt;
|
|
51
53
|
_classCallCheck(this, AssembledTransaction);
|
|
52
54
|
_defineProperty(this, "simulate", _asyncToGenerator(_regeneratorRuntime().mark(function _callee() {
|
|
55
|
+
var _restore;
|
|
56
|
+
var _ref2,
|
|
57
|
+
restore,
|
|
58
|
+
account,
|
|
59
|
+
result,
|
|
60
|
+
_this$options$fee,
|
|
61
|
+
_this$options$args,
|
|
62
|
+
_this$options$timeout,
|
|
63
|
+
contract,
|
|
64
|
+
_args = arguments;
|
|
53
65
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
54
66
|
while (1) switch (_context.prev = _context.next) {
|
|
55
67
|
case 0:
|
|
68
|
+
_ref2 = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}, restore = _ref2.restore;
|
|
69
|
+
if (_this.built) {
|
|
70
|
+
_context.next = 5;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
56
73
|
if (_this.raw) {
|
|
57
|
-
_context.next =
|
|
74
|
+
_context.next = 4;
|
|
58
75
|
break;
|
|
59
76
|
}
|
|
60
77
|
throw new Error("Transaction has not yet been assembled; " + "call `AssembledTransaction.build` first.");
|
|
61
|
-
case
|
|
78
|
+
case 4:
|
|
62
79
|
_this.built = _this.raw.build();
|
|
63
|
-
_context.next = 5;
|
|
64
|
-
return _this.server.simulateTransaction(_this.built);
|
|
65
80
|
case 5:
|
|
81
|
+
restore = (_restore = restore) !== null && _restore !== void 0 ? _restore : _this.options.restore;
|
|
82
|
+
delete _this.simulationResult;
|
|
83
|
+
delete _this.simulationTransactionData;
|
|
84
|
+
_context.next = 10;
|
|
85
|
+
return _this.server.simulateTransaction(_this.built);
|
|
86
|
+
case 10:
|
|
66
87
|
_this.simulation = _context.sent;
|
|
88
|
+
if (!(restore && _api.Api.isSimulationRestore(_this.simulation))) {
|
|
89
|
+
_context.next = 25;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
_context.next = 14;
|
|
93
|
+
return (0, _utils.getAccount)(_this.options, _this.server);
|
|
94
|
+
case 14:
|
|
95
|
+
account = _context.sent;
|
|
96
|
+
_context.next = 17;
|
|
97
|
+
return _this.restoreFootprint(_this.simulation.restorePreamble, account);
|
|
98
|
+
case 17:
|
|
99
|
+
result = _context.sent;
|
|
100
|
+
if (!(result.status === _api.Api.GetTransactionStatus.SUCCESS)) {
|
|
101
|
+
_context.next = 24;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
contract = new _stellarBase.Contract(_this.options.contractId);
|
|
105
|
+
_this.raw = new _stellarBase.TransactionBuilder(account, {
|
|
106
|
+
fee: (_this$options$fee = _this.options.fee) !== null && _this$options$fee !== void 0 ? _this$options$fee : _stellarBase.BASE_FEE,
|
|
107
|
+
networkPassphrase: _this.options.networkPassphrase
|
|
108
|
+
}).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 : _utils.DEFAULT_TIMEOUT);
|
|
109
|
+
_context.next = 23;
|
|
110
|
+
return _this.simulate();
|
|
111
|
+
case 23:
|
|
112
|
+
return _context.abrupt("return", _this);
|
|
113
|
+
case 24:
|
|
114
|
+
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)));
|
|
115
|
+
case 25:
|
|
67
116
|
if (_api.Api.isSimulationSuccess(_this.simulation)) {
|
|
68
117
|
_this.built = (0, _transaction.assembleTransaction)(_this.built, _this.simulation).build();
|
|
69
118
|
}
|
|
70
119
|
return _context.abrupt("return", _this);
|
|
71
|
-
case
|
|
120
|
+
case 27:
|
|
72
121
|
case "end":
|
|
73
122
|
return _context.stop();
|
|
74
123
|
}
|
|
75
124
|
}, _callee);
|
|
76
125
|
})));
|
|
77
|
-
_defineProperty(this, "
|
|
78
|
-
var
|
|
79
|
-
|
|
126
|
+
_defineProperty(this, "sign", _asyncToGenerator(_regeneratorRuntime().mark(function _callee2() {
|
|
127
|
+
var _this$options$timeout2;
|
|
128
|
+
var _ref4,
|
|
129
|
+
_ref4$force,
|
|
80
130
|
force,
|
|
81
|
-
|
|
131
|
+
_ref4$signTransaction,
|
|
82
132
|
signTransaction,
|
|
83
|
-
|
|
84
|
-
|
|
133
|
+
timeoutInSeconds,
|
|
134
|
+
signature,
|
|
85
135
|
_args2 = arguments;
|
|
86
136
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
87
137
|
while (1) switch (_context2.prev = _context2.next) {
|
|
88
138
|
case 0:
|
|
89
|
-
|
|
139
|
+
_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;
|
|
90
140
|
if (_this.built) {
|
|
91
141
|
_context2.next = 3;
|
|
92
142
|
break;
|
|
@@ -111,45 +161,80 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
111
161
|
}
|
|
112
162
|
throw new AssembledTransaction.Errors.NeedsMoreSignatures("Transaction requires more signatures. " + "See `needsNonInvokerSigningBy` for details.");
|
|
113
163
|
case 9:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
164
|
+
timeoutInSeconds = (_this$options$timeout2 = _this.options.timeoutInSeconds) !== null && _this$options$timeout2 !== void 0 ? _this$options$timeout2 : _utils.DEFAULT_TIMEOUT;
|
|
165
|
+
_this.built = _stellarBase.TransactionBuilder.cloneFrom(_this.built, {
|
|
166
|
+
fee: _this.built.fee,
|
|
167
|
+
timebounds: undefined,
|
|
168
|
+
sorobanData: _this.simulationData.transactionData
|
|
169
|
+
}).setTimeout(timeoutInSeconds).build();
|
|
170
|
+
_context2.next = 13;
|
|
171
|
+
return signTransaction(_this.built.toXDR(), {
|
|
172
|
+
networkPassphrase: _this.options.networkPassphrase
|
|
173
|
+
});
|
|
174
|
+
case 13:
|
|
175
|
+
signature = _context2.sent;
|
|
176
|
+
_this.signed = _stellarBase.TransactionBuilder.fromXDR(signature, _this.options.networkPassphrase);
|
|
177
|
+
case 15:
|
|
121
178
|
case "end":
|
|
122
179
|
return _context2.stop();
|
|
123
180
|
}
|
|
124
181
|
}, _callee2);
|
|
125
182
|
})));
|
|
126
|
-
_defineProperty(this, "
|
|
127
|
-
var
|
|
183
|
+
_defineProperty(this, "signAndSend", _asyncToGenerator(_regeneratorRuntime().mark(function _callee3() {
|
|
184
|
+
var _ref6,
|
|
185
|
+
_ref6$force,
|
|
186
|
+
force,
|
|
187
|
+
_ref6$signTransaction,
|
|
188
|
+
signTransaction,
|
|
189
|
+
_args3 = arguments;
|
|
128
190
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
129
191
|
while (1) switch (_context3.prev = _context3.next) {
|
|
130
192
|
case 0:
|
|
131
|
-
|
|
193
|
+
_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;
|
|
194
|
+
if (_this.signed) {
|
|
195
|
+
_context3.next = 4;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
_context3.next = 4;
|
|
199
|
+
return _this.sign({
|
|
200
|
+
force: force,
|
|
201
|
+
signTransaction: signTransaction
|
|
202
|
+
});
|
|
203
|
+
case 4:
|
|
204
|
+
return _context3.abrupt("return", _this.send());
|
|
205
|
+
case 5:
|
|
206
|
+
case "end":
|
|
207
|
+
return _context3.stop();
|
|
208
|
+
}
|
|
209
|
+
}, _callee3);
|
|
210
|
+
})));
|
|
211
|
+
_defineProperty(this, "getStorageExpiration", _asyncToGenerator(_regeneratorRuntime().mark(function _callee4() {
|
|
212
|
+
var entryRes;
|
|
213
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
214
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
215
|
+
case 0:
|
|
216
|
+
_context4.next = 2;
|
|
132
217
|
return _this.server.getLedgerEntries(new _stellarBase.Contract(_this.options.contractId).getFootprint());
|
|
133
218
|
case 2:
|
|
134
|
-
entryRes =
|
|
219
|
+
entryRes = _context4.sent;
|
|
135
220
|
if (!(!entryRes.entries || !entryRes.entries.length || !entryRes.entries[0].liveUntilLedgerSeq)) {
|
|
136
|
-
|
|
221
|
+
_context4.next = 5;
|
|
137
222
|
break;
|
|
138
223
|
}
|
|
139
224
|
throw new Error("failed to get ledger entry");
|
|
140
225
|
case 5:
|
|
141
|
-
return
|
|
226
|
+
return _context4.abrupt("return", entryRes.entries[0].liveUntilLedgerSeq);
|
|
142
227
|
case 6:
|
|
143
228
|
case "end":
|
|
144
|
-
return
|
|
229
|
+
return _context4.stop();
|
|
145
230
|
}
|
|
146
|
-
},
|
|
231
|
+
}, _callee4);
|
|
147
232
|
})));
|
|
148
233
|
_defineProperty(this, "needsNonInvokerSigningBy", function () {
|
|
149
234
|
var _rawInvokeHostFunctio;
|
|
150
|
-
var
|
|
151
|
-
|
|
152
|
-
includeAlreadySigned =
|
|
235
|
+
var _ref8 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
236
|
+
_ref8$includeAlreadyS = _ref8.includeAlreadySigned,
|
|
237
|
+
includeAlreadySigned = _ref8$includeAlreadyS === void 0 ? false : _ref8$includeAlreadyS;
|
|
153
238
|
if (!_this.built) {
|
|
154
239
|
throw new Error("Transaction has not yet been simulated");
|
|
155
240
|
}
|
|
@@ -163,14 +248,14 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
163
248
|
return _stellarBase.StrKey.encodeEd25519PublicKey(entry.credentials().address().address().accountId().ed25519());
|
|
164
249
|
})));
|
|
165
250
|
});
|
|
166
|
-
_defineProperty(this, "signAuthEntries", _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
251
|
+
_defineProperty(this, "signAuthEntries", _asyncToGenerator(_regeneratorRuntime().mark(function _callee6() {
|
|
167
252
|
var _rawInvokeHostFunctio2;
|
|
168
|
-
var
|
|
169
|
-
|
|
253
|
+
var _ref10,
|
|
254
|
+
_ref10$expiration,
|
|
170
255
|
expiration,
|
|
171
|
-
|
|
256
|
+
_ref10$signAuthEntry,
|
|
172
257
|
signAuthEntry,
|
|
173
|
-
|
|
258
|
+
_ref10$publicKey,
|
|
174
259
|
publicKey,
|
|
175
260
|
needsNonInvokerSigningBy,
|
|
176
261
|
rawInvokeHostFunctionOp,
|
|
@@ -181,32 +266,32 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
181
266
|
i,
|
|
182
267
|
entry,
|
|
183
268
|
pk,
|
|
184
|
-
|
|
185
|
-
return _regeneratorRuntime().wrap(function
|
|
186
|
-
while (1) switch (
|
|
269
|
+
_args6 = arguments;
|
|
270
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
271
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
187
272
|
case 0:
|
|
188
|
-
|
|
273
|
+
_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;
|
|
189
274
|
if (_this.built) {
|
|
190
|
-
|
|
275
|
+
_context6.next = 3;
|
|
191
276
|
break;
|
|
192
277
|
}
|
|
193
278
|
throw new Error("Transaction has not yet been assembled or simulated");
|
|
194
279
|
case 3:
|
|
195
280
|
needsNonInvokerSigningBy = _this.needsNonInvokerSigningBy();
|
|
196
281
|
if (needsNonInvokerSigningBy) {
|
|
197
|
-
|
|
282
|
+
_context6.next = 6;
|
|
198
283
|
break;
|
|
199
284
|
}
|
|
200
285
|
throw new AssembledTransaction.Errors.NoUnsignedNonInvokerAuthEntries("No unsigned non-invoker auth entries; maybe you already signed?");
|
|
201
286
|
case 6:
|
|
202
287
|
if (!(needsNonInvokerSigningBy.indexOf(publicKey !== null && publicKey !== void 0 ? publicKey : "") === -1)) {
|
|
203
|
-
|
|
288
|
+
_context6.next = 8;
|
|
204
289
|
break;
|
|
205
290
|
}
|
|
206
291
|
throw new AssembledTransaction.Errors.NoSignatureNeeded("No auth entries for public key \"".concat(publicKey, "\""));
|
|
207
292
|
case 8:
|
|
208
293
|
if (signAuthEntry) {
|
|
209
|
-
|
|
294
|
+
_context6.next = 10;
|
|
210
295
|
break;
|
|
211
296
|
}
|
|
212
297
|
throw new AssembledTransaction.Errors.NoSigner("You must provide `signAuthEntry` when calling `signAuthEntries`, " + "or when constructing the `Client` or `AssembledTransaction`");
|
|
@@ -214,78 +299,78 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
214
299
|
rawInvokeHostFunctionOp = _this.built.operations[0];
|
|
215
300
|
authEntries = (_rawInvokeHostFunctio2 = rawInvokeHostFunctionOp.auth) !== null && _rawInvokeHostFunctio2 !== void 0 ? _rawInvokeHostFunctio2 : [];
|
|
216
301
|
_iterator = _createForOfIteratorHelper(authEntries.entries());
|
|
217
|
-
|
|
302
|
+
_context6.prev = 13;
|
|
218
303
|
_iterator.s();
|
|
219
304
|
case 15:
|
|
220
305
|
if ((_step = _iterator.n()).done) {
|
|
221
|
-
|
|
306
|
+
_context6.next = 34;
|
|
222
307
|
break;
|
|
223
308
|
}
|
|
224
309
|
_step$value = _slicedToArray(_step.value, 2), i = _step$value[0], entry = _step$value[1];
|
|
225
310
|
if (!(entry.credentials().switch() !== _stellarBase.xdr.SorobanCredentialsType.sorobanCredentialsAddress())) {
|
|
226
|
-
|
|
311
|
+
_context6.next = 19;
|
|
227
312
|
break;
|
|
228
313
|
}
|
|
229
|
-
return
|
|
314
|
+
return _context6.abrupt("continue", 32);
|
|
230
315
|
case 19:
|
|
231
316
|
pk = _stellarBase.StrKey.encodeEd25519PublicKey(entry.credentials().address().address().accountId().ed25519());
|
|
232
317
|
if (!(pk !== publicKey)) {
|
|
233
|
-
|
|
318
|
+
_context6.next = 22;
|
|
234
319
|
break;
|
|
235
320
|
}
|
|
236
|
-
return
|
|
321
|
+
return _context6.abrupt("continue", 32);
|
|
237
322
|
case 22:
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
var
|
|
242
|
-
return _regeneratorRuntime().wrap(function
|
|
243
|
-
while (1) switch (
|
|
323
|
+
_context6.t0 = _stellarBase.authorizeEntry;
|
|
324
|
+
_context6.t1 = entry;
|
|
325
|
+
_context6.t2 = function () {
|
|
326
|
+
var _ref11 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee5(preimage) {
|
|
327
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
328
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
244
329
|
case 0:
|
|
245
|
-
|
|
246
|
-
|
|
330
|
+
_context5.t0 = Buffer;
|
|
331
|
+
_context5.next = 3;
|
|
247
332
|
return signAuthEntry(preimage.toXDR("base64"));
|
|
248
333
|
case 3:
|
|
249
|
-
|
|
250
|
-
return
|
|
334
|
+
_context5.t1 = _context5.sent;
|
|
335
|
+
return _context5.abrupt("return", _context5.t0.from.call(_context5.t0, _context5.t1, "base64"));
|
|
251
336
|
case 5:
|
|
252
337
|
case "end":
|
|
253
|
-
return
|
|
338
|
+
return _context5.stop();
|
|
254
339
|
}
|
|
255
|
-
},
|
|
340
|
+
}, _callee5);
|
|
256
341
|
}));
|
|
257
342
|
return function (_x) {
|
|
258
|
-
return
|
|
343
|
+
return _ref11.apply(this, arguments);
|
|
259
344
|
};
|
|
260
345
|
}();
|
|
261
|
-
|
|
346
|
+
_context6.next = 27;
|
|
262
347
|
return expiration;
|
|
263
348
|
case 27:
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
return (0,
|
|
349
|
+
_context6.t3 = _context6.sent;
|
|
350
|
+
_context6.t4 = _this.options.networkPassphrase;
|
|
351
|
+
_context6.next = 31;
|
|
352
|
+
return (0, _context6.t0)(_context6.t1, _context6.t2, _context6.t3, _context6.t4);
|
|
268
353
|
case 31:
|
|
269
|
-
authEntries[i] =
|
|
354
|
+
authEntries[i] = _context6.sent;
|
|
270
355
|
case 32:
|
|
271
|
-
|
|
356
|
+
_context6.next = 15;
|
|
272
357
|
break;
|
|
273
358
|
case 34:
|
|
274
|
-
|
|
359
|
+
_context6.next = 39;
|
|
275
360
|
break;
|
|
276
361
|
case 36:
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
_iterator.e(
|
|
362
|
+
_context6.prev = 36;
|
|
363
|
+
_context6.t5 = _context6["catch"](13);
|
|
364
|
+
_iterator.e(_context6.t5);
|
|
280
365
|
case 39:
|
|
281
|
-
|
|
366
|
+
_context6.prev = 39;
|
|
282
367
|
_iterator.f();
|
|
283
|
-
return
|
|
368
|
+
return _context6.finish(39);
|
|
284
369
|
case 42:
|
|
285
370
|
case "end":
|
|
286
|
-
return
|
|
371
|
+
return _context6.stop();
|
|
287
372
|
}
|
|
288
|
-
},
|
|
373
|
+
}, _callee6, null, [[13, 36, 39, 42]]);
|
|
289
374
|
})));
|
|
290
375
|
this.options = options;
|
|
291
376
|
this.options.simulate = (_this$options$simulat = this.options.simulate) !== null && _this$options$simulat !== void 0 ? _this$options$simulat : true;
|
|
@@ -309,9 +394,17 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
309
394
|
simulationTransactionData: this.simulationData.transactionData.toXDR("base64")
|
|
310
395
|
});
|
|
311
396
|
}
|
|
397
|
+
}, {
|
|
398
|
+
key: "toXDR",
|
|
399
|
+
value: function toXDR() {
|
|
400
|
+
var _this$built2;
|
|
401
|
+
if (!this.built) throw new Error("Transaction has not yet been simulated; " + "call `AssembledTransaction.simulate` first.");
|
|
402
|
+
return (_this$built2 = this.built) === null || _this$built2 === void 0 ? void 0 : _this$built2.toEnvelope().toXDR('base64');
|
|
403
|
+
}
|
|
312
404
|
}, {
|
|
313
405
|
key: "simulationData",
|
|
314
406
|
get: function get() {
|
|
407
|
+
var _simulation$result;
|
|
315
408
|
if (this.simulationResult && this.simulationTransactionData) {
|
|
316
409
|
return {
|
|
317
410
|
result: this.simulationResult,
|
|
@@ -326,12 +419,12 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
326
419
|
throw new Error("Transaction simulation failed: \"".concat(simulation.error, "\""));
|
|
327
420
|
}
|
|
328
421
|
if (_api.Api.isSimulationRestore(simulation)) {
|
|
329
|
-
throw new AssembledTransaction.Errors.ExpiredState("You need to restore some contract state before you can invoke this method
|
|
422
|
+
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.');
|
|
330
423
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
424
|
+
this.simulationResult = (_simulation$result = simulation.result) !== null && _simulation$result !== void 0 ? _simulation$result : {
|
|
425
|
+
auth: [],
|
|
426
|
+
retval: _stellarBase.xdr.ScVal.scvVoid()
|
|
427
|
+
};
|
|
335
428
|
this.simulationTransactionData = simulation.transactionData.build();
|
|
336
429
|
return {
|
|
337
430
|
result: this.simulationResult,
|
|
@@ -342,6 +435,9 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
342
435
|
key: "result",
|
|
343
436
|
get: function get() {
|
|
344
437
|
try {
|
|
438
|
+
if (!this.simulationData.result) {
|
|
439
|
+
throw new Error("No simulation result!");
|
|
440
|
+
}
|
|
345
441
|
return this.options.parseResultXdr(this.simulationData.result.retval);
|
|
346
442
|
} catch (e) {
|
|
347
443
|
if (!(0, _utils.implementsToString)(e)) throw e;
|
|
@@ -361,6 +457,36 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
361
457
|
if (!err) return undefined;
|
|
362
458
|
return new _rust_result.Err(err);
|
|
363
459
|
}
|
|
460
|
+
}, {
|
|
461
|
+
key: "send",
|
|
462
|
+
value: (function () {
|
|
463
|
+
var _send = _asyncToGenerator(_regeneratorRuntime().mark(function _callee7() {
|
|
464
|
+
var sent;
|
|
465
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
466
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
467
|
+
case 0:
|
|
468
|
+
if (this.signed) {
|
|
469
|
+
_context7.next = 2;
|
|
470
|
+
break;
|
|
471
|
+
}
|
|
472
|
+
throw new Error("The transaction has not yet been signed. Run `sign` first, or use `signAndSend` instead.");
|
|
473
|
+
case 2:
|
|
474
|
+
_context7.next = 4;
|
|
475
|
+
return _sent_transaction.SentTransaction.init(undefined, this);
|
|
476
|
+
case 4:
|
|
477
|
+
sent = _context7.sent;
|
|
478
|
+
return _context7.abrupt("return", sent);
|
|
479
|
+
case 6:
|
|
480
|
+
case "end":
|
|
481
|
+
return _context7.stop();
|
|
482
|
+
}
|
|
483
|
+
}, _callee7, this);
|
|
484
|
+
}));
|
|
485
|
+
function send() {
|
|
486
|
+
return _send.apply(this, arguments);
|
|
487
|
+
}
|
|
488
|
+
return send;
|
|
489
|
+
}())
|
|
364
490
|
}, {
|
|
365
491
|
key: "isReadCall",
|
|
366
492
|
get: function get() {
|
|
@@ -368,12 +494,67 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
368
494
|
var writeLength = this.simulationData.transactionData.resources().footprint().readWrite().length;
|
|
369
495
|
return authsCount === 0 && writeLength === 0;
|
|
370
496
|
}
|
|
497
|
+
}, {
|
|
498
|
+
key: "restoreFootprint",
|
|
499
|
+
value: (function () {
|
|
500
|
+
var _restoreFootprint = _asyncToGenerator(_regeneratorRuntime().mark(function _callee8(restorePreamble, account) {
|
|
501
|
+
var _account;
|
|
502
|
+
var restoreTx, sentTransaction;
|
|
503
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
504
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
505
|
+
case 0:
|
|
506
|
+
if (this.options.signTransaction) {
|
|
507
|
+
_context8.next = 2;
|
|
508
|
+
break;
|
|
509
|
+
}
|
|
510
|
+
throw new Error("For automatic restore to work you must provide a signTransaction function when initializing your Client");
|
|
511
|
+
case 2:
|
|
512
|
+
if (!((_account = account) !== null && _account !== void 0)) {
|
|
513
|
+
_context8.next = 6;
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
_context8.t0 = _account;
|
|
517
|
+
_context8.next = 9;
|
|
518
|
+
break;
|
|
519
|
+
case 6:
|
|
520
|
+
_context8.next = 8;
|
|
521
|
+
return (0, _utils.getAccount)(this.options, this.server);
|
|
522
|
+
case 8:
|
|
523
|
+
_context8.t0 = _context8.sent;
|
|
524
|
+
case 9:
|
|
525
|
+
account = _context8.t0;
|
|
526
|
+
_context8.next = 12;
|
|
527
|
+
return AssembledTransaction.buildFootprintRestoreTransaction(_objectSpread({}, this.options), restorePreamble.transactionData, account, restorePreamble.minResourceFee);
|
|
528
|
+
case 12:
|
|
529
|
+
restoreTx = _context8.sent;
|
|
530
|
+
_context8.next = 15;
|
|
531
|
+
return restoreTx.signAndSend();
|
|
532
|
+
case 15:
|
|
533
|
+
sentTransaction = _context8.sent;
|
|
534
|
+
if (sentTransaction.getTransactionResponse) {
|
|
535
|
+
_context8.next = 18;
|
|
536
|
+
break;
|
|
537
|
+
}
|
|
538
|
+
throw new AssembledTransaction.Errors.RestorationFailure("The attempt at automatic restore failed. \n".concat(JSON.stringify(sentTransaction)));
|
|
539
|
+
case 18:
|
|
540
|
+
return _context8.abrupt("return", sentTransaction.getTransactionResponse);
|
|
541
|
+
case 19:
|
|
542
|
+
case "end":
|
|
543
|
+
return _context8.stop();
|
|
544
|
+
}
|
|
545
|
+
}, _callee8, this);
|
|
546
|
+
}));
|
|
547
|
+
function restoreFootprint(_x2, _x3) {
|
|
548
|
+
return _restoreFootprint.apply(this, arguments);
|
|
549
|
+
}
|
|
550
|
+
return restoreFootprint;
|
|
551
|
+
}())
|
|
371
552
|
}], [{
|
|
372
553
|
key: "fromJSON",
|
|
373
|
-
value: function fromJSON(options,
|
|
374
|
-
var tx =
|
|
375
|
-
simulationResult =
|
|
376
|
-
simulationTransactionData =
|
|
554
|
+
value: function fromJSON(options, _ref12) {
|
|
555
|
+
var tx = _ref12.tx,
|
|
556
|
+
simulationResult = _ref12.simulationResult,
|
|
557
|
+
simulationTransactionData = _ref12.simulationTransactionData;
|
|
377
558
|
var txn = new AssembledTransaction(options);
|
|
378
559
|
txn.built = _stellarBase.TransactionBuilder.fromXDR(tx, options.networkPassphrase);
|
|
379
560
|
txn.simulationResult = {
|
|
@@ -385,54 +566,99 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
385
566
|
txn.simulationTransactionData = _stellarBase.xdr.SorobanTransactionData.fromXDR(simulationTransactionData, "base64");
|
|
386
567
|
return txn;
|
|
387
568
|
}
|
|
569
|
+
}, {
|
|
570
|
+
key: "fromXDR",
|
|
571
|
+
value: function fromXDR(options, encodedXDR, spec) {
|
|
572
|
+
var _operation$func;
|
|
573
|
+
var envelope = _stellarBase.xdr.TransactionEnvelope.fromXDR(encodedXDR, "base64");
|
|
574
|
+
var built = _stellarBase.TransactionBuilder.fromXDR(envelope, options.networkPassphrase);
|
|
575
|
+
var operation = built.operations[0];
|
|
576
|
+
if (!(operation !== null && operation !== void 0 && (_operation$func = operation.func) !== null && _operation$func !== void 0 && _operation$func.value) || typeof operation.func.value !== 'function') {
|
|
577
|
+
throw new Error("Could not extract the method from the transaction envelope.");
|
|
578
|
+
}
|
|
579
|
+
var invokeContractArgs = operation.func.value();
|
|
580
|
+
if (!(invokeContractArgs !== null && invokeContractArgs !== void 0 && invokeContractArgs.functionName)) {
|
|
581
|
+
throw new Error("Could not extract the method name from the transaction envelope.");
|
|
582
|
+
}
|
|
583
|
+
var method = invokeContractArgs.functionName().toString('utf-8');
|
|
584
|
+
var txn = new AssembledTransaction(_objectSpread(_objectSpread({}, options), {}, {
|
|
585
|
+
method: method,
|
|
586
|
+
parseResultXdr: function parseResultXdr(result) {
|
|
587
|
+
return spec.funcResToNative(method, result);
|
|
588
|
+
}
|
|
589
|
+
}));
|
|
590
|
+
txn.built = built;
|
|
591
|
+
return txn;
|
|
592
|
+
}
|
|
388
593
|
}, {
|
|
389
594
|
key: "build",
|
|
390
595
|
value: (function () {
|
|
391
|
-
var _build = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
596
|
+
var _build = _asyncToGenerator(_regeneratorRuntime().mark(function _callee9(options) {
|
|
392
597
|
var _options$fee, _options$args, _options$timeoutInSec;
|
|
393
598
|
var tx, contract, account;
|
|
394
|
-
return _regeneratorRuntime().wrap(function
|
|
395
|
-
while (1) switch (
|
|
599
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
600
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
396
601
|
case 0:
|
|
397
602
|
tx = new AssembledTransaction(options);
|
|
398
603
|
contract = new _stellarBase.Contract(options.contractId);
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
_context6.next = 5;
|
|
404
|
-
return tx.server.getAccount(options.publicKey);
|
|
405
|
-
case 5:
|
|
406
|
-
_context6.t0 = _context6.sent;
|
|
407
|
-
_context6.next = 9;
|
|
408
|
-
break;
|
|
409
|
-
case 8:
|
|
410
|
-
_context6.t0 = new _stellarBase.Account(NULL_ACCOUNT, "0");
|
|
411
|
-
case 9:
|
|
412
|
-
account = _context6.t0;
|
|
604
|
+
_context9.next = 4;
|
|
605
|
+
return (0, _utils.getAccount)(options, tx.server);
|
|
606
|
+
case 4:
|
|
607
|
+
account = _context9.sent;
|
|
413
608
|
tx.raw = new _stellarBase.TransactionBuilder(account, {
|
|
414
609
|
fee: (_options$fee = options.fee) !== null && _options$fee !== void 0 ? _options$fee : _stellarBase.BASE_FEE,
|
|
415
610
|
networkPassphrase: options.networkPassphrase
|
|
416
611
|
}).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 : _utils.DEFAULT_TIMEOUT);
|
|
417
612
|
if (!options.simulate) {
|
|
418
|
-
|
|
613
|
+
_context9.next = 9;
|
|
419
614
|
break;
|
|
420
615
|
}
|
|
421
|
-
|
|
616
|
+
_context9.next = 9;
|
|
422
617
|
return tx.simulate();
|
|
423
|
-
case
|
|
424
|
-
return
|
|
425
|
-
case
|
|
618
|
+
case 9:
|
|
619
|
+
return _context9.abrupt("return", tx);
|
|
620
|
+
case 10:
|
|
426
621
|
case "end":
|
|
427
|
-
return
|
|
622
|
+
return _context9.stop();
|
|
428
623
|
}
|
|
429
|
-
},
|
|
624
|
+
}, _callee9);
|
|
430
625
|
}));
|
|
431
|
-
function build(
|
|
626
|
+
function build(_x4) {
|
|
432
627
|
return _build.apply(this, arguments);
|
|
433
628
|
}
|
|
434
629
|
return build;
|
|
435
630
|
}())
|
|
631
|
+
}, {
|
|
632
|
+
key: "buildFootprintRestoreTransaction",
|
|
633
|
+
value: function () {
|
|
634
|
+
var _buildFootprintRestoreTransaction = _asyncToGenerator(_regeneratorRuntime().mark(function _callee10(options, sorobanData, account, fee) {
|
|
635
|
+
var _options$timeoutInSec2;
|
|
636
|
+
var tx;
|
|
637
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
638
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
639
|
+
case 0:
|
|
640
|
+
tx = new AssembledTransaction(options);
|
|
641
|
+
tx.raw = new _stellarBase.TransactionBuilder(account, {
|
|
642
|
+
fee: fee,
|
|
643
|
+
networkPassphrase: options.networkPassphrase
|
|
644
|
+
}).setSorobanData(sorobanData instanceof _stellarBase.SorobanDataBuilder ? sorobanData.build() : sorobanData).addOperation(_stellarBase.Operation.restoreFootprint({})).setTimeout((_options$timeoutInSec2 = options.timeoutInSeconds) !== null && _options$timeoutInSec2 !== void 0 ? _options$timeoutInSec2 : _utils.DEFAULT_TIMEOUT);
|
|
645
|
+
_context10.next = 4;
|
|
646
|
+
return tx.simulate({
|
|
647
|
+
restore: false
|
|
648
|
+
});
|
|
649
|
+
case 4:
|
|
650
|
+
return _context10.abrupt("return", tx);
|
|
651
|
+
case 5:
|
|
652
|
+
case "end":
|
|
653
|
+
return _context10.stop();
|
|
654
|
+
}
|
|
655
|
+
}, _callee10);
|
|
656
|
+
}));
|
|
657
|
+
function buildFootprintRestoreTransaction(_x5, _x6, _x7, _x8) {
|
|
658
|
+
return _buildFootprintRestoreTransaction.apply(this, arguments);
|
|
659
|
+
}
|
|
660
|
+
return buildFootprintRestoreTransaction;
|
|
661
|
+
}()
|
|
436
662
|
}]);
|
|
437
663
|
}();
|
|
438
664
|
_defineProperty(AssembledTransaction, "Errors", {
|
|
@@ -444,52 +670,60 @@ _defineProperty(AssembledTransaction, "Errors", {
|
|
|
444
670
|
_inherits(ExpiredStateError, _Error);
|
|
445
671
|
return _createClass(ExpiredStateError);
|
|
446
672
|
}(_wrapNativeSuper(Error)),
|
|
447
|
-
|
|
673
|
+
RestorationFailure: function (_Error2) {
|
|
674
|
+
function RestoreFailureError() {
|
|
675
|
+
_classCallCheck(this, RestoreFailureError);
|
|
676
|
+
return _callSuper(this, RestoreFailureError, arguments);
|
|
677
|
+
}
|
|
678
|
+
_inherits(RestoreFailureError, _Error2);
|
|
679
|
+
return _createClass(RestoreFailureError);
|
|
680
|
+
}(_wrapNativeSuper(Error)),
|
|
681
|
+
NeedsMoreSignatures: function (_Error3) {
|
|
448
682
|
function NeedsMoreSignaturesError() {
|
|
449
683
|
_classCallCheck(this, NeedsMoreSignaturesError);
|
|
450
684
|
return _callSuper(this, NeedsMoreSignaturesError, arguments);
|
|
451
685
|
}
|
|
452
|
-
_inherits(NeedsMoreSignaturesError,
|
|
686
|
+
_inherits(NeedsMoreSignaturesError, _Error3);
|
|
453
687
|
return _createClass(NeedsMoreSignaturesError);
|
|
454
688
|
}(_wrapNativeSuper(Error)),
|
|
455
|
-
NoSignatureNeeded: function (
|
|
689
|
+
NoSignatureNeeded: function (_Error4) {
|
|
456
690
|
function NoSignatureNeededError() {
|
|
457
691
|
_classCallCheck(this, NoSignatureNeededError);
|
|
458
692
|
return _callSuper(this, NoSignatureNeededError, arguments);
|
|
459
693
|
}
|
|
460
|
-
_inherits(NoSignatureNeededError,
|
|
694
|
+
_inherits(NoSignatureNeededError, _Error4);
|
|
461
695
|
return _createClass(NoSignatureNeededError);
|
|
462
696
|
}(_wrapNativeSuper(Error)),
|
|
463
|
-
NoUnsignedNonInvokerAuthEntries: function (
|
|
697
|
+
NoUnsignedNonInvokerAuthEntries: function (_Error5) {
|
|
464
698
|
function NoUnsignedNonInvokerAuthEntriesError() {
|
|
465
699
|
_classCallCheck(this, NoUnsignedNonInvokerAuthEntriesError);
|
|
466
700
|
return _callSuper(this, NoUnsignedNonInvokerAuthEntriesError, arguments);
|
|
467
701
|
}
|
|
468
|
-
_inherits(NoUnsignedNonInvokerAuthEntriesError,
|
|
702
|
+
_inherits(NoUnsignedNonInvokerAuthEntriesError, _Error5);
|
|
469
703
|
return _createClass(NoUnsignedNonInvokerAuthEntriesError);
|
|
470
704
|
}(_wrapNativeSuper(Error)),
|
|
471
|
-
NoSigner: function (
|
|
705
|
+
NoSigner: function (_Error6) {
|
|
472
706
|
function NoSignerError() {
|
|
473
707
|
_classCallCheck(this, NoSignerError);
|
|
474
708
|
return _callSuper(this, NoSignerError, arguments);
|
|
475
709
|
}
|
|
476
|
-
_inherits(NoSignerError,
|
|
710
|
+
_inherits(NoSignerError, _Error6);
|
|
477
711
|
return _createClass(NoSignerError);
|
|
478
712
|
}(_wrapNativeSuper(Error)),
|
|
479
|
-
NotYetSimulated: function (
|
|
713
|
+
NotYetSimulated: function (_Error7) {
|
|
480
714
|
function NotYetSimulatedError() {
|
|
481
715
|
_classCallCheck(this, NotYetSimulatedError);
|
|
482
716
|
return _callSuper(this, NotYetSimulatedError, arguments);
|
|
483
717
|
}
|
|
484
|
-
_inherits(NotYetSimulatedError,
|
|
718
|
+
_inherits(NotYetSimulatedError, _Error7);
|
|
485
719
|
return _createClass(NotYetSimulatedError);
|
|
486
720
|
}(_wrapNativeSuper(Error)),
|
|
487
|
-
FakeAccount: function (
|
|
721
|
+
FakeAccount: function (_Error8) {
|
|
488
722
|
function FakeAccountError() {
|
|
489
723
|
_classCallCheck(this, FakeAccountError);
|
|
490
724
|
return _callSuper(this, FakeAccountError, arguments);
|
|
491
725
|
}
|
|
492
|
-
_inherits(FakeAccountError,
|
|
726
|
+
_inherits(FakeAccountError, _Error8);
|
|
493
727
|
return _createClass(FakeAccountError);
|
|
494
728
|
}(_wrapNativeSuper(Error))
|
|
495
729
|
});
|