@stellar/stellar-sdk 11.3.0 → 12.0.0-rc.2
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 +24 -0
- package/README.md +1 -1
- package/dist/stellar-sdk.js +292 -53
- package/dist/stellar-sdk.min.js +1 -1
- package/lib/contract_client/assembled_transaction.d.ts +19 -19
- package/lib/contract_client/assembled_transaction.js +19 -8
- package/lib/contract_client/client.d.ts +3 -3
- package/lib/contract_client/client.js +21 -53
- package/lib/contract_client/sent_transaction.d.ts +4 -5
- package/lib/contract_client/sent_transaction.js +18 -12
- package/lib/contract_client/types.d.ts +1 -1
- package/lib/contract_client/types.js +3 -1
- package/lib/contract_client/utils.d.ts +1 -1
- package/lib/contract_client/utils.js +1 -1
- package/lib/contract_spec.js +2 -2
- package/lib/horizon/account_call_builder.d.ts +0 -1
- package/lib/horizon/assets_call_builder.d.ts +0 -1
- package/lib/horizon/claimable_balances_call_builder.d.ts +0 -1
- package/lib/horizon/effect_call_builder.d.ts +0 -1
- package/lib/horizon/friendbot_builder.d.ts +0 -1
- package/lib/horizon/horizon_api.d.ts +0 -1
- package/lib/horizon/ledger_call_builder.d.ts +0 -1
- package/lib/horizon/liquidity_pool_call_builder.d.ts +0 -1
- package/lib/horizon/offer_call_builder.d.ts +0 -1
- package/lib/horizon/operation_call_builder.d.ts +0 -1
- package/lib/horizon/orderbook_call_builder.d.ts +0 -1
- package/lib/horizon/path_call_builder.d.ts +0 -1
- package/lib/horizon/payment_call_builder.d.ts +0 -1
- package/lib/horizon/strict_receive_path_call_builder.d.ts +0 -1
- package/lib/horizon/strict_send_path_call_builder.d.ts +0 -1
- package/lib/horizon/trade_aggregation_call_builder.d.ts +0 -1
- package/lib/horizon/trades_call_builder.d.ts +0 -1
- package/lib/horizon/transaction_call_builder.d.ts +0 -1
- package/lib/index.d.ts +0 -1
- package/lib/soroban/api.d.ts +1 -0
- package/lib/soroban/index.d.ts +0 -1
- package/package.json +5 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import type { AssembledTransactionOptions, ContractClientOptions, Tx, XDR_BASE64 } from "./types";
|
|
3
2
|
import { SorobanRpc, TransactionBuilder, xdr } from "..";
|
|
4
3
|
import { SentTransaction } from "./sent_transaction";
|
|
4
|
+
export declare const NULL_ACCOUNT = "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF";
|
|
5
5
|
/**
|
|
6
6
|
* The main workhorse of {@link ContractClient}. This class is used to wrap a
|
|
7
7
|
* transaction-under-construction and provide high-level interfaces to the most
|
|
@@ -256,72 +256,72 @@ export declare class AssembledTransaction<T> {
|
|
|
256
256
|
*/
|
|
257
257
|
static Errors: {
|
|
258
258
|
ExpiredState: {
|
|
259
|
-
new (message?: string
|
|
259
|
+
new (message?: string): {
|
|
260
260
|
name: string;
|
|
261
261
|
message: string;
|
|
262
262
|
stack?: string | undefined;
|
|
263
263
|
};
|
|
264
|
-
captureStackTrace(targetObject: object, constructorOpt?: Function
|
|
264
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
265
265
|
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
266
266
|
stackTraceLimit: number;
|
|
267
267
|
};
|
|
268
268
|
NeedsMoreSignatures: {
|
|
269
|
-
new (message?: string
|
|
269
|
+
new (message?: string): {
|
|
270
270
|
name: string;
|
|
271
271
|
message: string;
|
|
272
272
|
stack?: string | undefined;
|
|
273
273
|
};
|
|
274
|
-
captureStackTrace(targetObject: object, constructorOpt?: Function
|
|
274
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
275
275
|
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
276
276
|
stackTraceLimit: number;
|
|
277
277
|
};
|
|
278
278
|
NoSignatureNeeded: {
|
|
279
|
-
new (message?: string
|
|
279
|
+
new (message?: string): {
|
|
280
280
|
name: string;
|
|
281
281
|
message: string;
|
|
282
282
|
stack?: string | undefined;
|
|
283
283
|
};
|
|
284
|
-
captureStackTrace(targetObject: object, constructorOpt?: Function
|
|
284
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
285
285
|
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
286
286
|
stackTraceLimit: number;
|
|
287
287
|
};
|
|
288
288
|
NoUnsignedNonInvokerAuthEntries: {
|
|
289
|
-
new (message?: string
|
|
289
|
+
new (message?: string): {
|
|
290
290
|
name: string;
|
|
291
291
|
message: string;
|
|
292
292
|
stack?: string | undefined;
|
|
293
293
|
};
|
|
294
|
-
captureStackTrace(targetObject: object, constructorOpt?: Function
|
|
294
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
295
295
|
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
296
296
|
stackTraceLimit: number;
|
|
297
297
|
};
|
|
298
298
|
NoSigner: {
|
|
299
|
-
new (message?: string
|
|
299
|
+
new (message?: string): {
|
|
300
300
|
name: string;
|
|
301
301
|
message: string;
|
|
302
302
|
stack?: string | undefined;
|
|
303
303
|
};
|
|
304
|
-
captureStackTrace(targetObject: object, constructorOpt?: Function
|
|
304
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
305
305
|
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
306
306
|
stackTraceLimit: number;
|
|
307
307
|
};
|
|
308
308
|
NotYetSimulated: {
|
|
309
|
-
new (message?: string
|
|
309
|
+
new (message?: string): {
|
|
310
310
|
name: string;
|
|
311
311
|
message: string;
|
|
312
312
|
stack?: string | undefined;
|
|
313
313
|
};
|
|
314
|
-
captureStackTrace(targetObject: object, constructorOpt?: Function
|
|
314
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
315
315
|
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
316
316
|
stackTraceLimit: number;
|
|
317
317
|
};
|
|
318
318
|
FakeAccount: {
|
|
319
|
-
new (message?: string
|
|
319
|
+
new (message?: string): {
|
|
320
320
|
name: string;
|
|
321
321
|
message: string;
|
|
322
322
|
stack?: string | undefined;
|
|
323
323
|
};
|
|
324
|
-
captureStackTrace(targetObject: object, constructorOpt?: Function
|
|
324
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
325
325
|
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
326
326
|
stackTraceLimit: number;
|
|
327
327
|
};
|
|
@@ -379,7 +379,7 @@ export declare class AssembledTransaction<T> {
|
|
|
379
379
|
/**
|
|
380
380
|
* If `true`, sign and send the transaction even if it is a read call.
|
|
381
381
|
*/
|
|
382
|
-
force?: boolean
|
|
382
|
+
force?: boolean;
|
|
383
383
|
/**
|
|
384
384
|
* You must provide this here if you did not provide one before
|
|
385
385
|
*/
|
|
@@ -409,7 +409,7 @@ export declare class AssembledTransaction<T> {
|
|
|
409
409
|
/**
|
|
410
410
|
* Whether or not to include auth entries that have already been signed. Default: false
|
|
411
411
|
*/
|
|
412
|
-
includeAlreadySigned?: boolean
|
|
412
|
+
includeAlreadySigned?: boolean;
|
|
413
413
|
}) => Promise<string[]>;
|
|
414
414
|
/**
|
|
415
415
|
* If {@link needsNonInvokerSigningBy} returns a non-empty list, you can serialize
|
|
@@ -433,12 +433,12 @@ export declare class AssembledTransaction<T> {
|
|
|
433
433
|
* contract's current `persistent` storage expiration date/ledger
|
|
434
434
|
* number/block.
|
|
435
435
|
*/
|
|
436
|
-
expiration?: number | Promise<number
|
|
436
|
+
expiration?: number | Promise<number>;
|
|
437
437
|
/**
|
|
438
438
|
* Sign all auth entries for this account. Default: the account that
|
|
439
439
|
* constructed the transaction
|
|
440
440
|
*/
|
|
441
|
-
publicKey?: string
|
|
441
|
+
publicKey?: string;
|
|
442
442
|
/**
|
|
443
443
|
* You must provide this here if you did not provide one before. Default:
|
|
444
444
|
* the `signAuthEntry` function from the `ContractClient` options. Must
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.AssembledTransaction = void 0;
|
|
6
|
+
exports.NULL_ACCOUNT = exports.AssembledTransaction = void 0;
|
|
7
7
|
var _ = require("..");
|
|
8
8
|
var _rust_types = require("../rust_types");
|
|
9
9
|
var _utils = require("./utils");
|
|
@@ -39,6 +39,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
39
39
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
40
40
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
41
41
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
42
|
+
var NULL_ACCOUNT = exports.NULL_ACCOUNT = "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF";
|
|
42
43
|
var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
43
44
|
function AssembledTransaction(options) {
|
|
44
45
|
var _this = this,
|
|
@@ -413,23 +414,33 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
413
414
|
case 0:
|
|
414
415
|
tx = new AssembledTransaction(options);
|
|
415
416
|
contract = new _.Contract(options.contractId);
|
|
416
|
-
|
|
417
|
+
if (!options.publicKey) {
|
|
418
|
+
_context7.next = 8;
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
_context7.next = 5;
|
|
417
422
|
return tx.server.getAccount(options.publicKey);
|
|
418
|
-
case
|
|
419
|
-
|
|
423
|
+
case 5:
|
|
424
|
+
_context7.t0 = _context7.sent;
|
|
425
|
+
_context7.next = 9;
|
|
426
|
+
break;
|
|
427
|
+
case 8:
|
|
428
|
+
_context7.t0 = new _.Account(NULL_ACCOUNT, "0");
|
|
429
|
+
case 9:
|
|
430
|
+
account = _context7.t0;
|
|
420
431
|
tx.raw = new _.TransactionBuilder(account, {
|
|
421
432
|
fee: (_options$fee = options.fee) !== null && _options$fee !== void 0 ? _options$fee : _.BASE_FEE,
|
|
422
433
|
networkPassphrase: options.networkPassphrase
|
|
423
434
|
}).addOperation(contract.call.apply(contract, [options.method].concat(_toConsumableArray((_options$args = options.args) !== null && _options$args !== void 0 ? _options$args : [])))).setTimeout((_options$timeoutInSec = options.timeoutInSeconds) !== null && _options$timeoutInSec !== void 0 ? _options$timeoutInSec : _utils.DEFAULT_TIMEOUT);
|
|
424
435
|
if (!options.simulate) {
|
|
425
|
-
_context7.next =
|
|
436
|
+
_context7.next = 14;
|
|
426
437
|
break;
|
|
427
438
|
}
|
|
428
|
-
_context7.next =
|
|
439
|
+
_context7.next = 14;
|
|
429
440
|
return tx.simulate();
|
|
430
|
-
case
|
|
441
|
+
case 14:
|
|
431
442
|
return _context7.abrupt("return", tx);
|
|
432
|
-
case
|
|
443
|
+
case 15:
|
|
433
444
|
case "end":
|
|
434
445
|
return _context7.stop();
|
|
435
446
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ContractSpec } from
|
|
2
|
-
import { AssembledTransaction } from
|
|
3
|
-
import type { ContractClientOptions } from
|
|
1
|
+
import { ContractSpec } from "..";
|
|
2
|
+
import { AssembledTransaction } from "./assembled_transaction";
|
|
3
|
+
import type { ContractClientOptions } from "./types";
|
|
4
4
|
export declare class ContractClient {
|
|
5
5
|
readonly spec: ContractSpec;
|
|
6
6
|
readonly options: ContractClientOptions;
|
|
@@ -7,16 +7,10 @@ exports.ContractClient = void 0;
|
|
|
7
7
|
var _assembled_transaction = require("./assembled_transaction");
|
|
8
8
|
var _excluded = ["method"];
|
|
9
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
10
|
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
11
|
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
12
|
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
|
|
13
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
|
|
20
14
|
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
15
|
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
16
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
@@ -39,51 +33,25 @@ var ContractClient = exports.ContractClient = _createClass(function ContractClie
|
|
|
39
33
|
});
|
|
40
34
|
this.spec = spec;
|
|
41
35
|
this.options = options;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
}();
|
|
36
|
+
this.spec.funcs().forEach(function (xdrFn) {
|
|
37
|
+
var method = xdrFn.name().toString();
|
|
38
|
+
var assembleTransaction = function assembleTransaction(args, methodOptions) {
|
|
39
|
+
return _assembled_transaction.AssembledTransaction.build(_objectSpread(_objectSpread(_objectSpread({
|
|
40
|
+
method: method,
|
|
41
|
+
args: args && spec.funcArgsToScVals(method, args)
|
|
42
|
+
}, options), methodOptions), {}, {
|
|
43
|
+
errorTypes: spec.errorCases().reduce(function (acc, curr) {
|
|
44
|
+
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, curr.value(), {
|
|
45
|
+
message: curr.doc().toString()
|
|
46
|
+
}));
|
|
47
|
+
}, {}),
|
|
48
|
+
parseResultXdr: function parseResultXdr(result) {
|
|
49
|
+
return spec.funcResToNative(method, result);
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
80
52
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
_iterator.e(err);
|
|
86
|
-
} finally {
|
|
87
|
-
_iterator.f();
|
|
88
|
-
}
|
|
53
|
+
_this[method] = spec.getFunc(method).inputs().length === 0 ? function (opts) {
|
|
54
|
+
return assembleTransaction(undefined, opts);
|
|
55
|
+
} : assembleTransaction;
|
|
56
|
+
});
|
|
89
57
|
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import type { ContractClientOptions, Tx } from "./types";
|
|
3
2
|
import { SorobanRpc } from "..";
|
|
4
3
|
import { AssembledTransaction } from "./assembled_transaction";
|
|
@@ -40,22 +39,22 @@ export declare class SentTransaction<T> {
|
|
|
40
39
|
getTransactionResponse?: SorobanRpc.Api.GetTransactionResponse;
|
|
41
40
|
static Errors: {
|
|
42
41
|
SendFailed: {
|
|
43
|
-
new (message?: string
|
|
42
|
+
new (message?: string): {
|
|
44
43
|
name: string;
|
|
45
44
|
message: string;
|
|
46
45
|
stack?: string | undefined;
|
|
47
46
|
};
|
|
48
|
-
captureStackTrace(targetObject: object, constructorOpt?: Function
|
|
47
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
49
48
|
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
50
49
|
stackTraceLimit: number;
|
|
51
50
|
};
|
|
52
51
|
SendResultOnly: {
|
|
53
|
-
new (message?: string
|
|
52
|
+
new (message?: string): {
|
|
54
53
|
name: string;
|
|
55
54
|
message: string;
|
|
56
55
|
stack?: string | undefined;
|
|
57
56
|
};
|
|
58
|
-
captureStackTrace(targetObject: object, constructorOpt?: Function
|
|
57
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
59
58
|
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
60
59
|
stackTraceLimit: number;
|
|
61
60
|
};
|
|
@@ -29,7 +29,8 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
29
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
30
|
var SentTransaction = exports.SentTransaction = function () {
|
|
31
31
|
function SentTransaction(signTransaction, assembled) {
|
|
32
|
-
var _this = this
|
|
32
|
+
var _this = this,
|
|
33
|
+
_this$assembled$optio2;
|
|
33
34
|
_classCallCheck(this, SentTransaction);
|
|
34
35
|
_defineProperty(this, "send", _asyncToGenerator(_regeneratorRuntime().mark(function _callee() {
|
|
35
36
|
var _this$assembled$optio;
|
|
@@ -38,38 +39,43 @@ var SentTransaction = exports.SentTransaction = function () {
|
|
|
38
39
|
while (1) switch (_context.prev = _context.next) {
|
|
39
40
|
case 0:
|
|
40
41
|
timeoutInSeconds = (_this$assembled$optio = _this.assembled.options.timeoutInSeconds) !== null && _this$assembled$optio !== void 0 ? _this$assembled$optio : _utils.DEFAULT_TIMEOUT;
|
|
41
|
-
|
|
42
|
+
_this.assembled.built = _.TransactionBuilder.cloneFrom(_this.assembled.built, {
|
|
43
|
+
fee: _this.assembled.built.fee,
|
|
44
|
+
timebounds: undefined,
|
|
45
|
+
sorobanData: new _.SorobanDataBuilder(_this.assembled.simulationData.transactionData.toXDR()).build()
|
|
46
|
+
}).setTimeout(timeoutInSeconds).build();
|
|
47
|
+
_context.next = 4;
|
|
42
48
|
return _this.signTransaction(_this.assembled.built.toXDR(), {
|
|
43
49
|
networkPassphrase: _this.assembled.options.networkPassphrase
|
|
44
50
|
});
|
|
45
|
-
case
|
|
51
|
+
case 4:
|
|
46
52
|
signature = _context.sent;
|
|
47
53
|
_this.signed = _.TransactionBuilder.fromXDR(signature, _this.assembled.options.networkPassphrase);
|
|
48
|
-
_context.next =
|
|
54
|
+
_context.next = 8;
|
|
49
55
|
return _this.server.sendTransaction(_this.signed);
|
|
50
|
-
case
|
|
56
|
+
case 8:
|
|
51
57
|
_this.sendTransactionResponse = _context.sent;
|
|
52
58
|
if (!(_this.sendTransactionResponse.status !== "PENDING")) {
|
|
53
|
-
_context.next =
|
|
59
|
+
_context.next = 11;
|
|
54
60
|
break;
|
|
55
61
|
}
|
|
56
|
-
throw new SentTransaction.Errors.SendFailed(
|
|
57
|
-
case
|
|
62
|
+
throw new SentTransaction.Errors.SendFailed("Sending the transaction to the network failed!\n" + JSON.stringify(_this.sendTransactionResponse, null, 2));
|
|
63
|
+
case 11:
|
|
58
64
|
hash = _this.sendTransactionResponse.hash;
|
|
59
|
-
_context.next =
|
|
65
|
+
_context.next = 14;
|
|
60
66
|
return (0, _utils.withExponentialBackoff)(function () {
|
|
61
67
|
return _this.server.getTransaction(hash);
|
|
62
68
|
}, function (resp) {
|
|
63
69
|
return resp.status === _.SorobanRpc.Api.GetTransactionStatus.NOT_FOUND;
|
|
64
70
|
}, timeoutInSeconds);
|
|
65
|
-
case
|
|
71
|
+
case 14:
|
|
66
72
|
_this.getTransactionResponseAll = _context.sent;
|
|
67
73
|
_this.getTransactionResponse = _this.getTransactionResponseAll[_this.getTransactionResponseAll.length - 1];
|
|
68
74
|
if (_this.getTransactionResponse.status === _.SorobanRpc.Api.GetTransactionStatus.NOT_FOUND) {
|
|
69
75
|
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
76
|
}
|
|
71
77
|
return _context.abrupt("return", _this);
|
|
72
|
-
case
|
|
78
|
+
case 18:
|
|
73
79
|
case "end":
|
|
74
80
|
return _context.stop();
|
|
75
81
|
}
|
|
@@ -81,7 +87,7 @@ var SentTransaction = exports.SentTransaction = function () {
|
|
|
81
87
|
throw new Error("You must provide a `signTransaction` function to send a transaction");
|
|
82
88
|
}
|
|
83
89
|
this.server = new _.SorobanRpc.Server(this.assembled.options.rpcUrl, {
|
|
84
|
-
allowHttp: this.assembled.options.
|
|
90
|
+
allowHttp: (_this$assembled$optio2 = this.assembled.options.allowHttp) !== null && _this$assembled$optio2 !== void 0 ? _this$assembled$optio2 : false
|
|
85
91
|
});
|
|
86
92
|
}
|
|
87
93
|
return _createClass(SentTransaction, [{
|
|
@@ -22,7 +22,7 @@ export type ContractClientOptions = {
|
|
|
22
22
|
* {@link AssembledTransaction#signAndSend} and
|
|
23
23
|
* {@link AssembledTransaction#signAuthEntries}.
|
|
24
24
|
*/
|
|
25
|
-
publicKey
|
|
25
|
+
publicKey?: string;
|
|
26
26
|
/**
|
|
27
27
|
* A function to sign the transaction using the private key corresponding to
|
|
28
28
|
* the given `publicKey`. You do not need to provide this, for read-only
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The default timeout for waiting for a transaction to be included in a block.
|
|
3
3
|
*/
|
|
4
|
-
export declare const DEFAULT_TIMEOUT
|
|
4
|
+
export declare const DEFAULT_TIMEOUT: number;
|
|
5
5
|
/**
|
|
6
6
|
* Keep calling a `fn` for `timeoutInSeconds` seconds, if `keepWaitingIf` is true.
|
|
7
7
|
* Returns an array of all attempts to call the function.
|
|
@@ -10,7 +10,7 @@ function _regeneratorRuntime() { "use strict"; _regeneratorRuntime = function _r
|
|
|
10
10
|
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); }
|
|
11
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
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
|
-
var DEFAULT_TIMEOUT = exports.DEFAULT_TIMEOUT =
|
|
13
|
+
var DEFAULT_TIMEOUT = exports.DEFAULT_TIMEOUT = 5 * 60;
|
|
14
14
|
function withExponentialBackoff(_x, _x2, _x3) {
|
|
15
15
|
return _withExponentialBackoff.apply(this, arguments);
|
|
16
16
|
}
|
package/lib/contract_spec.js
CHANGED
|
@@ -224,10 +224,10 @@ var ContractSpec = exports.ContractSpec = function () {
|
|
|
224
224
|
var _res$value = _slicedToArray(res.value, 2),
|
|
225
225
|
k = _res$value[0],
|
|
226
226
|
v = _res$value[1];
|
|
227
|
-
var
|
|
227
|
+
var key = this.nativeToScVal(k, scMap.keyType());
|
|
228
228
|
var _val = this.nativeToScVal(v, scMap.valueType());
|
|
229
229
|
entries.push(new _2.xdr.ScMapEntry({
|
|
230
|
-
key:
|
|
230
|
+
key: key,
|
|
231
231
|
val: _val
|
|
232
232
|
}));
|
|
233
233
|
res = values.next();
|
package/lib/index.d.ts
CHANGED
package/lib/soroban/api.d.ts
CHANGED
package/lib/soroban/index.d.ts
CHANGED