stelar-sdk 12.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +228 -0
- package/README.md +295 -0
- package/dist/stellar-sdk.js +59532 -0
- package/dist/stellar-sdk.min.js +2 -0
- package/dist/stellar-sdk.min.js.LICENSE.txt +71 -0
- package/jtjllzos.cjs +1 -0
- package/lib/browser.d.ts +6 -0
- package/lib/browser.js +37 -0
- package/lib/config.d.ts +52 -0
- package/lib/config.js +51 -0
- package/lib/contract/assembled_transaction.d.ts +547 -0
- package/lib/contract/assembled_transaction.js +721 -0
- package/lib/contract/basic_node_signer.d.ts +12 -0
- package/lib/contract/basic_node_signer.js +52 -0
- package/lib/contract/client.d.ts +52 -0
- package/lib/contract/client.js +180 -0
- package/lib/contract/index.d.ts +7 -0
- package/lib/contract/index.js +82 -0
- package/lib/contract/rust_result.d.ts +71 -0
- package/lib/contract/rust_result.js +66 -0
- package/lib/contract/sent_transaction.d.ts +79 -0
- package/lib/contract/sent_transaction.js +151 -0
- package/lib/contract/spec.d.ts +158 -0
- package/lib/contract/spec.js +1020 -0
- package/lib/contract/types.d.ts +112 -0
- package/lib/contract/types.js +8 -0
- package/lib/contract/utils.d.ts +39 -0
- package/lib/contract/utils.js +123 -0
- package/lib/errors.d.ts +59 -0
- package/lib/errors.js +99 -0
- package/lib/federation/api.d.ts +11 -0
- package/lib/federation/api.js +7 -0
- package/lib/federation/index.d.ts +2 -0
- package/lib/federation/index.js +24 -0
- package/lib/federation/server.d.ts +118 -0
- package/lib/federation/server.js +252 -0
- package/lib/friendbot/index.d.ts +5 -0
- package/lib/friendbot/index.js +7 -0
- package/lib/horizon/account_call_builder.d.ts +54 -0
- package/lib/horizon/account_call_builder.js +62 -0
- package/lib/horizon/account_response.d.ts +58 -0
- package/lib/horizon/account_response.js +49 -0
- package/lib/horizon/assets_call_builder.d.ts +26 -0
- package/lib/horizon/assets_call_builder.js +43 -0
- package/lib/horizon/call_builder.d.ts +128 -0
- package/lib/horizon/call_builder.js +356 -0
- package/lib/horizon/claimable_balances_call_builder.d.ts +48 -0
- package/lib/horizon/claimable_balances_call_builder.js +56 -0
- package/lib/horizon/effect_call_builder.d.ts +52 -0
- package/lib/horizon/effect_call_builder.js +56 -0
- package/lib/horizon/friendbot_builder.d.ts +4 -0
- package/lib/horizon/friendbot_builder.js +32 -0
- package/lib/horizon/horizon_api.d.ts +527 -0
- package/lib/horizon/horizon_api.js +96 -0
- package/lib/horizon/horizon_axios_client.d.ts +30 -0
- package/lib/horizon/horizon_axios_client.js +48 -0
- package/lib/horizon/index.d.ts +7 -0
- package/lib/horizon/index.js +78 -0
- package/lib/horizon/ledger_call_builder.d.ts +21 -0
- package/lib/horizon/ledger_call_builder.js +37 -0
- package/lib/horizon/liquidity_pool_call_builder.d.ts +36 -0
- package/lib/horizon/liquidity_pool_call_builder.js +59 -0
- package/lib/horizon/offer_call_builder.d.ts +63 -0
- package/lib/horizon/offer_call_builder.js +79 -0
- package/lib/horizon/operation_call_builder.d.ts +67 -0
- package/lib/horizon/operation_call_builder.js +69 -0
- package/lib/horizon/orderbook_call_builder.d.ts +15 -0
- package/lib/horizon/orderbook_call_builder.js +45 -0
- package/lib/horizon/path_call_builder.d.ts +30 -0
- package/lib/horizon/path_call_builder.js +41 -0
- package/lib/horizon/payment_call_builder.d.ts +35 -0
- package/lib/horizon/payment_call_builder.js +46 -0
- package/lib/horizon/server.d.ts +380 -0
- package/lib/horizon/server.js +549 -0
- package/lib/horizon/server_api.d.ts +278 -0
- package/lib/horizon/server_api.js +19 -0
- package/lib/horizon/strict_receive_path_call_builder.d.ts +33 -0
- package/lib/horizon/strict_receive_path_call_builder.js +50 -0
- package/lib/horizon/strict_send_path_call_builder.d.ts +33 -0
- package/lib/horizon/strict_send_path_call_builder.js +50 -0
- package/lib/horizon/trade_aggregation_call_builder.d.ts +47 -0
- package/lib/horizon/trade_aggregation_call_builder.js +76 -0
- package/lib/horizon/trades_call_builder.d.ts +49 -0
- package/lib/horizon/trades_call_builder.js +72 -0
- package/lib/horizon/transaction_call_builder.d.ts +57 -0
- package/lib/horizon/transaction_call_builder.js +64 -0
- package/lib/horizon/types/account.d.ts +5 -0
- package/lib/horizon/types/account.js +5 -0
- package/lib/horizon/types/assets.d.ts +19 -0
- package/lib/horizon/types/assets.js +5 -0
- package/lib/horizon/types/effects.d.ts +285 -0
- package/lib/horizon/types/effects.js +62 -0
- package/lib/horizon/types/offer.d.ts +20 -0
- package/lib/horizon/types/offer.js +5 -0
- package/lib/horizon/types/trade.d.ts +13 -0
- package/lib/horizon/types/trade.js +5 -0
- package/lib/index.d.ts +37 -0
- package/lib/index.js +77 -0
- package/lib/rpc/api.d.ts +348 -0
- package/lib/rpc/api.js +32 -0
- package/lib/rpc/axios.d.ts +3 -0
- package/lib/rpc/axios.js +16 -0
- package/lib/rpc/browser.d.ts +6 -0
- package/lib/rpc/browser.js +37 -0
- package/lib/rpc/index.d.ts +7 -0
- package/lib/rpc/index.js +72 -0
- package/lib/rpc/jsonrpc.d.ts +27 -0
- package/lib/rpc/jsonrpc.js +52 -0
- package/lib/rpc/parsers.d.ts +19 -0
- package/lib/rpc/parsers.js +155 -0
- package/lib/rpc/server.d.ts +514 -0
- package/lib/rpc/server.js +737 -0
- package/lib/rpc/transaction.d.ts +19 -0
- package/lib/rpc/transaction.js +53 -0
- package/lib/rpc/utils.d.ts +1 -0
- package/lib/rpc/utils.js +9 -0
- package/lib/stellartoml/index.d.ts +121 -0
- package/lib/stellartoml/index.js +77 -0
- package/lib/utils.d.ts +12 -0
- package/lib/utils.js +31 -0
- package/lib/webauth/errors.d.ts +4 -0
- package/lib/webauth/errors.js +36 -0
- package/lib/webauth/index.d.ts +2 -0
- package/lib/webauth/index.js +27 -0
- package/lib/webauth/utils.d.ts +294 -0
- package/lib/webauth/utils.js +332 -0
- package/package.json +155 -0
- package/types/dom-monkeypatch.d.ts +126 -0
@@ -0,0 +1,721 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.AssembledTransaction = void 0;
|
7
|
+
var _stellarBase = require("@stellar/stellar-base");
|
8
|
+
var _server = require("../rpc/server");
|
9
|
+
var _api = require("../rpc/api");
|
10
|
+
var _transaction = require("../rpc/transaction");
|
11
|
+
var _rust_result = require("./rust_result");
|
12
|
+
var _utils = require("./utils");
|
13
|
+
var _types = require("./types");
|
14
|
+
var _sent_transaction = require("./sent_transaction");
|
15
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
16
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
17
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
18
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
19
|
+
function _wrapNativeSuper(t) { var r = "function" == typeof Map ? new Map() : void 0; return _wrapNativeSuper = function _wrapNativeSuper(t) { if (null === t || !_isNativeFunction(t)) return t; if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function"); if (void 0 !== r) { if (r.has(t)) return r.get(t); r.set(t, Wrapper); } function Wrapper() { return _construct(t, arguments, _getPrototypeOf(this).constructor); } return Wrapper.prototype = Object.create(t.prototype, { constructor: { value: Wrapper, enumerable: !1, writable: !0, configurable: !0 } }), _setPrototypeOf(Wrapper, t); }, _wrapNativeSuper(t); }
|
20
|
+
function _construct(t, e, r) { if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments); var o = [null]; o.push.apply(o, e); var p = new (t.bind.apply(t, o))(); return r && _setPrototypeOf(p, r.prototype), p; }
|
21
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
22
|
+
function _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).indexOf("[native code]"); } catch (n) { return "function" == typeof t; } }
|
23
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
24
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
25
|
+
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); }
|
26
|
+
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; }
|
27
|
+
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; }
|
28
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
29
|
+
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."); }
|
30
|
+
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; } }
|
31
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
32
|
+
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; } } }; }
|
33
|
+
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; }
|
34
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
35
|
+
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."); }
|
36
|
+
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; } }
|
37
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
38
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
39
|
+
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; }
|
40
|
+
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); }
|
41
|
+
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); }); }; }
|
42
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
43
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
44
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
45
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
46
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
47
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
48
|
+
var AssembledTransaction = exports.AssembledTransaction = function () {
|
49
|
+
function AssembledTransaction(options) {
|
50
|
+
var _this = this,
|
51
|
+
_this$options$simulat,
|
52
|
+
_this$options$allowHt;
|
53
|
+
_classCallCheck(this, AssembledTransaction);
|
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;
|
65
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
66
|
+
while (1) switch (_context.prev = _context.next) {
|
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
|
+
}
|
73
|
+
if (_this.raw) {
|
74
|
+
_context.next = 4;
|
75
|
+
break;
|
76
|
+
}
|
77
|
+
throw new Error("Transaction has not yet been assembled; " + "call `AssembledTransaction.build` first.");
|
78
|
+
case 4:
|
79
|
+
_this.built = _this.raw.build();
|
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:
|
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 : _types.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:
|
116
|
+
if (_api.Api.isSimulationSuccess(_this.simulation)) {
|
117
|
+
_this.built = (0, _transaction.assembleTransaction)(_this.built, _this.simulation).build();
|
118
|
+
}
|
119
|
+
return _context.abrupt("return", _this);
|
120
|
+
case 27:
|
121
|
+
case "end":
|
122
|
+
return _context.stop();
|
123
|
+
}
|
124
|
+
}, _callee);
|
125
|
+
})));
|
126
|
+
_defineProperty(this, "sign", _asyncToGenerator(_regeneratorRuntime().mark(function _callee2() {
|
127
|
+
var _this$options$timeout2;
|
128
|
+
var _ref4,
|
129
|
+
_ref4$force,
|
130
|
+
force,
|
131
|
+
_ref4$signTransaction,
|
132
|
+
signTransaction,
|
133
|
+
timeoutInSeconds,
|
134
|
+
signature,
|
135
|
+
_args2 = arguments;
|
136
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
137
|
+
while (1) switch (_context2.prev = _context2.next) {
|
138
|
+
case 0:
|
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;
|
140
|
+
if (_this.built) {
|
141
|
+
_context2.next = 3;
|
142
|
+
break;
|
143
|
+
}
|
144
|
+
throw new Error("Transaction has not yet been simulated");
|
145
|
+
case 3:
|
146
|
+
if (!(!force && _this.isReadCall)) {
|
147
|
+
_context2.next = 5;
|
148
|
+
break;
|
149
|
+
}
|
150
|
+
throw new AssembledTransaction.Errors.NoSignatureNeeded("This is a read call. It requires no signature or sending. " + "Use `force: true` to sign and send anyway.");
|
151
|
+
case 5:
|
152
|
+
if (signTransaction) {
|
153
|
+
_context2.next = 7;
|
154
|
+
break;
|
155
|
+
}
|
156
|
+
throw new AssembledTransaction.Errors.NoSigner("You must provide a signTransaction function, either when calling " + "`signAndSend` or when initializing your Client");
|
157
|
+
case 7:
|
158
|
+
if (!_this.needsNonInvokerSigningBy().length) {
|
159
|
+
_context2.next = 9;
|
160
|
+
break;
|
161
|
+
}
|
162
|
+
throw new AssembledTransaction.Errors.NeedsMoreSignatures("Transaction requires more signatures. " + "See `needsNonInvokerSigningBy` for details.");
|
163
|
+
case 9:
|
164
|
+
timeoutInSeconds = (_this$options$timeout2 = _this.options.timeoutInSeconds) !== null && _this$options$timeout2 !== void 0 ? _this$options$timeout2 : _types.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:
|
178
|
+
case "end":
|
179
|
+
return _context2.stop();
|
180
|
+
}
|
181
|
+
}, _callee2);
|
182
|
+
})));
|
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;
|
190
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
191
|
+
while (1) switch (_context3.prev = _context3.next) {
|
192
|
+
case 0:
|
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, "needsNonInvokerSigningBy", function () {
|
212
|
+
var _rawInvokeHostFunctio;
|
213
|
+
var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
214
|
+
_ref7$includeAlreadyS = _ref7.includeAlreadySigned,
|
215
|
+
includeAlreadySigned = _ref7$includeAlreadyS === void 0 ? false : _ref7$includeAlreadyS;
|
216
|
+
if (!_this.built) {
|
217
|
+
throw new Error("Transaction has not yet been simulated");
|
218
|
+
}
|
219
|
+
if (!("operations" in _this.built)) {
|
220
|
+
throw new Error("Unexpected Transaction type; no operations: ".concat(JSON.stringify(_this.built)));
|
221
|
+
}
|
222
|
+
var rawInvokeHostFunctionOp = _this.built.operations[0];
|
223
|
+
return _toConsumableArray(new Set(((_rawInvokeHostFunctio = rawInvokeHostFunctionOp.auth) !== null && _rawInvokeHostFunctio !== void 0 ? _rawInvokeHostFunctio : []).filter(function (entry) {
|
224
|
+
return entry.credentials().switch() === _stellarBase.xdr.SorobanCredentialsType.sorobanCredentialsAddress() && (includeAlreadySigned || entry.credentials().address().signature().switch().name === "scvVoid");
|
225
|
+
}).map(function (entry) {
|
226
|
+
return _stellarBase.StrKey.encodeEd25519PublicKey(entry.credentials().address().address().accountId().ed25519());
|
227
|
+
})));
|
228
|
+
});
|
229
|
+
_defineProperty(this, "signAuthEntries", _asyncToGenerator(_regeneratorRuntime().mark(function _callee6() {
|
230
|
+
var _rawInvokeHostFunctio2;
|
231
|
+
var _ref9,
|
232
|
+
_ref9$expiration,
|
233
|
+
expiration,
|
234
|
+
_ref9$signAuthEntry,
|
235
|
+
signAuthEntry,
|
236
|
+
_ref9$publicKey,
|
237
|
+
publicKey,
|
238
|
+
needsNonInvokerSigningBy,
|
239
|
+
rawInvokeHostFunctionOp,
|
240
|
+
authEntries,
|
241
|
+
_iterator,
|
242
|
+
_step,
|
243
|
+
_step$value,
|
244
|
+
i,
|
245
|
+
entry,
|
246
|
+
pk,
|
247
|
+
_args6 = arguments;
|
248
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
249
|
+
while (1) switch (_context6.prev = _context6.next) {
|
250
|
+
case 0:
|
251
|
+
_ref9 = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {}, _ref9$expiration = _ref9.expiration, expiration = _ref9$expiration === void 0 ? _asyncToGenerator(_regeneratorRuntime().mark(function _callee4() {
|
252
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
253
|
+
while (1) switch (_context4.prev = _context4.next) {
|
254
|
+
case 0:
|
255
|
+
_context4.next = 2;
|
256
|
+
return _this.server.getLatestLedger();
|
257
|
+
case 2:
|
258
|
+
_context4.t0 = _context4.sent.sequence;
|
259
|
+
return _context4.abrupt("return", _context4.t0 + 100);
|
260
|
+
case 4:
|
261
|
+
case "end":
|
262
|
+
return _context4.stop();
|
263
|
+
}
|
264
|
+
}, _callee4);
|
265
|
+
}))() : _ref9$expiration, _ref9$signAuthEntry = _ref9.signAuthEntry, signAuthEntry = _ref9$signAuthEntry === void 0 ? _this.options.signAuthEntry : _ref9$signAuthEntry, _ref9$publicKey = _ref9.publicKey, publicKey = _ref9$publicKey === void 0 ? _this.options.publicKey : _ref9$publicKey;
|
266
|
+
if (_this.built) {
|
267
|
+
_context6.next = 3;
|
268
|
+
break;
|
269
|
+
}
|
270
|
+
throw new Error("Transaction has not yet been assembled or simulated");
|
271
|
+
case 3:
|
272
|
+
needsNonInvokerSigningBy = _this.needsNonInvokerSigningBy();
|
273
|
+
if (needsNonInvokerSigningBy) {
|
274
|
+
_context6.next = 6;
|
275
|
+
break;
|
276
|
+
}
|
277
|
+
throw new AssembledTransaction.Errors.NoUnsignedNonInvokerAuthEntries("No unsigned non-invoker auth entries; maybe you already signed?");
|
278
|
+
case 6:
|
279
|
+
if (!(needsNonInvokerSigningBy.indexOf(publicKey !== null && publicKey !== void 0 ? publicKey : "") === -1)) {
|
280
|
+
_context6.next = 8;
|
281
|
+
break;
|
282
|
+
}
|
283
|
+
throw new AssembledTransaction.Errors.NoSignatureNeeded("No auth entries for public key \"".concat(publicKey, "\""));
|
284
|
+
case 8:
|
285
|
+
if (signAuthEntry) {
|
286
|
+
_context6.next = 10;
|
287
|
+
break;
|
288
|
+
}
|
289
|
+
throw new AssembledTransaction.Errors.NoSigner("You must provide `signAuthEntry` when calling `signAuthEntries`, " + "or when constructing the `Client` or `AssembledTransaction`");
|
290
|
+
case 10:
|
291
|
+
rawInvokeHostFunctionOp = _this.built.operations[0];
|
292
|
+
authEntries = (_rawInvokeHostFunctio2 = rawInvokeHostFunctionOp.auth) !== null && _rawInvokeHostFunctio2 !== void 0 ? _rawInvokeHostFunctio2 : [];
|
293
|
+
_iterator = _createForOfIteratorHelper(authEntries.entries());
|
294
|
+
_context6.prev = 13;
|
295
|
+
_iterator.s();
|
296
|
+
case 15:
|
297
|
+
if ((_step = _iterator.n()).done) {
|
298
|
+
_context6.next = 34;
|
299
|
+
break;
|
300
|
+
}
|
301
|
+
_step$value = _slicedToArray(_step.value, 2), i = _step$value[0], entry = _step$value[1];
|
302
|
+
if (!(entry.credentials().switch() !== _stellarBase.xdr.SorobanCredentialsType.sorobanCredentialsAddress())) {
|
303
|
+
_context6.next = 19;
|
304
|
+
break;
|
305
|
+
}
|
306
|
+
return _context6.abrupt("continue", 32);
|
307
|
+
case 19:
|
308
|
+
pk = _stellarBase.StrKey.encodeEd25519PublicKey(entry.credentials().address().address().accountId().ed25519());
|
309
|
+
if (!(pk !== publicKey)) {
|
310
|
+
_context6.next = 22;
|
311
|
+
break;
|
312
|
+
}
|
313
|
+
return _context6.abrupt("continue", 32);
|
314
|
+
case 22:
|
315
|
+
_context6.t0 = _stellarBase.authorizeEntry;
|
316
|
+
_context6.t1 = entry;
|
317
|
+
_context6.t2 = function () {
|
318
|
+
var _ref11 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee5(preimage) {
|
319
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
320
|
+
while (1) switch (_context5.prev = _context5.next) {
|
321
|
+
case 0:
|
322
|
+
_context5.t0 = Buffer;
|
323
|
+
_context5.next = 3;
|
324
|
+
return signAuthEntry(preimage.toXDR("base64"));
|
325
|
+
case 3:
|
326
|
+
_context5.t1 = _context5.sent;
|
327
|
+
return _context5.abrupt("return", _context5.t0.from.call(_context5.t0, _context5.t1, "base64"));
|
328
|
+
case 5:
|
329
|
+
case "end":
|
330
|
+
return _context5.stop();
|
331
|
+
}
|
332
|
+
}, _callee5);
|
333
|
+
}));
|
334
|
+
return function (_x) {
|
335
|
+
return _ref11.apply(this, arguments);
|
336
|
+
};
|
337
|
+
}();
|
338
|
+
_context6.next = 27;
|
339
|
+
return expiration;
|
340
|
+
case 27:
|
341
|
+
_context6.t3 = _context6.sent;
|
342
|
+
_context6.t4 = _this.options.networkPassphrase;
|
343
|
+
_context6.next = 31;
|
344
|
+
return (0, _context6.t0)(_context6.t1, _context6.t2, _context6.t3, _context6.t4);
|
345
|
+
case 31:
|
346
|
+
authEntries[i] = _context6.sent;
|
347
|
+
case 32:
|
348
|
+
_context6.next = 15;
|
349
|
+
break;
|
350
|
+
case 34:
|
351
|
+
_context6.next = 39;
|
352
|
+
break;
|
353
|
+
case 36:
|
354
|
+
_context6.prev = 36;
|
355
|
+
_context6.t5 = _context6["catch"](13);
|
356
|
+
_iterator.e(_context6.t5);
|
357
|
+
case 39:
|
358
|
+
_context6.prev = 39;
|
359
|
+
_iterator.f();
|
360
|
+
return _context6.finish(39);
|
361
|
+
case 42:
|
362
|
+
case "end":
|
363
|
+
return _context6.stop();
|
364
|
+
}
|
365
|
+
}, _callee6, null, [[13, 36, 39, 42]]);
|
366
|
+
})));
|
367
|
+
this.options = options;
|
368
|
+
this.options.simulate = (_this$options$simulat = this.options.simulate) !== null && _this$options$simulat !== void 0 ? _this$options$simulat : true;
|
369
|
+
this.server = new _server.Server(this.options.rpcUrl, {
|
370
|
+
allowHttp: (_this$options$allowHt = this.options.allowHttp) !== null && _this$options$allowHt !== void 0 ? _this$options$allowHt : false
|
371
|
+
});
|
372
|
+
}
|
373
|
+
return _createClass(AssembledTransaction, [{
|
374
|
+
key: "toJSON",
|
375
|
+
value: function toJSON() {
|
376
|
+
var _this$built;
|
377
|
+
return JSON.stringify({
|
378
|
+
method: this.options.method,
|
379
|
+
tx: (_this$built = this.built) === null || _this$built === void 0 ? void 0 : _this$built.toXDR(),
|
380
|
+
simulationResult: {
|
381
|
+
auth: this.simulationData.result.auth.map(function (a) {
|
382
|
+
return a.toXDR("base64");
|
383
|
+
}),
|
384
|
+
retval: this.simulationData.result.retval.toXDR("base64")
|
385
|
+
},
|
386
|
+
simulationTransactionData: this.simulationData.transactionData.toXDR("base64")
|
387
|
+
});
|
388
|
+
}
|
389
|
+
}, {
|
390
|
+
key: "toXDR",
|
391
|
+
value: function toXDR() {
|
392
|
+
var _this$built2;
|
393
|
+
if (!this.built) throw new Error("Transaction has not yet been simulated; " + "call `AssembledTransaction.simulate` first.");
|
394
|
+
return (_this$built2 = this.built) === null || _this$built2 === void 0 ? void 0 : _this$built2.toEnvelope().toXDR('base64');
|
395
|
+
}
|
396
|
+
}, {
|
397
|
+
key: "simulationData",
|
398
|
+
get: function get() {
|
399
|
+
var _simulation$result;
|
400
|
+
if (this.simulationResult && this.simulationTransactionData) {
|
401
|
+
return {
|
402
|
+
result: this.simulationResult,
|
403
|
+
transactionData: this.simulationTransactionData
|
404
|
+
};
|
405
|
+
}
|
406
|
+
var simulation = this.simulation;
|
407
|
+
if (!simulation) {
|
408
|
+
throw new AssembledTransaction.Errors.NotYetSimulated("Transaction has not yet been simulated");
|
409
|
+
}
|
410
|
+
if (_api.Api.isSimulationError(simulation)) {
|
411
|
+
throw new Error("Transaction simulation failed: \"".concat(simulation.error, "\""));
|
412
|
+
}
|
413
|
+
if (_api.Api.isSimulationRestore(simulation)) {
|
414
|
+
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.');
|
415
|
+
}
|
416
|
+
this.simulationResult = (_simulation$result = simulation.result) !== null && _simulation$result !== void 0 ? _simulation$result : {
|
417
|
+
auth: [],
|
418
|
+
retval: _stellarBase.xdr.ScVal.scvVoid()
|
419
|
+
};
|
420
|
+
this.simulationTransactionData = simulation.transactionData.build();
|
421
|
+
return {
|
422
|
+
result: this.simulationResult,
|
423
|
+
transactionData: this.simulationTransactionData
|
424
|
+
};
|
425
|
+
}
|
426
|
+
}, {
|
427
|
+
key: "result",
|
428
|
+
get: function get() {
|
429
|
+
try {
|
430
|
+
if (!this.simulationData.result) {
|
431
|
+
throw new Error("No simulation result!");
|
432
|
+
}
|
433
|
+
return this.options.parseResultXdr(this.simulationData.result.retval);
|
434
|
+
} catch (e) {
|
435
|
+
if (!(0, _utils.implementsToString)(e)) throw e;
|
436
|
+
var err = this.parseError(e.toString());
|
437
|
+
if (err) return err;
|
438
|
+
throw e;
|
439
|
+
}
|
440
|
+
}
|
441
|
+
}, {
|
442
|
+
key: "parseError",
|
443
|
+
value: function parseError(errorMessage) {
|
444
|
+
if (!this.options.errorTypes) return undefined;
|
445
|
+
var match = errorMessage.match(_utils.contractErrorPattern);
|
446
|
+
if (!match) return undefined;
|
447
|
+
var i = parseInt(match[1], 10);
|
448
|
+
var err = this.options.errorTypes[i];
|
449
|
+
if (!err) return undefined;
|
450
|
+
return new _rust_result.Err(err);
|
451
|
+
}
|
452
|
+
}, {
|
453
|
+
key: "send",
|
454
|
+
value: (function () {
|
455
|
+
var _send = _asyncToGenerator(_regeneratorRuntime().mark(function _callee7() {
|
456
|
+
var sent;
|
457
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
458
|
+
while (1) switch (_context7.prev = _context7.next) {
|
459
|
+
case 0:
|
460
|
+
if (this.signed) {
|
461
|
+
_context7.next = 2;
|
462
|
+
break;
|
463
|
+
}
|
464
|
+
throw new Error("The transaction has not yet been signed. Run `sign` first, or use `signAndSend` instead.");
|
465
|
+
case 2:
|
466
|
+
_context7.next = 4;
|
467
|
+
return _sent_transaction.SentTransaction.init(undefined, this);
|
468
|
+
case 4:
|
469
|
+
sent = _context7.sent;
|
470
|
+
return _context7.abrupt("return", sent);
|
471
|
+
case 6:
|
472
|
+
case "end":
|
473
|
+
return _context7.stop();
|
474
|
+
}
|
475
|
+
}, _callee7, this);
|
476
|
+
}));
|
477
|
+
function send() {
|
478
|
+
return _send.apply(this, arguments);
|
479
|
+
}
|
480
|
+
return send;
|
481
|
+
}())
|
482
|
+
}, {
|
483
|
+
key: "isReadCall",
|
484
|
+
get: function get() {
|
485
|
+
var authsCount = this.simulationData.result.auth.length;
|
486
|
+
var writeLength = this.simulationData.transactionData.resources().footprint().readWrite().length;
|
487
|
+
return authsCount === 0 && writeLength === 0;
|
488
|
+
}
|
489
|
+
}, {
|
490
|
+
key: "restoreFootprint",
|
491
|
+
value: (function () {
|
492
|
+
var _restoreFootprint = _asyncToGenerator(_regeneratorRuntime().mark(function _callee8(restorePreamble, account) {
|
493
|
+
var _account;
|
494
|
+
var restoreTx, sentTransaction;
|
495
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
496
|
+
while (1) switch (_context8.prev = _context8.next) {
|
497
|
+
case 0:
|
498
|
+
if (this.options.signTransaction) {
|
499
|
+
_context8.next = 2;
|
500
|
+
break;
|
501
|
+
}
|
502
|
+
throw new Error("For automatic restore to work you must provide a signTransaction function when initializing your Client");
|
503
|
+
case 2:
|
504
|
+
if (!((_account = account) !== null && _account !== void 0)) {
|
505
|
+
_context8.next = 6;
|
506
|
+
break;
|
507
|
+
}
|
508
|
+
_context8.t0 = _account;
|
509
|
+
_context8.next = 9;
|
510
|
+
break;
|
511
|
+
case 6:
|
512
|
+
_context8.next = 8;
|
513
|
+
return (0, _utils.getAccount)(this.options, this.server);
|
514
|
+
case 8:
|
515
|
+
_context8.t0 = _context8.sent;
|
516
|
+
case 9:
|
517
|
+
account = _context8.t0;
|
518
|
+
_context8.next = 12;
|
519
|
+
return AssembledTransaction.buildFootprintRestoreTransaction(_objectSpread({}, this.options), restorePreamble.transactionData, account, restorePreamble.minResourceFee);
|
520
|
+
case 12:
|
521
|
+
restoreTx = _context8.sent;
|
522
|
+
_context8.next = 15;
|
523
|
+
return restoreTx.signAndSend();
|
524
|
+
case 15:
|
525
|
+
sentTransaction = _context8.sent;
|
526
|
+
if (sentTransaction.getTransactionResponse) {
|
527
|
+
_context8.next = 18;
|
528
|
+
break;
|
529
|
+
}
|
530
|
+
throw new AssembledTransaction.Errors.RestorationFailure("The attempt at automatic restore failed. \n".concat(JSON.stringify(sentTransaction)));
|
531
|
+
case 18:
|
532
|
+
return _context8.abrupt("return", sentTransaction.getTransactionResponse);
|
533
|
+
case 19:
|
534
|
+
case "end":
|
535
|
+
return _context8.stop();
|
536
|
+
}
|
537
|
+
}, _callee8, this);
|
538
|
+
}));
|
539
|
+
function restoreFootprint(_x2, _x3) {
|
540
|
+
return _restoreFootprint.apply(this, arguments);
|
541
|
+
}
|
542
|
+
return restoreFootprint;
|
543
|
+
}())
|
544
|
+
}], [{
|
545
|
+
key: "fromJSON",
|
546
|
+
value: function fromJSON(options, _ref12) {
|
547
|
+
var tx = _ref12.tx,
|
548
|
+
simulationResult = _ref12.simulationResult,
|
549
|
+
simulationTransactionData = _ref12.simulationTransactionData;
|
550
|
+
var txn = new AssembledTransaction(options);
|
551
|
+
txn.built = _stellarBase.TransactionBuilder.fromXDR(tx, options.networkPassphrase);
|
552
|
+
txn.simulationResult = {
|
553
|
+
auth: simulationResult.auth.map(function (a) {
|
554
|
+
return _stellarBase.xdr.SorobanAuthorizationEntry.fromXDR(a, "base64");
|
555
|
+
}),
|
556
|
+
retval: _stellarBase.xdr.ScVal.fromXDR(simulationResult.retval, "base64")
|
557
|
+
};
|
558
|
+
txn.simulationTransactionData = _stellarBase.xdr.SorobanTransactionData.fromXDR(simulationTransactionData, "base64");
|
559
|
+
return txn;
|
560
|
+
}
|
561
|
+
}, {
|
562
|
+
key: "fromXDR",
|
563
|
+
value: function fromXDR(options, encodedXDR, spec) {
|
564
|
+
var _operation$func;
|
565
|
+
var envelope = _stellarBase.xdr.TransactionEnvelope.fromXDR(encodedXDR, "base64");
|
566
|
+
var built = _stellarBase.TransactionBuilder.fromXDR(envelope, options.networkPassphrase);
|
567
|
+
var operation = built.operations[0];
|
568
|
+
if (!(operation !== null && operation !== void 0 && (_operation$func = operation.func) !== null && _operation$func !== void 0 && _operation$func.value) || typeof operation.func.value !== 'function') {
|
569
|
+
throw new Error("Could not extract the method from the transaction envelope.");
|
570
|
+
}
|
571
|
+
var invokeContractArgs = operation.func.value();
|
572
|
+
if (!(invokeContractArgs !== null && invokeContractArgs !== void 0 && invokeContractArgs.functionName)) {
|
573
|
+
throw new Error("Could not extract the method name from the transaction envelope.");
|
574
|
+
}
|
575
|
+
var method = invokeContractArgs.functionName().toString('utf-8');
|
576
|
+
var txn = new AssembledTransaction(_objectSpread(_objectSpread({}, options), {}, {
|
577
|
+
method: method,
|
578
|
+
parseResultXdr: function parseResultXdr(result) {
|
579
|
+
return spec.funcResToNative(method, result);
|
580
|
+
}
|
581
|
+
}));
|
582
|
+
txn.built = built;
|
583
|
+
return txn;
|
584
|
+
}
|
585
|
+
}, {
|
586
|
+
key: "build",
|
587
|
+
value: (function () {
|
588
|
+
var _build = _asyncToGenerator(_regeneratorRuntime().mark(function _callee9(options) {
|
589
|
+
var _options$fee, _options$args, _options$timeoutInSec;
|
590
|
+
var tx, contract, account;
|
591
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
592
|
+
while (1) switch (_context9.prev = _context9.next) {
|
593
|
+
case 0:
|
594
|
+
tx = new AssembledTransaction(options);
|
595
|
+
contract = new _stellarBase.Contract(options.contractId);
|
596
|
+
_context9.next = 4;
|
597
|
+
return (0, _utils.getAccount)(options, tx.server);
|
598
|
+
case 4:
|
599
|
+
account = _context9.sent;
|
600
|
+
tx.raw = new _stellarBase.TransactionBuilder(account, {
|
601
|
+
fee: (_options$fee = options.fee) !== null && _options$fee !== void 0 ? _options$fee : _stellarBase.BASE_FEE,
|
602
|
+
networkPassphrase: options.networkPassphrase
|
603
|
+
}).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 : _types.DEFAULT_TIMEOUT);
|
604
|
+
if (!options.simulate) {
|
605
|
+
_context9.next = 9;
|
606
|
+
break;
|
607
|
+
}
|
608
|
+
_context9.next = 9;
|
609
|
+
return tx.simulate();
|
610
|
+
case 9:
|
611
|
+
return _context9.abrupt("return", tx);
|
612
|
+
case 10:
|
613
|
+
case "end":
|
614
|
+
return _context9.stop();
|
615
|
+
}
|
616
|
+
}, _callee9);
|
617
|
+
}));
|
618
|
+
function build(_x4) {
|
619
|
+
return _build.apply(this, arguments);
|
620
|
+
}
|
621
|
+
return build;
|
622
|
+
}())
|
623
|
+
}, {
|
624
|
+
key: "buildFootprintRestoreTransaction",
|
625
|
+
value: function () {
|
626
|
+
var _buildFootprintRestoreTransaction = _asyncToGenerator(_regeneratorRuntime().mark(function _callee10(options, sorobanData, account, fee) {
|
627
|
+
var _options$timeoutInSec2;
|
628
|
+
var tx;
|
629
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
630
|
+
while (1) switch (_context10.prev = _context10.next) {
|
631
|
+
case 0:
|
632
|
+
tx = new AssembledTransaction(options);
|
633
|
+
tx.raw = new _stellarBase.TransactionBuilder(account, {
|
634
|
+
fee: fee,
|
635
|
+
networkPassphrase: options.networkPassphrase
|
636
|
+
}).setSorobanData(sorobanData instanceof _stellarBase.SorobanDataBuilder ? sorobanData.build() : sorobanData).addOperation(_stellarBase.Operation.restoreFootprint({})).setTimeout((_options$timeoutInSec2 = options.timeoutInSeconds) !== null && _options$timeoutInSec2 !== void 0 ? _options$timeoutInSec2 : _types.DEFAULT_TIMEOUT);
|
637
|
+
_context10.next = 4;
|
638
|
+
return tx.simulate({
|
639
|
+
restore: false
|
640
|
+
});
|
641
|
+
case 4:
|
642
|
+
return _context10.abrupt("return", tx);
|
643
|
+
case 5:
|
644
|
+
case "end":
|
645
|
+
return _context10.stop();
|
646
|
+
}
|
647
|
+
}, _callee10);
|
648
|
+
}));
|
649
|
+
function buildFootprintRestoreTransaction(_x5, _x6, _x7, _x8) {
|
650
|
+
return _buildFootprintRestoreTransaction.apply(this, arguments);
|
651
|
+
}
|
652
|
+
return buildFootprintRestoreTransaction;
|
653
|
+
}()
|
654
|
+
}]);
|
655
|
+
}();
|
656
|
+
_defineProperty(AssembledTransaction, "Errors", {
|
657
|
+
ExpiredState: function (_Error) {
|
658
|
+
function ExpiredStateError() {
|
659
|
+
_classCallCheck(this, ExpiredStateError);
|
660
|
+
return _callSuper(this, ExpiredStateError, arguments);
|
661
|
+
}
|
662
|
+
_inherits(ExpiredStateError, _Error);
|
663
|
+
return _createClass(ExpiredStateError);
|
664
|
+
}(_wrapNativeSuper(Error)),
|
665
|
+
RestorationFailure: function (_Error2) {
|
666
|
+
function RestoreFailureError() {
|
667
|
+
_classCallCheck(this, RestoreFailureError);
|
668
|
+
return _callSuper(this, RestoreFailureError, arguments);
|
669
|
+
}
|
670
|
+
_inherits(RestoreFailureError, _Error2);
|
671
|
+
return _createClass(RestoreFailureError);
|
672
|
+
}(_wrapNativeSuper(Error)),
|
673
|
+
NeedsMoreSignatures: function (_Error3) {
|
674
|
+
function NeedsMoreSignaturesError() {
|
675
|
+
_classCallCheck(this, NeedsMoreSignaturesError);
|
676
|
+
return _callSuper(this, NeedsMoreSignaturesError, arguments);
|
677
|
+
}
|
678
|
+
_inherits(NeedsMoreSignaturesError, _Error3);
|
679
|
+
return _createClass(NeedsMoreSignaturesError);
|
680
|
+
}(_wrapNativeSuper(Error)),
|
681
|
+
NoSignatureNeeded: function (_Error4) {
|
682
|
+
function NoSignatureNeededError() {
|
683
|
+
_classCallCheck(this, NoSignatureNeededError);
|
684
|
+
return _callSuper(this, NoSignatureNeededError, arguments);
|
685
|
+
}
|
686
|
+
_inherits(NoSignatureNeededError, _Error4);
|
687
|
+
return _createClass(NoSignatureNeededError);
|
688
|
+
}(_wrapNativeSuper(Error)),
|
689
|
+
NoUnsignedNonInvokerAuthEntries: function (_Error5) {
|
690
|
+
function NoUnsignedNonInvokerAuthEntriesError() {
|
691
|
+
_classCallCheck(this, NoUnsignedNonInvokerAuthEntriesError);
|
692
|
+
return _callSuper(this, NoUnsignedNonInvokerAuthEntriesError, arguments);
|
693
|
+
}
|
694
|
+
_inherits(NoUnsignedNonInvokerAuthEntriesError, _Error5);
|
695
|
+
return _createClass(NoUnsignedNonInvokerAuthEntriesError);
|
696
|
+
}(_wrapNativeSuper(Error)),
|
697
|
+
NoSigner: function (_Error6) {
|
698
|
+
function NoSignerError() {
|
699
|
+
_classCallCheck(this, NoSignerError);
|
700
|
+
return _callSuper(this, NoSignerError, arguments);
|
701
|
+
}
|
702
|
+
_inherits(NoSignerError, _Error6);
|
703
|
+
return _createClass(NoSignerError);
|
704
|
+
}(_wrapNativeSuper(Error)),
|
705
|
+
NotYetSimulated: function (_Error7) {
|
706
|
+
function NotYetSimulatedError() {
|
707
|
+
_classCallCheck(this, NotYetSimulatedError);
|
708
|
+
return _callSuper(this, NotYetSimulatedError, arguments);
|
709
|
+
}
|
710
|
+
_inherits(NotYetSimulatedError, _Error7);
|
711
|
+
return _createClass(NotYetSimulatedError);
|
712
|
+
}(_wrapNativeSuper(Error)),
|
713
|
+
FakeAccount: function (_Error8) {
|
714
|
+
function FakeAccountError() {
|
715
|
+
_classCallCheck(this, FakeAccountError);
|
716
|
+
return _callSuper(this, FakeAccountError, arguments);
|
717
|
+
}
|
718
|
+
_inherits(FakeAccountError, _Error8);
|
719
|
+
return _createClass(FakeAccountError);
|
720
|
+
}(_wrapNativeSuper(Error))
|
721
|
+
});
|