@stellar/stellar-sdk 12.0.0 → 12.0.1
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 +98 -1
- package/README.md +1 -1
- package/dist/stellar-sdk.js +2796 -1194
- package/dist/stellar-sdk.min.js +1 -1
- package/lib/browser.js +1 -1
- package/lib/config.js +3 -3
- package/lib/{contract_client → contract}/assembled_transaction.d.ts +74 -54
- package/lib/{contract_client → contract}/assembled_transaction.js +149 -167
- package/lib/{contract_client → contract}/basic_node_signer.d.ts +2 -2
- package/lib/{contract_client → contract}/basic_node_signer.js +5 -5
- package/lib/contract/client.d.ts +52 -0
- package/lib/contract/client.js +177 -0
- package/lib/contract/index.d.ts +7 -0
- package/lib/{contract_client → contract}/index.js +19 -8
- package/lib/{rust_types/result.js → contract/rust_result.js} +3 -3
- package/lib/{contract_client → contract}/sent_transaction.d.ts +26 -14
- package/lib/{contract_client → contract}/sent_transaction.js +51 -32
- package/lib/{contract_spec.d.ts → contract/spec.d.ts} +3 -3
- package/lib/{contract_spec.js → contract/spec.js} +169 -169
- package/lib/{contract_client → contract}/types.d.ts +10 -8
- package/lib/contract/utils.d.ts +41 -0
- package/lib/{contract_client → contract}/utils.js +15 -5
- package/lib/errors.js +10 -10
- package/lib/federation/server.js +10 -10
- package/lib/horizon/account_call_builder.d.ts +1 -0
- package/lib/horizon/account_call_builder.js +8 -8
- package/lib/horizon/account_response.js +7 -7
- package/lib/horizon/assets_call_builder.d.ts +1 -0
- package/lib/horizon/assets_call_builder.js +8 -8
- package/lib/horizon/call_builder.js +6 -6
- package/lib/horizon/claimable_balances_call_builder.d.ts +1 -0
- package/lib/horizon/claimable_balances_call_builder.js +8 -8
- package/lib/horizon/effect_call_builder.d.ts +1 -0
- package/lib/horizon/effect_call_builder.js +8 -8
- package/lib/horizon/friendbot_builder.d.ts +1 -0
- package/lib/horizon/friendbot_builder.js +8 -8
- package/lib/horizon/horizon_api.d.ts +1 -0
- package/lib/horizon/horizon_axios_client.js +1 -1
- package/lib/horizon/ledger_call_builder.d.ts +1 -0
- package/lib/horizon/ledger_call_builder.js +8 -8
- package/lib/horizon/liquidity_pool_call_builder.d.ts +1 -0
- package/lib/horizon/liquidity_pool_call_builder.js +8 -8
- package/lib/horizon/offer_call_builder.d.ts +1 -0
- package/lib/horizon/offer_call_builder.js +8 -8
- package/lib/horizon/operation_call_builder.d.ts +1 -0
- package/lib/horizon/operation_call_builder.js +8 -8
- package/lib/horizon/orderbook_call_builder.d.ts +1 -0
- package/lib/horizon/orderbook_call_builder.js +8 -8
- package/lib/horizon/path_call_builder.d.ts +1 -0
- package/lib/horizon/path_call_builder.js +8 -8
- package/lib/horizon/payment_call_builder.d.ts +1 -0
- package/lib/horizon/payment_call_builder.js +8 -8
- package/lib/horizon/server.js +6 -6
- package/lib/horizon/strict_receive_path_call_builder.d.ts +1 -0
- package/lib/horizon/strict_receive_path_call_builder.js +8 -8
- package/lib/horizon/strict_send_path_call_builder.d.ts +1 -0
- package/lib/horizon/strict_send_path_call_builder.js +8 -8
- package/lib/horizon/trade_aggregation_call_builder.d.ts +1 -0
- package/lib/horizon/trade_aggregation_call_builder.js +8 -8
- package/lib/horizon/trades_call_builder.d.ts +1 -0
- package/lib/horizon/trades_call_builder.js +8 -8
- package/lib/horizon/transaction_call_builder.d.ts +1 -0
- package/lib/horizon/transaction_call_builder.js +8 -8
- package/lib/index.d.ts +27 -2
- package/lib/index.js +10 -16
- package/lib/{soroban → rpc}/api.d.ts +25 -10
- package/lib/{soroban → rpc}/axios.js +1 -1
- package/lib/{soroban → rpc}/browser.js +1 -1
- package/lib/rpc/index.d.ts +8 -0
- package/lib/{soroban → rpc}/index.js +1 -1
- package/lib/{soroban → rpc}/jsonrpc.js +3 -3
- package/lib/{soroban → rpc}/parsers.js +12 -3
- package/lib/{soroban → rpc}/server.d.ts +50 -0
- package/lib/{soroban → rpc}/server.js +209 -128
- package/lib/stellartoml/index.js +6 -6
- package/lib/utils.js +3 -3
- package/lib/webauth/errors.js +10 -10
- package/lib/webauth/utils.js +9 -9
- package/package.json +32 -15
- package/lib/contract_client/client.d.ts +0 -17
- package/lib/contract_client/client.js +0 -57
- package/lib/contract_client/index.d.ts +0 -6
- package/lib/contract_client/utils.d.ts +0 -23
- package/lib/rust_types/index.d.ts +0 -1
- package/lib/rust_types/index.js +0 -16
- package/lib/soroban/index.d.ts +0 -7
- /package/lib/{rust_types/result.d.ts → contract/rust_result.d.ts} +0 -0
- /package/lib/{contract_client → contract}/types.js +0 -0
- /package/lib/{soroban → rpc}/api.js +0 -0
- /package/lib/{soroban → rpc}/axios.d.ts +0 -0
- /package/lib/{soroban → rpc}/browser.d.ts +0 -0
- /package/lib/{soroban → rpc}/jsonrpc.d.ts +0 -0
- /package/lib/{soroban → rpc}/parsers.d.ts +0 -0
- /package/lib/{soroban → rpc}/transaction.d.ts +0 -0
- /package/lib/{soroban → rpc}/transaction.js +0 -0
- /package/lib/{soroban → rpc}/utils.d.ts +0 -0
- /package/lib/{soroban → rpc}/utils.js +0 -0
|
@@ -4,39 +4,42 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.NULL_ACCOUNT = exports.AssembledTransaction = void 0;
|
|
7
|
-
var
|
|
8
|
-
var
|
|
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");
|
|
9
12
|
var _utils = require("./utils");
|
|
10
13
|
var _sent_transaction = require("./sent_transaction");
|
|
11
14
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
12
|
-
function _possibleConstructorReturn(
|
|
13
|
-
function _assertThisInitialized(
|
|
14
|
-
function _inherits(
|
|
15
|
-
function _wrapNativeSuper(
|
|
15
|
+
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); }
|
|
16
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
17
|
+
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); }
|
|
18
|
+
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); }
|
|
16
19
|
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; }
|
|
17
20
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
18
|
-
function _isNativeFunction(
|
|
19
|
-
function _setPrototypeOf(
|
|
20
|
-
function _getPrototypeOf(
|
|
21
|
+
function _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).indexOf("[native code]"); } catch (n) { return "function" == typeof t; } }
|
|
22
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
23
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
21
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); }
|
|
22
|
-
function _slicedToArray(
|
|
25
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
23
26
|
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."); }
|
|
24
27
|
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; } }
|
|
25
|
-
function _arrayWithHoles(
|
|
26
|
-
function _createForOfIteratorHelper(
|
|
27
|
-
function _toConsumableArray(
|
|
28
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
29
|
+
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; } } }; }
|
|
30
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
28
31
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
29
|
-
function _unsupportedIterableToArray(
|
|
30
|
-
function _iterableToArray(
|
|
31
|
-
function _arrayWithoutHoles(
|
|
32
|
-
function _arrayLikeToArray(
|
|
32
|
+
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
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
34
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
35
|
+
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; }
|
|
33
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; }
|
|
34
|
-
function asyncGeneratorStep(
|
|
35
|
-
function _asyncToGenerator(
|
|
36
|
-
function _classCallCheck(
|
|
37
|
-
function _defineProperties(
|
|
38
|
-
function _createClass(
|
|
39
|
-
function _defineProperty(
|
|
37
|
+
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
|
+
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
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
40
|
+
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); } }
|
|
41
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
42
|
+
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; }
|
|
40
43
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
41
44
|
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); }
|
|
42
45
|
var NULL_ACCOUNT = exports.NULL_ACCOUNT = "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF";
|
|
@@ -54,15 +57,15 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
54
57
|
_context.next = 2;
|
|
55
58
|
break;
|
|
56
59
|
}
|
|
57
|
-
throw new Error(
|
|
60
|
+
throw new Error("Transaction has not yet been assembled; " + "call `AssembledTransaction.build` first.");
|
|
58
61
|
case 2:
|
|
59
62
|
_this.built = _this.raw.build();
|
|
60
63
|
_context.next = 5;
|
|
61
64
|
return _this.server.simulateTransaction(_this.built);
|
|
62
65
|
case 5:
|
|
63
66
|
_this.simulation = _context.sent;
|
|
64
|
-
if (
|
|
65
|
-
_this.built =
|
|
67
|
+
if (_api.Api.isSimulationSuccess(_this.simulation)) {
|
|
68
|
+
_this.built = (0, _transaction.assembleTransaction)(_this.built, _this.simulation).build();
|
|
66
69
|
}
|
|
67
70
|
return _context.abrupt("return", _this);
|
|
68
71
|
case 8:
|
|
@@ -78,6 +81,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
78
81
|
_ref3$signTransaction,
|
|
79
82
|
signTransaction,
|
|
80
83
|
typeChecked,
|
|
84
|
+
sent,
|
|
81
85
|
_args2 = arguments;
|
|
82
86
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
83
87
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -99,23 +103,21 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
99
103
|
_context2.next = 7;
|
|
100
104
|
break;
|
|
101
105
|
}
|
|
102
|
-
throw new AssembledTransaction.Errors.NoSigner("You must provide a signTransaction function, either when calling " + "`signAndSend` or when initializing your
|
|
106
|
+
throw new AssembledTransaction.Errors.NoSigner("You must provide a signTransaction function, either when calling " + "`signAndSend` or when initializing your Client");
|
|
103
107
|
case 7:
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
case 9:
|
|
107
|
-
if (!_context2.sent.length) {
|
|
108
|
-
_context2.next = 11;
|
|
108
|
+
if (!_this.needsNonInvokerSigningBy().length) {
|
|
109
|
+
_context2.next = 9;
|
|
109
110
|
break;
|
|
110
111
|
}
|
|
111
112
|
throw new AssembledTransaction.Errors.NeedsMoreSignatures("Transaction requires more signatures. " + "See `needsNonInvokerSigningBy` for details.");
|
|
112
|
-
case
|
|
113
|
+
case 9:
|
|
113
114
|
typeChecked = _this;
|
|
114
|
-
_context2.next =
|
|
115
|
+
_context2.next = 12;
|
|
115
116
|
return _sent_transaction.SentTransaction.init(signTransaction, typeChecked);
|
|
117
|
+
case 12:
|
|
118
|
+
sent = _context2.sent;
|
|
119
|
+
return _context2.abrupt("return", sent);
|
|
116
120
|
case 14:
|
|
117
|
-
return _context2.abrupt("return", _context2.sent);
|
|
118
|
-
case 15:
|
|
119
121
|
case "end":
|
|
120
122
|
return _context2.stop();
|
|
121
123
|
}
|
|
@@ -127,7 +129,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
127
129
|
while (1) switch (_context3.prev = _context3.next) {
|
|
128
130
|
case 0:
|
|
129
131
|
_context3.next = 2;
|
|
130
|
-
return _this.server.getLedgerEntries(new
|
|
132
|
+
return _this.server.getLedgerEntries(new _stellarBase.Contract(_this.options.contractId).getFootprint());
|
|
131
133
|
case 2:
|
|
132
134
|
entryRes = _context3.sent;
|
|
133
135
|
if (!(!entryRes.entries || !entryRes.entries.length || !entryRes.entries[0].liveUntilLedgerSeq)) {
|
|
@@ -143,49 +145,32 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
143
145
|
}
|
|
144
146
|
}, _callee3);
|
|
145
147
|
})));
|
|
146
|
-
_defineProperty(this, "needsNonInvokerSigningBy",
|
|
148
|
+
_defineProperty(this, "needsNonInvokerSigningBy", function () {
|
|
147
149
|
var _rawInvokeHostFunctio;
|
|
148
|
-
var
|
|
149
|
-
|
|
150
|
-
includeAlreadySigned
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
throw new Error("Unexpected Transaction type; no operations: ".concat(JSON.stringify(_this.built)));
|
|
168
|
-
case 5:
|
|
169
|
-
rawInvokeHostFunctionOp = _this.built.operations[0];
|
|
170
|
-
return _context4.abrupt("return", _toConsumableArray(new Set(((_rawInvokeHostFunctio = rawInvokeHostFunctionOp.auth) !== null && _rawInvokeHostFunctio !== void 0 ? _rawInvokeHostFunctio : []).filter(function (entry) {
|
|
171
|
-
return entry.credentials().switch() === _.xdr.SorobanCredentialsType.sorobanCredentialsAddress() && (includeAlreadySigned || entry.credentials().address().signature().switch().name === "scvVoid");
|
|
172
|
-
}).map(function (entry) {
|
|
173
|
-
return _.StrKey.encodeEd25519PublicKey(entry.credentials().address().address().accountId().ed25519());
|
|
174
|
-
}))));
|
|
175
|
-
case 7:
|
|
176
|
-
case "end":
|
|
177
|
-
return _context4.stop();
|
|
178
|
-
}
|
|
179
|
-
}, _callee4);
|
|
180
|
-
})));
|
|
181
|
-
_defineProperty(this, "signAuthEntries", _asyncToGenerator(_regeneratorRuntime().mark(function _callee6() {
|
|
150
|
+
var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
151
|
+
_ref5$includeAlreadyS = _ref5.includeAlreadySigned,
|
|
152
|
+
includeAlreadySigned = _ref5$includeAlreadyS === void 0 ? false : _ref5$includeAlreadyS;
|
|
153
|
+
if (!_this.built) {
|
|
154
|
+
throw new Error("Transaction has not yet been simulated");
|
|
155
|
+
}
|
|
156
|
+
if (!("operations" in _this.built)) {
|
|
157
|
+
throw new Error("Unexpected Transaction type; no operations: ".concat(JSON.stringify(_this.built)));
|
|
158
|
+
}
|
|
159
|
+
var rawInvokeHostFunctionOp = _this.built.operations[0];
|
|
160
|
+
return _toConsumableArray(new Set(((_rawInvokeHostFunctio = rawInvokeHostFunctionOp.auth) !== null && _rawInvokeHostFunctio !== void 0 ? _rawInvokeHostFunctio : []).filter(function (entry) {
|
|
161
|
+
return entry.credentials().switch() === _stellarBase.xdr.SorobanCredentialsType.sorobanCredentialsAddress() && (includeAlreadySigned || entry.credentials().address().signature().switch().name === "scvVoid");
|
|
162
|
+
}).map(function (entry) {
|
|
163
|
+
return _stellarBase.StrKey.encodeEd25519PublicKey(entry.credentials().address().address().accountId().ed25519());
|
|
164
|
+
})));
|
|
165
|
+
});
|
|
166
|
+
_defineProperty(this, "signAuthEntries", _asyncToGenerator(_regeneratorRuntime().mark(function _callee5() {
|
|
182
167
|
var _rawInvokeHostFunctio2;
|
|
183
|
-
var
|
|
184
|
-
|
|
168
|
+
var _ref7,
|
|
169
|
+
_ref7$expiration,
|
|
185
170
|
expiration,
|
|
186
|
-
|
|
171
|
+
_ref7$signAuthEntry,
|
|
187
172
|
signAuthEntry,
|
|
188
|
-
|
|
173
|
+
_ref7$publicKey,
|
|
189
174
|
publicKey,
|
|
190
175
|
needsNonInvokerSigningBy,
|
|
191
176
|
rawInvokeHostFunctionOp,
|
|
@@ -196,118 +181,115 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
196
181
|
i,
|
|
197
182
|
entry,
|
|
198
183
|
pk,
|
|
199
|
-
|
|
200
|
-
return _regeneratorRuntime().wrap(function
|
|
201
|
-
while (1) switch (
|
|
184
|
+
_args5 = arguments;
|
|
185
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
186
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
202
187
|
case 0:
|
|
203
|
-
|
|
188
|
+
_ref7 = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {}, _ref7$expiration = _ref7.expiration, expiration = _ref7$expiration === void 0 ? _this.getStorageExpiration() : _ref7$expiration, _ref7$signAuthEntry = _ref7.signAuthEntry, signAuthEntry = _ref7$signAuthEntry === void 0 ? _this.options.signAuthEntry : _ref7$signAuthEntry, _ref7$publicKey = _ref7.publicKey, publicKey = _ref7$publicKey === void 0 ? _this.options.publicKey : _ref7$publicKey;
|
|
204
189
|
if (_this.built) {
|
|
205
|
-
|
|
190
|
+
_context5.next = 3;
|
|
206
191
|
break;
|
|
207
192
|
}
|
|
208
193
|
throw new Error("Transaction has not yet been assembled or simulated");
|
|
209
194
|
case 3:
|
|
210
|
-
|
|
211
|
-
return _this.needsNonInvokerSigningBy();
|
|
212
|
-
case 5:
|
|
213
|
-
needsNonInvokerSigningBy = _context6.sent;
|
|
195
|
+
needsNonInvokerSigningBy = _this.needsNonInvokerSigningBy();
|
|
214
196
|
if (needsNonInvokerSigningBy) {
|
|
215
|
-
|
|
197
|
+
_context5.next = 6;
|
|
216
198
|
break;
|
|
217
199
|
}
|
|
218
200
|
throw new AssembledTransaction.Errors.NoUnsignedNonInvokerAuthEntries("No unsigned non-invoker auth entries; maybe you already signed?");
|
|
219
|
-
case
|
|
220
|
-
if (!(needsNonInvokerSigningBy.indexOf(publicKey !== null && publicKey !== void 0 ? publicKey :
|
|
221
|
-
|
|
201
|
+
case 6:
|
|
202
|
+
if (!(needsNonInvokerSigningBy.indexOf(publicKey !== null && publicKey !== void 0 ? publicKey : "") === -1)) {
|
|
203
|
+
_context5.next = 8;
|
|
222
204
|
break;
|
|
223
205
|
}
|
|
224
206
|
throw new AssembledTransaction.Errors.NoSignatureNeeded("No auth entries for public key \"".concat(publicKey, "\""));
|
|
225
|
-
case
|
|
207
|
+
case 8:
|
|
226
208
|
if (signAuthEntry) {
|
|
227
|
-
|
|
209
|
+
_context5.next = 10;
|
|
228
210
|
break;
|
|
229
211
|
}
|
|
230
|
-
throw new AssembledTransaction.Errors.NoSigner(
|
|
231
|
-
case
|
|
212
|
+
throw new AssembledTransaction.Errors.NoSigner("You must provide `signAuthEntry` when calling `signAuthEntries`, " + "or when constructing the `Client` or `AssembledTransaction`");
|
|
213
|
+
case 10:
|
|
232
214
|
rawInvokeHostFunctionOp = _this.built.operations[0];
|
|
233
215
|
authEntries = (_rawInvokeHostFunctio2 = rawInvokeHostFunctionOp.auth) !== null && _rawInvokeHostFunctio2 !== void 0 ? _rawInvokeHostFunctio2 : [];
|
|
234
216
|
_iterator = _createForOfIteratorHelper(authEntries.entries());
|
|
235
|
-
|
|
217
|
+
_context5.prev = 13;
|
|
236
218
|
_iterator.s();
|
|
237
|
-
case
|
|
219
|
+
case 15:
|
|
238
220
|
if ((_step = _iterator.n()).done) {
|
|
239
|
-
|
|
221
|
+
_context5.next = 34;
|
|
240
222
|
break;
|
|
241
223
|
}
|
|
242
224
|
_step$value = _slicedToArray(_step.value, 2), i = _step$value[0], entry = _step$value[1];
|
|
243
|
-
if (!(entry.credentials().switch() !==
|
|
244
|
-
|
|
225
|
+
if (!(entry.credentials().switch() !== _stellarBase.xdr.SorobanCredentialsType.sorobanCredentialsAddress())) {
|
|
226
|
+
_context5.next = 19;
|
|
245
227
|
break;
|
|
246
228
|
}
|
|
247
|
-
return
|
|
248
|
-
case
|
|
249
|
-
pk =
|
|
229
|
+
return _context5.abrupt("continue", 32);
|
|
230
|
+
case 19:
|
|
231
|
+
pk = _stellarBase.StrKey.encodeEd25519PublicKey(entry.credentials().address().address().accountId().ed25519());
|
|
250
232
|
if (!(pk !== publicKey)) {
|
|
251
|
-
|
|
233
|
+
_context5.next = 22;
|
|
252
234
|
break;
|
|
253
235
|
}
|
|
254
|
-
return
|
|
255
|
-
case
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
var
|
|
260
|
-
return _regeneratorRuntime().wrap(function
|
|
261
|
-
while (1) switch (
|
|
236
|
+
return _context5.abrupt("continue", 32);
|
|
237
|
+
case 22:
|
|
238
|
+
_context5.t0 = _stellarBase.authorizeEntry;
|
|
239
|
+
_context5.t1 = entry;
|
|
240
|
+
_context5.t2 = function () {
|
|
241
|
+
var _ref8 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee4(preimage) {
|
|
242
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
243
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
262
244
|
case 0:
|
|
263
|
-
|
|
264
|
-
|
|
245
|
+
_context4.t0 = Buffer;
|
|
246
|
+
_context4.next = 3;
|
|
265
247
|
return signAuthEntry(preimage.toXDR("base64"));
|
|
266
248
|
case 3:
|
|
267
|
-
|
|
268
|
-
return
|
|
249
|
+
_context4.t1 = _context4.sent;
|
|
250
|
+
return _context4.abrupt("return", _context4.t0.from.call(_context4.t0, _context4.t1, "base64"));
|
|
269
251
|
case 5:
|
|
270
252
|
case "end":
|
|
271
|
-
return
|
|
253
|
+
return _context4.stop();
|
|
272
254
|
}
|
|
273
|
-
},
|
|
255
|
+
}, _callee4);
|
|
274
256
|
}));
|
|
275
257
|
return function (_x) {
|
|
276
|
-
return
|
|
258
|
+
return _ref8.apply(this, arguments);
|
|
277
259
|
};
|
|
278
260
|
}();
|
|
279
|
-
|
|
261
|
+
_context5.next = 27;
|
|
280
262
|
return expiration;
|
|
281
|
-
case
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
return (0,
|
|
286
|
-
case
|
|
287
|
-
authEntries[i] =
|
|
263
|
+
case 27:
|
|
264
|
+
_context5.t3 = _context5.sent;
|
|
265
|
+
_context5.t4 = _this.options.networkPassphrase;
|
|
266
|
+
_context5.next = 31;
|
|
267
|
+
return (0, _context5.t0)(_context5.t1, _context5.t2, _context5.t3, _context5.t4);
|
|
268
|
+
case 31:
|
|
269
|
+
authEntries[i] = _context5.sent;
|
|
270
|
+
case 32:
|
|
271
|
+
_context5.next = 15;
|
|
272
|
+
break;
|
|
288
273
|
case 34:
|
|
289
|
-
|
|
274
|
+
_context5.next = 39;
|
|
290
275
|
break;
|
|
291
276
|
case 36:
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
_iterator.e(_context6.t5);
|
|
298
|
-
case 41:
|
|
299
|
-
_context6.prev = 41;
|
|
277
|
+
_context5.prev = 36;
|
|
278
|
+
_context5.t5 = _context5["catch"](13);
|
|
279
|
+
_iterator.e(_context5.t5);
|
|
280
|
+
case 39:
|
|
281
|
+
_context5.prev = 39;
|
|
300
282
|
_iterator.f();
|
|
301
|
-
return
|
|
302
|
-
case
|
|
283
|
+
return _context5.finish(39);
|
|
284
|
+
case 42:
|
|
303
285
|
case "end":
|
|
304
|
-
return
|
|
286
|
+
return _context5.stop();
|
|
305
287
|
}
|
|
306
|
-
},
|
|
288
|
+
}, _callee5, null, [[13, 36, 39, 42]]);
|
|
307
289
|
})));
|
|
308
290
|
this.options = options;
|
|
309
291
|
this.options.simulate = (_this$options$simulat = this.options.simulate) !== null && _this$options$simulat !== void 0 ? _this$options$simulat : true;
|
|
310
|
-
this.server = new
|
|
292
|
+
this.server = new _server.Server(this.options.rpcUrl, {
|
|
311
293
|
allowHttp: (_this$options$allowHt = this.options.allowHttp) !== null && _this$options$allowHt !== void 0 ? _this$options$allowHt : false
|
|
312
294
|
});
|
|
313
295
|
}
|
|
@@ -340,10 +322,10 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
340
322
|
if (!simulation) {
|
|
341
323
|
throw new AssembledTransaction.Errors.NotYetSimulated("Transaction has not yet been simulated");
|
|
342
324
|
}
|
|
343
|
-
if (
|
|
325
|
+
if (_api.Api.isSimulationError(simulation)) {
|
|
344
326
|
throw new Error("Transaction simulation failed: \"".concat(simulation.error, "\""));
|
|
345
327
|
}
|
|
346
|
-
if (
|
|
328
|
+
if (_api.Api.isSimulationRestore(simulation)) {
|
|
347
329
|
throw new AssembledTransaction.Errors.ExpiredState("You need to restore some contract state before you can invoke this method. ".concat(JSON.stringify(simulation, null, 2)));
|
|
348
330
|
}
|
|
349
331
|
if (!simulation.result) {
|
|
@@ -377,7 +359,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
377
359
|
var i = parseInt(match[1], 10);
|
|
378
360
|
var err = this.options.errorTypes[i];
|
|
379
361
|
if (!err) return undefined;
|
|
380
|
-
return new
|
|
362
|
+
return new _rust_result.Err(err);
|
|
381
363
|
}
|
|
382
364
|
}, {
|
|
383
365
|
key: "isReadCall",
|
|
@@ -388,63 +370,63 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
388
370
|
}
|
|
389
371
|
}], [{
|
|
390
372
|
key: "fromJSON",
|
|
391
|
-
value: function fromJSON(options,
|
|
392
|
-
var tx =
|
|
393
|
-
simulationResult =
|
|
394
|
-
simulationTransactionData =
|
|
373
|
+
value: function fromJSON(options, _ref9) {
|
|
374
|
+
var tx = _ref9.tx,
|
|
375
|
+
simulationResult = _ref9.simulationResult,
|
|
376
|
+
simulationTransactionData = _ref9.simulationTransactionData;
|
|
395
377
|
var txn = new AssembledTransaction(options);
|
|
396
|
-
txn.built =
|
|
378
|
+
txn.built = _stellarBase.TransactionBuilder.fromXDR(tx, options.networkPassphrase);
|
|
397
379
|
txn.simulationResult = {
|
|
398
380
|
auth: simulationResult.auth.map(function (a) {
|
|
399
|
-
return
|
|
381
|
+
return _stellarBase.xdr.SorobanAuthorizationEntry.fromXDR(a, "base64");
|
|
400
382
|
}),
|
|
401
|
-
retval:
|
|
383
|
+
retval: _stellarBase.xdr.ScVal.fromXDR(simulationResult.retval, "base64")
|
|
402
384
|
};
|
|
403
|
-
txn.simulationTransactionData =
|
|
385
|
+
txn.simulationTransactionData = _stellarBase.xdr.SorobanTransactionData.fromXDR(simulationTransactionData, "base64");
|
|
404
386
|
return txn;
|
|
405
387
|
}
|
|
406
388
|
}, {
|
|
407
389
|
key: "build",
|
|
408
390
|
value: (function () {
|
|
409
|
-
var _build = _asyncToGenerator(_regeneratorRuntime().mark(function
|
|
391
|
+
var _build = _asyncToGenerator(_regeneratorRuntime().mark(function _callee6(options) {
|
|
410
392
|
var _options$fee, _options$args, _options$timeoutInSec;
|
|
411
393
|
var tx, contract, account;
|
|
412
|
-
return _regeneratorRuntime().wrap(function
|
|
413
|
-
while (1) switch (
|
|
394
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
395
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
414
396
|
case 0:
|
|
415
397
|
tx = new AssembledTransaction(options);
|
|
416
|
-
contract = new
|
|
398
|
+
contract = new _stellarBase.Contract(options.contractId);
|
|
417
399
|
if (!options.publicKey) {
|
|
418
|
-
|
|
400
|
+
_context6.next = 8;
|
|
419
401
|
break;
|
|
420
402
|
}
|
|
421
|
-
|
|
403
|
+
_context6.next = 5;
|
|
422
404
|
return tx.server.getAccount(options.publicKey);
|
|
423
405
|
case 5:
|
|
424
|
-
|
|
425
|
-
|
|
406
|
+
_context6.t0 = _context6.sent;
|
|
407
|
+
_context6.next = 9;
|
|
426
408
|
break;
|
|
427
409
|
case 8:
|
|
428
|
-
|
|
410
|
+
_context6.t0 = new _stellarBase.Account(NULL_ACCOUNT, "0");
|
|
429
411
|
case 9:
|
|
430
|
-
account =
|
|
431
|
-
tx.raw = new
|
|
432
|
-
fee: (_options$fee = options.fee) !== null && _options$fee !== void 0 ? _options$fee :
|
|
412
|
+
account = _context6.t0;
|
|
413
|
+
tx.raw = new _stellarBase.TransactionBuilder(account, {
|
|
414
|
+
fee: (_options$fee = options.fee) !== null && _options$fee !== void 0 ? _options$fee : _stellarBase.BASE_FEE,
|
|
433
415
|
networkPassphrase: options.networkPassphrase
|
|
434
416
|
}).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);
|
|
435
417
|
if (!options.simulate) {
|
|
436
|
-
|
|
418
|
+
_context6.next = 14;
|
|
437
419
|
break;
|
|
438
420
|
}
|
|
439
|
-
|
|
421
|
+
_context6.next = 14;
|
|
440
422
|
return tx.simulate();
|
|
441
423
|
case 14:
|
|
442
|
-
return
|
|
424
|
+
return _context6.abrupt("return", tx);
|
|
443
425
|
case 15:
|
|
444
426
|
case "end":
|
|
445
|
-
return
|
|
427
|
+
return _context6.stop();
|
|
446
428
|
}
|
|
447
|
-
},
|
|
429
|
+
}, _callee6);
|
|
448
430
|
}));
|
|
449
431
|
function build(_x2) {
|
|
450
432
|
return _build.apply(this, arguments);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Keypair } from
|
|
1
|
+
import { Keypair } from "@stellar/stellar-base";
|
|
2
2
|
/**
|
|
3
|
-
* For use with {@link
|
|
3
|
+
* For use with {@link Client} and {@link AssembledTransaction}.
|
|
4
4
|
* Implements `signTransaction` and `signAuthEntry` with signatures expected by
|
|
5
5
|
* those classes. This is useful for testing and maybe some simple Node
|
|
6
6
|
* applications. Feel free to use this as a starting point for your own
|
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.basicNodeSigner = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _stellarBase = require("@stellar/stellar-base");
|
|
9
9
|
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; }
|
|
10
|
-
function asyncGeneratorStep(
|
|
11
|
-
function _asyncToGenerator(
|
|
10
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
11
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
12
12
|
var basicNodeSigner = exports.basicNodeSigner = function basicNodeSigner(keypair, networkPassphrase) {
|
|
13
13
|
return {
|
|
14
14
|
signTransaction: function () {
|
|
@@ -17,7 +17,7 @@ var basicNodeSigner = exports.basicNodeSigner = function basicNodeSigner(keypair
|
|
|
17
17
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
18
18
|
while (1) switch (_context.prev = _context.next) {
|
|
19
19
|
case 0:
|
|
20
|
-
t =
|
|
20
|
+
t = _stellarBase.TransactionBuilder.fromXDR(tx, networkPassphrase);
|
|
21
21
|
t.sign(keypair);
|
|
22
22
|
return _context.abrupt("return", t.toXDR());
|
|
23
23
|
case 3:
|
|
@@ -36,7 +36,7 @@ var basicNodeSigner = exports.basicNodeSigner = function basicNodeSigner(keypair
|
|
|
36
36
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
37
37
|
while (1) switch (_context2.prev = _context2.next) {
|
|
38
38
|
case 0:
|
|
39
|
-
return _context2.abrupt("return", keypair.sign((0,
|
|
39
|
+
return _context2.abrupt("return", keypair.sign((0, _stellarBase.hash)(Buffer.from(entryXdr, "base64"))).toString("base64"));
|
|
40
40
|
case 1:
|
|
41
41
|
case "end":
|
|
42
42
|
return _context2.stop();
|