@stellar/stellar-sdk 11.2.2 → 11.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/stellar-sdk.js +1276 -1202
  3. package/dist/stellar-sdk.min.js +1 -1
  4. package/lib/browser.js +1 -1
  5. package/lib/config.js +2 -3
  6. package/lib/contract_client/assembled_transaction.d.ts +456 -0
  7. package/lib/contract_client/assembled_transaction.js +502 -0
  8. package/lib/contract_client/basic_node_signer.d.ts +12 -0
  9. package/lib/contract_client/basic_node_signer.js +52 -0
  10. package/lib/contract_client/client.d.ts +17 -0
  11. package/lib/contract_client/client.js +89 -0
  12. package/lib/contract_client/index.d.ts +6 -0
  13. package/lib/contract_client/index.js +71 -0
  14. package/lib/contract_client/sent_transaction.d.ts +72 -0
  15. package/lib/contract_client/sent_transaction.js +147 -0
  16. package/lib/contract_client/types.d.ts +100 -0
  17. package/lib/contract_client/types.js +3 -0
  18. package/lib/contract_client/utils.d.ts +23 -0
  19. package/lib/contract_client/utils.js +95 -0
  20. package/lib/contract_spec.d.ts +7 -0
  21. package/lib/contract_spec.js +13 -4
  22. package/lib/errors.js +7 -8
  23. package/lib/federation/index.js +1 -1
  24. package/lib/federation/server.js +3 -4
  25. package/lib/horizon/account_call_builder.js +3 -4
  26. package/lib/horizon/account_response.js +2 -3
  27. package/lib/horizon/assets_call_builder.js +3 -4
  28. package/lib/horizon/call_builder.js +3 -4
  29. package/lib/horizon/claimable_balances_call_builder.js +3 -4
  30. package/lib/horizon/effect_call_builder.js +3 -4
  31. package/lib/horizon/friendbot_builder.js +2 -2
  32. package/lib/horizon/index.js +1 -1
  33. package/lib/horizon/ledger_call_builder.js +3 -4
  34. package/lib/horizon/liquidity_pool_call_builder.js +3 -4
  35. package/lib/horizon/offer_call_builder.js +3 -4
  36. package/lib/horizon/operation_call_builder.js +3 -4
  37. package/lib/horizon/orderbook_call_builder.js +2 -2
  38. package/lib/horizon/path_call_builder.js +2 -2
  39. package/lib/horizon/payment_call_builder.js +3 -4
  40. package/lib/horizon/server.js +4 -5
  41. package/lib/horizon/strict_receive_path_call_builder.js +2 -2
  42. package/lib/horizon/strict_send_path_call_builder.js +2 -2
  43. package/lib/horizon/trade_aggregation_call_builder.js +3 -4
  44. package/lib/horizon/trades_call_builder.js +3 -4
  45. package/lib/horizon/transaction_call_builder.js +3 -4
  46. package/lib/index.d.ts +1 -1
  47. package/lib/index.js +13 -9
  48. package/lib/rust_types/index.d.ts +1 -0
  49. package/lib/rust_types/index.js +16 -0
  50. package/lib/rust_types/result.d.ts +71 -0
  51. package/lib/rust_types/result.js +66 -0
  52. package/lib/soroban/browser.js +1 -1
  53. package/lib/soroban/jsonrpc.d.ts +2 -8
  54. package/lib/soroban/jsonrpc.js +13 -54
  55. package/lib/soroban/parsers.js +1 -1
  56. package/lib/soroban/server.js +18 -13
  57. package/lib/stellartoml/index.js +3 -4
  58. package/lib/utils.js +2 -3
  59. package/lib/webauth/errors.js +2 -2
  60. package/package.json +32 -20
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ContractClient = void 0;
7
+ var _assembled_transaction = require("./assembled_transaction");
8
+ var _excluded = ["method"];
9
+ 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); }
10
+ 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; }
11
+ 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); } }
12
+ 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); }); }; }
13
+ 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; } } }; }
14
+ 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); }
15
+ 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; }
16
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
18
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
19
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
20
+ 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); } }
21
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
22
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
23
+ 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; }
24
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
25
+ 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); }
26
+ var ContractClient = exports.ContractClient = _createClass(function ContractClient(spec, options) {
27
+ var _this = this;
28
+ _classCallCheck(this, ContractClient);
29
+ _defineProperty(this, "txFromJSON", function (json) {
30
+ var _JSON$parse = JSON.parse(json),
31
+ method = _JSON$parse.method,
32
+ tx = _objectWithoutProperties(_JSON$parse, _excluded);
33
+ return _assembled_transaction.AssembledTransaction.fromJSON(_objectSpread(_objectSpread({}, _this.options), {}, {
34
+ method: method,
35
+ parseResultXdr: function parseResultXdr(result) {
36
+ return _this.spec.funcResToNative(method, result);
37
+ }
38
+ }), tx);
39
+ });
40
+ this.spec = spec;
41
+ this.options = options;
42
+ var methods = this.spec.funcs();
43
+ var _iterator = _createForOfIteratorHelper(methods),
44
+ _step;
45
+ try {
46
+ var _loop = function _loop() {
47
+ var method = _step.value;
48
+ var name = method.name().toString();
49
+ _this[name] = function () {
50
+ var _ref = _asyncToGenerator(_regeneratorRuntime().mark(function _callee(args, options) {
51
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
52
+ while (1) switch (_context.prev = _context.next) {
53
+ case 0:
54
+ _context.next = 2;
55
+ return _assembled_transaction.AssembledTransaction.build(_objectSpread(_objectSpread(_objectSpread({
56
+ method: name,
57
+ args: spec.funcArgsToScVals(name, args)
58
+ }, options), _this.options), {}, {
59
+ errorTypes: spec.errorCases().reduce(function (acc, curr) {
60
+ return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, curr.value(), {
61
+ message: curr.doc().toString()
62
+ }));
63
+ }, {}),
64
+ parseResultXdr: function parseResultXdr(result) {
65
+ return spec.funcResToNative(name, result);
66
+ }
67
+ }));
68
+ case 2:
69
+ return _context.abrupt("return", _context.sent);
70
+ case 3:
71
+ case "end":
72
+ return _context.stop();
73
+ }
74
+ }, _callee);
75
+ }));
76
+ return function (_x, _x2) {
77
+ return _ref.apply(this, arguments);
78
+ };
79
+ }();
80
+ };
81
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
82
+ _loop();
83
+ }
84
+ } catch (err) {
85
+ _iterator.e(err);
86
+ } finally {
87
+ _iterator.f();
88
+ }
89
+ });
@@ -0,0 +1,6 @@
1
+ export * from './assembled_transaction';
2
+ export * from './basic_node_signer';
3
+ export * from './client';
4
+ export * from './sent_transaction';
5
+ export * from './types';
6
+ export * from './utils';
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _assembled_transaction = require("./assembled_transaction");
7
+ Object.keys(_assembled_transaction).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _assembled_transaction[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function get() {
13
+ return _assembled_transaction[key];
14
+ }
15
+ });
16
+ });
17
+ var _basic_node_signer = require("./basic_node_signer");
18
+ Object.keys(_basic_node_signer).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _basic_node_signer[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function get() {
24
+ return _basic_node_signer[key];
25
+ }
26
+ });
27
+ });
28
+ var _client = require("./client");
29
+ Object.keys(_client).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _client[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function get() {
35
+ return _client[key];
36
+ }
37
+ });
38
+ });
39
+ var _sent_transaction = require("./sent_transaction");
40
+ Object.keys(_sent_transaction).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _sent_transaction[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function get() {
46
+ return _sent_transaction[key];
47
+ }
48
+ });
49
+ });
50
+ var _types = require("./types");
51
+ Object.keys(_types).forEach(function (key) {
52
+ if (key === "default" || key === "__esModule") return;
53
+ if (key in exports && exports[key] === _types[key]) return;
54
+ Object.defineProperty(exports, key, {
55
+ enumerable: true,
56
+ get: function get() {
57
+ return _types[key];
58
+ }
59
+ });
60
+ });
61
+ var _utils = require("./utils");
62
+ Object.keys(_utils).forEach(function (key) {
63
+ if (key === "default" || key === "__esModule") return;
64
+ if (key in exports && exports[key] === _utils[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function get() {
68
+ return _utils[key];
69
+ }
70
+ });
71
+ });
@@ -0,0 +1,72 @@
1
+ /// <reference types="node" />
2
+ import type { ContractClientOptions, Tx } from "./types";
3
+ import { SorobanRpc } from "..";
4
+ import { AssembledTransaction } from "./assembled_transaction";
5
+ /**
6
+ * A transaction that has been sent to the Soroban network. This happens in two steps:
7
+ *
8
+ * 1. `sendTransaction`: initial submission of the transaction to the network.
9
+ * If this step runs into problems, the attempt to sign and send will be
10
+ * aborted. You can see the result of this call in the
11
+ * `sendTransactionResponse` getter.
12
+ * 2. `getTransaction`: once the transaction has been submitted to the network
13
+ * successfully, you need to wait for it to finalize to get the result of the
14
+ * transaction. This will be retried with exponential backoff for
15
+ * {@link MethodOptions.timeoutInSeconds} seconds. See all attempts in
16
+ * `getTransactionResponseAll` and the most recent attempt in
17
+ * `getTransactionResponse`.
18
+ */
19
+ export declare class SentTransaction<T> {
20
+ signTransaction: ContractClientOptions["signTransaction"];
21
+ assembled: AssembledTransaction<T>;
22
+ server: SorobanRpc.Server;
23
+ signed?: Tx;
24
+ /**
25
+ * The result of calling `sendTransaction` to broadcast the transaction to the
26
+ * network.
27
+ */
28
+ sendTransactionResponse?: SorobanRpc.Api.SendTransactionResponse;
29
+ /**
30
+ * If `sendTransaction` completes successfully (which means it has `status: 'PENDING'`),
31
+ * then `getTransaction` will be called in a loop for
32
+ * {@link MethodOptions.timeoutInSeconds} seconds. This array contains all
33
+ * the results of those calls.
34
+ */
35
+ getTransactionResponseAll?: SorobanRpc.Api.GetTransactionResponse[];
36
+ /**
37
+ * The most recent result of calling `getTransaction`, from the
38
+ * `getTransactionResponseAll` array.
39
+ */
40
+ getTransactionResponse?: SorobanRpc.Api.GetTransactionResponse;
41
+ static Errors: {
42
+ SendFailed: {
43
+ new (message?: string | undefined): {
44
+ name: string;
45
+ message: string;
46
+ stack?: string | undefined;
47
+ };
48
+ captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
49
+ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
50
+ stackTraceLimit: number;
51
+ };
52
+ SendResultOnly: {
53
+ new (message?: string | undefined): {
54
+ name: string;
55
+ message: string;
56
+ stack?: string | undefined;
57
+ };
58
+ captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
59
+ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
60
+ stackTraceLimit: number;
61
+ };
62
+ };
63
+ constructor(signTransaction: ContractClientOptions["signTransaction"], assembled: AssembledTransaction<T>);
64
+ /**
65
+ * Initialize a `SentTransaction` from an existing `AssembledTransaction` and
66
+ * a `signTransaction` function. This will also send the transaction to the
67
+ * network.
68
+ */
69
+ static init: <T_1>(signTransaction: ContractClientOptions["signTransaction"], assembled: AssembledTransaction<T_1>) => Promise<SentTransaction<T_1>>;
70
+ private send;
71
+ get result(): T;
72
+ }
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SentTransaction = void 0;
7
+ var _ = require("..");
8
+ var _utils = require("./utils");
9
+ var _SentTransaction;
10
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
11
+ 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); }
12
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
13
+ 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); }
14
+ 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); }
15
+ 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; }
16
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
17
+ function _isNativeFunction(fn) { try { return Function.toString.call(fn).indexOf("[native code]") !== -1; } catch (e) { return typeof fn === "function"; } }
18
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
19
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
20
+ 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); }
21
+ 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; }
22
+ 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); } }
23
+ 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); }); }; }
24
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25
+ 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); } }
26
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
27
+ 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; }
28
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
29
+ 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); }
30
+ var SentTransaction = exports.SentTransaction = function () {
31
+ function SentTransaction(signTransaction, assembled) {
32
+ var _this = this;
33
+ _classCallCheck(this, SentTransaction);
34
+ _defineProperty(this, "send", _asyncToGenerator(_regeneratorRuntime().mark(function _callee() {
35
+ var _this$assembled$optio;
36
+ var timeoutInSeconds, signature, hash;
37
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
38
+ while (1) switch (_context.prev = _context.next) {
39
+ case 0:
40
+ timeoutInSeconds = (_this$assembled$optio = _this.assembled.options.timeoutInSeconds) !== null && _this$assembled$optio !== void 0 ? _this$assembled$optio : _utils.DEFAULT_TIMEOUT;
41
+ _context.next = 3;
42
+ return _this.signTransaction(_this.assembled.built.toXDR(), {
43
+ networkPassphrase: _this.assembled.options.networkPassphrase
44
+ });
45
+ case 3:
46
+ signature = _context.sent;
47
+ _this.signed = _.TransactionBuilder.fromXDR(signature, _this.assembled.options.networkPassphrase);
48
+ _context.next = 7;
49
+ return _this.server.sendTransaction(_this.signed);
50
+ case 7:
51
+ _this.sendTransactionResponse = _context.sent;
52
+ if (!(_this.sendTransactionResponse.status !== "PENDING")) {
53
+ _context.next = 10;
54
+ break;
55
+ }
56
+ throw new SentTransaction.Errors.SendFailed('Sending the transaction to the network failed!\n' + JSON.stringify(_this.sendTransactionResponse, null, 2));
57
+ case 10:
58
+ hash = _this.sendTransactionResponse.hash;
59
+ _context.next = 13;
60
+ return (0, _utils.withExponentialBackoff)(function () {
61
+ return _this.server.getTransaction(hash);
62
+ }, function (resp) {
63
+ return resp.status === _.SorobanRpc.Api.GetTransactionStatus.NOT_FOUND;
64
+ }, timeoutInSeconds);
65
+ case 13:
66
+ _this.getTransactionResponseAll = _context.sent;
67
+ _this.getTransactionResponse = _this.getTransactionResponseAll[_this.getTransactionResponseAll.length - 1];
68
+ if (_this.getTransactionResponse.status === _.SorobanRpc.Api.GetTransactionStatus.NOT_FOUND) {
69
+ console.error("Waited ".concat(timeoutInSeconds, " seconds for transaction to complete, but it did not. ") + "Returning anyway. Check the transaction status manually. " + "Sent transaction: ".concat(JSON.stringify(_this.sendTransactionResponse, null, 2), "\n") + "All attempts to get the result: ".concat(JSON.stringify(_this.getTransactionResponseAll, null, 2)));
70
+ }
71
+ return _context.abrupt("return", _this);
72
+ case 17:
73
+ case "end":
74
+ return _context.stop();
75
+ }
76
+ }, _callee);
77
+ })));
78
+ this.signTransaction = signTransaction;
79
+ this.assembled = assembled;
80
+ if (!signTransaction) {
81
+ throw new Error("You must provide a `signTransaction` function to send a transaction");
82
+ }
83
+ this.server = new _.SorobanRpc.Server(this.assembled.options.rpcUrl, {
84
+ allowHttp: this.assembled.options.rpcUrl.startsWith("http://")
85
+ });
86
+ }
87
+ return _createClass(SentTransaction, [{
88
+ key: "result",
89
+ get: function get() {
90
+ if ("getTransactionResponse" in this && this.getTransactionResponse) {
91
+ if ("returnValue" in this.getTransactionResponse) {
92
+ return this.assembled.options.parseResultXdr(this.getTransactionResponse.returnValue);
93
+ }
94
+ throw new Error("Transaction failed! Cannot parse result.");
95
+ }
96
+ if (this.sendTransactionResponse) {
97
+ var _this$sendTransaction;
98
+ var errorResult = (_this$sendTransaction = this.sendTransactionResponse.errorResult) === null || _this$sendTransaction === void 0 ? void 0 : _this$sendTransaction.result();
99
+ if (errorResult) {
100
+ throw new SentTransaction.Errors.SendFailed("Transaction simulation looked correct, but attempting to send the transaction failed. Check `simulation` and `sendTransactionResponseAll` to troubleshoot. Decoded `sendTransactionResponse.errorResultXdr`: ".concat(errorResult));
101
+ }
102
+ throw new SentTransaction.Errors.SendResultOnly("Transaction was sent to the network, but not yet awaited. No result to show. Await transaction completion with `getTransaction(sendTransactionResponse.hash)`");
103
+ }
104
+ throw new Error("Sending transaction failed: ".concat(JSON.stringify(this.assembled)));
105
+ }
106
+ }]);
107
+ }();
108
+ _SentTransaction = SentTransaction;
109
+ _defineProperty(SentTransaction, "Errors", {
110
+ SendFailed: function (_Error) {
111
+ function SendFailedError() {
112
+ _classCallCheck(this, SendFailedError);
113
+ return _callSuper(this, SendFailedError, arguments);
114
+ }
115
+ _inherits(SendFailedError, _Error);
116
+ return _createClass(SendFailedError);
117
+ }(_wrapNativeSuper(Error)),
118
+ SendResultOnly: function (_Error2) {
119
+ function SendResultOnlyError() {
120
+ _classCallCheck(this, SendResultOnlyError);
121
+ return _callSuper(this, SendResultOnlyError, arguments);
122
+ }
123
+ _inherits(SendResultOnlyError, _Error2);
124
+ return _createClass(SendResultOnlyError);
125
+ }(_wrapNativeSuper(Error))
126
+ });
127
+ _defineProperty(SentTransaction, "init", function () {
128
+ var _ref2 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee2(signTransaction, assembled) {
129
+ var tx;
130
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
131
+ while (1) switch (_context2.prev = _context2.next) {
132
+ case 0:
133
+ tx = new _SentTransaction(signTransaction, assembled);
134
+ _context2.next = 3;
135
+ return tx.send();
136
+ case 3:
137
+ return _context2.abrupt("return", _context2.sent);
138
+ case 4:
139
+ case "end":
140
+ return _context2.stop();
141
+ }
142
+ }, _callee2);
143
+ }));
144
+ return function (_x, _x2) {
145
+ return _ref2.apply(this, arguments);
146
+ };
147
+ }());
@@ -0,0 +1,100 @@
1
+ import { Memo, MemoType, Operation, Transaction, xdr } from "..";
2
+ export type XDR_BASE64 = string;
3
+ export type u32 = number;
4
+ export type i32 = number;
5
+ export type u64 = bigint;
6
+ export type i64 = bigint;
7
+ export type u128 = bigint;
8
+ export type i128 = bigint;
9
+ export type u256 = bigint;
10
+ export type i256 = bigint;
11
+ export type Option<T> = T | undefined;
12
+ export type Typepoint = bigint;
13
+ export type Duration = bigint;
14
+ /**
15
+ * A "regular" transaction, as opposed to a FeeBumpTransaction.
16
+ */
17
+ export type Tx = Transaction<Memo<MemoType>, Operation[]>;
18
+ export type ContractClientOptions = {
19
+ /**
20
+ * The public key of the account that will send this transaction. You can
21
+ * override this for specific methods later, like
22
+ * {@link AssembledTransaction#signAndSend} and
23
+ * {@link AssembledTransaction#signAuthEntries}.
24
+ */
25
+ publicKey: string;
26
+ /**
27
+ * A function to sign the transaction using the private key corresponding to
28
+ * the given `publicKey`. You do not need to provide this, for read-only
29
+ * calls, which only need to be simulated. If you do not need to sign and
30
+ * send, there is no need to provide this. If you do not provide it during
31
+ * initialization, you can provide it later when you call
32
+ * {@link AssembledTransaction#signAndSend}.
33
+ *
34
+ * Matches signature of `signTransaction` from Freighter.
35
+ */
36
+ signTransaction?: (tx: XDR_BASE64, opts?: {
37
+ network?: string;
38
+ networkPassphrase?: string;
39
+ accountToSign?: string;
40
+ }) => Promise<XDR_BASE64>;
41
+ /**
42
+ * A function to sign a specific auth entry for a transaction, using the
43
+ * private key corresponding to the provided `publicKey`. This is only needed
44
+ * for multi-auth transactions, in which one transaction is signed by
45
+ * multiple parties. If you do not provide it during initialization, you can
46
+ * provide it later when you call {@link AssembledTransaction#signAuthEntries}.
47
+ *
48
+ * Matches signature of `signAuthEntry` from Freighter.
49
+ */
50
+ signAuthEntry?: (entryXdr: XDR_BASE64, opts?: {
51
+ accountToSign?: string;
52
+ }) => Promise<XDR_BASE64>;
53
+ contractId: string;
54
+ networkPassphrase: string;
55
+ rpcUrl: string;
56
+ /**
57
+ * If true, will allow HTTP requests to the Soroban network. If false, will
58
+ * only allow HTTPS requests. @default false
59
+ */
60
+ allowHttp?: boolean;
61
+ /**
62
+ * This gets filled in automatically from the ContractSpec if you use
63
+ * {@link ContractClient.generate} to create your ContractClient.
64
+ *
65
+ * Background: If the contract you're calling uses the `#[contracterror]`
66
+ * macro to create an `Error` enum, then those errors get included in the
67
+ * on-chain XDR that also describes your contract's methods. Each error will
68
+ * have a specific number.
69
+ *
70
+ * A ContractClient makes method calls with an {@link AssembledTransaction}.
71
+ * When one of these method calls encounters an error, `AssembledTransaction`
72
+ * will first attempt to parse the error as an "official" `contracterror`
73
+ * error, by using this passed-in `errorTypes` object. See
74
+ * {@link AssembledTransaction#parseError}. If `errorTypes` is blank or no
75
+ * matching error is found, then it will throw the raw error.
76
+ * @default {}
77
+ */
78
+ errorTypes?: Record<number, {
79
+ message: string;
80
+ }>;
81
+ };
82
+ export type MethodOptions = {
83
+ /**
84
+ * The fee to pay for the transaction. Default: {@link BASE_FEE}
85
+ */
86
+ fee?: string;
87
+ /**
88
+ * The maximum amount of time to wait for the transaction to complete. Default: {@link DEFAULT_TIMEOUT}
89
+ */
90
+ timeoutInSeconds?: number;
91
+ /**
92
+ * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
93
+ */
94
+ simulate?: boolean;
95
+ };
96
+ export type AssembledTransactionOptions<T = string> = MethodOptions & ContractClientOptions & {
97
+ method: string;
98
+ args?: any[];
99
+ parseResultXdr: (xdr: xdr.ScVal) => T;
100
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ var _ = require("..");
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The default timeout for waiting for a transaction to be included in a block.
3
+ */
4
+ export declare const DEFAULT_TIMEOUT = 10;
5
+ /**
6
+ * Keep calling a `fn` for `timeoutInSeconds` seconds, if `keepWaitingIf` is true.
7
+ * Returns an array of all attempts to call the function.
8
+ */
9
+ export declare function withExponentialBackoff<T>(fn: (previousFailure?: T) => Promise<T>, keepWaitingIf: (result: T) => boolean, timeoutInSeconds: number, exponentialFactor?: number, verbose?: boolean): Promise<T[]>;
10
+ /**
11
+ * If contracts are implemented using the `#[contracterror]` macro, then the
12
+ * errors get included in the on-chain XDR that also describes your contract's
13
+ * methods. Each error will have a specific number. This Regular Expression
14
+ * matches these "expected error types" that a contract may throw, and helps
15
+ * @{link AssembledTransaction} parse these errors.
16
+ */
17
+ export declare const contractErrorPattern: RegExp;
18
+ /**
19
+ * A TypeScript type guard that checks if an object has a `toString` method.
20
+ */
21
+ export declare function implementsToString(obj: unknown): obj is {
22
+ toString(): string;
23
+ };