@paraspell/sdk-pjs 8.0.0 → 8.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/dist/index.cjs +372 -273
- package/dist/index.d.ts +27 -6
- package/dist/index.mjs +373 -274
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getOtherAssets, InvalidCurrencyError, getParaId, createApiInstanceForNode as createApiInstanceForNode$1, getNode, isForeignAsset, computeFeeFromDryRunPjs, resolveModuleError, getAssetsObject, send as send$1, getDryRun as getDryRun$1, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getTransferInfo as getTransferInfo$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, getMaxNativeTransferableAmount as getMaxNativeTransferableAmount$1, getMaxForeignTransferableAmount as getMaxForeignTransferableAmount$1, getTransferableAmount as getTransferableAmount$1, transferMoonbeamEvm, Builder as Builder$1, GeneralBuilder as GeneralBuilder$1 } from '@paraspell/sdk-core';
|
|
1
|
+
import { getOtherAssets, InvalidCurrencyError, getParaId, createApiInstanceForNode as createApiInstanceForNode$1, getNode, isForeignAsset, computeFeeFromDryRunPjs, resolveModuleError, getAssetsObject, send as send$1, getDryRun as getDryRun$1, getBalanceNative as getBalanceNative$1, getBalanceForeign as getBalanceForeign$1, getTransferInfo as getTransferInfo$1, getAssetBalance as getAssetBalance$1, claimAssets as claimAssets$1, getOriginFeeDetails as getOriginFeeDetails$1, getMaxNativeTransferableAmount as getMaxNativeTransferableAmount$1, getMaxForeignTransferableAmount as getMaxForeignTransferableAmount$1, getTransferableAmount as getTransferableAmount$1, Foreign, ForeignAbstract, Native, Override, getAllAssetsSymbols, getAssetBySymbolOrId, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getRelayChainSymbol, getSupportedAssets, getTNode, hasSupportForAsset, isNodeEvm, transferMoonbeamEvm, Builder as Builder$1, GeneralBuilder as GeneralBuilder$1 } from '@paraspell/sdk-core';
|
|
2
2
|
export * from '@paraspell/sdk-core';
|
|
3
3
|
import { contextFactory, toPolkadot, environment } from '@snowbridge/api';
|
|
4
4
|
import { WsProvider, ApiPromise } from '@polkadot/api';
|
|
@@ -17,6 +17,31 @@ function _arrayWithHoles(r) {
|
|
|
17
17
|
function _arrayWithoutHoles(r) {
|
|
18
18
|
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
19
19
|
}
|
|
20
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
21
|
+
try {
|
|
22
|
+
var i = n[a](c),
|
|
23
|
+
u = i.value;
|
|
24
|
+
} catch (n) {
|
|
25
|
+
return void e(n);
|
|
26
|
+
}
|
|
27
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
28
|
+
}
|
|
29
|
+
function _asyncToGenerator(n) {
|
|
30
|
+
return function () {
|
|
31
|
+
var t = this,
|
|
32
|
+
e = arguments;
|
|
33
|
+
return new Promise(function (r, o) {
|
|
34
|
+
var a = n.apply(t, e);
|
|
35
|
+
function _next(n) {
|
|
36
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
37
|
+
}
|
|
38
|
+
function _throw(n) {
|
|
39
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
40
|
+
}
|
|
41
|
+
_next(void 0);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
}
|
|
20
45
|
function _classCallCheck(a, n) {
|
|
21
46
|
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
22
47
|
}
|
|
@@ -31,6 +56,14 @@ function _createClass(e, r, t) {
|
|
|
31
56
|
writable: !1
|
|
32
57
|
}), e;
|
|
33
58
|
}
|
|
59
|
+
function _defineProperty(e, r, t) {
|
|
60
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
61
|
+
value: t,
|
|
62
|
+
enumerable: !0,
|
|
63
|
+
configurable: !0,
|
|
64
|
+
writable: !0
|
|
65
|
+
}) : e[r] = t, e;
|
|
66
|
+
}
|
|
34
67
|
function _iterableToArray(r) {
|
|
35
68
|
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
36
69
|
}
|
|
@@ -64,6 +97,27 @@ function _nonIterableRest() {
|
|
|
64
97
|
function _nonIterableSpread() {
|
|
65
98
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
66
99
|
}
|
|
100
|
+
function ownKeys(e, r) {
|
|
101
|
+
var t = Object.keys(e);
|
|
102
|
+
if (Object.getOwnPropertySymbols) {
|
|
103
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
104
|
+
r && (o = o.filter(function (r) {
|
|
105
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
106
|
+
})), t.push.apply(t, o);
|
|
107
|
+
}
|
|
108
|
+
return t;
|
|
109
|
+
}
|
|
110
|
+
function _objectSpread2(e) {
|
|
111
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
112
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
113
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
|
114
|
+
_defineProperty(e, r, t[r]);
|
|
115
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
116
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return e;
|
|
120
|
+
}
|
|
67
121
|
function _regeneratorRuntime() {
|
|
68
122
|
_regeneratorRuntime = function () {
|
|
69
123
|
return e;
|
|
@@ -375,11 +429,11 @@ function _toPrimitive(t, r) {
|
|
|
375
429
|
if ("object" != typeof t || !t) return t;
|
|
376
430
|
var e = t[Symbol.toPrimitive];
|
|
377
431
|
if (void 0 !== e) {
|
|
378
|
-
var i = e.call(t, r);
|
|
432
|
+
var i = e.call(t, r || "default");
|
|
379
433
|
if ("object" != typeof i) return i;
|
|
380
434
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
381
435
|
}
|
|
382
|
-
return (String )(t);
|
|
436
|
+
return ("string" === r ? String : Number)(t);
|
|
383
437
|
}
|
|
384
438
|
function _toPropertyKey(t) {
|
|
385
439
|
var i = _toPrimitive(t, "string");
|
|
@@ -402,38 +456,6 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
402
456
|
}
|
|
403
457
|
}
|
|
404
458
|
|
|
405
|
-
/******************************************************************************
|
|
406
|
-
Copyright (c) Microsoft Corporation.
|
|
407
|
-
|
|
408
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
409
|
-
purpose with or without fee is hereby granted.
|
|
410
|
-
|
|
411
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
412
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
413
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
414
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
415
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
416
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
417
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
418
|
-
***************************************************************************** */
|
|
419
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
423
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
424
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
425
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
426
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
427
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
428
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
433
|
-
var e = new Error(message);
|
|
434
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
435
|
-
};
|
|
436
|
-
|
|
437
459
|
var findEthAsset = function findEthAsset(currency) {
|
|
438
460
|
var ethAssets = getOtherAssets('Ethereum');
|
|
439
461
|
var ethAsset = 'symbol' in currency ? ethAssets.find(function (asset) {
|
|
@@ -447,8 +469,8 @@ var findEthAsset = function findEthAsset(currency) {
|
|
|
447
469
|
return ethAsset;
|
|
448
470
|
};
|
|
449
471
|
|
|
450
|
-
var createContext = function
|
|
451
|
-
|
|
472
|
+
var createContext = /*#__PURE__*/function () {
|
|
473
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(executionUrl, config) {
|
|
452
474
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
453
475
|
while (1) switch (_context.prev = _context.next) {
|
|
454
476
|
case 0:
|
|
@@ -476,7 +498,10 @@ var createContext = function createContext(executionUrl, config) {
|
|
|
476
498
|
}
|
|
477
499
|
}, _callee);
|
|
478
500
|
}));
|
|
479
|
-
|
|
501
|
+
return function createContext(_x, _x2) {
|
|
502
|
+
return _ref.apply(this, arguments);
|
|
503
|
+
};
|
|
504
|
+
}();
|
|
480
505
|
|
|
481
506
|
var checkPlanFailure = function checkPlanFailure(plan) {
|
|
482
507
|
if (plan.failure) {
|
|
@@ -500,109 +525,106 @@ var isEthersSigner = function isEthersSigner(signer) {
|
|
|
500
525
|
*
|
|
501
526
|
* @throws Will throw an error if the transfer validation fails or if the transfer cannot be completed.
|
|
502
527
|
*/
|
|
503
|
-
var transferEthToPolkadot$1 = function
|
|
504
|
-
|
|
505
|
-
var
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
}
|
|
519
|
-
throw new Error('provider parameter is required for Snowbridge transfers.');
|
|
520
|
-
case 2:
|
|
521
|
-
if (isEthersSigner(signer)) {
|
|
522
|
-
_context.next = 4;
|
|
523
|
-
break;
|
|
524
|
-
}
|
|
525
|
-
throw new Error('Snowbridge does not support Viem provider yet.');
|
|
526
|
-
case 4:
|
|
527
|
-
ethAsset = findEthAsset(currency);
|
|
528
|
-
env = environment.SNOWBRIDGE_ENV['polkadot_mainnet'];
|
|
529
|
-
_context.next = 8;
|
|
530
|
-
return createContext(provider, env.config);
|
|
531
|
-
case 8:
|
|
532
|
-
context = _context.sent;
|
|
533
|
-
destParaId = getParaId(to);
|
|
534
|
-
_context.next = 12;
|
|
535
|
-
return toPolkadot.validateSend(context, signer, address, (_b = ethAsset.assetId) !== null && _b !== void 0 ? _b : '', destParaId, BigInt(currency.amount), BigInt(0));
|
|
536
|
-
case 12:
|
|
537
|
-
plan = _context.sent;
|
|
538
|
-
checkPlanFailure(plan);
|
|
539
|
-
_context.next = 16;
|
|
540
|
-
return toPolkadot.send(context, signer, plan);
|
|
541
|
-
case 16:
|
|
542
|
-
result = _context.sent;
|
|
543
|
-
return _context.abrupt("return", {
|
|
544
|
-
result: result,
|
|
545
|
-
plan: plan
|
|
546
|
-
});
|
|
547
|
-
case 18:
|
|
548
|
-
case "end":
|
|
549
|
-
return _context.stop();
|
|
550
|
-
}
|
|
551
|
-
}, _callee);
|
|
552
|
-
})();
|
|
553
|
-
});
|
|
554
|
-
};
|
|
555
|
-
|
|
556
|
-
var buildEthTransferOptions = function buildEthTransferOptions(_a) {
|
|
557
|
-
return __awaiter(void 0, [_a], void 0, function (_ref) {
|
|
558
|
-
var currency = _ref.currency,
|
|
559
|
-
to = _ref.to,
|
|
560
|
-
address = _ref.address,
|
|
561
|
-
destAddress = _ref.destAddress;
|
|
562
|
-
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
563
|
-
var _b, ethAsset, env, EXECUTION_URL, context, destParaId, signer, plan;
|
|
564
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
565
|
-
while (1) switch (_context.prev = _context.next) {
|
|
566
|
-
case 0:
|
|
567
|
-
ethAsset = findEthAsset(currency);
|
|
568
|
-
env = environment.SNOWBRIDGE_ENV['polkadot_mainnet'];
|
|
569
|
-
EXECUTION_URL = 'https://eth.llamarpc.com';
|
|
528
|
+
var transferEthToPolkadot$1 = /*#__PURE__*/function () {
|
|
529
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
530
|
+
var _ethAsset$assetId;
|
|
531
|
+
var provider, signer, address, to, currency, ethAsset, env, context, destParaId, plan, result;
|
|
532
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
533
|
+
while (1) switch (_context.prev = _context.next) {
|
|
534
|
+
case 0:
|
|
535
|
+
provider = _ref.provider, signer = _ref.signer, address = _ref.address, to = _ref.to, currency = _ref.currency;
|
|
536
|
+
if (provider) {
|
|
537
|
+
_context.next = 3;
|
|
538
|
+
break;
|
|
539
|
+
}
|
|
540
|
+
throw new Error('provider parameter is required for Snowbridge transfers.');
|
|
541
|
+
case 3:
|
|
542
|
+
if (isEthersSigner(signer)) {
|
|
570
543
|
_context.next = 5;
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
546
|
+
throw new Error('Snowbridge does not support Viem provider yet.');
|
|
547
|
+
case 5:
|
|
548
|
+
ethAsset = findEthAsset(currency);
|
|
549
|
+
env = environment.SNOWBRIDGE_ENV['polkadot_mainnet'];
|
|
550
|
+
_context.next = 9;
|
|
551
|
+
return createContext(provider, env.config);
|
|
552
|
+
case 9:
|
|
553
|
+
context = _context.sent;
|
|
554
|
+
destParaId = getParaId(to);
|
|
555
|
+
_context.next = 13;
|
|
556
|
+
return toPolkadot.validateSend(context, signer, address, (_ethAsset$assetId = ethAsset.assetId) !== null && _ethAsset$assetId !== void 0 ? _ethAsset$assetId : '', destParaId, BigInt(currency.amount), 0n);
|
|
557
|
+
case 13:
|
|
558
|
+
plan = _context.sent;
|
|
559
|
+
checkPlanFailure(plan);
|
|
560
|
+
_context.next = 17;
|
|
561
|
+
return toPolkadot.send(context, signer, plan);
|
|
562
|
+
case 17:
|
|
563
|
+
result = _context.sent;
|
|
564
|
+
return _context.abrupt("return", {
|
|
565
|
+
result: result,
|
|
566
|
+
plan: plan
|
|
567
|
+
});
|
|
568
|
+
case 19:
|
|
569
|
+
case "end":
|
|
570
|
+
return _context.stop();
|
|
571
|
+
}
|
|
572
|
+
}, _callee);
|
|
573
|
+
}));
|
|
574
|
+
return function transferEthToPolkadot(_x) {
|
|
575
|
+
return _ref2.apply(this, arguments);
|
|
576
|
+
};
|
|
577
|
+
}();
|
|
578
|
+
|
|
579
|
+
var buildEthTransferOptions = /*#__PURE__*/function () {
|
|
580
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
581
|
+
var _ethAsset$assetId;
|
|
582
|
+
var currency, to, address, destAddress, ethAsset, env, EXECUTION_URL, context, destParaId, signer, plan;
|
|
583
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
584
|
+
while (1) switch (_context.prev = _context.next) {
|
|
585
|
+
case 0:
|
|
586
|
+
currency = _ref.currency, to = _ref.to, address = _ref.address, destAddress = _ref.destAddress;
|
|
587
|
+
ethAsset = findEthAsset(currency);
|
|
588
|
+
env = environment.SNOWBRIDGE_ENV['polkadot_mainnet'];
|
|
589
|
+
EXECUTION_URL = 'https://eth.llamarpc.com';
|
|
590
|
+
_context.next = 6;
|
|
591
|
+
return createContext(EXECUTION_URL, env.config);
|
|
592
|
+
case 6:
|
|
593
|
+
context = _context.sent;
|
|
594
|
+
destParaId = getParaId(to);
|
|
595
|
+
signer = {
|
|
596
|
+
getAddress: function getAddress() {
|
|
597
|
+
return Promise.resolve(address);
|
|
588
598
|
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
599
|
+
};
|
|
600
|
+
_context.next = 11;
|
|
601
|
+
return toPolkadot.validateSend(context, signer, destAddress, (_ethAsset$assetId = ethAsset.assetId) !== null && _ethAsset$assetId !== void 0 ? _ethAsset$assetId : '', destParaId, BigInt(currency.amount), 0n);
|
|
602
|
+
case 11:
|
|
603
|
+
plan = _context.sent;
|
|
604
|
+
checkPlanFailure(plan);
|
|
605
|
+
if (plan.success) {
|
|
606
|
+
_context.next = 15;
|
|
607
|
+
break;
|
|
608
|
+
}
|
|
609
|
+
throw new Error('Failed to validate send');
|
|
610
|
+
case 15:
|
|
611
|
+
return _context.abrupt("return", {
|
|
612
|
+
token: plan.success.token,
|
|
613
|
+
destinationParaId: plan.success.destinationParaId,
|
|
614
|
+
destinationFee: plan.success.destinationFee,
|
|
615
|
+
amount: plan.success.amount,
|
|
616
|
+
fee: plan.success.fee
|
|
617
|
+
});
|
|
618
|
+
case 16:
|
|
619
|
+
case "end":
|
|
620
|
+
return _context.stop();
|
|
621
|
+
}
|
|
622
|
+
}, _callee);
|
|
623
|
+
}));
|
|
624
|
+
return function buildEthTransferOptions(_x) {
|
|
625
|
+
return _ref2.apply(this, arguments);
|
|
626
|
+
};
|
|
627
|
+
}();
|
|
606
628
|
|
|
607
629
|
var lowercaseFirstLetter = function lowercaseFirstLetter(value) {
|
|
608
630
|
return value.charAt(0).toLowerCase() + value.slice(1);
|
|
@@ -635,9 +657,9 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
635
657
|
}
|
|
636
658
|
}, {
|
|
637
659
|
key: "init",
|
|
638
|
-
value: function
|
|
639
|
-
|
|
640
|
-
var
|
|
660
|
+
value: function () {
|
|
661
|
+
var _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(node) {
|
|
662
|
+
var _this$_api;
|
|
641
663
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
642
664
|
while (1) switch (_context.prev = _context.next) {
|
|
643
665
|
case 0:
|
|
@@ -658,11 +680,11 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
658
680
|
_context.next = 16;
|
|
659
681
|
break;
|
|
660
682
|
case 8:
|
|
661
|
-
if (!((
|
|
683
|
+
if (!((_this$_api = this._api) !== null && _this$_api !== void 0)) {
|
|
662
684
|
_context.next = 12;
|
|
663
685
|
break;
|
|
664
686
|
}
|
|
665
|
-
_context.t0 =
|
|
687
|
+
_context.t0 = _this$_api;
|
|
666
688
|
_context.next = 15;
|
|
667
689
|
break;
|
|
668
690
|
case 12:
|
|
@@ -680,11 +702,15 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
680
702
|
}
|
|
681
703
|
}, _callee, this);
|
|
682
704
|
}));
|
|
683
|
-
|
|
705
|
+
function init(_x) {
|
|
706
|
+
return _init.apply(this, arguments);
|
|
707
|
+
}
|
|
708
|
+
return init;
|
|
709
|
+
}()
|
|
684
710
|
}, {
|
|
685
711
|
key: "createApiInstance",
|
|
686
|
-
value: function
|
|
687
|
-
|
|
712
|
+
value: function () {
|
|
713
|
+
var _createApiInstance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(wsUrl) {
|
|
688
714
|
var wsProvider;
|
|
689
715
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
690
716
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -699,7 +725,11 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
699
725
|
}
|
|
700
726
|
}, _callee2);
|
|
701
727
|
}));
|
|
702
|
-
|
|
728
|
+
function createApiInstance(_x2) {
|
|
729
|
+
return _createApiInstance.apply(this, arguments);
|
|
730
|
+
}
|
|
731
|
+
return createApiInstance;
|
|
732
|
+
}()
|
|
703
733
|
}, {
|
|
704
734
|
key: "createAccountId",
|
|
705
735
|
value: function createAccountId(address) {
|
|
@@ -730,8 +760,8 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
730
760
|
}
|
|
731
761
|
}, {
|
|
732
762
|
key: "calculateTransactionFee",
|
|
733
|
-
value: function
|
|
734
|
-
|
|
763
|
+
value: function () {
|
|
764
|
+
var _calculateTransactionFee = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(tx, address) {
|
|
735
765
|
var _yield$tx$paymentInfo, partialFee;
|
|
736
766
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
737
767
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -748,11 +778,15 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
748
778
|
}
|
|
749
779
|
}, _callee3);
|
|
750
780
|
}));
|
|
751
|
-
|
|
781
|
+
function calculateTransactionFee(_x3, _x4) {
|
|
782
|
+
return _calculateTransactionFee.apply(this, arguments);
|
|
783
|
+
}
|
|
784
|
+
return calculateTransactionFee;
|
|
785
|
+
}()
|
|
752
786
|
}, {
|
|
753
787
|
key: "getBalanceNative",
|
|
754
|
-
value: function
|
|
755
|
-
|
|
788
|
+
value: function () {
|
|
789
|
+
var _getBalanceNative = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(address) {
|
|
756
790
|
var response;
|
|
757
791
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
758
792
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -768,11 +802,15 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
768
802
|
}
|
|
769
803
|
}, _callee4, this);
|
|
770
804
|
}));
|
|
771
|
-
|
|
805
|
+
function getBalanceNative(_x5) {
|
|
806
|
+
return _getBalanceNative.apply(this, arguments);
|
|
807
|
+
}
|
|
808
|
+
return getBalanceNative;
|
|
809
|
+
}()
|
|
772
810
|
}, {
|
|
773
811
|
key: "getBalanceForeignPolkadotXcm",
|
|
774
|
-
value: function
|
|
775
|
-
|
|
812
|
+
value: function () {
|
|
813
|
+
var _getBalanceForeignPolkadotXcm = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(address, id) {
|
|
776
814
|
var parsedId, response, obj;
|
|
777
815
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
778
816
|
while (1) switch (_context5.prev = _context5.next) {
|
|
@@ -783,18 +821,22 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
783
821
|
case 3:
|
|
784
822
|
response = _context5.sent;
|
|
785
823
|
obj = response.toJSON();
|
|
786
|
-
return _context5.abrupt("return", obj.balance ? BigInt(obj.balance) :
|
|
824
|
+
return _context5.abrupt("return", obj.balance ? BigInt(obj.balance) : 0n);
|
|
787
825
|
case 6:
|
|
788
826
|
case "end":
|
|
789
827
|
return _context5.stop();
|
|
790
828
|
}
|
|
791
829
|
}, _callee5, this);
|
|
792
830
|
}));
|
|
793
|
-
|
|
831
|
+
function getBalanceForeignPolkadotXcm(_x6, _x7) {
|
|
832
|
+
return _getBalanceForeignPolkadotXcm.apply(this, arguments);
|
|
833
|
+
}
|
|
834
|
+
return getBalanceForeignPolkadotXcm;
|
|
835
|
+
}()
|
|
794
836
|
}, {
|
|
795
837
|
key: "getMythosForeignBalance",
|
|
796
|
-
value: function
|
|
797
|
-
|
|
838
|
+
value: function () {
|
|
839
|
+
var _getMythosForeignBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(address) {
|
|
798
840
|
var response, obj;
|
|
799
841
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
800
842
|
while (1) switch (_context6.prev = _context6.next) {
|
|
@@ -804,18 +846,22 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
804
846
|
case 2:
|
|
805
847
|
response = _context6.sent;
|
|
806
848
|
obj = response.toJSON();
|
|
807
|
-
return _context6.abrupt("return", obj.free ? BigInt(obj.free) :
|
|
849
|
+
return _context6.abrupt("return", obj.free ? BigInt(obj.free) : 0n);
|
|
808
850
|
case 5:
|
|
809
851
|
case "end":
|
|
810
852
|
return _context6.stop();
|
|
811
853
|
}
|
|
812
854
|
}, _callee6, this);
|
|
813
855
|
}));
|
|
814
|
-
|
|
856
|
+
function getMythosForeignBalance(_x8) {
|
|
857
|
+
return _getMythosForeignBalance.apply(this, arguments);
|
|
858
|
+
}
|
|
859
|
+
return getMythosForeignBalance;
|
|
860
|
+
}()
|
|
815
861
|
}, {
|
|
816
862
|
key: "getAssetHubForeignBalance",
|
|
817
|
-
value: function
|
|
818
|
-
|
|
863
|
+
value: function () {
|
|
864
|
+
var _getAssetHubForeignBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(address, multiLocation) {
|
|
819
865
|
var response, obj;
|
|
820
866
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
821
867
|
while (1) switch (_context7.prev = _context7.next) {
|
|
@@ -832,11 +878,15 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
832
878
|
}
|
|
833
879
|
}, _callee7, this);
|
|
834
880
|
}));
|
|
835
|
-
|
|
881
|
+
function getAssetHubForeignBalance(_x9, _x10) {
|
|
882
|
+
return _getAssetHubForeignBalance.apply(this, arguments);
|
|
883
|
+
}
|
|
884
|
+
return getAssetHubForeignBalance;
|
|
885
|
+
}()
|
|
836
886
|
}, {
|
|
837
887
|
key: "getForeignAssetsByIdBalance",
|
|
838
|
-
value: function
|
|
839
|
-
|
|
888
|
+
value: function () {
|
|
889
|
+
var _getForeignAssetsByIdBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(address, assetId) {
|
|
840
890
|
var response, obj;
|
|
841
891
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
842
892
|
while (1) switch (_context8.prev = _context8.next) {
|
|
@@ -853,11 +903,15 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
853
903
|
}
|
|
854
904
|
}, _callee8, this);
|
|
855
905
|
}));
|
|
856
|
-
|
|
906
|
+
function getForeignAssetsByIdBalance(_x11, _x12) {
|
|
907
|
+
return _getForeignAssetsByIdBalance.apply(this, arguments);
|
|
908
|
+
}
|
|
909
|
+
return getForeignAssetsByIdBalance;
|
|
910
|
+
}()
|
|
857
911
|
}, {
|
|
858
912
|
key: "getBalanceForeignBifrost",
|
|
859
|
-
value: function
|
|
860
|
-
|
|
913
|
+
value: function () {
|
|
914
|
+
var _getBalanceForeignBifrost = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(address, asset) {
|
|
861
915
|
var currencySelection, response, accountData;
|
|
862
916
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
863
917
|
while (1) switch (_context9.prev = _context9.next) {
|
|
@@ -868,18 +922,22 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
868
922
|
case 3:
|
|
869
923
|
response = _context9.sent;
|
|
870
924
|
accountData = response ? response : null;
|
|
871
|
-
return _context9.abrupt("return", accountData ? BigInt(accountData.free.toString()) :
|
|
925
|
+
return _context9.abrupt("return", accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
872
926
|
case 6:
|
|
873
927
|
case "end":
|
|
874
928
|
return _context9.stop();
|
|
875
929
|
}
|
|
876
930
|
}, _callee9, this);
|
|
877
931
|
}));
|
|
878
|
-
|
|
932
|
+
function getBalanceForeignBifrost(_x13, _x14) {
|
|
933
|
+
return _getBalanceForeignBifrost.apply(this, arguments);
|
|
934
|
+
}
|
|
935
|
+
return getBalanceForeignBifrost;
|
|
936
|
+
}()
|
|
879
937
|
}, {
|
|
880
938
|
key: "getBalanceNativeAcala",
|
|
881
|
-
value: function
|
|
882
|
-
|
|
939
|
+
value: function () {
|
|
940
|
+
var _getBalanceNativeAcala = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(address, symbol) {
|
|
883
941
|
var response, accountData;
|
|
884
942
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
885
943
|
while (1) switch (_context10.prev = _context10.next) {
|
|
@@ -891,18 +949,22 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
891
949
|
case 2:
|
|
892
950
|
response = _context10.sent;
|
|
893
951
|
accountData = response ? response : null;
|
|
894
|
-
return _context10.abrupt("return", accountData ? BigInt(accountData.free.toString()) :
|
|
952
|
+
return _context10.abrupt("return", accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
895
953
|
case 5:
|
|
896
954
|
case "end":
|
|
897
955
|
return _context10.stop();
|
|
898
956
|
}
|
|
899
957
|
}, _callee10, this);
|
|
900
958
|
}));
|
|
901
|
-
|
|
959
|
+
function getBalanceNativeAcala(_x15, _x16) {
|
|
960
|
+
return _getBalanceNativeAcala.apply(this, arguments);
|
|
961
|
+
}
|
|
962
|
+
return getBalanceNativeAcala;
|
|
963
|
+
}()
|
|
902
964
|
}, {
|
|
903
965
|
key: "getBalanceForeignXTokens",
|
|
904
|
-
value: function
|
|
905
|
-
|
|
966
|
+
value: function () {
|
|
967
|
+
var _getBalanceForeignXTokens = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(node, address, asset) {
|
|
906
968
|
var pallet, response, entry, accountData;
|
|
907
969
|
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
908
970
|
while (1) switch (_context11.prev = _context11.next) {
|
|
@@ -916,28 +978,32 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
916
978
|
case 4:
|
|
917
979
|
response = _context11.sent;
|
|
918
980
|
entry = response.find(function (_ref2) {
|
|
981
|
+
var _asset$symbol, _asset$assetId, _assetItem$toHuman, _asset$symbol2, _assetItem$toHuman2, _asset$assetId2;
|
|
919
982
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
920
983
|
_ref3$0$args = _slicedToArray(_ref3[0].args, 2);
|
|
921
984
|
_ref3$0$args[0];
|
|
922
985
|
var assetItem = _ref3$0$args[1];
|
|
923
986
|
_ref3[1];
|
|
924
|
-
var _a, _b, _c, _d, _e, _f;
|
|
925
987
|
var assetSymbol = assetItem.toString().toLowerCase();
|
|
926
|
-
return assetSymbol === ((
|
|
988
|
+
return assetSymbol === ((_asset$symbol = asset.symbol) === null || _asset$symbol === void 0 ? void 0 : _asset$symbol.toLowerCase()) || isForeignAsset(asset) && assetSymbol === ((_asset$assetId = asset.assetId) === null || _asset$assetId === void 0 ? void 0 : _asset$assetId.toLowerCase()) || Object.values((_assetItem$toHuman = assetItem.toHuman()) !== null && _assetItem$toHuman !== void 0 ? _assetItem$toHuman : {}).toString().toLowerCase() === ((_asset$symbol2 = asset.symbol) === null || _asset$symbol2 === void 0 ? void 0 : _asset$symbol2.toLowerCase()) || isForeignAsset(asset) && Object.values((_assetItem$toHuman2 = assetItem.toHuman()) !== null && _assetItem$toHuman2 !== void 0 ? _assetItem$toHuman2 : {}).toString().toLowerCase() === ((_asset$assetId2 = asset.assetId) === null || _asset$assetId2 === void 0 ? void 0 : _asset$assetId2.toLowerCase());
|
|
927
989
|
});
|
|
928
990
|
accountData = entry ? entry[1] : null;
|
|
929
|
-
return _context11.abrupt("return", accountData ? BigInt(accountData.free.toString()) :
|
|
991
|
+
return _context11.abrupt("return", accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
930
992
|
case 8:
|
|
931
993
|
case "end":
|
|
932
994
|
return _context11.stop();
|
|
933
995
|
}
|
|
934
996
|
}, _callee11, this);
|
|
935
997
|
}));
|
|
936
|
-
|
|
998
|
+
function getBalanceForeignXTokens(_x17, _x18, _x19) {
|
|
999
|
+
return _getBalanceForeignXTokens.apply(this, arguments);
|
|
1000
|
+
}
|
|
1001
|
+
return getBalanceForeignXTokens;
|
|
1002
|
+
}()
|
|
937
1003
|
}, {
|
|
938
1004
|
key: "getBalanceForeignAssetsAccount",
|
|
939
|
-
value: function
|
|
940
|
-
|
|
1005
|
+
value: function () {
|
|
1006
|
+
var _getBalanceForeignAssetsAccount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(address, assetId) {
|
|
941
1007
|
var response, obj;
|
|
942
1008
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
943
1009
|
while (1) switch (_context12.prev = _context12.next) {
|
|
@@ -954,11 +1020,15 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
954
1020
|
}
|
|
955
1021
|
}, _callee12, this);
|
|
956
1022
|
}));
|
|
957
|
-
|
|
1023
|
+
function getBalanceForeignAssetsAccount(_x20, _x21) {
|
|
1024
|
+
return _getBalanceForeignAssetsAccount.apply(this, arguments);
|
|
1025
|
+
}
|
|
1026
|
+
return getBalanceForeignAssetsAccount;
|
|
1027
|
+
}()
|
|
958
1028
|
}, {
|
|
959
1029
|
key: "getFromStorage",
|
|
960
|
-
value: function
|
|
961
|
-
|
|
1030
|
+
value: function () {
|
|
1031
|
+
var _getFromStorage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(key) {
|
|
962
1032
|
var response;
|
|
963
1033
|
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
964
1034
|
while (1) switch (_context13.prev = _context13.next) {
|
|
@@ -974,7 +1044,11 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
974
1044
|
}
|
|
975
1045
|
}, _callee13, this);
|
|
976
1046
|
}));
|
|
977
|
-
|
|
1047
|
+
function getFromStorage(_x22) {
|
|
1048
|
+
return _getFromStorage.apply(this, arguments);
|
|
1049
|
+
}
|
|
1050
|
+
return getFromStorage;
|
|
1051
|
+
}()
|
|
978
1052
|
}, {
|
|
979
1053
|
key: "clone",
|
|
980
1054
|
value: function clone() {
|
|
@@ -982,8 +1056,8 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
982
1056
|
}
|
|
983
1057
|
}, {
|
|
984
1058
|
key: "createApiForNode",
|
|
985
|
-
value: function
|
|
986
|
-
|
|
1059
|
+
value: function () {
|
|
1060
|
+
var _createApiForNode = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(node) {
|
|
987
1061
|
var api;
|
|
988
1062
|
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
989
1063
|
while (1) switch (_context14.prev = _context14.next) {
|
|
@@ -999,64 +1073,67 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
999
1073
|
}
|
|
1000
1074
|
}, _callee14);
|
|
1001
1075
|
}));
|
|
1002
|
-
|
|
1076
|
+
function createApiForNode(_x23) {
|
|
1077
|
+
return _createApiForNode.apply(this, arguments);
|
|
1078
|
+
}
|
|
1079
|
+
return createApiForNode;
|
|
1080
|
+
}()
|
|
1003
1081
|
}, {
|
|
1004
1082
|
key: "getDryRun",
|
|
1005
|
-
value: function
|
|
1006
|
-
|
|
1007
|
-
var
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
_context15.next = 5;
|
|
1024
|
-
return _this.api.call.dryRunApi.dryRunCall({
|
|
1025
|
-
system: {
|
|
1026
|
-
Signed: address
|
|
1027
|
-
}
|
|
1028
|
-
}, tx);
|
|
1029
|
-
case 5:
|
|
1030
|
-
result = _context15.sent.toHuman();
|
|
1031
|
-
isSuccess = result.Ok && result.Ok.executionResult.Ok;
|
|
1032
|
-
if (isSuccess) {
|
|
1033
|
-
_context15.next = 11;
|
|
1034
|
-
break;
|
|
1083
|
+
value: function () {
|
|
1084
|
+
var _getDryRun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(_ref4) {
|
|
1085
|
+
var tx, address, node, supportsDryRunApi, result, isSuccess, moduleError, failureReason, executionFee, fee;
|
|
1086
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1087
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1088
|
+
case 0:
|
|
1089
|
+
tx = _ref4.tx, address = _ref4.address, node = _ref4.node;
|
|
1090
|
+
supportsDryRunApi = getAssetsObject(node).supportsDryRunApi;
|
|
1091
|
+
if (supportsDryRunApi) {
|
|
1092
|
+
_context15.next = 4;
|
|
1093
|
+
break;
|
|
1094
|
+
}
|
|
1095
|
+
throw new Error("DryRunApi is not available on node ".concat(node));
|
|
1096
|
+
case 4:
|
|
1097
|
+
_context15.next = 6;
|
|
1098
|
+
return this.api.call.dryRunApi.dryRunCall({
|
|
1099
|
+
system: {
|
|
1100
|
+
Signed: address
|
|
1035
1101
|
}
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1102
|
+
}, tx);
|
|
1103
|
+
case 6:
|
|
1104
|
+
result = _context15.sent.toHuman();
|
|
1105
|
+
isSuccess = result.Ok && result.Ok.executionResult.Ok;
|
|
1106
|
+
if (isSuccess) {
|
|
1107
|
+
_context15.next = 12;
|
|
1108
|
+
break;
|
|
1109
|
+
}
|
|
1110
|
+
moduleError = result.Ok.executionResult.Err.error.Module;
|
|
1111
|
+
failureReason = resolveModuleError(node, moduleError);
|
|
1112
|
+
return _context15.abrupt("return", {
|
|
1113
|
+
success: false,
|
|
1114
|
+
failureReason: failureReason
|
|
1115
|
+
});
|
|
1116
|
+
case 12:
|
|
1117
|
+
_context15.next = 14;
|
|
1118
|
+
return this.calculateTransactionFee(tx, address);
|
|
1119
|
+
case 14:
|
|
1120
|
+
executionFee = _context15.sent;
|
|
1121
|
+
fee = computeFeeFromDryRunPjs(result, node, executionFee);
|
|
1122
|
+
return _context15.abrupt("return", {
|
|
1123
|
+
success: true,
|
|
1124
|
+
fee: fee
|
|
1125
|
+
});
|
|
1126
|
+
case 17:
|
|
1127
|
+
case "end":
|
|
1128
|
+
return _context15.stop();
|
|
1129
|
+
}
|
|
1130
|
+
}, _callee15, this);
|
|
1131
|
+
}));
|
|
1132
|
+
function getDryRun(_x24) {
|
|
1133
|
+
return _getDryRun.apply(this, arguments);
|
|
1134
|
+
}
|
|
1135
|
+
return getDryRun;
|
|
1136
|
+
}()
|
|
1060
1137
|
}, {
|
|
1061
1138
|
key: "setDisconnectAllowed",
|
|
1062
1139
|
value: function setDisconnectAllowed(allowed) {
|
|
@@ -1069,8 +1146,8 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1069
1146
|
}
|
|
1070
1147
|
}, {
|
|
1071
1148
|
key: "disconnect",
|
|
1072
|
-
value: function
|
|
1073
|
-
|
|
1149
|
+
value: function () {
|
|
1150
|
+
var _disconnect = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
1074
1151
|
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1075
1152
|
while (1) switch (_context16.prev = _context16.next) {
|
|
1076
1153
|
case 0:
|
|
@@ -1092,7 +1169,11 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1092
1169
|
}
|
|
1093
1170
|
}, _callee16, this);
|
|
1094
1171
|
}));
|
|
1095
|
-
|
|
1172
|
+
function disconnect() {
|
|
1173
|
+
return _disconnect.apply(this, arguments);
|
|
1174
|
+
}
|
|
1175
|
+
return disconnect;
|
|
1176
|
+
}()
|
|
1096
1177
|
}]);
|
|
1097
1178
|
}();
|
|
1098
1179
|
|
|
@@ -1101,15 +1182,15 @@ var createApiInstanceForNode = function createApiInstanceForNode(node) {
|
|
|
1101
1182
|
return createApiInstanceForNode$1(pjsApi, node);
|
|
1102
1183
|
};
|
|
1103
1184
|
var createPolkadotJsApiCall = function createPolkadotJsApiCall(apiCall) {
|
|
1104
|
-
return function (
|
|
1105
|
-
|
|
1185
|
+
return /*#__PURE__*/function () {
|
|
1186
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
1106
1187
|
var pjsApi, optionsWithApi;
|
|
1107
1188
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1108
1189
|
while (1) switch (_context.prev = _context.next) {
|
|
1109
1190
|
case 0:
|
|
1110
1191
|
pjsApi = new PolkadotJsApi();
|
|
1111
1192
|
pjsApi.setApi(options.api);
|
|
1112
|
-
optionsWithApi =
|
|
1193
|
+
optionsWithApi = _objectSpread2(_objectSpread2({}, options), {}, {
|
|
1113
1194
|
api: pjsApi
|
|
1114
1195
|
});
|
|
1115
1196
|
return _context.abrupt("return", apiCall(optionsWithApi));
|
|
@@ -1119,7 +1200,10 @@ var createPolkadotJsApiCall = function createPolkadotJsApiCall(apiCall) {
|
|
|
1119
1200
|
}
|
|
1120
1201
|
}, _callee);
|
|
1121
1202
|
}));
|
|
1122
|
-
|
|
1203
|
+
return function (_x) {
|
|
1204
|
+
return _ref.apply(this, arguments);
|
|
1205
|
+
};
|
|
1206
|
+
}();
|
|
1123
1207
|
};
|
|
1124
1208
|
|
|
1125
1209
|
/**
|
|
@@ -1127,19 +1211,10 @@ var createPolkadotJsApiCall = function createPolkadotJsApiCall(apiCall) {
|
|
|
1127
1211
|
* @param options - The transfer options.
|
|
1128
1212
|
* @returns An extrinsic to be signed and sent.
|
|
1129
1213
|
*/
|
|
1130
|
-
var send =
|
|
1131
|
-
var pjsApi = new PolkadotJsApi();
|
|
1132
|
-
pjsApi.setApi(options.api);
|
|
1133
|
-
var destPjsApi = new PolkadotJsApi();
|
|
1134
|
-
destPjsApi.setApi(options.destApiForKeepAlive);
|
|
1135
|
-
return send$1(Object.assign(Object.assign({}, options), {
|
|
1136
|
-
api: pjsApi,
|
|
1137
|
-
destApiForKeepAlive: destPjsApi
|
|
1138
|
-
}));
|
|
1139
|
-
};
|
|
1214
|
+
var send = createPolkadotJsApiCall(send$1);
|
|
1140
1215
|
var getDryRun = createPolkadotJsApiCall(getDryRun$1);
|
|
1141
1216
|
var transferEthToPolkadot = function transferEthToPolkadot(options) {
|
|
1142
|
-
return transferEthToPolkadot$1(
|
|
1217
|
+
return transferEthToPolkadot$1(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
1143
1218
|
api: new PolkadotJsApi()
|
|
1144
1219
|
}));
|
|
1145
1220
|
};
|
|
@@ -1189,15 +1264,34 @@ var getTransferableAmount = createPolkadotJsApiCall(getTransferableAmount$1);
|
|
|
1189
1264
|
|
|
1190
1265
|
var assets = /*#__PURE__*/Object.freeze({
|
|
1191
1266
|
__proto__: null,
|
|
1267
|
+
Foreign: Foreign,
|
|
1268
|
+
ForeignAbstract: ForeignAbstract,
|
|
1269
|
+
Native: Native,
|
|
1270
|
+
Override: Override,
|
|
1192
1271
|
claimAssets: claimAssets,
|
|
1272
|
+
getAllAssetsSymbols: getAllAssetsSymbols,
|
|
1193
1273
|
getAssetBalance: getAssetBalance,
|
|
1274
|
+
getAssetBySymbolOrId: getAssetBySymbolOrId,
|
|
1275
|
+
getAssetDecimals: getAssetDecimals,
|
|
1276
|
+
getAssetId: getAssetId,
|
|
1277
|
+
getAssets: getAssets,
|
|
1278
|
+
getAssetsObject: getAssetsObject,
|
|
1194
1279
|
getBalanceForeign: getBalanceForeign,
|
|
1195
1280
|
getBalanceNative: getBalanceNative,
|
|
1281
|
+
getExistentialDeposit: getExistentialDeposit,
|
|
1196
1282
|
getMaxForeignTransferableAmount: getMaxForeignTransferableAmount,
|
|
1197
1283
|
getMaxNativeTransferableAmount: getMaxNativeTransferableAmount,
|
|
1284
|
+
getNativeAssetSymbol: getNativeAssetSymbol,
|
|
1285
|
+
getNativeAssets: getNativeAssets,
|
|
1198
1286
|
getOriginFeeDetails: getOriginFeeDetails,
|
|
1287
|
+
getOtherAssets: getOtherAssets,
|
|
1288
|
+
getRelayChainSymbol: getRelayChainSymbol,
|
|
1289
|
+
getSupportedAssets: getSupportedAssets,
|
|
1290
|
+
getTNode: getTNode,
|
|
1199
1291
|
getTransferInfo: getTransferInfo,
|
|
1200
|
-
getTransferableAmount: getTransferableAmount
|
|
1292
|
+
getTransferableAmount: getTransferableAmount,
|
|
1293
|
+
hasSupportForAsset: hasSupportForAsset,
|
|
1294
|
+
isNodeEvm: isNodeEvm
|
|
1201
1295
|
});
|
|
1202
1296
|
|
|
1203
1297
|
/**
|
|
@@ -1271,9 +1365,10 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1271
1365
|
*/
|
|
1272
1366
|
}, {
|
|
1273
1367
|
key: "build",
|
|
1274
|
-
value: function
|
|
1275
|
-
|
|
1276
|
-
var
|
|
1368
|
+
value: (function () {
|
|
1369
|
+
var _build = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1370
|
+
var _yield$transferEthToP, _yield$transferEthToP2;
|
|
1371
|
+
var requiredParams, _i, _requiredParams, param;
|
|
1277
1372
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1278
1373
|
while (1) switch (_context.prev = _context.next) {
|
|
1279
1374
|
case 0:
|
|
@@ -1307,13 +1402,13 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1307
1402
|
_context.next = 15;
|
|
1308
1403
|
return transferEthToPolkadot$1(this._options);
|
|
1309
1404
|
case 15:
|
|
1310
|
-
_context.t2 =
|
|
1405
|
+
_context.t2 = _yield$transferEthToP2 = _context.sent.result.success;
|
|
1311
1406
|
_context.t1 = _context.t2 === null;
|
|
1312
1407
|
if (_context.t1) {
|
|
1313
1408
|
_context.next = 19;
|
|
1314
1409
|
break;
|
|
1315
1410
|
}
|
|
1316
|
-
_context.t1 =
|
|
1411
|
+
_context.t1 = _yield$transferEthToP2 === void 0;
|
|
1317
1412
|
case 19:
|
|
1318
1413
|
if (!_context.t1) {
|
|
1319
1414
|
_context.next = 23;
|
|
@@ -1323,21 +1418,21 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1323
1418
|
_context.next = 24;
|
|
1324
1419
|
break;
|
|
1325
1420
|
case 23:
|
|
1326
|
-
_context.t3 =
|
|
1421
|
+
_context.t3 = _yield$transferEthToP2.ethereum.blockHash;
|
|
1327
1422
|
case 24:
|
|
1328
|
-
_context.t4 =
|
|
1423
|
+
_context.t4 = _yield$transferEthToP = _context.t3;
|
|
1329
1424
|
_context.t0 = _context.t4 !== null;
|
|
1330
1425
|
if (!_context.t0) {
|
|
1331
1426
|
_context.next = 28;
|
|
1332
1427
|
break;
|
|
1333
1428
|
}
|
|
1334
|
-
_context.t0 =
|
|
1429
|
+
_context.t0 = _yield$transferEthToP !== void 0;
|
|
1335
1430
|
case 28:
|
|
1336
1431
|
if (!_context.t0) {
|
|
1337
1432
|
_context.next = 32;
|
|
1338
1433
|
break;
|
|
1339
1434
|
}
|
|
1340
|
-
_context.t5 =
|
|
1435
|
+
_context.t5 = _yield$transferEthToP;
|
|
1341
1436
|
_context.next = 33;
|
|
1342
1437
|
break;
|
|
1343
1438
|
case 32:
|
|
@@ -1350,7 +1445,11 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1350
1445
|
}
|
|
1351
1446
|
}, _callee, this);
|
|
1352
1447
|
}));
|
|
1353
|
-
|
|
1448
|
+
function build() {
|
|
1449
|
+
return _build.apply(this, arguments);
|
|
1450
|
+
}
|
|
1451
|
+
return build;
|
|
1452
|
+
}())
|
|
1354
1453
|
}]);
|
|
1355
1454
|
}();
|
|
1356
1455
|
/**
|