@stellar/stellar-sdk 11.2.2 → 12.0.0-rc.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +1 -1
  3. package/dist/stellar-sdk.js +1566 -1253
  4. package/dist/stellar-sdk.min.js +1 -1
  5. package/lib/browser.js +1 -1
  6. package/lib/config.js +2 -3
  7. package/lib/contract_client/assembled_transaction.d.ts +456 -0
  8. package/lib/contract_client/assembled_transaction.js +513 -0
  9. package/lib/contract_client/basic_node_signer.d.ts +12 -0
  10. package/lib/contract_client/basic_node_signer.js +52 -0
  11. package/lib/contract_client/client.d.ts +17 -0
  12. package/lib/contract_client/client.js +57 -0
  13. package/lib/contract_client/index.d.ts +6 -0
  14. package/lib/contract_client/index.js +71 -0
  15. package/lib/contract_client/sent_transaction.d.ts +71 -0
  16. package/lib/contract_client/sent_transaction.js +148 -0
  17. package/lib/contract_client/types.d.ts +100 -0
  18. package/lib/contract_client/types.js +5 -0
  19. package/lib/contract_client/utils.d.ts +23 -0
  20. package/lib/contract_client/utils.js +95 -0
  21. package/lib/contract_spec.d.ts +7 -0
  22. package/lib/contract_spec.js +15 -6
  23. package/lib/errors.js +7 -8
  24. package/lib/federation/index.js +1 -1
  25. package/lib/federation/server.js +3 -4
  26. package/lib/horizon/account_call_builder.d.ts +0 -1
  27. package/lib/horizon/account_call_builder.js +3 -4
  28. package/lib/horizon/account_response.js +2 -3
  29. package/lib/horizon/assets_call_builder.d.ts +0 -1
  30. package/lib/horizon/assets_call_builder.js +3 -4
  31. package/lib/horizon/call_builder.js +3 -4
  32. package/lib/horizon/claimable_balances_call_builder.d.ts +0 -1
  33. package/lib/horizon/claimable_balances_call_builder.js +3 -4
  34. package/lib/horizon/effect_call_builder.d.ts +0 -1
  35. package/lib/horizon/effect_call_builder.js +3 -4
  36. package/lib/horizon/friendbot_builder.d.ts +0 -1
  37. package/lib/horizon/friendbot_builder.js +2 -2
  38. package/lib/horizon/horizon_api.d.ts +0 -1
  39. package/lib/horizon/index.js +1 -1
  40. package/lib/horizon/ledger_call_builder.d.ts +0 -1
  41. package/lib/horizon/ledger_call_builder.js +3 -4
  42. package/lib/horizon/liquidity_pool_call_builder.d.ts +0 -1
  43. package/lib/horizon/liquidity_pool_call_builder.js +3 -4
  44. package/lib/horizon/offer_call_builder.d.ts +0 -1
  45. package/lib/horizon/offer_call_builder.js +3 -4
  46. package/lib/horizon/operation_call_builder.d.ts +0 -1
  47. package/lib/horizon/operation_call_builder.js +3 -4
  48. package/lib/horizon/orderbook_call_builder.d.ts +0 -1
  49. package/lib/horizon/orderbook_call_builder.js +2 -2
  50. package/lib/horizon/path_call_builder.d.ts +0 -1
  51. package/lib/horizon/path_call_builder.js +2 -2
  52. package/lib/horizon/payment_call_builder.d.ts +0 -1
  53. package/lib/horizon/payment_call_builder.js +3 -4
  54. package/lib/horizon/server.js +4 -5
  55. package/lib/horizon/strict_receive_path_call_builder.d.ts +0 -1
  56. package/lib/horizon/strict_receive_path_call_builder.js +2 -2
  57. package/lib/horizon/strict_send_path_call_builder.d.ts +0 -1
  58. package/lib/horizon/strict_send_path_call_builder.js +2 -2
  59. package/lib/horizon/trade_aggregation_call_builder.d.ts +0 -1
  60. package/lib/horizon/trade_aggregation_call_builder.js +3 -4
  61. package/lib/horizon/trades_call_builder.d.ts +0 -1
  62. package/lib/horizon/trades_call_builder.js +3 -4
  63. package/lib/horizon/transaction_call_builder.d.ts +0 -1
  64. package/lib/horizon/transaction_call_builder.js +3 -4
  65. package/lib/index.d.ts +1 -2
  66. package/lib/index.js +13 -9
  67. package/lib/rust_types/index.d.ts +1 -0
  68. package/lib/rust_types/index.js +16 -0
  69. package/lib/rust_types/result.d.ts +71 -0
  70. package/lib/rust_types/result.js +66 -0
  71. package/lib/soroban/api.d.ts +1 -0
  72. package/lib/soroban/browser.js +1 -1
  73. package/lib/soroban/index.d.ts +0 -1
  74. package/lib/soroban/jsonrpc.d.ts +2 -8
  75. package/lib/soroban/jsonrpc.js +13 -54
  76. package/lib/soroban/parsers.js +1 -1
  77. package/lib/soroban/server.js +18 -13
  78. package/lib/stellartoml/index.js +3 -4
  79. package/lib/utils.js +2 -3
  80. package/lib/webauth/errors.js +2 -2
  81. package/package.json +34 -23
