@paraspell/sdk-pjs 8.0.0 → 8.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +416 -284
- package/dist/index.d.ts +29 -8
- package/dist/index.mjs +417 -285
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getParaId, isForeignAsset, InvalidCurrencyError, getAssetBySymbolOrId, isOverrideMultiLocationSpecifier, createApiInstanceForNode as createApiInstanceForNode$1, getNode, 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, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getOtherAssets, 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,53 +456,8 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
402
456
|
}
|
|
403
457
|
}
|
|
404
458
|
|
|
405
|
-
|
|
406
|
-
|
|
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
|
-
var findEthAsset = function findEthAsset(currency) {
|
|
438
|
-
var ethAssets = getOtherAssets('Ethereum');
|
|
439
|
-
var ethAsset = 'symbol' in currency ? ethAssets.find(function (asset) {
|
|
440
|
-
return asset.symbol === currency.symbol;
|
|
441
|
-
}) : ethAssets.find(function (asset) {
|
|
442
|
-
return asset.assetId === currency.id;
|
|
443
|
-
});
|
|
444
|
-
if (!ethAsset) {
|
|
445
|
-
throw new InvalidCurrencyError("Currency ".concat(JSON.stringify(currency), " is not supported for Ethereum transfers"));
|
|
446
|
-
}
|
|
447
|
-
return ethAsset;
|
|
448
|
-
};
|
|
449
|
-
|
|
450
|
-
var createContext = function createContext(executionUrl, config) {
|
|
451
|
-
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
459
|
+
var createContext = /*#__PURE__*/function () {
|
|
460
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(executionUrl, config) {
|
|
452
461
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
453
462
|
while (1) switch (_context.prev = _context.next) {
|
|
454
463
|
case 0:
|
|
@@ -476,7 +485,10 @@ var createContext = function createContext(executionUrl, config) {
|
|
|
476
485
|
}
|
|
477
486
|
}, _callee);
|
|
478
487
|
}));
|
|
479
|
-
|
|
488
|
+
return function createContext(_x, _x2) {
|
|
489
|
+
return _ref.apply(this, arguments);
|
|
490
|
+
};
|
|
491
|
+
}();
|
|
480
492
|
|
|
481
493
|
var checkPlanFailure = function checkPlanFailure(plan) {
|
|
482
494
|
if (plan.failure) {
|
|
@@ -500,109 +512,152 @@ var isEthersSigner = function isEthersSigner(signer) {
|
|
|
500
512
|
*
|
|
501
513
|
* @throws Will throw an error if the transfer validation fails or if the transfer cannot be completed.
|
|
502
514
|
*/
|
|
503
|
-
var transferEthToPolkadot$1 = function
|
|
504
|
-
|
|
505
|
-
var provider
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
_context.next =
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
515
|
+
var transferEthToPolkadot$1 = /*#__PURE__*/function () {
|
|
516
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
517
|
+
var provider, signer, address, to, currency, ethAsset, env, context, destParaId, plan, result;
|
|
518
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
519
|
+
while (1) switch (_context.prev = _context.next) {
|
|
520
|
+
case 0:
|
|
521
|
+
provider = _ref.provider, signer = _ref.signer, address = _ref.address, to = _ref.to, currency = _ref.currency;
|
|
522
|
+
if (!('multiasset' in currency)) {
|
|
523
|
+
_context.next = 3;
|
|
524
|
+
break;
|
|
525
|
+
}
|
|
526
|
+
throw new Error('Multiassets syntax is not supported for Evm transfers');
|
|
527
|
+
case 3:
|
|
528
|
+
if (!('multilocation' in currency && isOverrideMultiLocationSpecifier(currency.multilocation))) {
|
|
529
|
+
_context.next = 5;
|
|
530
|
+
break;
|
|
531
|
+
}
|
|
532
|
+
throw new Error('Override multilocation is not supported for Evm transfers');
|
|
533
|
+
case 5:
|
|
534
|
+
if (provider) {
|
|
535
|
+
_context.next = 7;
|
|
536
|
+
break;
|
|
537
|
+
}
|
|
538
|
+
throw new Error('provider parameter is required for Snowbridge transfers.');
|
|
539
|
+
case 7:
|
|
540
|
+
if (isEthersSigner(signer)) {
|
|
541
|
+
_context.next = 9;
|
|
542
|
+
break;
|
|
543
|
+
}
|
|
544
|
+
throw new Error('Snowbridge does not support Viem provider yet.');
|
|
545
|
+
case 9:
|
|
546
|
+
ethAsset = getAssetBySymbolOrId('Ethereum', currency, to);
|
|
547
|
+
if (!(ethAsset === null)) {
|
|
534
548
|
_context.next = 12;
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
549
|
+
break;
|
|
550
|
+
}
|
|
551
|
+
throw new InvalidCurrencyError("Origin node Ethereum does not support currency ".concat(JSON.stringify(currency), "."));
|
|
552
|
+
case 12:
|
|
553
|
+
env = environment.SNOWBRIDGE_ENV['polkadot_mainnet'];
|
|
554
|
+
_context.next = 15;
|
|
555
|
+
return createContext(provider, env.config);
|
|
556
|
+
case 15:
|
|
557
|
+
context = _context.sent;
|
|
558
|
+
destParaId = getParaId(to);
|
|
559
|
+
if (!(!isForeignAsset(ethAsset) || ethAsset.assetId === undefined)) {
|
|
560
|
+
_context.next = 19;
|
|
561
|
+
break;
|
|
562
|
+
}
|
|
563
|
+
throw new InvalidCurrencyError('Selected asset has no asset id');
|
|
564
|
+
case 19:
|
|
565
|
+
_context.next = 21;
|
|
566
|
+
return toPolkadot.validateSend(context, signer, address, ethAsset.assetId, destParaId, BigInt(currency.amount), 0n);
|
|
567
|
+
case 21:
|
|
568
|
+
plan = _context.sent;
|
|
569
|
+
checkPlanFailure(plan);
|
|
570
|
+
_context.next = 25;
|
|
571
|
+
return toPolkadot.send(context, signer, plan);
|
|
572
|
+
case 25:
|
|
573
|
+
result = _context.sent;
|
|
574
|
+
return _context.abrupt("return", {
|
|
575
|
+
result: result,
|
|
576
|
+
plan: plan
|
|
577
|
+
});
|
|
578
|
+
case 27:
|
|
579
|
+
case "end":
|
|
580
|
+
return _context.stop();
|
|
581
|
+
}
|
|
582
|
+
}, _callee);
|
|
583
|
+
}));
|
|
584
|
+
return function transferEthToPolkadot(_x) {
|
|
585
|
+
return _ref2.apply(this, arguments);
|
|
586
|
+
};
|
|
587
|
+
}();
|
|
555
588
|
|
|
556
|
-
var buildEthTransferOptions = function
|
|
557
|
-
|
|
558
|
-
var currency
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
589
|
+
var buildEthTransferOptions = /*#__PURE__*/function () {
|
|
590
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
591
|
+
var currency, to, address, destAddress, ethAsset, env, EXECUTION_URL, context, destParaId, signer, plan;
|
|
592
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
593
|
+
while (1) switch (_context.prev = _context.next) {
|
|
594
|
+
case 0:
|
|
595
|
+
currency = _ref.currency, to = _ref.to, address = _ref.address, destAddress = _ref.destAddress;
|
|
596
|
+
if (!('multiasset' in currency)) {
|
|
597
|
+
_context.next = 3;
|
|
598
|
+
break;
|
|
599
|
+
}
|
|
600
|
+
throw new Error('Multiassets syntax is not supported for Evm transfers');
|
|
601
|
+
case 3:
|
|
602
|
+
if (!('multilocation' in currency && isOverrideMultiLocationSpecifier(currency.multilocation))) {
|
|
570
603
|
_context.next = 5;
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
604
|
+
break;
|
|
605
|
+
}
|
|
606
|
+
throw new Error('Override multilocation is not supported for Evm transfers');
|
|
607
|
+
case 5:
|
|
608
|
+
ethAsset = getAssetBySymbolOrId('Ethereum', currency, to);
|
|
609
|
+
if (!(ethAsset === null)) {
|
|
610
|
+
_context.next = 8;
|
|
611
|
+
break;
|
|
612
|
+
}
|
|
613
|
+
throw new InvalidCurrencyError("Origin node Ethereum does not support currency ".concat(JSON.stringify(currency), "."));
|
|
614
|
+
case 8:
|
|
615
|
+
env = environment.SNOWBRIDGE_ENV['polkadot_mainnet'];
|
|
616
|
+
EXECUTION_URL = 'https://eth.llamarpc.com';
|
|
617
|
+
_context.next = 12;
|
|
618
|
+
return createContext(EXECUTION_URL, env.config);
|
|
619
|
+
case 12:
|
|
620
|
+
context = _context.sent;
|
|
621
|
+
destParaId = getParaId(to);
|
|
622
|
+
signer = {
|
|
623
|
+
getAddress: function getAddress() {
|
|
624
|
+
return Promise.resolve(address);
|
|
588
625
|
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
626
|
+
};
|
|
627
|
+
if (!(!isForeignAsset(ethAsset) || ethAsset.assetId === undefined)) {
|
|
628
|
+
_context.next = 17;
|
|
629
|
+
break;
|
|
630
|
+
}
|
|
631
|
+
throw new InvalidCurrencyError('Selected asset has no asset id');
|
|
632
|
+
case 17:
|
|
633
|
+
_context.next = 19;
|
|
634
|
+
return toPolkadot.validateSend(context, signer, destAddress, ethAsset.assetId, destParaId, BigInt(currency.amount), 0n);
|
|
635
|
+
case 19:
|
|
636
|
+
plan = _context.sent;
|
|
637
|
+
checkPlanFailure(plan);
|
|
638
|
+
if (plan.success) {
|
|
639
|
+
_context.next = 23;
|
|
640
|
+
break;
|
|
641
|
+
}
|
|
642
|
+
throw new Error('Failed to validate send');
|
|
643
|
+
case 23:
|
|
644
|
+
return _context.abrupt("return", {
|
|
645
|
+
token: plan.success.token,
|
|
646
|
+
destinationParaId: plan.success.destinationParaId,
|
|
647
|
+
destinationFee: plan.success.destinationFee,
|
|
648
|
+
amount: plan.success.amount,
|
|
649
|
+
fee: plan.success.fee
|
|
650
|
+
});
|
|
651
|
+
case 24:
|
|
652
|
+
case "end":
|
|
653
|
+
return _context.stop();
|
|
654
|
+
}
|
|
655
|
+
}, _callee);
|
|
656
|
+
}));
|
|
657
|
+
return function buildEthTransferOptions(_x) {
|
|
658
|
+
return _ref2.apply(this, arguments);
|
|
659
|
+
};
|
|
660
|
+
}();
|
|
606
661
|
|
|
607
662
|
var lowercaseFirstLetter = function lowercaseFirstLetter(value) {
|
|
608
663
|
return value.charAt(0).toLowerCase() + value.slice(1);
|
|
@@ -635,9 +690,9 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
635
690
|
}
|
|
636
691
|
}, {
|
|
637
692
|
key: "init",
|
|
638
|
-
value: function
|
|
639
|
-
|
|
640
|
-
var
|
|
693
|
+
value: function () {
|
|
694
|
+
var _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(node) {
|
|
695
|
+
var _this$_api;
|
|
641
696
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
642
697
|
while (1) switch (_context.prev = _context.next) {
|
|
643
698
|
case 0:
|
|
@@ -658,11 +713,11 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
658
713
|
_context.next = 16;
|
|
659
714
|
break;
|
|
660
715
|
case 8:
|
|
661
|
-
if (!((
|
|
716
|
+
if (!((_this$_api = this._api) !== null && _this$_api !== void 0)) {
|
|
662
717
|
_context.next = 12;
|
|
663
718
|
break;
|
|
664
719
|
}
|
|
665
|
-
_context.t0 =
|
|
720
|
+
_context.t0 = _this$_api;
|
|
666
721
|
_context.next = 15;
|
|
667
722
|
break;
|
|
668
723
|
case 12:
|
|
@@ -680,11 +735,15 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
680
735
|
}
|
|
681
736
|
}, _callee, this);
|
|
682
737
|
}));
|
|
683
|
-
|
|
738
|
+
function init(_x) {
|
|
739
|
+
return _init.apply(this, arguments);
|
|
740
|
+
}
|
|
741
|
+
return init;
|
|
742
|
+
}()
|
|
684
743
|
}, {
|
|
685
744
|
key: "createApiInstance",
|
|
686
|
-
value: function
|
|
687
|
-
|
|
745
|
+
value: function () {
|
|
746
|
+
var _createApiInstance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(wsUrl) {
|
|
688
747
|
var wsProvider;
|
|
689
748
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
690
749
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -699,7 +758,11 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
699
758
|
}
|
|
700
759
|
}, _callee2);
|
|
701
760
|
}));
|
|
702
|
-
|
|
761
|
+
function createApiInstance(_x2) {
|
|
762
|
+
return _createApiInstance.apply(this, arguments);
|
|
763
|
+
}
|
|
764
|
+
return createApiInstance;
|
|
765
|
+
}()
|
|
703
766
|
}, {
|
|
704
767
|
key: "createAccountId",
|
|
705
768
|
value: function createAccountId(address) {
|
|
@@ -730,8 +793,8 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
730
793
|
}
|
|
731
794
|
}, {
|
|
732
795
|
key: "calculateTransactionFee",
|
|
733
|
-
value: function
|
|
734
|
-
|
|
796
|
+
value: function () {
|
|
797
|
+
var _calculateTransactionFee = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(tx, address) {
|
|
735
798
|
var _yield$tx$paymentInfo, partialFee;
|
|
736
799
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
737
800
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -748,11 +811,15 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
748
811
|
}
|
|
749
812
|
}, _callee3);
|
|
750
813
|
}));
|
|
751
|
-
|
|
814
|
+
function calculateTransactionFee(_x3, _x4) {
|
|
815
|
+
return _calculateTransactionFee.apply(this, arguments);
|
|
816
|
+
}
|
|
817
|
+
return calculateTransactionFee;
|
|
818
|
+
}()
|
|
752
819
|
}, {
|
|
753
820
|
key: "getBalanceNative",
|
|
754
|
-
value: function
|
|
755
|
-
|
|
821
|
+
value: function () {
|
|
822
|
+
var _getBalanceNative = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(address) {
|
|
756
823
|
var response;
|
|
757
824
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
758
825
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -768,11 +835,15 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
768
835
|
}
|
|
769
836
|
}, _callee4, this);
|
|
770
837
|
}));
|
|
771
|
-
|
|
838
|
+
function getBalanceNative(_x5) {
|
|
839
|
+
return _getBalanceNative.apply(this, arguments);
|
|
840
|
+
}
|
|
841
|
+
return getBalanceNative;
|
|
842
|
+
}()
|
|
772
843
|
}, {
|
|
773
844
|
key: "getBalanceForeignPolkadotXcm",
|
|
774
|
-
value: function
|
|
775
|
-
|
|
845
|
+
value: function () {
|
|
846
|
+
var _getBalanceForeignPolkadotXcm = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(address, id) {
|
|
776
847
|
var parsedId, response, obj;
|
|
777
848
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
778
849
|
while (1) switch (_context5.prev = _context5.next) {
|
|
@@ -783,18 +854,22 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
783
854
|
case 3:
|
|
784
855
|
response = _context5.sent;
|
|
785
856
|
obj = response.toJSON();
|
|
786
|
-
return _context5.abrupt("return", obj.balance ? BigInt(obj.balance) :
|
|
857
|
+
return _context5.abrupt("return", obj.balance ? BigInt(obj.balance) : 0n);
|
|
787
858
|
case 6:
|
|
788
859
|
case "end":
|
|
789
860
|
return _context5.stop();
|
|
790
861
|
}
|
|
791
862
|
}, _callee5, this);
|
|
792
863
|
}));
|
|
793
|
-
|
|
864
|
+
function getBalanceForeignPolkadotXcm(_x6, _x7) {
|
|
865
|
+
return _getBalanceForeignPolkadotXcm.apply(this, arguments);
|
|
866
|
+
}
|
|
867
|
+
return getBalanceForeignPolkadotXcm;
|
|
868
|
+
}()
|
|
794
869
|
}, {
|
|
795
870
|
key: "getMythosForeignBalance",
|
|
796
|
-
value: function
|
|
797
|
-
|
|
871
|
+
value: function () {
|
|
872
|
+
var _getMythosForeignBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(address) {
|
|
798
873
|
var response, obj;
|
|
799
874
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
800
875
|
while (1) switch (_context6.prev = _context6.next) {
|
|
@@ -804,18 +879,22 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
804
879
|
case 2:
|
|
805
880
|
response = _context6.sent;
|
|
806
881
|
obj = response.toJSON();
|
|
807
|
-
return _context6.abrupt("return", obj.free ? BigInt(obj.free) :
|
|
882
|
+
return _context6.abrupt("return", obj.free ? BigInt(obj.free) : 0n);
|
|
808
883
|
case 5:
|
|
809
884
|
case "end":
|
|
810
885
|
return _context6.stop();
|
|
811
886
|
}
|
|
812
887
|
}, _callee6, this);
|
|
813
888
|
}));
|
|
814
|
-
|
|
889
|
+
function getMythosForeignBalance(_x8) {
|
|
890
|
+
return _getMythosForeignBalance.apply(this, arguments);
|
|
891
|
+
}
|
|
892
|
+
return getMythosForeignBalance;
|
|
893
|
+
}()
|
|
815
894
|
}, {
|
|
816
895
|
key: "getAssetHubForeignBalance",
|
|
817
|
-
value: function
|
|
818
|
-
|
|
896
|
+
value: function () {
|
|
897
|
+
var _getAssetHubForeignBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(address, multiLocation) {
|
|
819
898
|
var response, obj;
|
|
820
899
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
821
900
|
while (1) switch (_context7.prev = _context7.next) {
|
|
@@ -832,11 +911,15 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
832
911
|
}
|
|
833
912
|
}, _callee7, this);
|
|
834
913
|
}));
|
|
835
|
-
|
|
914
|
+
function getAssetHubForeignBalance(_x9, _x10) {
|
|
915
|
+
return _getAssetHubForeignBalance.apply(this, arguments);
|
|
916
|
+
}
|
|
917
|
+
return getAssetHubForeignBalance;
|
|
918
|
+
}()
|
|
836
919
|
}, {
|
|
837
920
|
key: "getForeignAssetsByIdBalance",
|
|
838
|
-
value: function
|
|
839
|
-
|
|
921
|
+
value: function () {
|
|
922
|
+
var _getForeignAssetsByIdBalance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(address, assetId) {
|
|
840
923
|
var response, obj;
|
|
841
924
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
842
925
|
while (1) switch (_context8.prev = _context8.next) {
|
|
@@ -853,11 +936,15 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
853
936
|
}
|
|
854
937
|
}, _callee8, this);
|
|
855
938
|
}));
|
|
856
|
-
|
|
939
|
+
function getForeignAssetsByIdBalance(_x11, _x12) {
|
|
940
|
+
return _getForeignAssetsByIdBalance.apply(this, arguments);
|
|
941
|
+
}
|
|
942
|
+
return getForeignAssetsByIdBalance;
|
|
943
|
+
}()
|
|
857
944
|
}, {
|
|
858
945
|
key: "getBalanceForeignBifrost",
|
|
859
|
-
value: function
|
|
860
|
-
|
|
946
|
+
value: function () {
|
|
947
|
+
var _getBalanceForeignBifrost = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(address, asset) {
|
|
861
948
|
var currencySelection, response, accountData;
|
|
862
949
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
863
950
|
while (1) switch (_context9.prev = _context9.next) {
|
|
@@ -868,18 +955,22 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
868
955
|
case 3:
|
|
869
956
|
response = _context9.sent;
|
|
870
957
|
accountData = response ? response : null;
|
|
871
|
-
return _context9.abrupt("return", accountData ? BigInt(accountData.free.toString()) :
|
|
958
|
+
return _context9.abrupt("return", accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
872
959
|
case 6:
|
|
873
960
|
case "end":
|
|
874
961
|
return _context9.stop();
|
|
875
962
|
}
|
|
876
963
|
}, _callee9, this);
|
|
877
964
|
}));
|
|
878
|
-
|
|
965
|
+
function getBalanceForeignBifrost(_x13, _x14) {
|
|
966
|
+
return _getBalanceForeignBifrost.apply(this, arguments);
|
|
967
|
+
}
|
|
968
|
+
return getBalanceForeignBifrost;
|
|
969
|
+
}()
|
|
879
970
|
}, {
|
|
880
971
|
key: "getBalanceNativeAcala",
|
|
881
|
-
value: function
|
|
882
|
-
|
|
972
|
+
value: function () {
|
|
973
|
+
var _getBalanceNativeAcala = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(address, symbol) {
|
|
883
974
|
var response, accountData;
|
|
884
975
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
885
976
|
while (1) switch (_context10.prev = _context10.next) {
|
|
@@ -891,18 +982,22 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
891
982
|
case 2:
|
|
892
983
|
response = _context10.sent;
|
|
893
984
|
accountData = response ? response : null;
|
|
894
|
-
return _context10.abrupt("return", accountData ? BigInt(accountData.free.toString()) :
|
|
985
|
+
return _context10.abrupt("return", accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
895
986
|
case 5:
|
|
896
987
|
case "end":
|
|
897
988
|
return _context10.stop();
|
|
898
989
|
}
|
|
899
990
|
}, _callee10, this);
|
|
900
991
|
}));
|
|
901
|
-
|
|
992
|
+
function getBalanceNativeAcala(_x15, _x16) {
|
|
993
|
+
return _getBalanceNativeAcala.apply(this, arguments);
|
|
994
|
+
}
|
|
995
|
+
return getBalanceNativeAcala;
|
|
996
|
+
}()
|
|
902
997
|
}, {
|
|
903
998
|
key: "getBalanceForeignXTokens",
|
|
904
|
-
value: function
|
|
905
|
-
|
|
999
|
+
value: function () {
|
|
1000
|
+
var _getBalanceForeignXTokens = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(node, address, asset) {
|
|
906
1001
|
var pallet, response, entry, accountData;
|
|
907
1002
|
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
908
1003
|
while (1) switch (_context11.prev = _context11.next) {
|
|
@@ -916,28 +1011,32 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
916
1011
|
case 4:
|
|
917
1012
|
response = _context11.sent;
|
|
918
1013
|
entry = response.find(function (_ref2) {
|
|
1014
|
+
var _asset$symbol, _asset$assetId, _assetItem$toHuman, _asset$symbol2, _assetItem$toHuman2, _asset$assetId2;
|
|
919
1015
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
920
1016
|
_ref3$0$args = _slicedToArray(_ref3[0].args, 2);
|
|
921
1017
|
_ref3$0$args[0];
|
|
922
1018
|
var assetItem = _ref3$0$args[1];
|
|
923
1019
|
_ref3[1];
|
|
924
|
-
var _a, _b, _c, _d, _e, _f;
|
|
925
1020
|
var assetSymbol = assetItem.toString().toLowerCase();
|
|
926
|
-
return assetSymbol === ((
|
|
1021
|
+
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
1022
|
});
|
|
928
1023
|
accountData = entry ? entry[1] : null;
|
|
929
|
-
return _context11.abrupt("return", accountData ? BigInt(accountData.free.toString()) :
|
|
1024
|
+
return _context11.abrupt("return", accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
930
1025
|
case 8:
|
|
931
1026
|
case "end":
|
|
932
1027
|
return _context11.stop();
|
|
933
1028
|
}
|
|
934
1029
|
}, _callee11, this);
|
|
935
1030
|
}));
|
|
936
|
-
|
|
1031
|
+
function getBalanceForeignXTokens(_x17, _x18, _x19) {
|
|
1032
|
+
return _getBalanceForeignXTokens.apply(this, arguments);
|
|
1033
|
+
}
|
|
1034
|
+
return getBalanceForeignXTokens;
|
|
1035
|
+
}()
|
|
937
1036
|
}, {
|
|
938
1037
|
key: "getBalanceForeignAssetsAccount",
|
|
939
|
-
value: function
|
|
940
|
-
|
|
1038
|
+
value: function () {
|
|
1039
|
+
var _getBalanceForeignAssetsAccount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(address, assetId) {
|
|
941
1040
|
var response, obj;
|
|
942
1041
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
943
1042
|
while (1) switch (_context12.prev = _context12.next) {
|
|
@@ -954,11 +1053,15 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
954
1053
|
}
|
|
955
1054
|
}, _callee12, this);
|
|
956
1055
|
}));
|
|
957
|
-
|
|
1056
|
+
function getBalanceForeignAssetsAccount(_x20, _x21) {
|
|
1057
|
+
return _getBalanceForeignAssetsAccount.apply(this, arguments);
|
|
1058
|
+
}
|
|
1059
|
+
return getBalanceForeignAssetsAccount;
|
|
1060
|
+
}()
|
|
958
1061
|
}, {
|
|
959
1062
|
key: "getFromStorage",
|
|
960
|
-
value: function
|
|
961
|
-
|
|
1063
|
+
value: function () {
|
|
1064
|
+
var _getFromStorage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(key) {
|
|
962
1065
|
var response;
|
|
963
1066
|
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
964
1067
|
while (1) switch (_context13.prev = _context13.next) {
|
|
@@ -974,7 +1077,11 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
974
1077
|
}
|
|
975
1078
|
}, _callee13, this);
|
|
976
1079
|
}));
|
|
977
|
-
|
|
1080
|
+
function getFromStorage(_x22) {
|
|
1081
|
+
return _getFromStorage.apply(this, arguments);
|
|
1082
|
+
}
|
|
1083
|
+
return getFromStorage;
|
|
1084
|
+
}()
|
|
978
1085
|
}, {
|
|
979
1086
|
key: "clone",
|
|
980
1087
|
value: function clone() {
|
|
@@ -982,8 +1089,8 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
982
1089
|
}
|
|
983
1090
|
}, {
|
|
984
1091
|
key: "createApiForNode",
|
|
985
|
-
value: function
|
|
986
|
-
|
|
1092
|
+
value: function () {
|
|
1093
|
+
var _createApiForNode = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(node) {
|
|
987
1094
|
var api;
|
|
988
1095
|
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
989
1096
|
while (1) switch (_context14.prev = _context14.next) {
|
|
@@ -999,64 +1106,67 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
999
1106
|
}
|
|
1000
1107
|
}, _callee14);
|
|
1001
1108
|
}));
|
|
1002
|
-
|
|
1109
|
+
function createApiForNode(_x23) {
|
|
1110
|
+
return _createApiForNode.apply(this, arguments);
|
|
1111
|
+
}
|
|
1112
|
+
return createApiForNode;
|
|
1113
|
+
}()
|
|
1003
1114
|
}, {
|
|
1004
1115
|
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;
|
|
1116
|
+
value: function () {
|
|
1117
|
+
var _getDryRun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15(_ref4) {
|
|
1118
|
+
var tx, address, node, supportsDryRunApi, result, isSuccess, moduleError, failureReason, executionFee, fee;
|
|
1119
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1120
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1121
|
+
case 0:
|
|
1122
|
+
tx = _ref4.tx, address = _ref4.address, node = _ref4.node;
|
|
1123
|
+
supportsDryRunApi = getAssetsObject(node).supportsDryRunApi;
|
|
1124
|
+
if (supportsDryRunApi) {
|
|
1125
|
+
_context15.next = 4;
|
|
1126
|
+
break;
|
|
1127
|
+
}
|
|
1128
|
+
throw new Error("DryRunApi is not available on node ".concat(node));
|
|
1129
|
+
case 4:
|
|
1130
|
+
_context15.next = 6;
|
|
1131
|
+
return this.api.call.dryRunApi.dryRunCall({
|
|
1132
|
+
system: {
|
|
1133
|
+
Signed: address
|
|
1035
1134
|
}
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1135
|
+
}, tx);
|
|
1136
|
+
case 6:
|
|
1137
|
+
result = _context15.sent.toHuman();
|
|
1138
|
+
isSuccess = result.Ok && result.Ok.executionResult.Ok;
|
|
1139
|
+
if (isSuccess) {
|
|
1140
|
+
_context15.next = 12;
|
|
1141
|
+
break;
|
|
1142
|
+
}
|
|
1143
|
+
moduleError = result.Ok.executionResult.Err.error.Module;
|
|
1144
|
+
failureReason = resolveModuleError(node, moduleError);
|
|
1145
|
+
return _context15.abrupt("return", {
|
|
1146
|
+
success: false,
|
|
1147
|
+
failureReason: failureReason
|
|
1148
|
+
});
|
|
1149
|
+
case 12:
|
|
1150
|
+
_context15.next = 14;
|
|
1151
|
+
return this.calculateTransactionFee(tx, address);
|
|
1152
|
+
case 14:
|
|
1153
|
+
executionFee = _context15.sent;
|
|
1154
|
+
fee = computeFeeFromDryRunPjs(result, node, executionFee);
|
|
1155
|
+
return _context15.abrupt("return", {
|
|
1156
|
+
success: true,
|
|
1157
|
+
fee: fee
|
|
1158
|
+
});
|
|
1159
|
+
case 17:
|
|
1160
|
+
case "end":
|
|
1161
|
+
return _context15.stop();
|
|
1162
|
+
}
|
|
1163
|
+
}, _callee15, this);
|
|
1164
|
+
}));
|
|
1165
|
+
function getDryRun(_x24) {
|
|
1166
|
+
return _getDryRun.apply(this, arguments);
|
|
1167
|
+
}
|
|
1168
|
+
return getDryRun;
|
|
1169
|
+
}()
|
|
1060
1170
|
}, {
|
|
1061
1171
|
key: "setDisconnectAllowed",
|
|
1062
1172
|
value: function setDisconnectAllowed(allowed) {
|
|
@@ -1069,8 +1179,8 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1069
1179
|
}
|
|
1070
1180
|
}, {
|
|
1071
1181
|
key: "disconnect",
|
|
1072
|
-
value: function
|
|
1073
|
-
|
|
1182
|
+
value: function () {
|
|
1183
|
+
var _disconnect = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
1074
1184
|
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1075
1185
|
while (1) switch (_context16.prev = _context16.next) {
|
|
1076
1186
|
case 0:
|
|
@@ -1092,7 +1202,11 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1092
1202
|
}
|
|
1093
1203
|
}, _callee16, this);
|
|
1094
1204
|
}));
|
|
1095
|
-
|
|
1205
|
+
function disconnect() {
|
|
1206
|
+
return _disconnect.apply(this, arguments);
|
|
1207
|
+
}
|
|
1208
|
+
return disconnect;
|
|
1209
|
+
}()
|
|
1096
1210
|
}]);
|
|
1097
1211
|
}();
|
|
1098
1212
|
|
|
@@ -1101,15 +1215,15 @@ var createApiInstanceForNode = function createApiInstanceForNode(node) {
|
|
|
1101
1215
|
return createApiInstanceForNode$1(pjsApi, node);
|
|
1102
1216
|
};
|
|
1103
1217
|
var createPolkadotJsApiCall = function createPolkadotJsApiCall(apiCall) {
|
|
1104
|
-
return function (
|
|
1105
|
-
|
|
1218
|
+
return /*#__PURE__*/function () {
|
|
1219
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
1106
1220
|
var pjsApi, optionsWithApi;
|
|
1107
1221
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1108
1222
|
while (1) switch (_context.prev = _context.next) {
|
|
1109
1223
|
case 0:
|
|
1110
1224
|
pjsApi = new PolkadotJsApi();
|
|
1111
1225
|
pjsApi.setApi(options.api);
|
|
1112
|
-
optionsWithApi =
|
|
1226
|
+
optionsWithApi = _objectSpread2(_objectSpread2({}, options), {}, {
|
|
1113
1227
|
api: pjsApi
|
|
1114
1228
|
});
|
|
1115
1229
|
return _context.abrupt("return", apiCall(optionsWithApi));
|
|
@@ -1119,7 +1233,10 @@ var createPolkadotJsApiCall = function createPolkadotJsApiCall(apiCall) {
|
|
|
1119
1233
|
}
|
|
1120
1234
|
}, _callee);
|
|
1121
1235
|
}));
|
|
1122
|
-
|
|
1236
|
+
return function (_x) {
|
|
1237
|
+
return _ref.apply(this, arguments);
|
|
1238
|
+
};
|
|
1239
|
+
}();
|
|
1123
1240
|
};
|
|
1124
1241
|
|
|
1125
1242
|
/**
|
|
@@ -1127,19 +1244,10 @@ var createPolkadotJsApiCall = function createPolkadotJsApiCall(apiCall) {
|
|
|
1127
1244
|
* @param options - The transfer options.
|
|
1128
1245
|
* @returns An extrinsic to be signed and sent.
|
|
1129
1246
|
*/
|
|
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
|
-
};
|
|
1247
|
+
var send = createPolkadotJsApiCall(send$1);
|
|
1140
1248
|
var getDryRun = createPolkadotJsApiCall(getDryRun$1);
|
|
1141
1249
|
var transferEthToPolkadot = function transferEthToPolkadot(options) {
|
|
1142
|
-
return transferEthToPolkadot$1(
|
|
1250
|
+
return transferEthToPolkadot$1(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
1143
1251
|
api: new PolkadotJsApi()
|
|
1144
1252
|
}));
|
|
1145
1253
|
};
|
|
@@ -1189,15 +1297,34 @@ var getTransferableAmount = createPolkadotJsApiCall(getTransferableAmount$1);
|
|
|
1189
1297
|
|
|
1190
1298
|
var assets = /*#__PURE__*/Object.freeze({
|
|
1191
1299
|
__proto__: null,
|
|
1300
|
+
Foreign: Foreign,
|
|
1301
|
+
ForeignAbstract: ForeignAbstract,
|
|
1302
|
+
Native: Native,
|
|
1303
|
+
Override: Override,
|
|
1192
1304
|
claimAssets: claimAssets,
|
|
1305
|
+
getAllAssetsSymbols: getAllAssetsSymbols,
|
|
1193
1306
|
getAssetBalance: getAssetBalance,
|
|
1307
|
+
getAssetBySymbolOrId: getAssetBySymbolOrId,
|
|
1308
|
+
getAssetDecimals: getAssetDecimals,
|
|
1309
|
+
getAssetId: getAssetId,
|
|
1310
|
+
getAssets: getAssets,
|
|
1311
|
+
getAssetsObject: getAssetsObject,
|
|
1194
1312
|
getBalanceForeign: getBalanceForeign,
|
|
1195
1313
|
getBalanceNative: getBalanceNative,
|
|
1314
|
+
getExistentialDeposit: getExistentialDeposit,
|
|
1196
1315
|
getMaxForeignTransferableAmount: getMaxForeignTransferableAmount,
|
|
1197
1316
|
getMaxNativeTransferableAmount: getMaxNativeTransferableAmount,
|
|
1317
|
+
getNativeAssetSymbol: getNativeAssetSymbol,
|
|
1318
|
+
getNativeAssets: getNativeAssets,
|
|
1198
1319
|
getOriginFeeDetails: getOriginFeeDetails,
|
|
1320
|
+
getOtherAssets: getOtherAssets,
|
|
1321
|
+
getRelayChainSymbol: getRelayChainSymbol,
|
|
1322
|
+
getSupportedAssets: getSupportedAssets,
|
|
1323
|
+
getTNode: getTNode,
|
|
1199
1324
|
getTransferInfo: getTransferInfo,
|
|
1200
|
-
getTransferableAmount: getTransferableAmount
|
|
1325
|
+
getTransferableAmount: getTransferableAmount,
|
|
1326
|
+
hasSupportForAsset: hasSupportForAsset,
|
|
1327
|
+
isNodeEvm: isNodeEvm
|
|
1201
1328
|
});
|
|
1202
1329
|
|
|
1203
1330
|
/**
|
|
@@ -1271,9 +1398,10 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1271
1398
|
*/
|
|
1272
1399
|
}, {
|
|
1273
1400
|
key: "build",
|
|
1274
|
-
value: function
|
|
1275
|
-
|
|
1276
|
-
var
|
|
1401
|
+
value: (function () {
|
|
1402
|
+
var _build = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1403
|
+
var _yield$transferEthToP, _yield$transferEthToP2;
|
|
1404
|
+
var requiredParams, _i, _requiredParams, param;
|
|
1277
1405
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1278
1406
|
while (1) switch (_context.prev = _context.next) {
|
|
1279
1407
|
case 0:
|
|
@@ -1307,13 +1435,13 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1307
1435
|
_context.next = 15;
|
|
1308
1436
|
return transferEthToPolkadot$1(this._options);
|
|
1309
1437
|
case 15:
|
|
1310
|
-
_context.t2 =
|
|
1438
|
+
_context.t2 = _yield$transferEthToP2 = _context.sent.result.success;
|
|
1311
1439
|
_context.t1 = _context.t2 === null;
|
|
1312
1440
|
if (_context.t1) {
|
|
1313
1441
|
_context.next = 19;
|
|
1314
1442
|
break;
|
|
1315
1443
|
}
|
|
1316
|
-
_context.t1 =
|
|
1444
|
+
_context.t1 = _yield$transferEthToP2 === void 0;
|
|
1317
1445
|
case 19:
|
|
1318
1446
|
if (!_context.t1) {
|
|
1319
1447
|
_context.next = 23;
|
|
@@ -1323,21 +1451,21 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1323
1451
|
_context.next = 24;
|
|
1324
1452
|
break;
|
|
1325
1453
|
case 23:
|
|
1326
|
-
_context.t3 =
|
|
1454
|
+
_context.t3 = _yield$transferEthToP2.ethereum.blockHash;
|
|
1327
1455
|
case 24:
|
|
1328
|
-
_context.t4 =
|
|
1456
|
+
_context.t4 = _yield$transferEthToP = _context.t3;
|
|
1329
1457
|
_context.t0 = _context.t4 !== null;
|
|
1330
1458
|
if (!_context.t0) {
|
|
1331
1459
|
_context.next = 28;
|
|
1332
1460
|
break;
|
|
1333
1461
|
}
|
|
1334
|
-
_context.t0 =
|
|
1462
|
+
_context.t0 = _yield$transferEthToP !== void 0;
|
|
1335
1463
|
case 28:
|
|
1336
1464
|
if (!_context.t0) {
|
|
1337
1465
|
_context.next = 32;
|
|
1338
1466
|
break;
|
|
1339
1467
|
}
|
|
1340
|
-
_context.t5 =
|
|
1468
|
+
_context.t5 = _yield$transferEthToP;
|
|
1341
1469
|
_context.next = 33;
|
|
1342
1470
|
break;
|
|
1343
1471
|
case 32:
|
|
@@ -1350,7 +1478,11 @@ var EvmBuilderClass = /*#__PURE__*/function () {
|
|
|
1350
1478
|
}
|
|
1351
1479
|
}, _callee, this);
|
|
1352
1480
|
}));
|
|
1353
|
-
|
|
1481
|
+
function build() {
|
|
1482
|
+
return _build.apply(this, arguments);
|
|
1483
|
+
}
|
|
1484
|
+
return build;
|
|
1485
|
+
}())
|
|
1354
1486
|
}]);
|
|
1355
1487
|
}();
|
|
1356
1488
|
/**
|