@stellar/stellar-sdk 12.0.0 → 12.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +98 -1
- package/README.md +1 -1
- package/dist/stellar-sdk.js +2796 -1194
- package/dist/stellar-sdk.min.js +1 -1
- package/lib/browser.js +1 -1
- package/lib/config.js +3 -3
- package/lib/{contract_client → contract}/assembled_transaction.d.ts +74 -54
- package/lib/{contract_client → contract}/assembled_transaction.js +149 -167
- package/lib/{contract_client → contract}/basic_node_signer.d.ts +2 -2
- package/lib/{contract_client → contract}/basic_node_signer.js +5 -5
- package/lib/contract/client.d.ts +52 -0
- package/lib/contract/client.js +177 -0
- package/lib/contract/index.d.ts +7 -0
- package/lib/{contract_client → contract}/index.js +19 -8
- package/lib/{rust_types/result.js → contract/rust_result.js} +3 -3
- package/lib/{contract_client → contract}/sent_transaction.d.ts +26 -14
- package/lib/{contract_client → contract}/sent_transaction.js +51 -32
- package/lib/{contract_spec.d.ts → contract/spec.d.ts} +3 -3
- package/lib/{contract_spec.js → contract/spec.js} +169 -169
- package/lib/{contract_client → contract}/types.d.ts +10 -8
- package/lib/contract/utils.d.ts +41 -0
- package/lib/{contract_client → contract}/utils.js +15 -5
- package/lib/errors.js +10 -10
- package/lib/federation/server.js +10 -10
- package/lib/horizon/account_call_builder.d.ts +1 -0
- package/lib/horizon/account_call_builder.js +8 -8
- package/lib/horizon/account_response.js +7 -7
- package/lib/horizon/assets_call_builder.d.ts +1 -0
- package/lib/horizon/assets_call_builder.js +8 -8
- package/lib/horizon/call_builder.js +6 -6
- package/lib/horizon/claimable_balances_call_builder.d.ts +1 -0
- package/lib/horizon/claimable_balances_call_builder.js +8 -8
- package/lib/horizon/effect_call_builder.d.ts +1 -0
- package/lib/horizon/effect_call_builder.js +8 -8
- package/lib/horizon/friendbot_builder.d.ts +1 -0
- package/lib/horizon/friendbot_builder.js +8 -8
- package/lib/horizon/horizon_api.d.ts +1 -0
- package/lib/horizon/horizon_axios_client.js +1 -1
- package/lib/horizon/ledger_call_builder.d.ts +1 -0
- package/lib/horizon/ledger_call_builder.js +8 -8
- package/lib/horizon/liquidity_pool_call_builder.d.ts +1 -0
- package/lib/horizon/liquidity_pool_call_builder.js +8 -8
- package/lib/horizon/offer_call_builder.d.ts +1 -0
- package/lib/horizon/offer_call_builder.js +8 -8
- package/lib/horizon/operation_call_builder.d.ts +1 -0
- package/lib/horizon/operation_call_builder.js +8 -8
- package/lib/horizon/orderbook_call_builder.d.ts +1 -0
- package/lib/horizon/orderbook_call_builder.js +8 -8
- package/lib/horizon/path_call_builder.d.ts +1 -0
- package/lib/horizon/path_call_builder.js +8 -8
- package/lib/horizon/payment_call_builder.d.ts +1 -0
- package/lib/horizon/payment_call_builder.js +8 -8
- package/lib/horizon/server.js +6 -6
- package/lib/horizon/strict_receive_path_call_builder.d.ts +1 -0
- package/lib/horizon/strict_receive_path_call_builder.js +8 -8
- package/lib/horizon/strict_send_path_call_builder.d.ts +1 -0
- package/lib/horizon/strict_send_path_call_builder.js +8 -8
- package/lib/horizon/trade_aggregation_call_builder.d.ts +1 -0
- package/lib/horizon/trade_aggregation_call_builder.js +8 -8
- package/lib/horizon/trades_call_builder.d.ts +1 -0
- package/lib/horizon/trades_call_builder.js +8 -8
- package/lib/horizon/transaction_call_builder.d.ts +1 -0
- package/lib/horizon/transaction_call_builder.js +8 -8
- package/lib/index.d.ts +27 -2
- package/lib/index.js +10 -16
- package/lib/{soroban → rpc}/api.d.ts +25 -10
- package/lib/{soroban → rpc}/axios.js +1 -1
- package/lib/{soroban → rpc}/browser.js +1 -1
- package/lib/rpc/index.d.ts +8 -0
- package/lib/{soroban → rpc}/index.js +1 -1
- package/lib/{soroban → rpc}/jsonrpc.js +3 -3
- package/lib/{soroban → rpc}/parsers.js +12 -3
- package/lib/{soroban → rpc}/server.d.ts +50 -0
- package/lib/{soroban → rpc}/server.js +209 -128
- package/lib/stellartoml/index.js +6 -6
- package/lib/utils.js +3 -3
- package/lib/webauth/errors.js +10 -10
- package/lib/webauth/utils.js +9 -9
- package/package.json +32 -15
- package/lib/contract_client/client.d.ts +0 -17
- package/lib/contract_client/client.js +0 -57
- package/lib/contract_client/index.d.ts +0 -6
- package/lib/contract_client/utils.d.ts +0 -23
- package/lib/rust_types/index.d.ts +0 -1
- package/lib/rust_types/index.js +0 -16
- package/lib/soroban/index.d.ts +0 -7
- /package/lib/{rust_types/result.d.ts → contract/rust_result.d.ts} +0 -0
- /package/lib/{contract_client → contract}/types.js +0 -0
- /package/lib/{soroban → rpc}/api.js +0 -0
- /package/lib/{soroban → rpc}/axios.d.ts +0 -0
- /package/lib/{soroban → rpc}/browser.d.ts +0 -0
- /package/lib/{soroban → rpc}/jsonrpc.d.ts +0 -0
- /package/lib/{soroban → rpc}/parsers.d.ts +0 -0
- /package/lib/{soroban → rpc}/transaction.d.ts +0 -0
- /package/lib/{soroban → rpc}/transaction.js +0 -0
- /package/lib/{soroban → rpc}/utils.d.ts +0 -0
- /package/lib/{soroban → rpc}/utils.js +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Spec } from "./spec";
|
|
3
|
+
import { AssembledTransaction } from "./assembled_transaction";
|
|
4
|
+
import type { ClientOptions } from "./types";
|
|
5
|
+
export declare class Client {
|
|
6
|
+
/** {@link Spec} to construct a Client for */
|
|
7
|
+
readonly spec: Spec;
|
|
8
|
+
/** see {@link ClientOptions} */
|
|
9
|
+
readonly options: ClientOptions;
|
|
10
|
+
/**
|
|
11
|
+
* Generate a class from the contract spec that where each contract method
|
|
12
|
+
* gets included with an identical name.
|
|
13
|
+
*
|
|
14
|
+
* Each method returns an {@link AssembledTransaction} that can be used to
|
|
15
|
+
* modify, simulate, decode results, and possibly sign, & submit the
|
|
16
|
+
* transaction.
|
|
17
|
+
*/
|
|
18
|
+
constructor(
|
|
19
|
+
/** {@link Spec} to construct a Client for */
|
|
20
|
+
spec: Spec,
|
|
21
|
+
/** see {@link ClientOptions} */
|
|
22
|
+
options: ClientOptions);
|
|
23
|
+
/**
|
|
24
|
+
* Generates a Client instance from the provided ClientOptions and the contract's wasm hash.
|
|
25
|
+
* The wasmHash can be provided in either hex or base64 format.
|
|
26
|
+
*
|
|
27
|
+
* @param wasmHash The hash of the contract's wasm binary, in either hex or base64 format.
|
|
28
|
+
* @param options The ClientOptions object containing the necessary configuration, including the rpcUrl.
|
|
29
|
+
* @param format The format of the provided wasmHash, either "hex" or "base64". Defaults to "hex".
|
|
30
|
+
* @returns A Promise that resolves to a Client instance.
|
|
31
|
+
* @throws {TypeError} If the provided options object does not contain an rpcUrl.
|
|
32
|
+
*/
|
|
33
|
+
static fromWasmHash(wasmHash: Buffer | string, options: ClientOptions, format?: "hex" | "base64"): Promise<Client>;
|
|
34
|
+
/**
|
|
35
|
+
* Generates a Client instance from the provided ClientOptions and the contract's wasm binary.
|
|
36
|
+
*
|
|
37
|
+
* @param wasm The contract's wasm binary as a Buffer.
|
|
38
|
+
* @param options The ClientOptions object containing the necessary configuration.
|
|
39
|
+
* @returns A Promise that resolves to a Client instance.
|
|
40
|
+
* @throws {Error} If the contract spec cannot be obtained from the provided wasm binary.
|
|
41
|
+
*/
|
|
42
|
+
static fromWasm(wasm: Buffer, options: ClientOptions): Promise<Client>;
|
|
43
|
+
/**
|
|
44
|
+
* Generates a Client instance from the provided ClientOptions, which must include the contractId and rpcUrl.
|
|
45
|
+
*
|
|
46
|
+
* @param options The ClientOptions object containing the necessary configuration, including the contractId and rpcUrl.
|
|
47
|
+
* @returns A Promise that resolves to a Client instance.
|
|
48
|
+
* @throws {TypeError} If the provided options object does not contain both rpcUrl and contractId.
|
|
49
|
+
*/
|
|
50
|
+
static from(options: ClientOptions): Promise<Client>;
|
|
51
|
+
txFromJSON: <T>(json: string) => AssembledTransaction<T>;
|
|
52
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Client = void 0;
|
|
7
|
+
var _spec = require("./spec");
|
|
8
|
+
var _rpc = require("../rpc");
|
|
9
|
+
var _assembled_transaction = require("./assembled_transaction");
|
|
10
|
+
var _utils = require("./utils");
|
|
11
|
+
var _excluded = ["method"];
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
15
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
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(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
19
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
|
|
20
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
21
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
22
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
23
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
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 Client = exports.Client = function () {
|
|
27
|
+
function Client(spec, options) {
|
|
28
|
+
var _this = this;
|
|
29
|
+
_classCallCheck(this, Client);
|
|
30
|
+
_defineProperty(this, "txFromJSON", function (json) {
|
|
31
|
+
var _JSON$parse = JSON.parse(json),
|
|
32
|
+
method = _JSON$parse.method,
|
|
33
|
+
tx = _objectWithoutProperties(_JSON$parse, _excluded);
|
|
34
|
+
return _assembled_transaction.AssembledTransaction.fromJSON(_objectSpread(_objectSpread({}, _this.options), {}, {
|
|
35
|
+
method: method,
|
|
36
|
+
parseResultXdr: function parseResultXdr(result) {
|
|
37
|
+
return _this.spec.funcResToNative(method, result);
|
|
38
|
+
}
|
|
39
|
+
}), tx);
|
|
40
|
+
});
|
|
41
|
+
this.spec = spec;
|
|
42
|
+
this.options = options;
|
|
43
|
+
this.spec.funcs().forEach(function (xdrFn) {
|
|
44
|
+
var method = xdrFn.name().toString();
|
|
45
|
+
var assembleTransaction = function assembleTransaction(args, methodOptions) {
|
|
46
|
+
return _assembled_transaction.AssembledTransaction.build(_objectSpread(_objectSpread(_objectSpread({
|
|
47
|
+
method: method,
|
|
48
|
+
args: args && spec.funcArgsToScVals(method, args)
|
|
49
|
+
}, options), methodOptions), {}, {
|
|
50
|
+
errorTypes: spec.errorCases().reduce(function (acc, curr) {
|
|
51
|
+
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, curr.value(), {
|
|
52
|
+
message: curr.doc().toString()
|
|
53
|
+
}));
|
|
54
|
+
}, {}),
|
|
55
|
+
parseResultXdr: function parseResultXdr(result) {
|
|
56
|
+
return spec.funcResToNative(method, result);
|
|
57
|
+
}
|
|
58
|
+
}));
|
|
59
|
+
};
|
|
60
|
+
_this[method] = spec.getFunc(method).inputs().length === 0 ? function (opts) {
|
|
61
|
+
return assembleTransaction(undefined, opts);
|
|
62
|
+
} : assembleTransaction;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return _createClass(Client, null, [{
|
|
66
|
+
key: "fromWasmHash",
|
|
67
|
+
value: (function () {
|
|
68
|
+
var _fromWasmHash = _asyncToGenerator(_regeneratorRuntime().mark(function _callee(wasmHash, options) {
|
|
69
|
+
var format,
|
|
70
|
+
rpcUrl,
|
|
71
|
+
allowHttp,
|
|
72
|
+
serverOpts,
|
|
73
|
+
server,
|
|
74
|
+
wasm,
|
|
75
|
+
_args = arguments;
|
|
76
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
77
|
+
while (1) switch (_context.prev = _context.next) {
|
|
78
|
+
case 0:
|
|
79
|
+
format = _args.length > 2 && _args[2] !== undefined ? _args[2] : "hex";
|
|
80
|
+
if (!(!options || !options.rpcUrl)) {
|
|
81
|
+
_context.next = 3;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
throw new TypeError('options must contain rpcUrl');
|
|
85
|
+
case 3:
|
|
86
|
+
rpcUrl = options.rpcUrl, allowHttp = options.allowHttp;
|
|
87
|
+
serverOpts = {
|
|
88
|
+
allowHttp: allowHttp
|
|
89
|
+
};
|
|
90
|
+
server = new _rpc.Server(rpcUrl, serverOpts);
|
|
91
|
+
_context.next = 8;
|
|
92
|
+
return server.getContractWasmByHash(wasmHash, format);
|
|
93
|
+
case 8:
|
|
94
|
+
wasm = _context.sent;
|
|
95
|
+
return _context.abrupt("return", Client.fromWasm(wasm, options));
|
|
96
|
+
case 10:
|
|
97
|
+
case "end":
|
|
98
|
+
return _context.stop();
|
|
99
|
+
}
|
|
100
|
+
}, _callee);
|
|
101
|
+
}));
|
|
102
|
+
function fromWasmHash(_x, _x2) {
|
|
103
|
+
return _fromWasmHash.apply(this, arguments);
|
|
104
|
+
}
|
|
105
|
+
return fromWasmHash;
|
|
106
|
+
}())
|
|
107
|
+
}, {
|
|
108
|
+
key: "fromWasm",
|
|
109
|
+
value: (function () {
|
|
110
|
+
var _fromWasm = _asyncToGenerator(_regeneratorRuntime().mark(function _callee2(wasm, options) {
|
|
111
|
+
var wasmModule, xdrSections, bufferSection, specEntryArray, spec;
|
|
112
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
113
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
114
|
+
case 0:
|
|
115
|
+
_context2.next = 2;
|
|
116
|
+
return WebAssembly.compile(wasm);
|
|
117
|
+
case 2:
|
|
118
|
+
wasmModule = _context2.sent;
|
|
119
|
+
xdrSections = WebAssembly.Module.customSections(wasmModule, "contractspecv0");
|
|
120
|
+
if (!(xdrSections.length === 0)) {
|
|
121
|
+
_context2.next = 6;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
throw new Error('Could not obtain contract spec from wasm');
|
|
125
|
+
case 6:
|
|
126
|
+
bufferSection = Buffer.from(xdrSections[0]);
|
|
127
|
+
specEntryArray = (0, _utils.processSpecEntryStream)(bufferSection);
|
|
128
|
+
spec = new _spec.Spec(specEntryArray);
|
|
129
|
+
return _context2.abrupt("return", new Client(spec, options));
|
|
130
|
+
case 10:
|
|
131
|
+
case "end":
|
|
132
|
+
return _context2.stop();
|
|
133
|
+
}
|
|
134
|
+
}, _callee2);
|
|
135
|
+
}));
|
|
136
|
+
function fromWasm(_x3, _x4) {
|
|
137
|
+
return _fromWasm.apply(this, arguments);
|
|
138
|
+
}
|
|
139
|
+
return fromWasm;
|
|
140
|
+
}())
|
|
141
|
+
}, {
|
|
142
|
+
key: "from",
|
|
143
|
+
value: (function () {
|
|
144
|
+
var _from = _asyncToGenerator(_regeneratorRuntime().mark(function _callee3(options) {
|
|
145
|
+
var rpcUrl, contractId, allowHttp, serverOpts, server, wasm;
|
|
146
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
147
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
148
|
+
case 0:
|
|
149
|
+
if (!(!options || !options.rpcUrl || !options.contractId)) {
|
|
150
|
+
_context3.next = 2;
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
throw new TypeError('options must contain rpcUrl and contractId');
|
|
154
|
+
case 2:
|
|
155
|
+
rpcUrl = options.rpcUrl, contractId = options.contractId, allowHttp = options.allowHttp;
|
|
156
|
+
serverOpts = {
|
|
157
|
+
allowHttp: allowHttp
|
|
158
|
+
};
|
|
159
|
+
server = new _rpc.Server(rpcUrl, serverOpts);
|
|
160
|
+
_context3.next = 7;
|
|
161
|
+
return server.getContractWasmByContractId(contractId);
|
|
162
|
+
case 7:
|
|
163
|
+
wasm = _context3.sent;
|
|
164
|
+
return _context3.abrupt("return", Client.fromWasm(wasm, options));
|
|
165
|
+
case 9:
|
|
166
|
+
case "end":
|
|
167
|
+
return _context3.stop();
|
|
168
|
+
}
|
|
169
|
+
}, _callee3);
|
|
170
|
+
}));
|
|
171
|
+
function from(_x5) {
|
|
172
|
+
return _from.apply(this, arguments);
|
|
173
|
+
}
|
|
174
|
+
return from;
|
|
175
|
+
}())
|
|
176
|
+
}]);
|
|
177
|
+
}();
|
|
@@ -36,6 +36,17 @@ Object.keys(_client).forEach(function (key) {
|
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
|
+
var _rust_result = require("./rust_result");
|
|
40
|
+
Object.keys(_rust_result).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _rust_result[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function get() {
|
|
46
|
+
return _rust_result[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
39
50
|
var _sent_transaction = require("./sent_transaction");
|
|
40
51
|
Object.keys(_sent_transaction).forEach(function (key) {
|
|
41
52
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -47,25 +58,25 @@ Object.keys(_sent_transaction).forEach(function (key) {
|
|
|
47
58
|
}
|
|
48
59
|
});
|
|
49
60
|
});
|
|
50
|
-
var
|
|
51
|
-
Object.keys(
|
|
61
|
+
var _spec = require("./spec");
|
|
62
|
+
Object.keys(_spec).forEach(function (key) {
|
|
52
63
|
if (key === "default" || key === "__esModule") return;
|
|
53
|
-
if (key in exports && exports[key] ===
|
|
64
|
+
if (key in exports && exports[key] === _spec[key]) return;
|
|
54
65
|
Object.defineProperty(exports, key, {
|
|
55
66
|
enumerable: true,
|
|
56
67
|
get: function get() {
|
|
57
|
-
return
|
|
68
|
+
return _spec[key];
|
|
58
69
|
}
|
|
59
70
|
});
|
|
60
71
|
});
|
|
61
|
-
var
|
|
62
|
-
Object.keys(
|
|
72
|
+
var _types = require("./types");
|
|
73
|
+
Object.keys(_types).forEach(function (key) {
|
|
63
74
|
if (key === "default" || key === "__esModule") return;
|
|
64
|
-
if (key in exports && exports[key] ===
|
|
75
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
65
76
|
Object.defineProperty(exports, key, {
|
|
66
77
|
enumerable: true,
|
|
67
78
|
get: function get() {
|
|
68
|
-
return
|
|
79
|
+
return _types[key];
|
|
69
80
|
}
|
|
70
81
|
});
|
|
71
82
|
});
|
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Ok = exports.Err = void 0;
|
|
7
7
|
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); }
|
|
8
|
-
function _classCallCheck(
|
|
9
|
-
function _defineProperties(
|
|
10
|
-
function _createClass(
|
|
8
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
9
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
10
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
11
11
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
12
12
|
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); }
|
|
13
13
|
var Ok = exports.Ok = function () {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { ClientOptions, Tx } from "./types";
|
|
3
|
+
import { Server } from "../rpc/server";
|
|
4
|
+
import { Api } from "../rpc/api";
|
|
5
|
+
import type { AssembledTransaction } from "./assembled_transaction";
|
|
4
6
|
/**
|
|
5
7
|
* A transaction that has been sent to the Soroban network. This happens in two steps:
|
|
6
8
|
*
|
|
@@ -16,56 +18,66 @@ import { AssembledTransaction } from "./assembled_transaction";
|
|
|
16
18
|
* `getTransactionResponse`.
|
|
17
19
|
*/
|
|
18
20
|
export declare class SentTransaction<T> {
|
|
19
|
-
signTransaction:
|
|
21
|
+
signTransaction: ClientOptions["signTransaction"];
|
|
20
22
|
assembled: AssembledTransaction<T>;
|
|
21
|
-
server:
|
|
23
|
+
server: Server;
|
|
22
24
|
signed?: Tx;
|
|
23
25
|
/**
|
|
24
26
|
* The result of calling `sendTransaction` to broadcast the transaction to the
|
|
25
27
|
* network.
|
|
26
28
|
*/
|
|
27
|
-
sendTransactionResponse?:
|
|
29
|
+
sendTransactionResponse?: Api.SendTransactionResponse;
|
|
28
30
|
/**
|
|
29
31
|
* If `sendTransaction` completes successfully (which means it has `status: 'PENDING'`),
|
|
30
32
|
* then `getTransaction` will be called in a loop for
|
|
31
33
|
* {@link MethodOptions.timeoutInSeconds} seconds. This array contains all
|
|
32
34
|
* the results of those calls.
|
|
33
35
|
*/
|
|
34
|
-
getTransactionResponseAll?:
|
|
36
|
+
getTransactionResponseAll?: Api.GetTransactionResponse[];
|
|
35
37
|
/**
|
|
36
38
|
* The most recent result of calling `getTransaction`, from the
|
|
37
39
|
* `getTransactionResponseAll` array.
|
|
38
40
|
*/
|
|
39
|
-
getTransactionResponse?:
|
|
41
|
+
getTransactionResponse?: Api.GetTransactionResponse;
|
|
40
42
|
static Errors: {
|
|
41
43
|
SendFailed: {
|
|
42
|
-
new (message?: string): {
|
|
44
|
+
new (message?: string | undefined): {
|
|
43
45
|
name: string;
|
|
44
46
|
message: string;
|
|
45
47
|
stack?: string | undefined;
|
|
46
48
|
};
|
|
47
|
-
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
49
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
|
|
48
50
|
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
49
51
|
stackTraceLimit: number;
|
|
50
52
|
};
|
|
51
53
|
SendResultOnly: {
|
|
52
|
-
new (message?: string): {
|
|
54
|
+
new (message?: string | undefined): {
|
|
53
55
|
name: string;
|
|
54
56
|
message: string;
|
|
55
57
|
stack?: string | undefined;
|
|
56
58
|
};
|
|
57
|
-
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
59
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
|
|
60
|
+
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
61
|
+
stackTraceLimit: number;
|
|
62
|
+
};
|
|
63
|
+
TransactionStillPending: {
|
|
64
|
+
new (message?: string | undefined): {
|
|
65
|
+
name: string;
|
|
66
|
+
message: string;
|
|
67
|
+
stack?: string | undefined;
|
|
68
|
+
};
|
|
69
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
|
|
58
70
|
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
59
71
|
stackTraceLimit: number;
|
|
60
72
|
};
|
|
61
73
|
};
|
|
62
|
-
constructor(signTransaction:
|
|
74
|
+
constructor(signTransaction: ClientOptions["signTransaction"], assembled: AssembledTransaction<T>);
|
|
63
75
|
/**
|
|
64
76
|
* Initialize a `SentTransaction` from an existing `AssembledTransaction` and
|
|
65
77
|
* a `signTransaction` function. This will also send the transaction to the
|
|
66
78
|
* network.
|
|
67
79
|
*/
|
|
68
|
-
static init: <
|
|
80
|
+
static init: <U>(signTransaction: ClientOptions["signTransaction"], assembled: AssembledTransaction<U>) => Promise<SentTransaction<U>>;
|
|
69
81
|
private send;
|
|
70
82
|
get result(): T;
|
|
71
83
|
}
|
|
@@ -4,27 +4,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SentTransaction = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _stellarBase = require("@stellar/stellar-base");
|
|
8
|
+
var _server = require("../rpc/server");
|
|
9
|
+
var _api = require("../rpc/api");
|
|
8
10
|
var _utils = require("./utils");
|
|
9
11
|
var _SentTransaction;
|
|
10
12
|
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(
|
|
12
|
-
function _assertThisInitialized(
|
|
13
|
-
function _inherits(
|
|
14
|
-
function _wrapNativeSuper(
|
|
13
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
14
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
15
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
16
|
+
function _wrapNativeSuper(t) { var r = "function" == typeof Map ? new Map() : void 0; return _wrapNativeSuper = function _wrapNativeSuper(t) { if (null === t || !_isNativeFunction(t)) return t; if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function"); if (void 0 !== r) { if (r.has(t)) return r.get(t); r.set(t, Wrapper); } function Wrapper() { return _construct(t, arguments, _getPrototypeOf(this).constructor); } return Wrapper.prototype = Object.create(t.prototype, { constructor: { value: Wrapper, enumerable: !1, writable: !0, configurable: !0 } }), _setPrototypeOf(Wrapper, t); }, _wrapNativeSuper(t); }
|
|
15
17
|
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
18
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
17
|
-
function _isNativeFunction(
|
|
18
|
-
function _setPrototypeOf(
|
|
19
|
-
function _getPrototypeOf(
|
|
19
|
+
function _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).indexOf("[native code]"); } catch (n) { return "function" == typeof t; } }
|
|
20
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
21
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
20
22
|
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
23
|
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(
|
|
23
|
-
function _asyncToGenerator(
|
|
24
|
-
function _classCallCheck(
|
|
25
|
-
function _defineProperties(
|
|
26
|
-
function _createClass(
|
|
27
|
-
function _defineProperty(
|
|
24
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
25
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
26
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
27
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
28
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
29
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
28
30
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
29
31
|
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
32
|
var SentTransaction = exports.SentTransaction = function () {
|
|
@@ -39,38 +41,46 @@ var SentTransaction = exports.SentTransaction = function () {
|
|
|
39
41
|
while (1) switch (_context.prev = _context.next) {
|
|
40
42
|
case 0:
|
|
41
43
|
timeoutInSeconds = (_this$assembled$optio = _this.assembled.options.timeoutInSeconds) !== null && _this$assembled$optio !== void 0 ? _this$assembled$optio : _utils.DEFAULT_TIMEOUT;
|
|
42
|
-
|
|
44
|
+
_this.assembled.built = _stellarBase.TransactionBuilder.cloneFrom(_this.assembled.built, {
|
|
45
|
+
fee: _this.assembled.built.fee,
|
|
46
|
+
timebounds: undefined,
|
|
47
|
+
sorobanData: new _stellarBase.SorobanDataBuilder(_this.assembled.simulationData.transactionData.toXDR()).build()
|
|
48
|
+
}).setTimeout(timeoutInSeconds).build();
|
|
49
|
+
_context.next = 4;
|
|
43
50
|
return _this.signTransaction(_this.assembled.built.toXDR(), {
|
|
44
51
|
networkPassphrase: _this.assembled.options.networkPassphrase
|
|
45
52
|
});
|
|
46
|
-
case
|
|
53
|
+
case 4:
|
|
47
54
|
signature = _context.sent;
|
|
48
|
-
_this.signed =
|
|
49
|
-
_context.next =
|
|
55
|
+
_this.signed = _stellarBase.TransactionBuilder.fromXDR(signature, _this.assembled.options.networkPassphrase);
|
|
56
|
+
_context.next = 8;
|
|
50
57
|
return _this.server.sendTransaction(_this.signed);
|
|
51
|
-
case
|
|
58
|
+
case 8:
|
|
52
59
|
_this.sendTransactionResponse = _context.sent;
|
|
53
60
|
if (!(_this.sendTransactionResponse.status !== "PENDING")) {
|
|
54
|
-
_context.next =
|
|
61
|
+
_context.next = 11;
|
|
55
62
|
break;
|
|
56
63
|
}
|
|
57
|
-
throw new SentTransaction.Errors.SendFailed("Sending the transaction to the network failed!\n"
|
|
58
|
-
case
|
|
64
|
+
throw new SentTransaction.Errors.SendFailed("Sending the transaction to the network failed!\n".concat(JSON.stringify(_this.sendTransactionResponse, null, 2)));
|
|
65
|
+
case 11:
|
|
59
66
|
hash = _this.sendTransactionResponse.hash;
|
|
60
|
-
_context.next =
|
|
67
|
+
_context.next = 14;
|
|
61
68
|
return (0, _utils.withExponentialBackoff)(function () {
|
|
62
69
|
return _this.server.getTransaction(hash);
|
|
63
70
|
}, function (resp) {
|
|
64
|
-
return resp.status ===
|
|
71
|
+
return resp.status === _api.Api.GetTransactionStatus.NOT_FOUND;
|
|
65
72
|
}, timeoutInSeconds);
|
|
66
|
-
case
|
|
73
|
+
case 14:
|
|
67
74
|
_this.getTransactionResponseAll = _context.sent;
|
|
68
75
|
_this.getTransactionResponse = _this.getTransactionResponseAll[_this.getTransactionResponseAll.length - 1];
|
|
69
|
-
if (_this.getTransactionResponse.status ===
|
|
70
|
-
|
|
76
|
+
if (!(_this.getTransactionResponse.status === _api.Api.GetTransactionStatus.NOT_FOUND)) {
|
|
77
|
+
_context.next = 18;
|
|
78
|
+
break;
|
|
71
79
|
}
|
|
80
|
+
throw new SentTransaction.Errors.TransactionStillPending("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)));
|
|
81
|
+
case 18:
|
|
72
82
|
return _context.abrupt("return", _this);
|
|
73
|
-
case
|
|
83
|
+
case 19:
|
|
74
84
|
case "end":
|
|
75
85
|
return _context.stop();
|
|
76
86
|
}
|
|
@@ -81,7 +91,7 @@ var SentTransaction = exports.SentTransaction = function () {
|
|
|
81
91
|
if (!signTransaction) {
|
|
82
92
|
throw new Error("You must provide a `signTransaction` function to send a transaction");
|
|
83
93
|
}
|
|
84
|
-
this.server = new
|
|
94
|
+
this.server = new _server.Server(this.assembled.options.rpcUrl, {
|
|
85
95
|
allowHttp: (_this$assembled$optio2 = this.assembled.options.allowHttp) !== null && _this$assembled$optio2 !== void 0 ? _this$assembled$optio2 : false
|
|
86
96
|
});
|
|
87
97
|
}
|
|
@@ -123,11 +133,19 @@ _defineProperty(SentTransaction, "Errors", {
|
|
|
123
133
|
}
|
|
124
134
|
_inherits(SendResultOnlyError, _Error2);
|
|
125
135
|
return _createClass(SendResultOnlyError);
|
|
136
|
+
}(_wrapNativeSuper(Error)),
|
|
137
|
+
TransactionStillPending: function (_Error3) {
|
|
138
|
+
function TransactionStillPendingError() {
|
|
139
|
+
_classCallCheck(this, TransactionStillPendingError);
|
|
140
|
+
return _callSuper(this, TransactionStillPendingError, arguments);
|
|
141
|
+
}
|
|
142
|
+
_inherits(TransactionStillPendingError, _Error3);
|
|
143
|
+
return _createClass(TransactionStillPendingError);
|
|
126
144
|
}(_wrapNativeSuper(Error))
|
|
127
145
|
});
|
|
128
146
|
_defineProperty(SentTransaction, "init", function () {
|
|
129
147
|
var _ref2 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee2(signTransaction, assembled) {
|
|
130
|
-
var tx;
|
|
148
|
+
var tx, sent;
|
|
131
149
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
132
150
|
while (1) switch (_context2.prev = _context2.next) {
|
|
133
151
|
case 0:
|
|
@@ -135,8 +153,9 @@ _defineProperty(SentTransaction, "init", function () {
|
|
|
135
153
|
_context2.next = 3;
|
|
136
154
|
return tx.send();
|
|
137
155
|
case 3:
|
|
138
|
-
|
|
139
|
-
|
|
156
|
+
sent = _context2.sent;
|
|
157
|
+
return _context2.abrupt("return", sent);
|
|
158
|
+
case 5:
|
|
140
159
|
case "end":
|
|
141
160
|
return _context2.stop();
|
|
142
161
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { JSONSchema7 } from "json-schema";
|
|
2
|
-
import { xdr } from "
|
|
1
|
+
import type { JSONSchema7 } from "json-schema";
|
|
2
|
+
import { xdr } from "@stellar/stellar-base";
|
|
3
3
|
export interface Union<T> {
|
|
4
4
|
tag: string;
|
|
5
5
|
values?: T;
|
|
@@ -29,7 +29,7 @@ export interface Union<T> {
|
|
|
29
29
|
* console.log(result); // {success: true}
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
|
-
export declare class
|
|
32
|
+
export declare class Spec {
|
|
33
33
|
entries: xdr.ScSpecEntry[];
|
|
34
34
|
/**
|
|
35
35
|
* Constructs a new ContractSpec from an array of XDR spec entries.
|