@@ -0,0 +1,513 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NULL_ACCOUNT = exports.AssembledTransaction = void 0;
7
+ var _ = require("..");
8
+ var _rust_types = require("../rust_types");
9
+ var _utils = require("./utils");
10
+ var _sent_transaction = require("./sent_transaction");
11
+ 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(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
13
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
14
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
15
+ function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
16
+ 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
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
18
+ function _isNativeFunction(fn) { try { return Function.toString.call(fn).indexOf("[native code]") !== -1; } catch (e) { return typeof fn === "function"; } }
19
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
20
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
21
+ 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(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
23
+ 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
+ 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(arr) { if (Array.isArray(arr)) return arr; }
26
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
27
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
28
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
29
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
30
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
31
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
32
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
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 asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
35
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
36
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
37
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
38
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
39
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
40
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
41
+ 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
+ var NULL_ACCOUNT = exports.NULL_ACCOUNT = "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF";
43
+ var AssembledTransaction = exports.AssembledTransaction = function () {
44
+ function AssembledTransaction(options) {
45
+ var _this = this,
46
+ _this$options$simulat,
47
+ _this$options$allowHt;
48
+ _classCallCheck(this, AssembledTransaction);
49
+ _defineProperty(this, "simulate", _asyncToGenerator(_regeneratorRuntime().mark(function _callee() {
50
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
51
+ while (1) switch (_context.prev = _context.next) {
52
+ case 0:
53
+ if (_this.raw) {
54
+ _context.next = 2;
55
+ break;
56
+ }
57
+ throw new Error('Transaction has not yet been assembled; ' + 'call `AssembledTransaction.build` first.');
58
+ case 2:
59
+ _this.built = _this.raw.build();
60
+ _context.next = 5;
61
+ return _this.server.simulateTransaction(_this.built);
62
+ case 5:
63
+ _this.simulation = _context.sent;
64
+ if (_.SorobanRpc.Api.isSimulationSuccess(_this.simulation)) {
65
+ _this.built = _.SorobanRpc.assembleTransaction(_this.built, _this.simulation).build();
66
+ }
67
+ return _context.abrupt("return", _this);
68
+ case 8:
69
+ case "end":
70
+ return _context.stop();
71
+ }
72
+ }, _callee);
73
+ })));
74
+ _defineProperty(this, "signAndSend", _asyncToGenerator(_regeneratorRuntime().mark(function _callee2() {
75
+ var _ref3,
76
+ _ref3$force,
77
+ force,
78
+ _ref3$signTransaction,
79
+ signTransaction,
80
+ typeChecked,
81
+ _args2 = arguments;
82
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
83
+ while (1) switch (_context2.prev = _context2.next) {
84
+ case 0:
85
+ _ref3 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, _ref3$force = _ref3.force, force = _ref3$force === void 0 ? false : _ref3$force, _ref3$signTransaction = _ref3.signTransaction, signTransaction = _ref3$signTransaction === void 0 ? _this.options.signTransaction : _ref3$signTransaction;
86
+ if (_this.built) {
87
+ _context2.next = 3;
88
+ break;
89
+ }
90
+ throw new Error("Transaction has not yet been simulated");
91
+ case 3:
92
+ if (!(!force && _this.isReadCall)) {
93
+ _context2.next = 5;
94
+ break;
95
+ }
96
+ throw new AssembledTransaction.Errors.NoSignatureNeeded("This is a read call. It requires no signature or sending. " + "Use `force: true` to sign and send anyway.");
97
+ case 5:
98
+ if (signTransaction) {
99
+ _context2.next = 7;
100
+ break;
101
+ }
102
+ throw new AssembledTransaction.Errors.NoSigner("You must provide a signTransaction function, either when calling " + "`signAndSend` or when initializing your ContractClient");
103
+ case 7:
104
+ _context2.next = 9;
105
+ return _this.needsNonInvokerSigningBy();
106
+ case 9:
107
+ if (!_context2.sent.length) {
108
+ _context2.next = 11;
109
+ break;
110
+ }
111
+ throw new AssembledTransaction.Errors.NeedsMoreSignatures("Transaction requires more signatures. " + "See `needsNonInvokerSigningBy` for details.");
112
+ case 11:
113
+ typeChecked = _this;
114
+ _context2.next = 14;
115
+ return _sent_transaction.SentTransaction.init(signTransaction, typeChecked);
116
+ case 14:
117
+ return _context2.abrupt("return", _context2.sent);
118
+ case 15:
119
+ case "end":
120
+ return _context2.stop();
121
+ }
122
+ }, _callee2);
123
+ })));
124
+ _defineProperty(this, "getStorageExpiration", _asyncToGenerator(_regeneratorRuntime().mark(function _callee3() {
125
+ var entryRes;
126
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
127
+ while (1) switch (_context3.prev = _context3.next) {
128
+ case 0:
129
+ _context3.next = 2;
130
+ return _this.server.getLedgerEntries(new _.Contract(_this.options.contractId).getFootprint());
131
+ case 2:
132
+ entryRes = _context3.sent;
133
+ if (!(!entryRes.entries || !entryRes.entries.length || !entryRes.entries[0].liveUntilLedgerSeq)) {
134
+ _context3.next = 5;
135
+ break;
136
+ }
137
+ throw new Error("failed to get ledger entry");
138
+ case 5:
139
+ return _context3.abrupt("return", entryRes.entries[0].liveUntilLedgerSeq);
140
+ case 6:
141
+ case "end":
142
+ return _context3.stop();
143
+ }
144
+ }, _callee3);
145
+ })));
146
+ _defineProperty(this, "needsNonInvokerSigningBy", _asyncToGenerator(_regeneratorRuntime().mark(function _callee4() {
147
+ var _rawInvokeHostFunctio;
148
+ var _ref6,
149
+ _ref6$includeAlreadyS,
150
+ includeAlreadySigned,
151
+ rawInvokeHostFunctionOp,
152
+ _args4 = arguments;
153
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
154
+ while (1) switch (_context4.prev = _context4.next) {
155
+ case 0:
156
+ _ref6 = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {}, _ref6$includeAlreadyS = _ref6.includeAlreadySigned, includeAlreadySigned = _ref6$includeAlreadyS === void 0 ? false : _ref6$includeAlreadyS;
157
+ if (_this.built) {
158
+ _context4.next = 3;
159
+ break;
160
+ }
161
+ throw new Error("Transaction has not yet been simulated");
162
+ case 3:
163
+ if ("operations" in _this.built) {
164
+ _context4.next = 5;
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() {
182
+ var _rawInvokeHostFunctio2;
183
+ var _ref8,
184
+ _ref8$expiration,
185
+ expiration,
186
+ _ref8$signAuthEntry,
187
+ signAuthEntry,
188
+ _ref8$publicKey,
189
+ publicKey,
190
+ needsNonInvokerSigningBy,
191
+ rawInvokeHostFunctionOp,
192
+ authEntries,
193
+ _iterator,
194
+ _step,
195
+ _step$value,
196
+ i,
197
+ entry,
198
+ pk,
199
+ _args6 = arguments;
200
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
201
+ while (1) switch (_context6.prev = _context6.next) {
202
+ case 0:
203
+ _ref8 = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {}, _ref8$expiration = _ref8.expiration, expiration = _ref8$expiration === void 0 ? _this.getStorageExpiration() : _ref8$expiration, _ref8$signAuthEntry = _ref8.signAuthEntry, signAuthEntry = _ref8$signAuthEntry === void 0 ? _this.options.signAuthEntry : _ref8$signAuthEntry, _ref8$publicKey = _ref8.publicKey, publicKey = _ref8$publicKey === void 0 ? _this.options.publicKey : _ref8$publicKey;
204
+ if (_this.built) {
205
+ _context6.next = 3;
206
+ break;
207
+ }
208
+ throw new Error("Transaction has not yet been assembled or simulated");
209
+ case 3:
210
+ _context6.next = 5;
211
+ return _this.needsNonInvokerSigningBy();
212
+ case 5:
213
+ needsNonInvokerSigningBy = _context6.sent;
214
+ if (needsNonInvokerSigningBy) {
215
+ _context6.next = 8;
216
+ break;
217
+ }
218
+ throw new AssembledTransaction.Errors.NoUnsignedNonInvokerAuthEntries("No unsigned non-invoker auth entries; maybe you already signed?");
219
+ case 8:
220
+ if (!(needsNonInvokerSigningBy.indexOf(publicKey !== null && publicKey !== void 0 ? publicKey : '') === -1)) {
221
+ _context6.next = 10;
222
+ break;
223
+ }
224
+ throw new AssembledTransaction.Errors.NoSignatureNeeded("No auth entries for public key \"".concat(publicKey, "\""));
225
+ case 10:
226
+ if (signAuthEntry) {
227
+ _context6.next = 12;
228
+ break;
229
+ }
230
+ throw new AssembledTransaction.Errors.NoSigner('You must provide `signAuthEntry` when calling `signAuthEntries`, ' + 'or when constructing the `ContractClient` or `AssembledTransaction`');
231
+ case 12:
232
+ rawInvokeHostFunctionOp = _this.built.operations[0];
233
+ authEntries = (_rawInvokeHostFunctio2 = rawInvokeHostFunctionOp.auth) !== null && _rawInvokeHostFunctio2 !== void 0 ? _rawInvokeHostFunctio2 : [];
234
+ _iterator = _createForOfIteratorHelper(authEntries.entries());
235
+ _context6.prev = 15;
236
+ _iterator.s();
237
+ case 17:
238
+ if ((_step = _iterator.n()).done) {
239
+ _context6.next = 36;
240
+ break;
241
+ }
242
+ _step$value = _slicedToArray(_step.value, 2), i = _step$value[0], entry = _step$value[1];
243
+ if (!(entry.credentials().switch() !== _.xdr.SorobanCredentialsType.sorobanCredentialsAddress())) {
244
+ _context6.next = 21;
245
+ break;
246
+ }
247
+ return _context6.abrupt("continue", 34);
248
+ case 21:
249
+ pk = _.StrKey.encodeEd25519PublicKey(entry.credentials().address().address().accountId().ed25519());
250
+ if (!(pk !== publicKey)) {
251
+ _context6.next = 24;
252
+ break;
253
+ }
254
+ return _context6.abrupt("continue", 34);
255
+ case 24:
256
+ _context6.t0 = _.authorizeEntry;
257
+ _context6.t1 = entry;
258
+ _context6.t2 = function () {
259
+ var _ref9 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee5(preimage) {
260
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
261
+ while (1) switch (_context5.prev = _context5.next) {
262
+ case 0:
263
+ _context5.t0 = Buffer;
264
+ _context5.next = 3;
265
+ return signAuthEntry(preimage.toXDR("base64"));
266
+ case 3:
267
+ _context5.t1 = _context5.sent;
268
+ return _context5.abrupt("return", _context5.t0.from.call(_context5.t0, _context5.t1, "base64"));
269
+ case 5:
270
+ case "end":
271
+ return _context5.stop();
272
+ }
273
+ }, _callee5);
274
+ }));
275
+ return function (_x) {
276
+ return _ref9.apply(this, arguments);
277
+ };
278
+ }();
279
+ _context6.next = 29;
280
+ return expiration;
281
+ case 29:
282
+ _context6.t3 = _context6.sent;
283
+ _context6.t4 = _this.options.networkPassphrase;
284
+ _context6.next = 33;
285
+ return (0, _context6.t0)(_context6.t1, _context6.t2, _context6.t3, _context6.t4);
286
+ case 33:
287
+ authEntries[i] = _context6.sent;
288
+ case 34:
289
+ _context6.next = 17;
290
+ break;
291
+ case 36:
292
+ _context6.next = 41;
293
+ break;
294
+ case 38:
295
+ _context6.prev = 38;
296
+ _context6.t5 = _context6["catch"](15);
297
+ _iterator.e(_context6.t5);
298
+ case 41:
299
+ _context6.prev = 41;
300
+ _iterator.f();
301
+ return _context6.finish(41);
302
+ case 44:
303
+ case "end":
304
+ return _context6.stop();
305
+ }
306
+ }, _callee6, null, [[15, 38, 41, 44]]);
307
+ })));
308
+ this.options = options;
309
+ this.options.simulate = (_this$options$simulat = this.options.simulate) !== null && _this$options$simulat !== void 0 ? _this$options$simulat : true;
310
+ this.server = new _.SorobanRpc.Server(this.options.rpcUrl, {
311
+ allowHttp: (_this$options$allowHt = this.options.allowHttp) !== null && _this$options$allowHt !== void 0 ? _this$options$allowHt : false
312
+ });
313
+ }
314
+ return _createClass(AssembledTransaction, [{
315
+ key: "toJSON",
316
+ value: function toJSON() {
317
+ var _this$built;
318
+ return JSON.stringify({
319
+ method: this.options.method,
320
+ tx: (_this$built = this.built) === null || _this$built === void 0 ? void 0 : _this$built.toXDR(),
321
+ simulationResult: {
322
+ auth: this.simulationData.result.auth.map(function (a) {
323
+ return a.toXDR("base64");
324
+ }),
325
+ retval: this.simulationData.result.retval.toXDR("base64")
326
+ },
327
+ simulationTransactionData: this.simulationData.transactionData.toXDR("base64")
328
+ });
329
+ }
330
+ }, {
331
+ key: "simulationData",
332
+ get: function get() {
333
+ if (this.simulationResult && this.simulationTransactionData) {
334
+ return {
335
+ result: this.simulationResult,
336
+ transactionData: this.simulationTransactionData
337
+ };
338
+ }
339
+ var simulation = this.simulation;
340
+ if (!simulation) {
341
+ throw new AssembledTransaction.Errors.NotYetSimulated("Transaction has not yet been simulated");
342
+ }
343
+ if (_.SorobanRpc.Api.isSimulationError(simulation)) {
344
+ throw new Error("Transaction simulation failed: \"".concat(simulation.error, "\""));
345
+ }
346
+ if (_.SorobanRpc.Api.isSimulationRestore(simulation)) {
347
+ 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
+ }
349
+ if (!simulation.result) {
350
+ throw new Error("Expected an invocation simulation, but got no 'result' field. Simulation: ".concat(JSON.stringify(simulation, null, 2)));
351
+ }
352
+ this.simulationResult = simulation.result;
353
+ this.simulationTransactionData = simulation.transactionData.build();
354
+ return {
355
+ result: this.simulationResult,
356
+ transactionData: this.simulationTransactionData
357
+ };
358
+ }
359
+ }, {
360
+ key: "result",
361
+ get: function get() {
362
+ try {
363
+ return this.options.parseResultXdr(this.simulationData.result.retval);
364
+ } catch (e) {
365
+ if (!(0, _utils.implementsToString)(e)) throw e;
366
+ var err = this.parseError(e.toString());
367
+ if (err) return err;
368
+ throw e;
369
+ }
370
+ }
371
+ }, {
372
+ key: "parseError",
373
+ value: function parseError(errorMessage) {
374
+ if (!this.options.errorTypes) return undefined;
375
+ var match = errorMessage.match(_utils.contractErrorPattern);
376
+ if (!match) return undefined;
377
+ var i = parseInt(match[1], 10);
378
+ var err = this.options.errorTypes[i];
379
+ if (!err) return undefined;
380
+ return new _rust_types.Err(err);
381
+ }
382
+ }, {
383
+ key: "isReadCall",
384
+ get: function get() {
385
+ var authsCount = this.simulationData.result.auth.length;
386
+ var writeLength = this.simulationData.transactionData.resources().footprint().readWrite().length;
387
+ return authsCount === 0 && writeLength === 0;
388
+ }
389
+ }], [{
390
+ key: "fromJSON",
391
+ value: function fromJSON(options, _ref10) {
392
+ var tx = _ref10.tx,
393
+ simulationResult = _ref10.simulationResult,
394
+ simulationTransactionData = _ref10.simulationTransactionData;
395
+ var txn = new AssembledTransaction(options);
396
+ txn.built = _.TransactionBuilder.fromXDR(tx, options.networkPassphrase);
397
+ txn.simulationResult = {
398
+ auth: simulationResult.auth.map(function (a) {
399
+ return _.xdr.SorobanAuthorizationEntry.fromXDR(a, "base64");
400
+ }),
401
+ retval: _.xdr.ScVal.fromXDR(simulationResult.retval, "base64")
402
+ };
403
+ txn.simulationTransactionData = _.xdr.SorobanTransactionData.fromXDR(simulationTransactionData, "base64");
404
+ return txn;
405
+ }
406
+ }, {
407
+ key: "build",
408
+ value: (function () {
409
+ var _build = _asyncToGenerator(_regeneratorRuntime().mark(function _callee7(options) {
410
+ var _options$fee, _options$args, _options$timeoutInSec;
411
+ var tx, contract, account;
412
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
413
+ while (1) switch (_context7.prev = _context7.next) {
414
+ case 0:
415
+ tx = new AssembledTransaction(options);
416
+ contract = new _.Contract(options.contractId);
417
+ if (!options.publicKey) {
418
+ _context7.next = 8;
419
+ break;
420
+ }
421
+ _context7.next = 5;
422
+ return tx.server.getAccount(options.publicKey);
423
+ case 5:
424
+ _context7.t0 = _context7.sent;
425
+ _context7.next = 9;
426
+ break;
427
+ case 8:
428
+ _context7.t0 = new _.Account(NULL_ACCOUNT, "0");
429
+ case 9:
430
+ account = _context7.t0;
431
+ tx.raw = new _.TransactionBuilder(account, {
432
+ fee: (_options$fee = options.fee) !== null && _options$fee !== void 0 ? _options$fee : _.BASE_FEE,
433
+ networkPassphrase: options.networkPassphrase
434
+ }).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
+ if (!options.simulate) {
436
+ _context7.next = 14;
437
+ break;
438
+ }
439
+ _context7.next = 14;
440
+ return tx.simulate();
441
+ case 14:
442
+ return _context7.abrupt("return", tx);
443
+ case 15:
444
+ case "end":
445
+ return _context7.stop();
446
+ }
447
+ }, _callee7);
448
+ }));
449
+ function build(_x2) {
450
+ return _build.apply(this, arguments);
451
+ }
452
+ return build;
453
+ }())
454
+ }]);
455
+ }();
456
+ _defineProperty(AssembledTransaction, "Errors", {
457
+ ExpiredState: function (_Error) {
458
+ function ExpiredStateError() {
459
+ _classCallCheck(this, ExpiredStateError);
460
+ return _callSuper(this, ExpiredStateError, arguments);
461
+ }
462
+ _inherits(ExpiredStateError, _Error);
463
+ return _createClass(ExpiredStateError);
464
+ }(_wrapNativeSuper(Error)),
465
+ NeedsMoreSignatures: function (_Error2) {
466
+ function NeedsMoreSignaturesError() {
467
+ _classCallCheck(this, NeedsMoreSignaturesError);
468
+ return _callSuper(this, NeedsMoreSignaturesError, arguments);
469
+ }
470
+ _inherits(NeedsMoreSignaturesError, _Error2);
471
+ return _createClass(NeedsMoreSignaturesError);
472
+ }(_wrapNativeSuper(Error)),
473
+ NoSignatureNeeded: function (_Error3) {
474
+ function NoSignatureNeededError() {
475
+ _classCallCheck(this, NoSignatureNeededError);
476
+ return _callSuper(this, NoSignatureNeededError, arguments);
477
+ }
478
+ _inherits(NoSignatureNeededError, _Error3);
479
+ return _createClass(NoSignatureNeededError);
480
+ }(_wrapNativeSuper(Error)),
481
+ NoUnsignedNonInvokerAuthEntries: function (_Error4) {
482
+ function NoUnsignedNonInvokerAuthEntriesError() {
483
+ _classCallCheck(this, NoUnsignedNonInvokerAuthEntriesError);
484
+ return _callSuper(this, NoUnsignedNonInvokerAuthEntriesError, arguments);
485
+ }
486
+ _inherits(NoUnsignedNonInvokerAuthEntriesError, _Error4);
487
+ return _createClass(NoUnsignedNonInvokerAuthEntriesError);
488
+ }(_wrapNativeSuper(Error)),
489
+ NoSigner: function (_Error5) {
490
+ function NoSignerError() {
491
+ _classCallCheck(this, NoSignerError);
492
+ return _callSuper(this, NoSignerError, arguments);
493
+ }
494
+ _inherits(NoSignerError, _Error5);
495
+ return _createClass(NoSignerError);
496
+ }(_wrapNativeSuper(Error)),
497
+ NotYetSimulated: function (_Error6) {
498
+ function NotYetSimulatedError() {
499
+ _classCallCheck(this, NotYetSimulatedError);
500
+ return _callSuper(this, NotYetSimulatedError, arguments);
501
+ }
502
+ _inherits(NotYetSimulatedError, _Error6);
503
+ return _createClass(NotYetSimulatedError);
504
+ }(_wrapNativeSuper(Error)),
505
+ FakeAccount: function (_Error7) {
506
+ function FakeAccountError() {
507
+ _classCallCheck(this, FakeAccountError);
508
+ return _callSuper(this, FakeAccountError, arguments);
509
+ }
510
+ _inherits(FakeAccountError, _Error7);
511
+ return _createClass(FakeAccountError);
512
+ }(_wrapNativeSuper(Error))
513
+ });
@@ -0,0 +1,12 @@
1
+ import { Keypair } from '..';
2
+ /**
3
+ * For use with {@link ContractClient} and {@link AssembledTransaction}.
4
+ * Implements `signTransaction` and `signAuthEntry` with signatures expected by
5
+ * those classes. This is useful for testing and maybe some simple Node
6
+ * applications. Feel free to use this as a starting point for your own
7
+ * Wallet/TransactionSigner implementation.
8
+ */
9
+ export declare const basicNodeSigner: (keypair: Keypair, networkPassphrase: string) => {
10
+ signTransaction: (tx: string) => Promise<string>;
11
+ signAuthEntry: (entryXdr: string) => Promise<string>;
12
+ };
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ 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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.basicNodeSigner = void 0;
8
+ var _ = require("..");
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(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
11
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
12
+ var basicNodeSigner = exports.basicNodeSigner = function basicNodeSigner(keypair, networkPassphrase) {
13
+ return {
14
+ signTransaction: function () {
15
+ var _signTransaction = _asyncToGenerator(_regeneratorRuntime().mark(function _callee(tx) {
16
+ var t;
17
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
18
+ while (1) switch (_context.prev = _context.next) {
19
+ case 0:
20
+ t = _.TransactionBuilder.fromXDR(tx, networkPassphrase);
21
+ t.sign(keypair);
22
+ return _context.abrupt("return", t.toXDR());
23
+ case 3:
24
+ case "end":
25
+ return _context.stop();
26
+ }
27
+ }, _callee);
28
+ }));
29
+ function signTransaction(_x) {
30
+ return _signTransaction.apply(this, arguments);
31
+ }
32
+ return signTransaction;
33
+ }(),
34
+ signAuthEntry: function () {
35
+ var _signAuthEntry = _asyncToGenerator(_regeneratorRuntime().mark(function _callee2(entryXdr) {
36
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
37
+ while (1) switch (_context2.prev = _context2.next) {
38
+ case 0:
39
+ return _context2.abrupt("return", keypair.sign((0, _.hash)(Buffer.from(entryXdr, "base64"))).toString('base64'));
40
+ case 1:
41
+ case "end":
42
+ return _context2.stop();
43
+ }
44
+ }, _callee2);
45
+ }));
46
+ function signAuthEntry(_x2) {
47
+ return _signAuthEntry.apply(this, arguments);
48
+ }
49
+ return signAuthEntry;
50
+ }()
51
+ };
52
+ };
@@ -0,0 +1,17 @@
1
+ import { ContractSpec } from "..";
2
+ import { AssembledTransaction } from "./assembled_transaction";
3
+ import type { ContractClientOptions } from "./types";
4
+ export declare class ContractClient {
5
+ readonly spec: ContractSpec;
6
+ readonly options: ContractClientOptions;
7
+ /**
8
+ * Generate a class from the contract spec that where each contract method
9
+ * gets included with an identical name.
10
+ *
11
+ * Each method returns an {@link AssembledTransaction} that can be used to
12
+ * modify, simulate, decode results, and possibly sign, & submit the
13
+ * transaction.
14
+ */
15
+ constructor(spec: ContractSpec, options: ContractClientOptions);
16
+ txFromJSON: <T>(json: string) => AssembledTransaction<T>;
17
+ }