@stellar/stellar-sdk 14.0.0-rc.3 → 14.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +140 -1
- package/dist/stellar-sdk-minimal.js +293 -177
- package/dist/stellar-sdk-minimal.min.js +1 -1
- package/dist/stellar-sdk-no-axios.js +293 -177
- package/dist/stellar-sdk-no-axios.min.js +1 -1
- package/dist/stellar-sdk-no-eventsource.js +338 -185
- package/dist/stellar-sdk-no-eventsource.min.js +1 -1
- package/dist/stellar-sdk.js +338 -185
- package/dist/stellar-sdk.min.js +1 -1
- package/lib/contract/assembled_transaction.d.ts +15 -5
- package/lib/contract/assembled_transaction.js +25 -26
- package/lib/contract/basic_node_signer.js +1 -1
- package/lib/contract/client.d.ts +2 -0
- package/lib/contract/client.js +18 -48
- package/lib/contract/sent_transaction.d.ts +16 -3
- package/lib/contract/sent_transaction.js +70 -50
- package/lib/contract/spec.d.ts +20 -1
- package/lib/contract/spec.js +42 -13
- package/lib/contract/utils.d.ts +1 -0
- package/lib/contract/utils.js +99 -15
- package/lib/federation/server.js +1 -1
- package/lib/horizon/account_response.d.ts +3 -0
- package/lib/horizon/call_builder.js +1 -1
- package/lib/horizon/horizon_api.d.ts +0 -2
- package/lib/horizon/horizon_axios_client.js +1 -1
- package/lib/horizon/payment_call_builder.d.ts +8 -0
- package/lib/horizon/payment_call_builder.js +6 -0
- package/lib/horizon/server.js +10 -3
- package/lib/minimal/contract/assembled_transaction.d.ts +15 -5
- package/lib/minimal/contract/assembled_transaction.js +25 -26
- package/lib/minimal/contract/basic_node_signer.js +1 -1
- package/lib/minimal/contract/client.d.ts +2 -0
- package/lib/minimal/contract/client.js +18 -48
- package/lib/minimal/contract/sent_transaction.d.ts +16 -3
- package/lib/minimal/contract/sent_transaction.js +70 -50
- package/lib/minimal/contract/spec.d.ts +20 -1
- package/lib/minimal/contract/spec.js +42 -13
- package/lib/minimal/contract/utils.d.ts +1 -0
- package/lib/minimal/contract/utils.js +99 -15
- package/lib/minimal/federation/server.js +1 -1
- package/lib/minimal/horizon/account_response.d.ts +3 -0
- package/lib/minimal/horizon/call_builder.js +1 -1
- package/lib/minimal/horizon/horizon_api.d.ts +0 -2
- package/lib/minimal/horizon/horizon_axios_client.js +1 -1
- package/lib/minimal/horizon/payment_call_builder.d.ts +8 -0
- package/lib/minimal/horizon/payment_call_builder.js +6 -0
- package/lib/minimal/horizon/server.js +10 -3
- package/lib/minimal/rpc/api.d.ts +1 -1
- package/lib/minimal/rpc/axios.js +1 -1
- package/lib/minimal/rpc/jsonrpc.js +1 -1
- package/lib/minimal/rpc/server.js +2 -2
- package/lib/minimal/stellartoml/index.js +1 -1
- package/lib/no-axios/contract/assembled_transaction.d.ts +15 -5
- package/lib/no-axios/contract/assembled_transaction.js +25 -26
- package/lib/no-axios/contract/basic_node_signer.js +1 -1
- package/lib/no-axios/contract/client.d.ts +2 -0
- package/lib/no-axios/contract/client.js +18 -48
- package/lib/no-axios/contract/sent_transaction.d.ts +16 -3
- package/lib/no-axios/contract/sent_transaction.js +70 -50
- package/lib/no-axios/contract/spec.d.ts +20 -1
- package/lib/no-axios/contract/spec.js +42 -13
- package/lib/no-axios/contract/utils.d.ts +1 -0
- package/lib/no-axios/contract/utils.js +99 -15
- package/lib/no-axios/federation/server.js +1 -1
- package/lib/no-axios/horizon/account_response.d.ts +3 -0
- package/lib/no-axios/horizon/call_builder.js +1 -1
- package/lib/no-axios/horizon/horizon_api.d.ts +0 -2
- package/lib/no-axios/horizon/horizon_axios_client.js +1 -1
- package/lib/no-axios/horizon/payment_call_builder.d.ts +8 -0
- package/lib/no-axios/horizon/payment_call_builder.js +6 -0
- package/lib/no-axios/horizon/server.js +10 -3
- package/lib/no-axios/rpc/api.d.ts +1 -1
- package/lib/no-axios/rpc/axios.js +1 -1
- package/lib/no-axios/rpc/jsonrpc.js +1 -1
- package/lib/no-axios/rpc/server.js +2 -2
- package/lib/no-axios/stellartoml/index.js +1 -1
- package/lib/no-eventsource/contract/assembled_transaction.d.ts +15 -5
- package/lib/no-eventsource/contract/assembled_transaction.js +25 -26
- package/lib/no-eventsource/contract/basic_node_signer.js +1 -1
- package/lib/no-eventsource/contract/client.d.ts +2 -0
- package/lib/no-eventsource/contract/client.js +18 -48
- package/lib/no-eventsource/contract/sent_transaction.d.ts +16 -3
- package/lib/no-eventsource/contract/sent_transaction.js +70 -50
- package/lib/no-eventsource/contract/spec.d.ts +20 -1
- package/lib/no-eventsource/contract/spec.js +42 -13
- package/lib/no-eventsource/contract/utils.d.ts +1 -0
- package/lib/no-eventsource/contract/utils.js +99 -15
- package/lib/no-eventsource/federation/server.js +1 -1
- package/lib/no-eventsource/horizon/account_response.d.ts +3 -0
- package/lib/no-eventsource/horizon/call_builder.js +1 -1
- package/lib/no-eventsource/horizon/horizon_api.d.ts +0 -2
- package/lib/no-eventsource/horizon/horizon_axios_client.js +1 -1
- package/lib/no-eventsource/horizon/payment_call_builder.d.ts +8 -0
- package/lib/no-eventsource/horizon/payment_call_builder.js +6 -0
- package/lib/no-eventsource/horizon/server.js +10 -3
- package/lib/no-eventsource/rpc/api.d.ts +1 -1
- package/lib/no-eventsource/rpc/axios.js +1 -1
- package/lib/no-eventsource/rpc/jsonrpc.js +1 -1
- package/lib/no-eventsource/rpc/server.js +2 -2
- package/lib/no-eventsource/stellartoml/index.js +1 -1
- package/lib/rpc/api.d.ts +1 -1
- package/lib/rpc/axios.js +1 -1
- package/lib/rpc/jsonrpc.js +1 -1
- package/lib/rpc/server.js +2 -2
- package/lib/stellartoml/index.js +1 -1
- package/package.json +5 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Account, SorobanDataBuilder, TransactionBuilder, authorizeEntry as stellarBaseAuthorizeEntry, xdr } from "@stellar/stellar-base";
|
|
2
2
|
import type { AssembledTransactionOptions, ClientOptions, Tx, XDR_BASE64 } from "./types";
|
|
3
3
|
import { Api } from "../rpc/api";
|
|
4
|
-
import { SentTransaction } from "./sent_transaction";
|
|
4
|
+
import { SentTransaction, Watcher } from "./sent_transaction";
|
|
5
5
|
import { Spec } from "./spec";
|
|
6
6
|
/** @module contract */
|
|
7
7
|
/**
|
|
@@ -502,16 +502,20 @@ export declare class AssembledTransaction<T> {
|
|
|
502
502
|
}) => Promise<void>;
|
|
503
503
|
/**
|
|
504
504
|
* Sends the transaction to the network to return a `SentTransaction` that
|
|
505
|
-
* keeps track of all the attempts to fetch the transaction.
|
|
505
|
+
* keeps track of all the attempts to fetch the transaction. Optionally pass
|
|
506
|
+
* a {@link Watcher} that allows you to keep track of the progress as the
|
|
507
|
+
* transaction is sent and processed.
|
|
506
508
|
*/
|
|
507
|
-
send(): Promise<SentTransaction<T>>;
|
|
509
|
+
send(watcher?: Watcher): Promise<SentTransaction<T>>;
|
|
508
510
|
/**
|
|
509
511
|
* Sign the transaction with the `signTransaction` function included previously.
|
|
510
512
|
* If you did not previously include one, you need to include one now.
|
|
511
513
|
* After signing, this method will send the transaction to the network and
|
|
512
|
-
* return a `SentTransaction` that keeps track
|
|
514
|
+
* return a `SentTransaction` that keeps track of all the attempts to fetch
|
|
515
|
+
* the transaction. You may pass a {@link Watcher} to keep
|
|
516
|
+
* track of this progress.
|
|
513
517
|
*/
|
|
514
|
-
signAndSend: ({ force, signTransaction, }?: {
|
|
518
|
+
signAndSend: ({ force, signTransaction, watcher, }?: {
|
|
515
519
|
/**
|
|
516
520
|
* If `true`, sign and send the transaction even if it is a read call
|
|
517
521
|
*/
|
|
@@ -520,6 +524,12 @@ export declare class AssembledTransaction<T> {
|
|
|
520
524
|
* You must provide this here if you did not provide one before
|
|
521
525
|
*/
|
|
522
526
|
signTransaction?: ClientOptions["signTransaction"];
|
|
527
|
+
/**
|
|
528
|
+
* A {@link Watcher} to notify after the transaction is successfully
|
|
529
|
+
* submitted to the network (`onSubmitted`) and as the transaction is
|
|
530
|
+
* processed (`onProgress`).
|
|
531
|
+
*/
|
|
532
|
+
watcher?: Watcher;
|
|
523
533
|
}) => Promise<SentTransaction<T>>;
|
|
524
534
|
/**
|
|
525
535
|
* Get a list of accounts, other than the invoker of the simulation, that
|
|
@@ -32,7 +32,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
32
32
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
33
33
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
34
34
|
function _regenerator() { var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
35
|
-
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) {
|
|
35
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
36
36
|
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
37
37
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
38
38
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
@@ -158,7 +158,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
158
158
|
throw new AssembledTransaction.Errors.NoSigner("You must provide a signTransaction function, either when calling " + "`signAndSend` or when initializing your Client");
|
|
159
159
|
case 3:
|
|
160
160
|
sigsNeeded = _this.needsNonInvokerSigningBy().filter(function (id) {
|
|
161
|
-
return !id.startsWith(
|
|
161
|
+
return !id.startsWith("C");
|
|
162
162
|
});
|
|
163
163
|
if (!sigsNeeded.length) {
|
|
164
164
|
_context2.n = 4;
|
|
@@ -197,12 +197,13 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
197
197
|
force,
|
|
198
198
|
_ref6$signTransaction,
|
|
199
199
|
signTransaction,
|
|
200
|
+
watcher,
|
|
200
201
|
originalSubmit,
|
|
201
202
|
_args3 = arguments;
|
|
202
203
|
return _regenerator().w(function (_context3) {
|
|
203
204
|
while (1) switch (_context3.p = _context3.n) {
|
|
204
205
|
case 0:
|
|
205
|
-
_ref6 = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {}, _ref6$force = _ref6.force, force = _ref6$force === void 0 ? false : _ref6$force, _ref6$signTransaction = _ref6.signTransaction, signTransaction = _ref6$signTransaction === void 0 ? _this.options.signTransaction : _ref6$signTransaction;
|
|
206
|
+
_ref6 = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {}, _ref6$force = _ref6.force, force = _ref6$force === void 0 ? false : _ref6$force, _ref6$signTransaction = _ref6.signTransaction, signTransaction = _ref6$signTransaction === void 0 ? _this.options.signTransaction : _ref6$signTransaction, watcher = _ref6.watcher;
|
|
206
207
|
if (_this.signed) {
|
|
207
208
|
_context3.n = 3;
|
|
208
209
|
break;
|
|
@@ -222,7 +223,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
222
223
|
_this.options.submit = originalSubmit;
|
|
223
224
|
return _context3.f(2);
|
|
224
225
|
case 3:
|
|
225
|
-
return _context3.a(2, _this.send());
|
|
226
|
+
return _context3.a(2, _this.send(watcher));
|
|
226
227
|
}
|
|
227
228
|
}, _callee3, null, [[1,, 2, 3]]);
|
|
228
229
|
})));
|
|
@@ -263,7 +264,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
263
264
|
_loop,
|
|
264
265
|
_ret,
|
|
265
266
|
_args7 = arguments,
|
|
266
|
-
|
|
267
|
+
_t5;
|
|
267
268
|
return _regenerator().w(function (_context7) {
|
|
268
269
|
while (1) switch (_context7.p = _context7.n) {
|
|
269
270
|
case 0:
|
|
@@ -314,7 +315,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
314
315
|
_iterator = _createForOfIteratorHelper(authEntries.entries());
|
|
315
316
|
_context7.p = 5;
|
|
316
317
|
_loop = _regenerator().m(function _loop() {
|
|
317
|
-
var _step$value, i, entry, credentials, authEntryAddress, sign, _t2, _t3, _t4
|
|
318
|
+
var _step$value, i, entry, credentials, authEntryAddress, sign, _t2, _t3, _t4;
|
|
318
319
|
return _regenerator().w(function (_context6) {
|
|
319
320
|
while (1) switch (_context6.n) {
|
|
320
321
|
case 0:
|
|
@@ -362,10 +363,8 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
362
363
|
_context6.n = 3;
|
|
363
364
|
return expiration;
|
|
364
365
|
case 3:
|
|
365
|
-
_t5 = _context6.v;
|
|
366
|
-
_t6 = _this.options.networkPassphrase;
|
|
367
366
|
_context6.n = 4;
|
|
368
|
-
return _t2(_t3, _t4,
|
|
367
|
+
return _t2(_t3, _t4, _context6.v, _this.options.networkPassphrase);
|
|
369
368
|
case 4:
|
|
370
369
|
authEntries[i] = _context6.v;
|
|
371
370
|
case 5:
|
|
@@ -395,8 +394,8 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
395
394
|
break;
|
|
396
395
|
case 10:
|
|
397
396
|
_context7.p = 10;
|
|
398
|
-
|
|
399
|
-
_iterator.e(
|
|
397
|
+
_t5 = _context7.v;
|
|
398
|
+
_iterator.e(_t5);
|
|
400
399
|
case 11:
|
|
401
400
|
_context7.p = 11;
|
|
402
401
|
_iterator.f();
|
|
@@ -433,7 +432,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
433
432
|
value: function toXDR() {
|
|
434
433
|
var _this$built2;
|
|
435
434
|
if (!this.built) throw new Error("Transaction has not yet been simulated; " + "call `AssembledTransaction.simulate` first.");
|
|
436
|
-
return (_this$built2 = this.built) === null || _this$built2 === void 0 ? void 0 : _this$built2.toEnvelope().toXDR(
|
|
435
|
+
return (_this$built2 = this.built) === null || _this$built2 === void 0 ? void 0 : _this$built2.toEnvelope().toXDR("base64");
|
|
437
436
|
}
|
|
438
437
|
}, {
|
|
439
438
|
key: "handleWalletError",
|
|
@@ -441,7 +440,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
441
440
|
if (!error) return;
|
|
442
441
|
var message = error.message,
|
|
443
442
|
code = error.code;
|
|
444
|
-
var fullMessage = "".concat(message).concat(error.ext ? " (".concat(error.ext.join(
|
|
443
|
+
var fullMessage = "".concat(message).concat(error.ext ? " (".concat(error.ext.join(", "), ")") : "");
|
|
445
444
|
switch (code) {
|
|
446
445
|
case -1:
|
|
447
446
|
throw new AssembledTransaction.Errors.InternalWalletError(fullMessage);
|
|
@@ -473,7 +472,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
473
472
|
throw new AssembledTransaction.Errors.SimulationFailed("Transaction simulation failed: \"".concat(simulation.error, "\""));
|
|
474
473
|
}
|
|
475
474
|
if (_api.Api.isSimulationRestore(simulation)) {
|
|
476
|
-
throw new AssembledTransaction.Errors.ExpiredState("You need to restore some contract state before you can invoke this method.\n" +
|
|
475
|
+
throw new AssembledTransaction.Errors.ExpiredState("You need to restore some contract state before you can invoke this method.\n" + "You can set `restore` to true in the method options in order to " + "automatically restore the contract state when needed.");
|
|
477
476
|
}
|
|
478
477
|
this.simulationResult = (_simulation$result = simulation.result) !== null && _simulation$result !== void 0 ? _simulation$result : {
|
|
479
478
|
auth: [],
|
|
@@ -514,7 +513,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
514
513
|
}, {
|
|
515
514
|
key: "send",
|
|
516
515
|
value: (function () {
|
|
517
|
-
var _send = _asyncToGenerator(_regenerator().m(function _callee7() {
|
|
516
|
+
var _send = _asyncToGenerator(_regenerator().m(function _callee7(watcher) {
|
|
518
517
|
var sent;
|
|
519
518
|
return _regenerator().w(function (_context8) {
|
|
520
519
|
while (1) switch (_context8.n) {
|
|
@@ -526,14 +525,14 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
526
525
|
throw new Error("The transaction has not yet been signed. Run `sign` first, or use `signAndSend` instead.");
|
|
527
526
|
case 1:
|
|
528
527
|
_context8.n = 2;
|
|
529
|
-
return _sent_transaction.SentTransaction.init(this);
|
|
528
|
+
return _sent_transaction.SentTransaction.init(this, watcher);
|
|
530
529
|
case 2:
|
|
531
530
|
sent = _context8.v;
|
|
532
531
|
return _context8.a(2, sent);
|
|
533
532
|
}
|
|
534
533
|
}, _callee7, this);
|
|
535
534
|
}));
|
|
536
|
-
function send() {
|
|
535
|
+
function send(_x2) {
|
|
537
536
|
return _send.apply(this, arguments);
|
|
538
537
|
}
|
|
539
538
|
return send;
|
|
@@ -549,7 +548,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
549
548
|
key: "restoreFootprint",
|
|
550
549
|
value: (function () {
|
|
551
550
|
var _restoreFootprint = _asyncToGenerator(_regenerator().m(function _callee8(restorePreamble, account) {
|
|
552
|
-
var restoreTx, sentTransaction,
|
|
551
|
+
var restoreTx, sentTransaction, _t6;
|
|
553
552
|
return _regenerator().w(function (_context9) {
|
|
554
553
|
while (1) switch (_context9.n) {
|
|
555
554
|
case 0:
|
|
@@ -563,16 +562,16 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
563
562
|
_context9.n = 2;
|
|
564
563
|
break;
|
|
565
564
|
}
|
|
566
|
-
|
|
565
|
+
_t6 = account;
|
|
567
566
|
_context9.n = 4;
|
|
568
567
|
break;
|
|
569
568
|
case 2:
|
|
570
569
|
_context9.n = 3;
|
|
571
570
|
return (0, _utils.getAccount)(this.options, this.server);
|
|
572
571
|
case 3:
|
|
573
|
-
|
|
572
|
+
_t6 = _context9.v;
|
|
574
573
|
case 4:
|
|
575
|
-
account =
|
|
574
|
+
account = _t6;
|
|
576
575
|
_context9.n = 5;
|
|
577
576
|
return AssembledTransaction.buildFootprintRestoreTransaction(_objectSpread({}, this.options), restorePreamble.transactionData, account, restorePreamble.minResourceFee);
|
|
578
577
|
case 5:
|
|
@@ -591,7 +590,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
591
590
|
}
|
|
592
591
|
}, _callee8, this);
|
|
593
592
|
}));
|
|
594
|
-
function restoreFootprint(
|
|
593
|
+
function restoreFootprint(_x3, _x4) {
|
|
595
594
|
return _restoreFootprint.apply(this, arguments);
|
|
596
595
|
}
|
|
597
596
|
return restoreFootprint;
|
|
@@ -620,14 +619,14 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
620
619
|
var envelope = _stellarBase.xdr.TransactionEnvelope.fromXDR(encodedXDR, "base64");
|
|
621
620
|
var built = _stellarBase.TransactionBuilder.fromXDR(envelope, options.networkPassphrase);
|
|
622
621
|
var operation = built.operations[0];
|
|
623
|
-
if (!(operation !== null && operation !== void 0 && (_operation$func = operation.func) !== null && _operation$func !== void 0 && _operation$func.value) || typeof operation.func.value !==
|
|
622
|
+
if (!(operation !== null && operation !== void 0 && (_operation$func = operation.func) !== null && _operation$func !== void 0 && _operation$func.value) || typeof operation.func.value !== "function") {
|
|
624
623
|
throw new Error("Could not extract the method from the transaction envelope.");
|
|
625
624
|
}
|
|
626
625
|
var invokeContractArgs = operation.func.value();
|
|
627
626
|
if (!(invokeContractArgs !== null && invokeContractArgs !== void 0 && invokeContractArgs.functionName)) {
|
|
628
627
|
throw new Error("Could not extract the method name from the transaction envelope.");
|
|
629
628
|
}
|
|
630
|
-
var method = invokeContractArgs.functionName().toString(
|
|
629
|
+
var method = invokeContractArgs.functionName().toString("utf-8");
|
|
631
630
|
var txn = new AssembledTransaction(_objectSpread(_objectSpread({}, options), {}, {
|
|
632
631
|
method: method,
|
|
633
632
|
parseResultXdr: function parseResultXdr(result) {
|
|
@@ -673,7 +672,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
673
672
|
}
|
|
674
673
|
}, _callee9);
|
|
675
674
|
}));
|
|
676
|
-
function buildWithOp(
|
|
675
|
+
function buildWithOp(_x5, _x6) {
|
|
677
676
|
return _buildWithOp.apply(this, arguments);
|
|
678
677
|
}
|
|
679
678
|
return buildWithOp;
|
|
@@ -701,7 +700,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
701
700
|
}
|
|
702
701
|
}, _callee0);
|
|
703
702
|
}));
|
|
704
|
-
function buildFootprintRestoreTransaction(
|
|
703
|
+
function buildFootprintRestoreTransaction(_x7, _x8, _x9, _x0) {
|
|
705
704
|
return _buildFootprintRestoreTransaction.apply(this, arguments);
|
|
706
705
|
}
|
|
707
706
|
return buildFootprintRestoreTransaction;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.basicNodeSigner = void 0;
|
|
7
7
|
var _stellarBase = require("@stellar/stellar-base");
|
|
8
8
|
function _regenerator() { var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
9
|
-
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) {
|
|
9
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
10
10
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
11
11
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
12
12
|
var basicNodeSigner = exports.basicNodeSigner = function basicNodeSigner(keypair, networkPassphrase) {
|
package/lib/contract/client.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ export declare class Client {
|
|
|
29
29
|
salt?: Buffer | Uint8Array;
|
|
30
30
|
/** The format used to decode `wasmHash`, if it's provided as a string. */
|
|
31
31
|
format?: "hex" | "base64";
|
|
32
|
+
/** The address to use to deploy the custom contract */
|
|
33
|
+
address?: string;
|
|
32
34
|
}): Promise<AssembledTransaction<T>>;
|
|
33
35
|
constructor(spec: Spec, options: ClientOptions);
|
|
34
36
|
/**
|
package/lib/contract/client.js
CHANGED
|
@@ -9,11 +9,10 @@ var _stellarBase = require("@stellar/stellar-base");
|
|
|
9
9
|
var _spec = require("./spec");
|
|
10
10
|
var _rpc = require("../rpc");
|
|
11
11
|
var _assembled_transaction = require("./assembled_transaction");
|
|
12
|
-
var _utils = require("./utils");
|
|
13
12
|
var _excluded = ["method"],
|
|
14
13
|
_excluded2 = ["wasmHash", "salt", "format", "fee", "timeoutInSeconds", "simulate"];
|
|
15
14
|
function _regenerator() { var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
16
|
-
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) {
|
|
15
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
17
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; }
|
|
18
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; }
|
|
19
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], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
@@ -27,53 +26,24 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
27
26
|
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); }
|
|
28
27
|
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); }); }; }
|
|
29
28
|
var CONSTRUCTOR_FUNC = "__constructor";
|
|
30
|
-
function
|
|
31
|
-
return _specFromWasm.apply(this, arguments);
|
|
32
|
-
}
|
|
33
|
-
function _specFromWasm() {
|
|
34
|
-
_specFromWasm = _asyncToGenerator(_regenerator().m(function _callee5(wasm) {
|
|
35
|
-
var wasmModule, xdrSections, bufferSection, specEntryArray, spec;
|
|
36
|
-
return _regenerator().w(function (_context5) {
|
|
37
|
-
while (1) switch (_context5.n) {
|
|
38
|
-
case 0:
|
|
39
|
-
_context5.n = 1;
|
|
40
|
-
return WebAssembly.compile(wasm);
|
|
41
|
-
case 1:
|
|
42
|
-
wasmModule = _context5.v;
|
|
43
|
-
xdrSections = WebAssembly.Module.customSections(wasmModule, "contractspecv0");
|
|
44
|
-
if (!(xdrSections.length === 0)) {
|
|
45
|
-
_context5.n = 2;
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
throw new Error("Could not obtain contract spec from wasm");
|
|
49
|
-
case 2:
|
|
50
|
-
bufferSection = Buffer.from(xdrSections[0]);
|
|
51
|
-
specEntryArray = (0, _utils.processSpecEntryStream)(bufferSection);
|
|
52
|
-
spec = new _spec.Spec(specEntryArray);
|
|
53
|
-
return _context5.a(2, spec);
|
|
54
|
-
}
|
|
55
|
-
}, _callee5);
|
|
56
|
-
}));
|
|
57
|
-
return _specFromWasm.apply(this, arguments);
|
|
58
|
-
}
|
|
59
|
-
function specFromWasmHash(_x2, _x3) {
|
|
29
|
+
function specFromWasmHash(_x, _x2) {
|
|
60
30
|
return _specFromWasmHash.apply(this, arguments);
|
|
61
31
|
}
|
|
62
32
|
function _specFromWasmHash() {
|
|
63
|
-
_specFromWasmHash = _asyncToGenerator(_regenerator().m(function
|
|
33
|
+
_specFromWasmHash = _asyncToGenerator(_regenerator().m(function _callee5(wasmHash, options) {
|
|
64
34
|
var format,
|
|
65
35
|
rpcUrl,
|
|
66
36
|
allowHttp,
|
|
67
37
|
serverOpts,
|
|
68
38
|
server,
|
|
69
39
|
wasm,
|
|
70
|
-
|
|
71
|
-
return _regenerator().w(function (
|
|
72
|
-
while (1) switch (
|
|
40
|
+
_args5 = arguments;
|
|
41
|
+
return _regenerator().w(function (_context5) {
|
|
42
|
+
while (1) switch (_context5.n) {
|
|
73
43
|
case 0:
|
|
74
|
-
format =
|
|
44
|
+
format = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : "hex";
|
|
75
45
|
if (!(!options || !options.rpcUrl)) {
|
|
76
|
-
|
|
46
|
+
_context5.n = 1;
|
|
77
47
|
break;
|
|
78
48
|
}
|
|
79
49
|
throw new TypeError("options must contain rpcUrl");
|
|
@@ -83,13 +53,13 @@ function _specFromWasmHash() {
|
|
|
83
53
|
allowHttp: allowHttp
|
|
84
54
|
};
|
|
85
55
|
server = new _rpc.Server(rpcUrl, serverOpts);
|
|
86
|
-
|
|
56
|
+
_context5.n = 2;
|
|
87
57
|
return server.getContractWasmByHash(wasmHash, format);
|
|
88
58
|
case 2:
|
|
89
|
-
wasm =
|
|
90
|
-
return
|
|
59
|
+
wasm = _context5.v;
|
|
60
|
+
return _context5.a(2, _spec.Spec.fromWasm(wasm));
|
|
91
61
|
}
|
|
92
|
-
},
|
|
62
|
+
}, _callee5);
|
|
93
63
|
}));
|
|
94
64
|
return _specFromWasmHash.apply(this, arguments);
|
|
95
65
|
}
|
|
@@ -152,7 +122,7 @@ var Client = exports.Client = function () {
|
|
|
152
122
|
case 1:
|
|
153
123
|
spec = _context.v;
|
|
154
124
|
operation = _stellarBase.Operation.createCustomContract({
|
|
155
|
-
address: new _stellarBase.Address(options.publicKey),
|
|
125
|
+
address: new _stellarBase.Address(options.address || options.publicKey),
|
|
156
126
|
wasmHash: typeof wasmHash === "string" ? Buffer.from(wasmHash, format !== null && format !== void 0 ? format : "hex") : wasmHash,
|
|
157
127
|
salt: salt,
|
|
158
128
|
constructorArgs: args ? spec.funcArgsToScVals(CONSTRUCTOR_FUNC, args) : []
|
|
@@ -173,7 +143,7 @@ var Client = exports.Client = function () {
|
|
|
173
143
|
}
|
|
174
144
|
}, _callee);
|
|
175
145
|
}));
|
|
176
|
-
function deploy(
|
|
146
|
+
function deploy(_x3, _x4) {
|
|
177
147
|
return _deploy.apply(this, arguments);
|
|
178
148
|
}
|
|
179
149
|
return deploy;
|
|
@@ -212,7 +182,7 @@ var Client = exports.Client = function () {
|
|
|
212
182
|
}
|
|
213
183
|
}, _callee2);
|
|
214
184
|
}));
|
|
215
|
-
function fromWasmHash(
|
|
185
|
+
function fromWasmHash(_x5, _x6) {
|
|
216
186
|
return _fromWasmHash.apply(this, arguments);
|
|
217
187
|
}
|
|
218
188
|
return fromWasmHash;
|
|
@@ -226,14 +196,14 @@ var Client = exports.Client = function () {
|
|
|
226
196
|
while (1) switch (_context3.n) {
|
|
227
197
|
case 0:
|
|
228
198
|
_context3.n = 1;
|
|
229
|
-
return
|
|
199
|
+
return _spec.Spec.fromWasm(wasm);
|
|
230
200
|
case 1:
|
|
231
201
|
spec = _context3.v;
|
|
232
202
|
return _context3.a(2, new Client(spec, options));
|
|
233
203
|
}
|
|
234
204
|
}, _callee3);
|
|
235
205
|
}));
|
|
236
|
-
function fromWasm(
|
|
206
|
+
function fromWasm(_x7, _x8) {
|
|
237
207
|
return _fromWasm.apply(this, arguments);
|
|
238
208
|
}
|
|
239
209
|
return fromWasm;
|
|
@@ -265,7 +235,7 @@ var Client = exports.Client = function () {
|
|
|
265
235
|
}
|
|
266
236
|
}, _callee4);
|
|
267
237
|
}));
|
|
268
|
-
function from(
|
|
238
|
+
function from(_x9) {
|
|
269
239
|
return _from.apply(this, arguments);
|
|
270
240
|
}
|
|
271
241
|
return from;
|
|
@@ -75,10 +75,23 @@ export declare class SentTransaction<T> {
|
|
|
75
75
|
};
|
|
76
76
|
constructor(assembled: AssembledTransaction<T>);
|
|
77
77
|
/**
|
|
78
|
-
* Initialize a `SentTransaction` from
|
|
79
|
-
*
|
|
78
|
+
* Initialize a `SentTransaction` from {@link AssembledTransaction}
|
|
79
|
+
* `assembled`, passing an optional {@link Watcher} `watcher`. This will also
|
|
80
|
+
* send the transaction to the network.
|
|
80
81
|
*/
|
|
81
|
-
static init: <U>(assembled: AssembledTransaction<U
|
|
82
|
+
static init: <U>(assembled: AssembledTransaction<U>, watcher?: Watcher) => Promise<SentTransaction<U>>;
|
|
82
83
|
private send;
|
|
83
84
|
get result(): T;
|
|
84
85
|
}
|
|
86
|
+
export declare abstract class Watcher {
|
|
87
|
+
/**
|
|
88
|
+
* Function to call after transaction has been submitted successfully to
|
|
89
|
+
* the network for processing
|
|
90
|
+
*/
|
|
91
|
+
abstract onSubmitted?(response?: Api.SendTransactionResponse): void;
|
|
92
|
+
/**
|
|
93
|
+
* Function to call every time the submitted transaction's status is
|
|
94
|
+
* checked while awaiting its full inclusion in the ledger
|
|
95
|
+
*/
|
|
96
|
+
abstract onProgress?(response?: Api.GetTransactionResponse): void;
|
|
97
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.SentTransaction = void 0;
|
|
6
|
+
exports.Watcher = exports.SentTransaction = void 0;
|
|
7
7
|
var _rpc = require("../rpc");
|
|
8
8
|
var _api = require("../rpc/api");
|
|
9
9
|
var _utils = require("./utils");
|
|
@@ -21,7 +21,7 @@ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf
|
|
|
21
21
|
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
22
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); }
|
|
23
23
|
function _regenerator() { var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
24
|
-
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) {
|
|
24
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
25
25
|
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); }
|
|
26
26
|
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); }); }; }
|
|
27
27
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
@@ -35,43 +35,60 @@ var SentTransaction = exports.SentTransaction = function () {
|
|
|
35
35
|
var _this = this,
|
|
36
36
|
_this$assembled$optio2;
|
|
37
37
|
_classCallCheck(this, SentTransaction);
|
|
38
|
-
_defineProperty(this, "send",
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
38
|
+
_defineProperty(this, "send", function () {
|
|
39
|
+
var _ref = _asyncToGenerator(_regenerator().m(function _callee2(watcher) {
|
|
40
|
+
var _this$assembled$optio;
|
|
41
|
+
var hash, timeoutInSeconds;
|
|
42
|
+
return _regenerator().w(function (_context2) {
|
|
43
|
+
while (1) switch (_context2.n) {
|
|
44
|
+
case 0:
|
|
45
|
+
_context2.n = 1;
|
|
46
|
+
return _this.server.sendTransaction(_this.assembled.signed);
|
|
47
|
+
case 1:
|
|
48
|
+
_this.sendTransactionResponse = _context2.v;
|
|
49
|
+
if (!(_this.sendTransactionResponse.status !== "PENDING")) {
|
|
50
|
+
_context2.n = 2;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
throw new SentTransaction.Errors.SendFailed("Sending the transaction to the network failed!\n".concat(JSON.stringify(_this.sendTransactionResponse, null, 2)));
|
|
54
|
+
case 2:
|
|
55
|
+
if (watcher !== null && watcher !== void 0 && watcher.onSubmitted) watcher.onSubmitted(_this.sendTransactionResponse);
|
|
56
|
+
hash = _this.sendTransactionResponse.hash;
|
|
57
|
+
timeoutInSeconds = (_this$assembled$optio = _this.assembled.options.timeoutInSeconds) !== null && _this$assembled$optio !== void 0 ? _this$assembled$optio : _types.DEFAULT_TIMEOUT;
|
|
58
|
+
_context2.n = 3;
|
|
59
|
+
return (0, _utils.withExponentialBackoff)(_asyncToGenerator(_regenerator().m(function _callee() {
|
|
60
|
+
var tx;
|
|
61
|
+
return _regenerator().w(function (_context) {
|
|
62
|
+
while (1) switch (_context.n) {
|
|
63
|
+
case 0:
|
|
64
|
+
_context.n = 1;
|
|
65
|
+
return _this.server.getTransaction(hash);
|
|
66
|
+
case 1:
|
|
67
|
+
tx = _context.v;
|
|
68
|
+
if (watcher !== null && watcher !== void 0 && watcher.onProgress) watcher.onProgress(tx);
|
|
69
|
+
return _context.a(2, tx);
|
|
70
|
+
}
|
|
71
|
+
}, _callee);
|
|
72
|
+
})), function (resp) {
|
|
73
|
+
return resp.status === _api.Api.GetTransactionStatus.NOT_FOUND;
|
|
74
|
+
}, timeoutInSeconds);
|
|
75
|
+
case 3:
|
|
76
|
+
_this.getTransactionResponseAll = _context2.v;
|
|
77
|
+
_this.getTransactionResponse = _this.getTransactionResponseAll[_this.getTransactionResponseAll.length - 1];
|
|
78
|
+
if (!(_this.getTransactionResponse.status === _api.Api.GetTransactionStatus.NOT_FOUND)) {
|
|
79
|
+
_context2.n = 4;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
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)));
|
|
83
|
+
case 4:
|
|
84
|
+
return _context2.a(2, _this);
|
|
85
|
+
}
|
|
86
|
+
}, _callee2);
|
|
87
|
+
}));
|
|
88
|
+
return function (_x) {
|
|
89
|
+
return _ref.apply(this, arguments);
|
|
90
|
+
};
|
|
91
|
+
}());
|
|
75
92
|
this.assembled = assembled;
|
|
76
93
|
this.server = new _rpc.Server(this.assembled.options.rpcUrl, {
|
|
77
94
|
allowHttp: (_this$assembled$optio2 = this.assembled.options.allowHttp) !== null && _this$assembled$optio2 !== void 0 ? _this$assembled$optio2 : false
|
|
@@ -126,21 +143,24 @@ _defineProperty(SentTransaction, "Errors", {
|
|
|
126
143
|
}(_wrapNativeSuper(Error))
|
|
127
144
|
});
|
|
128
145
|
_defineProperty(SentTransaction, "init", function () {
|
|
129
|
-
var
|
|
146
|
+
var _ref3 = _asyncToGenerator(_regenerator().m(function _callee3(assembled, watcher) {
|
|
130
147
|
var tx, sent;
|
|
131
|
-
return _regenerator().w(function (
|
|
132
|
-
while (1) switch (
|
|
148
|
+
return _regenerator().w(function (_context3) {
|
|
149
|
+
while (1) switch (_context3.n) {
|
|
133
150
|
case 0:
|
|
134
151
|
tx = new _SentTransaction(assembled);
|
|
135
|
-
|
|
136
|
-
return tx.send();
|
|
152
|
+
_context3.n = 1;
|
|
153
|
+
return tx.send(watcher);
|
|
137
154
|
case 1:
|
|
138
|
-
sent =
|
|
139
|
-
return
|
|
155
|
+
sent = _context3.v;
|
|
156
|
+
return _context3.a(2, sent);
|
|
140
157
|
}
|
|
141
|
-
},
|
|
158
|
+
}, _callee3);
|
|
142
159
|
}));
|
|
143
|
-
return function (
|
|
144
|
-
return
|
|
160
|
+
return function (_x2, _x3) {
|
|
161
|
+
return _ref3.apply(this, arguments);
|
|
145
162
|
};
|
|
146
|
-
}());
|
|
163
|
+
}());
|
|
164
|
+
var Watcher = exports.Watcher = _createClass(function Watcher() {
|
|
165
|
+
_classCallCheck(this, Watcher);
|
|
166
|
+
});
|