@paraspell/sdk 6.2.1 → 6.2.3
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/README.md +1 -1
- package/dist/index.cjs +139 -144
- package/dist/index.d.ts +5 -2
- package/dist/index.mjs +139 -145
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -293,7 +293,7 @@ await getBalanceForeign(address, Parachain name, currency /*- {id: currencyID} |
|
|
|
293
293
|
await getBalanceNative(address, Parachain name)
|
|
294
294
|
|
|
295
295
|
//Get fee information regarding XCM call
|
|
296
|
-
await getOriginFeeDetails(from, to, currency /*- {id: currencyID} | {symbol: currencySymbol}*/, amount, originAddress)
|
|
296
|
+
await getOriginFeeDetails(from, to, currency /*- {id: currencyID} | {symbol: currencySymbol}*/, amount, originAddress, api /* optional */, feeMargin /* 10% by default */)
|
|
297
297
|
|
|
298
298
|
//Get all the information about XCM transfer
|
|
299
299
|
await getTransferInfo(from, to, address, destinationAddress, currency /*- {id: currencyID} | {symbol: currencySymbol}*/, amount)
|
package/dist/index.cjs
CHANGED
|
@@ -11518,60 +11518,6 @@ var getBalanceForeign = function getBalanceForeign(address, node, symbolOrId, ap
|
|
|
11518
11518
|
}));
|
|
11519
11519
|
};
|
|
11520
11520
|
|
|
11521
|
-
var getAssetBalance = function getAssetBalance(account, node, currency) {
|
|
11522
|
-
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
11523
|
-
var _a, api, isNativeSymbol;
|
|
11524
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
11525
|
-
while (1) switch (_context.prev = _context.next) {
|
|
11526
|
-
case 0:
|
|
11527
|
-
_context.next = 2;
|
|
11528
|
-
return createApiInstanceForNode(node);
|
|
11529
|
-
case 2:
|
|
11530
|
-
api = _context.sent;
|
|
11531
|
-
isNativeSymbol = 'symbol' in currency && getNativeAssetSymbol(node) === currency.symbol;
|
|
11532
|
-
if (!isNativeSymbol) {
|
|
11533
|
-
_context.next = 10;
|
|
11534
|
-
break;
|
|
11535
|
-
}
|
|
11536
|
-
_context.next = 7;
|
|
11537
|
-
return getBalanceNative(account, node, api);
|
|
11538
|
-
case 7:
|
|
11539
|
-
_context.t0 = _context.sent;
|
|
11540
|
-
_context.next = 22;
|
|
11541
|
-
break;
|
|
11542
|
-
case 10:
|
|
11543
|
-
_context.next = 12;
|
|
11544
|
-
return getBalanceForeign(account, node, currency, api);
|
|
11545
|
-
case 12:
|
|
11546
|
-
_context.t2 = _a = _context.sent;
|
|
11547
|
-
_context.t1 = _context.t2 !== null;
|
|
11548
|
-
if (!_context.t1) {
|
|
11549
|
-
_context.next = 16;
|
|
11550
|
-
break;
|
|
11551
|
-
}
|
|
11552
|
-
_context.t1 = _a !== void 0;
|
|
11553
|
-
case 16:
|
|
11554
|
-
if (!_context.t1) {
|
|
11555
|
-
_context.next = 20;
|
|
11556
|
-
break;
|
|
11557
|
-
}
|
|
11558
|
-
_context.t3 = _a;
|
|
11559
|
-
_context.next = 21;
|
|
11560
|
-
break;
|
|
11561
|
-
case 20:
|
|
11562
|
-
_context.t3 = BigInt(0);
|
|
11563
|
-
case 21:
|
|
11564
|
-
_context.t0 = _context.t3;
|
|
11565
|
-
case 22:
|
|
11566
|
-
return _context.abrupt("return", _context.t0);
|
|
11567
|
-
case 23:
|
|
11568
|
-
case "end":
|
|
11569
|
-
return _context.stop();
|
|
11570
|
-
}
|
|
11571
|
-
}, _callee);
|
|
11572
|
-
}));
|
|
11573
|
-
};
|
|
11574
|
-
|
|
11575
11521
|
var palletsMap = edsMapJson;
|
|
11576
11522
|
var getExistentialDeposit = function getExistentialDeposit(node) {
|
|
11577
11523
|
return BigInt(palletsMap[node]);
|
|
@@ -12689,6 +12635,26 @@ var EvmBuilder = function EvmBuilder(provider) {
|
|
|
12689
12635
|
return new EvmBuilderClass(provider);
|
|
12690
12636
|
};
|
|
12691
12637
|
|
|
12638
|
+
var calculateTransactionFee = function calculateTransactionFee(tx, address) {
|
|
12639
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
12640
|
+
var _yield$tx$paymentInfo, partialFee;
|
|
12641
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
12642
|
+
while (1) switch (_context.prev = _context.next) {
|
|
12643
|
+
case 0:
|
|
12644
|
+
_context.next = 2;
|
|
12645
|
+
return tx.paymentInfo(address);
|
|
12646
|
+
case 2:
|
|
12647
|
+
_yield$tx$paymentInfo = _context.sent;
|
|
12648
|
+
partialFee = _yield$tx$paymentInfo.partialFee;
|
|
12649
|
+
return _context.abrupt("return", partialFee.toBn());
|
|
12650
|
+
case 5:
|
|
12651
|
+
case "end":
|
|
12652
|
+
return _context.stop();
|
|
12653
|
+
}
|
|
12654
|
+
}, _callee);
|
|
12655
|
+
}));
|
|
12656
|
+
};
|
|
12657
|
+
|
|
12692
12658
|
var createTx$1 = function createTx(originApi, address, amount, currency, originNode, destNode) {
|
|
12693
12659
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
12694
12660
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -12723,74 +12689,115 @@ var createTx$1 = function createTx(originApi, address, amount, currency, originN
|
|
|
12723
12689
|
}, _callee);
|
|
12724
12690
|
}));
|
|
12725
12691
|
};
|
|
12726
|
-
var
|
|
12727
|
-
|
|
12728
|
-
|
|
12729
|
-
|
|
12730
|
-
|
|
12731
|
-
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
|
|
12735
|
-
|
|
12736
|
-
|
|
12737
|
-
|
|
12738
|
-
|
|
12739
|
-
|
|
12740
|
-
|
|
12741
|
-
|
|
12742
|
-
|
|
12743
|
-
|
|
12692
|
+
var getOriginFeeDetails = function getOriginFeeDetails(origin_1, destination_1, currency_1, amount_1, account_1, api_1) {
|
|
12693
|
+
for (var _len = arguments.length, args_1 = new Array(_len > 6 ? _len - 6 : 0), _key = 6; _key < _len; _key++) {
|
|
12694
|
+
args_1[_key - 6] = arguments[_key];
|
|
12695
|
+
}
|
|
12696
|
+
return __awaiter(void 0, [origin_1, destination_1, currency_1, amount_1, account_1, api_1].concat(args_1), void 0, function (origin, destination, currency, amount, account, api) {
|
|
12697
|
+
var feeMarginPercentage = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 10;
|
|
12698
|
+
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
12699
|
+
var nativeBalance, minTransferableAmount, apiWithFallback, tx, xcmFee, xcmFeeBigInt, xcmFeeWithMargin, sufficientForXCM;
|
|
12700
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
12701
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
12702
|
+
case 0:
|
|
12703
|
+
_context2.next = 2;
|
|
12704
|
+
return getBalanceNative(account, origin);
|
|
12705
|
+
case 2:
|
|
12706
|
+
nativeBalance = _context2.sent;
|
|
12707
|
+
minTransferableAmount = getMinNativeTransferableAmount(origin);
|
|
12708
|
+
if (!(api !== null && api !== void 0)) {
|
|
12709
|
+
_context2.next = 8;
|
|
12710
|
+
break;
|
|
12711
|
+
}
|
|
12712
|
+
_context2.t0 = api;
|
|
12713
|
+
_context2.next = 11;
|
|
12714
|
+
break;
|
|
12715
|
+
case 8:
|
|
12716
|
+
_context2.next = 10;
|
|
12717
|
+
return createApiInstanceForNode(origin);
|
|
12718
|
+
case 10:
|
|
12719
|
+
_context2.t0 = _context2.sent;
|
|
12720
|
+
case 11:
|
|
12721
|
+
apiWithFallback = _context2.t0;
|
|
12722
|
+
_context2.next = 14;
|
|
12723
|
+
return createTx$1(apiWithFallback, account, amount, currency, origin, destination);
|
|
12724
|
+
case 14:
|
|
12725
|
+
tx = _context2.sent;
|
|
12726
|
+
_context2.next = 17;
|
|
12727
|
+
return calculateTransactionFee(tx, account);
|
|
12728
|
+
case 17:
|
|
12729
|
+
xcmFee = _context2.sent;
|
|
12730
|
+
xcmFeeBigInt = BigInt(xcmFee.toString());
|
|
12731
|
+
xcmFeeWithMargin = xcmFeeBigInt + xcmFeeBigInt / BigInt(feeMarginPercentage);
|
|
12732
|
+
console.log('nativeBalance', nativeBalance);
|
|
12733
|
+
console.log('minTransferableAmount', minTransferableAmount);
|
|
12734
|
+
console.log('xcmFeeBigInt', xcmFeeBigInt);
|
|
12735
|
+
console.log('xcmFeeWithMargin', xcmFeeWithMargin);
|
|
12736
|
+
sufficientForXCM = nativeBalance - minTransferableAmount - xcmFeeWithMargin > 0;
|
|
12737
|
+
return _context2.abrupt("return", {
|
|
12738
|
+
sufficientForXCM: sufficientForXCM,
|
|
12739
|
+
xcmFee: xcmFeeBigInt
|
|
12740
|
+
});
|
|
12741
|
+
case 26:
|
|
12742
|
+
case "end":
|
|
12743
|
+
return _context2.stop();
|
|
12744
|
+
}
|
|
12745
|
+
}, _callee2);
|
|
12746
|
+
})();
|
|
12747
|
+
});
|
|
12744
12748
|
};
|
|
12745
|
-
|
|
12746
|
-
|
|
12747
|
-
|
|
12748
|
-
|
|
12749
|
-
|
|
12749
|
+
|
|
12750
|
+
var getAssetBalance = function getAssetBalance(account, node, currency) {
|
|
12751
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
12752
|
+
var _a, api, isNativeSymbol;
|
|
12753
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
12754
|
+
while (1) switch (_context.prev = _context.next) {
|
|
12750
12755
|
case 0:
|
|
12751
|
-
|
|
12752
|
-
return
|
|
12756
|
+
_context.next = 2;
|
|
12757
|
+
return createApiInstanceForNode(node);
|
|
12753
12758
|
case 2:
|
|
12754
|
-
|
|
12755
|
-
|
|
12756
|
-
if (!
|
|
12757
|
-
|
|
12759
|
+
api = _context.sent;
|
|
12760
|
+
isNativeSymbol = 'symbol' in currency && getNativeAssetSymbol(node) === currency.symbol;
|
|
12761
|
+
if (!isNativeSymbol) {
|
|
12762
|
+
_context.next = 10;
|
|
12758
12763
|
break;
|
|
12759
12764
|
}
|
|
12760
|
-
|
|
12761
|
-
|
|
12765
|
+
_context.next = 7;
|
|
12766
|
+
return getBalanceNative(account, node, api);
|
|
12767
|
+
case 7:
|
|
12768
|
+
_context.t0 = _context.sent;
|
|
12769
|
+
_context.next = 22;
|
|
12762
12770
|
break;
|
|
12763
|
-
case 8:
|
|
12764
|
-
_context3.next = 10;
|
|
12765
|
-
return createApiInstanceForNode(origin);
|
|
12766
12771
|
case 10:
|
|
12767
|
-
|
|
12768
|
-
|
|
12769
|
-
|
|
12770
|
-
|
|
12771
|
-
|
|
12772
|
-
|
|
12773
|
-
|
|
12774
|
-
|
|
12775
|
-
|
|
12776
|
-
|
|
12777
|
-
|
|
12778
|
-
|
|
12779
|
-
|
|
12780
|
-
|
|
12781
|
-
|
|
12782
|
-
|
|
12783
|
-
|
|
12784
|
-
|
|
12785
|
-
|
|
12786
|
-
|
|
12787
|
-
|
|
12788
|
-
|
|
12789
|
-
case
|
|
12772
|
+
_context.next = 12;
|
|
12773
|
+
return getBalanceForeign(account, node, currency, api);
|
|
12774
|
+
case 12:
|
|
12775
|
+
_context.t2 = _a = _context.sent;
|
|
12776
|
+
_context.t1 = _context.t2 !== null;
|
|
12777
|
+
if (!_context.t1) {
|
|
12778
|
+
_context.next = 16;
|
|
12779
|
+
break;
|
|
12780
|
+
}
|
|
12781
|
+
_context.t1 = _a !== void 0;
|
|
12782
|
+
case 16:
|
|
12783
|
+
if (!_context.t1) {
|
|
12784
|
+
_context.next = 20;
|
|
12785
|
+
break;
|
|
12786
|
+
}
|
|
12787
|
+
_context.t3 = _a;
|
|
12788
|
+
_context.next = 21;
|
|
12789
|
+
break;
|
|
12790
|
+
case 20:
|
|
12791
|
+
_context.t3 = BigInt(0);
|
|
12792
|
+
case 21:
|
|
12793
|
+
_context.t0 = _context.t3;
|
|
12794
|
+
case 22:
|
|
12795
|
+
return _context.abrupt("return", _context.t0);
|
|
12796
|
+
case 23:
|
|
12790
12797
|
case "end":
|
|
12791
|
-
return
|
|
12798
|
+
return _context.stop();
|
|
12792
12799
|
}
|
|
12793
|
-
},
|
|
12800
|
+
}, _callee);
|
|
12794
12801
|
}));
|
|
12795
12802
|
};
|
|
12796
12803
|
|
|
@@ -12826,35 +12833,41 @@ var getTransferInfo = function getTransferInfo(origin, destination, accountOrigi
|
|
|
12826
12833
|
destXcmFee = _yield$getOriginFeeDe.xcmFee;
|
|
12827
12834
|
expectedBalanceAfterXCMDelivery = originBalance - destXcmFee;
|
|
12828
12835
|
asset = getAssetBySymbolOrId(origin, currency);
|
|
12836
|
+
if (asset) {
|
|
12837
|
+
_context.next = 14;
|
|
12838
|
+
break;
|
|
12839
|
+
}
|
|
12840
|
+
throw new InvalidCurrencyError("Asset ".concat('symbol' in currency ? currency.symbol : currency.id, " not found on ").concat(origin));
|
|
12841
|
+
case 14:
|
|
12829
12842
|
_context.t0 = {
|
|
12830
12843
|
origin: origin,
|
|
12831
12844
|
destination: destination,
|
|
12832
12845
|
ecosystem: determineRelayChainSymbol(origin)
|
|
12833
12846
|
};
|
|
12834
|
-
_context.next =
|
|
12847
|
+
_context.next = 17;
|
|
12835
12848
|
return getAssetBalance(accountOrigin, origin, currency);
|
|
12836
|
-
case
|
|
12849
|
+
case 17:
|
|
12837
12850
|
_context.t1 = _context.sent;
|
|
12838
12851
|
_context.t2 = (_a = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _a !== void 0 ? _a : '';
|
|
12839
12852
|
_context.t3 = {
|
|
12840
12853
|
balance: _context.t1,
|
|
12841
12854
|
currency: _context.t2
|
|
12842
12855
|
};
|
|
12843
|
-
_context.next =
|
|
12856
|
+
_context.next = 22;
|
|
12844
12857
|
return getBalanceNative(accountOrigin, origin, originApi);
|
|
12845
|
-
case
|
|
12858
|
+
case 22:
|
|
12846
12859
|
_context.t4 = _context.sent;
|
|
12847
12860
|
_context.t5 = expectedBalanceAfterXCMDelivery;
|
|
12848
|
-
_context.next =
|
|
12861
|
+
_context.next = 26;
|
|
12849
12862
|
return getOriginFeeDetails(origin, destination, currency, amount, accountOrigin, originApi);
|
|
12850
|
-
case
|
|
12863
|
+
case 26:
|
|
12851
12864
|
_context.t6 = _context.sent;
|
|
12852
12865
|
_context.t7 = BigInt((_b = getExistentialDeposit(origin)) !== null && _b !== void 0 ? _b : 0);
|
|
12853
12866
|
_context.t8 = getNativeAssetSymbol(origin);
|
|
12854
12867
|
_context.t9 = getMinNativeTransferableAmount(origin);
|
|
12855
|
-
_context.next =
|
|
12868
|
+
_context.next = 32;
|
|
12856
12869
|
return getMaxNativeTransferableAmount(accountOrigin, origin);
|
|
12857
|
-
case
|
|
12870
|
+
case 32:
|
|
12858
12871
|
_context.t10 = _context.sent;
|
|
12859
12872
|
_context.t11 = {
|
|
12860
12873
|
balance: _context.t4,
|
|
@@ -12865,9 +12878,9 @@ var getTransferInfo = function getTransferInfo(origin, destination, accountOrigi
|
|
|
12865
12878
|
minNativeTransferableAmount: _context.t9,
|
|
12866
12879
|
maxNativeTransferableAmount: _context.t10
|
|
12867
12880
|
};
|
|
12868
|
-
_context.next =
|
|
12881
|
+
_context.next = 36;
|
|
12869
12882
|
return getBalanceNative(accountDestination, destination);
|
|
12870
|
-
case
|
|
12883
|
+
case 36:
|
|
12871
12884
|
_context.t12 = _context.sent;
|
|
12872
12885
|
_context.t13 = getNativeAssetSymbol(destination);
|
|
12873
12886
|
_context.t14 = getExistentialDeposit(destination);
|
|
@@ -12882,7 +12895,7 @@ var getTransferInfo = function getTransferInfo(origin, destination, accountOrigi
|
|
|
12882
12895
|
originFeeBalance: _context.t11,
|
|
12883
12896
|
destinationFeeBalance: _context.t15
|
|
12884
12897
|
});
|
|
12885
|
-
case
|
|
12898
|
+
case 41:
|
|
12886
12899
|
case "end":
|
|
12887
12900
|
return _context.stop();
|
|
12888
12901
|
}
|
|
@@ -12940,6 +12953,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
12940
12953
|
getExistentialDeposit: getExistentialDeposit$1,
|
|
12941
12954
|
getNativeAssetSymbol: getNativeAssetSymbol,
|
|
12942
12955
|
getNativeAssets: getNativeAssets,
|
|
12956
|
+
getOriginFeeDetails: getOriginFeeDetails,
|
|
12943
12957
|
getOtherAssets: getOtherAssets,
|
|
12944
12958
|
getParaId: getParaId,
|
|
12945
12959
|
getRelayChainSymbol: getRelayChainSymbol,
|
|
@@ -13216,26 +13230,6 @@ var KeepAliveError = /*#__PURE__*/function (_Error) {
|
|
|
13216
13230
|
return _createClass(KeepAliveError);
|
|
13217
13231
|
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
13218
13232
|
|
|
13219
|
-
var calculateTransactionFee = function calculateTransactionFee(tx, address) {
|
|
13220
|
-
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
13221
|
-
var _yield$tx$paymentInfo, partialFee;
|
|
13222
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
13223
|
-
while (1) switch (_context.prev = _context.next) {
|
|
13224
|
-
case 0:
|
|
13225
|
-
_context.next = 2;
|
|
13226
|
-
return tx.paymentInfo(address);
|
|
13227
|
-
case 2:
|
|
13228
|
-
_yield$tx$paymentInfo = _context.sent;
|
|
13229
|
-
partialFee = _yield$tx$paymentInfo.partialFee;
|
|
13230
|
-
return _context.abrupt("return", partialFee.toBn());
|
|
13231
|
-
case 5:
|
|
13232
|
-
case "end":
|
|
13233
|
-
return _context.stop();
|
|
13234
|
-
}
|
|
13235
|
-
}, _callee);
|
|
13236
|
-
}));
|
|
13237
|
-
};
|
|
13238
|
-
|
|
13239
13233
|
var createTx = function createTx(originApi, destApi, address, amount, currencySymbol, originNode, destNode) {
|
|
13240
13234
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
13241
13235
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -13840,6 +13834,7 @@ exports.getNativeAssets = getNativeAssets;
|
|
|
13840
13834
|
exports.getNode = getNode;
|
|
13841
13835
|
exports.getNodeEndpointOption = getNodeEndpointOption;
|
|
13842
13836
|
exports.getNodeProvider = getNodeProvider;
|
|
13837
|
+
exports.getOriginFeeDetails = getOriginFeeDetails;
|
|
13843
13838
|
exports.getOtherAssets = getOtherAssets;
|
|
13844
13839
|
exports.getParaId = getParaId;
|
|
13845
13840
|
exports.getRelayChainSymbol = getRelayChainSymbol;
|
package/dist/index.d.ts
CHANGED
|
@@ -1121,6 +1121,8 @@ declare const getBalanceNative: (address: string, node: TNodeWithRelayChains, ap
|
|
|
1121
1121
|
*/
|
|
1122
1122
|
declare const getBalanceForeign: (address: string, node: TNodePolkadotKusama, symbolOrId: TCurrencyCore, api?: ApiPromise) => Promise<bigint | null>;
|
|
1123
1123
|
|
|
1124
|
+
declare const getOriginFeeDetails: (origin: TNodeDotKsmWithRelayChains, destination: TNodeDotKsmWithRelayChains, currency: TCurrencyCore, amount: string, account: string, api?: ApiPromise, feeMarginPercentage?: number) => Promise<TOriginFeeDetails>;
|
|
1125
|
+
|
|
1124
1126
|
/**
|
|
1125
1127
|
* Retrieves detailed transfer information for a cross-chain transfer.
|
|
1126
1128
|
*
|
|
@@ -1153,6 +1155,7 @@ declare const index_getBalanceNative: typeof getBalanceNative;
|
|
|
1153
1155
|
declare const index_getExistentialDeposit: typeof getExistentialDeposit;
|
|
1154
1156
|
declare const index_getNativeAssetSymbol: typeof getNativeAssetSymbol;
|
|
1155
1157
|
declare const index_getNativeAssets: typeof getNativeAssets;
|
|
1158
|
+
declare const index_getOriginFeeDetails: typeof getOriginFeeDetails;
|
|
1156
1159
|
declare const index_getOtherAssets: typeof getOtherAssets;
|
|
1157
1160
|
declare const index_getParaId: typeof getParaId;
|
|
1158
1161
|
declare const index_getRelayChainSymbol: typeof getRelayChainSymbol;
|
|
@@ -1161,7 +1164,7 @@ declare const index_getTNode: typeof getTNode;
|
|
|
1161
1164
|
declare const index_getTransferInfo: typeof getTransferInfo;
|
|
1162
1165
|
declare const index_hasSupportForAsset: typeof hasSupportForAsset;
|
|
1163
1166
|
declare namespace index {
|
|
1164
|
-
export { index_getAllAssetsSymbols as getAllAssetsSymbols, index_getAssetDecimals as getAssetDecimals, index_getAssetId as getAssetId, index_getAssets as getAssets, index_getAssetsObject as getAssetsObject, index_getBalanceForeign as getBalanceForeign, index_getBalanceNative as getBalanceNative, index_getExistentialDeposit as getExistentialDeposit, index_getNativeAssetSymbol as getNativeAssetSymbol, index_getNativeAssets as getNativeAssets, index_getOtherAssets as getOtherAssets, index_getParaId as getParaId, index_getRelayChainSymbol as getRelayChainSymbol, index_getSupportedAssets as getSupportedAssets, index_getTNode as getTNode, index_getTransferInfo as getTransferInfo, index_hasSupportForAsset as hasSupportForAsset };
|
|
1167
|
+
export { index_getAllAssetsSymbols as getAllAssetsSymbols, index_getAssetDecimals as getAssetDecimals, index_getAssetId as getAssetId, index_getAssets as getAssets, index_getAssetsObject as getAssetsObject, index_getBalanceForeign as getBalanceForeign, index_getBalanceNative as getBalanceNative, index_getExistentialDeposit as getExistentialDeposit, index_getNativeAssetSymbol as getNativeAssetSymbol, index_getNativeAssets as getNativeAssets, index_getOriginFeeDetails as getOriginFeeDetails, index_getOtherAssets as getOtherAssets, index_getParaId as getParaId, index_getRelayChainSymbol as getRelayChainSymbol, index_getSupportedAssets as getSupportedAssets, index_getTNode as getTNode, index_getTransferInfo as getTransferInfo, index_hasSupportForAsset as hasSupportForAsset };
|
|
1165
1168
|
}
|
|
1166
1169
|
|
|
1167
1170
|
/**
|
|
@@ -1514,4 +1517,4 @@ declare class DuplicateAssetIdError extends Error {
|
|
|
1514
1517
|
constructor(id: string);
|
|
1515
1518
|
}
|
|
1516
1519
|
|
|
1517
|
-
export { BatchMode, Builder, type CheckKeepAliveOptions, DuplicateAssetError, DuplicateAssetIdError, EvmBuilder, type Extrinsic, GeneralBuilder, type HexString$1 as HexString, type IPolkadotXCMTransfer, type IXTokensTransfer, type IXTransferTransfer, IncompatibleNodesError, InvalidCurrencyError, type JunctionParachain, type JunctionType, type Junctions, NODES_WITH_RELAY_CHAINS, NODES_WITH_RELAY_CHAINS_DOT_KSM, NODE_NAMES, NODE_NAMES_DOT_KSM, NoXCMSupportImplementedError, NodeNotSupportedError, Parents, type PolkadotXCMTransferInput, type PolkadotXcmModule, type PolkadotXcmSection, SUPPORTED_PALLETS, ScenarioNotSupportedError, type TAddress, type TAmount, type TApiType, type TAsset, type TAssetDetails, type TAssetJsonMap, type TBatchOptions, type TBifrostToken, type TCurrency, type TCurrencyCore, type TCurrencyInput, type TCurrencySelection, type TCurrencySelectionHeader, type TCurrencySelectionHeaderArr, type TCurrencySelectionV4, type TCurrencySymbol, type TDestWeight, type TDestination, type TEdJsonMap, type TEvmBuilderOptions, type TForeignAsset, type TForeignAssetId, type TForeignOrNativeAsset, type TForeignOrTokenAsset, type TJunction, type TMantaAsset, type TMultiAsset, type TMultiAssetV3, type TMultiAssetV4, type TMultiLocation, type TMultiLocationHeader, type TNativeAssetDetails, type TNativeTokenAsset, type TNode, type TNodeAssets, type TNodeDotKsmWithRelayChains, type TNodePolkadotKusama, type TNodeWithRelayChains, type TNodleAsset, type TOptionalEvmBuilderOptions, type TOriginFeeDetails, type TOtherReserveAsset, type TPallet, type TPalletJsonMap, type TPalletMap, type TRelayChainSymbol, type TRelayChainType, type TRelayToParaCommonOptions, type TRelayToParaInternalOptions, type TRelayToParaOptions, type TResType, type TReserveAsset, type TScenario, type TSelfReserveAsset, type TSendBaseOptions, type TSendInternalOptions, type TSendOptions, type TSendOptionsCommon, type TSerializeEthTransferOptions, type TSerializedApiCall, type TSerializedEthTransfer, type TTransferInfo, type TTransferReturn, type TVersionClaimAssets, type TXTokensCurrencySelection, type TXcmAsset, type TZeitgeistAsset, type UseKeepAliveFinalBuilder, Version, type XTokensModule, type XTokensSection, type XTokensTransferInput, type XTransferModule, type XTransferSection, type XTransferTransferInput, index as assets, buildEthTransferOptions, createApiInstanceForNode, determineRelayChain, getAllAssetsSymbols, getAllNodeProviders, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getBalanceForeign, getBalanceNative, getDefaultPallet, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getNode, getNodeEndpointOption, getNodeProvider, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedAssets, getSupportedPallets, getTNode, getTransferInfo, hasSupportForAsset, isRelayChain, send, sendSerializedApiCall, transferRelayToPara, transferRelayToParaCommon, transferRelayToParaSerializedApiCall, index$1 as xcmPallet };
|
|
1520
|
+
export { BatchMode, Builder, type CheckKeepAliveOptions, DuplicateAssetError, DuplicateAssetIdError, EvmBuilder, type Extrinsic, GeneralBuilder, type HexString$1 as HexString, type IPolkadotXCMTransfer, type IXTokensTransfer, type IXTransferTransfer, IncompatibleNodesError, InvalidCurrencyError, type JunctionParachain, type JunctionType, type Junctions, NODES_WITH_RELAY_CHAINS, NODES_WITH_RELAY_CHAINS_DOT_KSM, NODE_NAMES, NODE_NAMES_DOT_KSM, NoXCMSupportImplementedError, NodeNotSupportedError, Parents, type PolkadotXCMTransferInput, type PolkadotXcmModule, type PolkadotXcmSection, SUPPORTED_PALLETS, ScenarioNotSupportedError, type TAddress, type TAmount, type TApiType, type TAsset, type TAssetDetails, type TAssetJsonMap, type TBatchOptions, type TBifrostToken, type TCurrency, type TCurrencyCore, type TCurrencyInput, type TCurrencySelection, type TCurrencySelectionHeader, type TCurrencySelectionHeaderArr, type TCurrencySelectionV4, type TCurrencySymbol, type TDestWeight, type TDestination, type TEdJsonMap, type TEvmBuilderOptions, type TForeignAsset, type TForeignAssetId, type TForeignOrNativeAsset, type TForeignOrTokenAsset, type TJunction, type TMantaAsset, type TMultiAsset, type TMultiAssetV3, type TMultiAssetV4, type TMultiLocation, type TMultiLocationHeader, type TNativeAssetDetails, type TNativeTokenAsset, type TNode, type TNodeAssets, type TNodeDotKsmWithRelayChains, type TNodePolkadotKusama, type TNodeWithRelayChains, type TNodleAsset, type TOptionalEvmBuilderOptions, type TOriginFeeDetails, type TOtherReserveAsset, type TPallet, type TPalletJsonMap, type TPalletMap, type TRelayChainSymbol, type TRelayChainType, type TRelayToParaCommonOptions, type TRelayToParaInternalOptions, type TRelayToParaOptions, type TResType, type TReserveAsset, type TScenario, type TSelfReserveAsset, type TSendBaseOptions, type TSendInternalOptions, type TSendOptions, type TSendOptionsCommon, type TSerializeEthTransferOptions, type TSerializedApiCall, type TSerializedEthTransfer, type TTransferInfo, type TTransferReturn, type TVersionClaimAssets, type TXTokensCurrencySelection, type TXcmAsset, type TZeitgeistAsset, type UseKeepAliveFinalBuilder, Version, type XTokensModule, type XTokensSection, type XTokensTransferInput, type XTransferModule, type XTransferSection, type XTransferTransferInput, index as assets, buildEthTransferOptions, createApiInstanceForNode, determineRelayChain, getAllAssetsSymbols, getAllNodeProviders, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getBalanceForeign, getBalanceNative, getDefaultPallet, getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getNode, getNodeEndpointOption, getNodeProvider, getOriginFeeDetails, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedAssets, getSupportedPallets, getTNode, getTransferInfo, hasSupportForAsset, isRelayChain, send, sendSerializedApiCall, transferRelayToPara, transferRelayToParaCommon, transferRelayToParaSerializedApiCall, index$1 as xcmPallet };
|
package/dist/index.mjs
CHANGED
|
@@ -11516,60 +11516,6 @@ var getBalanceForeign = function getBalanceForeign(address, node, symbolOrId, ap
|
|
|
11516
11516
|
}));
|
|
11517
11517
|
};
|
|
11518
11518
|
|
|
11519
|
-
var getAssetBalance = function getAssetBalance(account, node, currency) {
|
|
11520
|
-
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
11521
|
-
var _a, api, isNativeSymbol;
|
|
11522
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
11523
|
-
while (1) switch (_context.prev = _context.next) {
|
|
11524
|
-
case 0:
|
|
11525
|
-
_context.next = 2;
|
|
11526
|
-
return createApiInstanceForNode(node);
|
|
11527
|
-
case 2:
|
|
11528
|
-
api = _context.sent;
|
|
11529
|
-
isNativeSymbol = 'symbol' in currency && getNativeAssetSymbol(node) === currency.symbol;
|
|
11530
|
-
if (!isNativeSymbol) {
|
|
11531
|
-
_context.next = 10;
|
|
11532
|
-
break;
|
|
11533
|
-
}
|
|
11534
|
-
_context.next = 7;
|
|
11535
|
-
return getBalanceNative(account, node, api);
|
|
11536
|
-
case 7:
|
|
11537
|
-
_context.t0 = _context.sent;
|
|
11538
|
-
_context.next = 22;
|
|
11539
|
-
break;
|
|
11540
|
-
case 10:
|
|
11541
|
-
_context.next = 12;
|
|
11542
|
-
return getBalanceForeign(account, node, currency, api);
|
|
11543
|
-
case 12:
|
|
11544
|
-
_context.t2 = _a = _context.sent;
|
|
11545
|
-
_context.t1 = _context.t2 !== null;
|
|
11546
|
-
if (!_context.t1) {
|
|
11547
|
-
_context.next = 16;
|
|
11548
|
-
break;
|
|
11549
|
-
}
|
|
11550
|
-
_context.t1 = _a !== void 0;
|
|
11551
|
-
case 16:
|
|
11552
|
-
if (!_context.t1) {
|
|
11553
|
-
_context.next = 20;
|
|
11554
|
-
break;
|
|
11555
|
-
}
|
|
11556
|
-
_context.t3 = _a;
|
|
11557
|
-
_context.next = 21;
|
|
11558
|
-
break;
|
|
11559
|
-
case 20:
|
|
11560
|
-
_context.t3 = BigInt(0);
|
|
11561
|
-
case 21:
|
|
11562
|
-
_context.t0 = _context.t3;
|
|
11563
|
-
case 22:
|
|
11564
|
-
return _context.abrupt("return", _context.t0);
|
|
11565
|
-
case 23:
|
|
11566
|
-
case "end":
|
|
11567
|
-
return _context.stop();
|
|
11568
|
-
}
|
|
11569
|
-
}, _callee);
|
|
11570
|
-
}));
|
|
11571
|
-
};
|
|
11572
|
-
|
|
11573
11519
|
var palletsMap = edsMapJson;
|
|
11574
11520
|
var getExistentialDeposit = function getExistentialDeposit(node) {
|
|
11575
11521
|
return BigInt(palletsMap[node]);
|
|
@@ -12687,6 +12633,26 @@ var EvmBuilder = function EvmBuilder(provider) {
|
|
|
12687
12633
|
return new EvmBuilderClass(provider);
|
|
12688
12634
|
};
|
|
12689
12635
|
|
|
12636
|
+
var calculateTransactionFee = function calculateTransactionFee(tx, address) {
|
|
12637
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
12638
|
+
var _yield$tx$paymentInfo, partialFee;
|
|
12639
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
12640
|
+
while (1) switch (_context.prev = _context.next) {
|
|
12641
|
+
case 0:
|
|
12642
|
+
_context.next = 2;
|
|
12643
|
+
return tx.paymentInfo(address);
|
|
12644
|
+
case 2:
|
|
12645
|
+
_yield$tx$paymentInfo = _context.sent;
|
|
12646
|
+
partialFee = _yield$tx$paymentInfo.partialFee;
|
|
12647
|
+
return _context.abrupt("return", partialFee.toBn());
|
|
12648
|
+
case 5:
|
|
12649
|
+
case "end":
|
|
12650
|
+
return _context.stop();
|
|
12651
|
+
}
|
|
12652
|
+
}, _callee);
|
|
12653
|
+
}));
|
|
12654
|
+
};
|
|
12655
|
+
|
|
12690
12656
|
var createTx$1 = function createTx(originApi, address, amount, currency, originNode, destNode) {
|
|
12691
12657
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
12692
12658
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -12721,74 +12687,115 @@ var createTx$1 = function createTx(originApi, address, amount, currency, originN
|
|
|
12721
12687
|
}, _callee);
|
|
12722
12688
|
}));
|
|
12723
12689
|
};
|
|
12724
|
-
var
|
|
12725
|
-
|
|
12726
|
-
|
|
12727
|
-
|
|
12728
|
-
|
|
12729
|
-
|
|
12730
|
-
|
|
12731
|
-
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
|
|
12735
|
-
|
|
12736
|
-
|
|
12737
|
-
|
|
12738
|
-
|
|
12739
|
-
|
|
12740
|
-
|
|
12741
|
-
|
|
12690
|
+
var getOriginFeeDetails = function getOriginFeeDetails(origin_1, destination_1, currency_1, amount_1, account_1, api_1) {
|
|
12691
|
+
for (var _len = arguments.length, args_1 = new Array(_len > 6 ? _len - 6 : 0), _key = 6; _key < _len; _key++) {
|
|
12692
|
+
args_1[_key - 6] = arguments[_key];
|
|
12693
|
+
}
|
|
12694
|
+
return __awaiter(void 0, [origin_1, destination_1, currency_1, amount_1, account_1, api_1].concat(args_1), void 0, function (origin, destination, currency, amount, account, api) {
|
|
12695
|
+
var feeMarginPercentage = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 10;
|
|
12696
|
+
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
12697
|
+
var nativeBalance, minTransferableAmount, apiWithFallback, tx, xcmFee, xcmFeeBigInt, xcmFeeWithMargin, sufficientForXCM;
|
|
12698
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
12699
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
12700
|
+
case 0:
|
|
12701
|
+
_context2.next = 2;
|
|
12702
|
+
return getBalanceNative(account, origin);
|
|
12703
|
+
case 2:
|
|
12704
|
+
nativeBalance = _context2.sent;
|
|
12705
|
+
minTransferableAmount = getMinNativeTransferableAmount(origin);
|
|
12706
|
+
if (!(api !== null && api !== void 0)) {
|
|
12707
|
+
_context2.next = 8;
|
|
12708
|
+
break;
|
|
12709
|
+
}
|
|
12710
|
+
_context2.t0 = api;
|
|
12711
|
+
_context2.next = 11;
|
|
12712
|
+
break;
|
|
12713
|
+
case 8:
|
|
12714
|
+
_context2.next = 10;
|
|
12715
|
+
return createApiInstanceForNode(origin);
|
|
12716
|
+
case 10:
|
|
12717
|
+
_context2.t0 = _context2.sent;
|
|
12718
|
+
case 11:
|
|
12719
|
+
apiWithFallback = _context2.t0;
|
|
12720
|
+
_context2.next = 14;
|
|
12721
|
+
return createTx$1(apiWithFallback, account, amount, currency, origin, destination);
|
|
12722
|
+
case 14:
|
|
12723
|
+
tx = _context2.sent;
|
|
12724
|
+
_context2.next = 17;
|
|
12725
|
+
return calculateTransactionFee(tx, account);
|
|
12726
|
+
case 17:
|
|
12727
|
+
xcmFee = _context2.sent;
|
|
12728
|
+
xcmFeeBigInt = BigInt(xcmFee.toString());
|
|
12729
|
+
xcmFeeWithMargin = xcmFeeBigInt + xcmFeeBigInt / BigInt(feeMarginPercentage);
|
|
12730
|
+
console.log('nativeBalance', nativeBalance);
|
|
12731
|
+
console.log('minTransferableAmount', minTransferableAmount);
|
|
12732
|
+
console.log('xcmFeeBigInt', xcmFeeBigInt);
|
|
12733
|
+
console.log('xcmFeeWithMargin', xcmFeeWithMargin);
|
|
12734
|
+
sufficientForXCM = nativeBalance - minTransferableAmount - xcmFeeWithMargin > 0;
|
|
12735
|
+
return _context2.abrupt("return", {
|
|
12736
|
+
sufficientForXCM: sufficientForXCM,
|
|
12737
|
+
xcmFee: xcmFeeBigInt
|
|
12738
|
+
});
|
|
12739
|
+
case 26:
|
|
12740
|
+
case "end":
|
|
12741
|
+
return _context2.stop();
|
|
12742
|
+
}
|
|
12743
|
+
}, _callee2);
|
|
12744
|
+
})();
|
|
12745
|
+
});
|
|
12742
12746
|
};
|
|
12743
|
-
|
|
12744
|
-
|
|
12745
|
-
|
|
12746
|
-
|
|
12747
|
-
|
|
12747
|
+
|
|
12748
|
+
var getAssetBalance = function getAssetBalance(account, node, currency) {
|
|
12749
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
12750
|
+
var _a, api, isNativeSymbol;
|
|
12751
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
12752
|
+
while (1) switch (_context.prev = _context.next) {
|
|
12748
12753
|
case 0:
|
|
12749
|
-
|
|
12750
|
-
return
|
|
12754
|
+
_context.next = 2;
|
|
12755
|
+
return createApiInstanceForNode(node);
|
|
12751
12756
|
case 2:
|
|
12752
|
-
|
|
12753
|
-
|
|
12754
|
-
if (!
|
|
12755
|
-
|
|
12757
|
+
api = _context.sent;
|
|
12758
|
+
isNativeSymbol = 'symbol' in currency && getNativeAssetSymbol(node) === currency.symbol;
|
|
12759
|
+
if (!isNativeSymbol) {
|
|
12760
|
+
_context.next = 10;
|
|
12756
12761
|
break;
|
|
12757
12762
|
}
|
|
12758
|
-
|
|
12759
|
-
|
|
12763
|
+
_context.next = 7;
|
|
12764
|
+
return getBalanceNative(account, node, api);
|
|
12765
|
+
case 7:
|
|
12766
|
+
_context.t0 = _context.sent;
|
|
12767
|
+
_context.next = 22;
|
|
12760
12768
|
break;
|
|
12761
|
-
case 8:
|
|
12762
|
-
_context3.next = 10;
|
|
12763
|
-
return createApiInstanceForNode(origin);
|
|
12764
12769
|
case 10:
|
|
12765
|
-
|
|
12766
|
-
|
|
12767
|
-
|
|
12768
|
-
|
|
12769
|
-
|
|
12770
|
-
|
|
12771
|
-
|
|
12772
|
-
|
|
12773
|
-
|
|
12774
|
-
|
|
12775
|
-
|
|
12776
|
-
|
|
12777
|
-
|
|
12778
|
-
|
|
12779
|
-
|
|
12780
|
-
|
|
12781
|
-
|
|
12782
|
-
|
|
12783
|
-
|
|
12784
|
-
|
|
12785
|
-
|
|
12786
|
-
|
|
12787
|
-
case
|
|
12770
|
+
_context.next = 12;
|
|
12771
|
+
return getBalanceForeign(account, node, currency, api);
|
|
12772
|
+
case 12:
|
|
12773
|
+
_context.t2 = _a = _context.sent;
|
|
12774
|
+
_context.t1 = _context.t2 !== null;
|
|
12775
|
+
if (!_context.t1) {
|
|
12776
|
+
_context.next = 16;
|
|
12777
|
+
break;
|
|
12778
|
+
}
|
|
12779
|
+
_context.t1 = _a !== void 0;
|
|
12780
|
+
case 16:
|
|
12781
|
+
if (!_context.t1) {
|
|
12782
|
+
_context.next = 20;
|
|
12783
|
+
break;
|
|
12784
|
+
}
|
|
12785
|
+
_context.t3 = _a;
|
|
12786
|
+
_context.next = 21;
|
|
12787
|
+
break;
|
|
12788
|
+
case 20:
|
|
12789
|
+
_context.t3 = BigInt(0);
|
|
12790
|
+
case 21:
|
|
12791
|
+
_context.t0 = _context.t3;
|
|
12792
|
+
case 22:
|
|
12793
|
+
return _context.abrupt("return", _context.t0);
|
|
12794
|
+
case 23:
|
|
12788
12795
|
case "end":
|
|
12789
|
-
return
|
|
12796
|
+
return _context.stop();
|
|
12790
12797
|
}
|
|
12791
|
-
},
|
|
12798
|
+
}, _callee);
|
|
12792
12799
|
}));
|
|
12793
12800
|
};
|
|
12794
12801
|
|
|
@@ -12824,35 +12831,41 @@ var getTransferInfo = function getTransferInfo(origin, destination, accountOrigi
|
|
|
12824
12831
|
destXcmFee = _yield$getOriginFeeDe.xcmFee;
|
|
12825
12832
|
expectedBalanceAfterXCMDelivery = originBalance - destXcmFee;
|
|
12826
12833
|
asset = getAssetBySymbolOrId(origin, currency);
|
|
12834
|
+
if (asset) {
|
|
12835
|
+
_context.next = 14;
|
|
12836
|
+
break;
|
|
12837
|
+
}
|
|
12838
|
+
throw new InvalidCurrencyError("Asset ".concat('symbol' in currency ? currency.symbol : currency.id, " not found on ").concat(origin));
|
|
12839
|
+
case 14:
|
|
12827
12840
|
_context.t0 = {
|
|
12828
12841
|
origin: origin,
|
|
12829
12842
|
destination: destination,
|
|
12830
12843
|
ecosystem: determineRelayChainSymbol(origin)
|
|
12831
12844
|
};
|
|
12832
|
-
_context.next =
|
|
12845
|
+
_context.next = 17;
|
|
12833
12846
|
return getAssetBalance(accountOrigin, origin, currency);
|
|
12834
|
-
case
|
|
12847
|
+
case 17:
|
|
12835
12848
|
_context.t1 = _context.sent;
|
|
12836
12849
|
_context.t2 = (_a = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _a !== void 0 ? _a : '';
|
|
12837
12850
|
_context.t3 = {
|
|
12838
12851
|
balance: _context.t1,
|
|
12839
12852
|
currency: _context.t2
|
|
12840
12853
|
};
|
|
12841
|
-
_context.next =
|
|
12854
|
+
_context.next = 22;
|
|
12842
12855
|
return getBalanceNative(accountOrigin, origin, originApi);
|
|
12843
|
-
case
|
|
12856
|
+
case 22:
|
|
12844
12857
|
_context.t4 = _context.sent;
|
|
12845
12858
|
_context.t5 = expectedBalanceAfterXCMDelivery;
|
|
12846
|
-
_context.next =
|
|
12859
|
+
_context.next = 26;
|
|
12847
12860
|
return getOriginFeeDetails(origin, destination, currency, amount, accountOrigin, originApi);
|
|
12848
|
-
case
|
|
12861
|
+
case 26:
|
|
12849
12862
|
_context.t6 = _context.sent;
|
|
12850
12863
|
_context.t7 = BigInt((_b = getExistentialDeposit(origin)) !== null && _b !== void 0 ? _b : 0);
|
|
12851
12864
|
_context.t8 = getNativeAssetSymbol(origin);
|
|
12852
12865
|
_context.t9 = getMinNativeTransferableAmount(origin);
|
|
12853
|
-
_context.next =
|
|
12866
|
+
_context.next = 32;
|
|
12854
12867
|
return getMaxNativeTransferableAmount(accountOrigin, origin);
|
|
12855
|
-
case
|
|
12868
|
+
case 32:
|
|
12856
12869
|
_context.t10 = _context.sent;
|
|
12857
12870
|
_context.t11 = {
|
|
12858
12871
|
balance: _context.t4,
|
|
@@ -12863,9 +12876,9 @@ var getTransferInfo = function getTransferInfo(origin, destination, accountOrigi
|
|
|
12863
12876
|
minNativeTransferableAmount: _context.t9,
|
|
12864
12877
|
maxNativeTransferableAmount: _context.t10
|
|
12865
12878
|
};
|
|
12866
|
-
_context.next =
|
|
12879
|
+
_context.next = 36;
|
|
12867
12880
|
return getBalanceNative(accountDestination, destination);
|
|
12868
|
-
case
|
|
12881
|
+
case 36:
|
|
12869
12882
|
_context.t12 = _context.sent;
|
|
12870
12883
|
_context.t13 = getNativeAssetSymbol(destination);
|
|
12871
12884
|
_context.t14 = getExistentialDeposit(destination);
|
|
@@ -12880,7 +12893,7 @@ var getTransferInfo = function getTransferInfo(origin, destination, accountOrigi
|
|
|
12880
12893
|
originFeeBalance: _context.t11,
|
|
12881
12894
|
destinationFeeBalance: _context.t15
|
|
12882
12895
|
});
|
|
12883
|
-
case
|
|
12896
|
+
case 41:
|
|
12884
12897
|
case "end":
|
|
12885
12898
|
return _context.stop();
|
|
12886
12899
|
}
|
|
@@ -12938,6 +12951,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
|
|
|
12938
12951
|
getExistentialDeposit: getExistentialDeposit$1,
|
|
12939
12952
|
getNativeAssetSymbol: getNativeAssetSymbol,
|
|
12940
12953
|
getNativeAssets: getNativeAssets,
|
|
12954
|
+
getOriginFeeDetails: getOriginFeeDetails,
|
|
12941
12955
|
getOtherAssets: getOtherAssets,
|
|
12942
12956
|
getParaId: getParaId,
|
|
12943
12957
|
getRelayChainSymbol: getRelayChainSymbol,
|
|
@@ -13214,26 +13228,6 @@ var KeepAliveError = /*#__PURE__*/function (_Error) {
|
|
|
13214
13228
|
return _createClass(KeepAliveError);
|
|
13215
13229
|
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
13216
13230
|
|
|
13217
|
-
var calculateTransactionFee = function calculateTransactionFee(tx, address) {
|
|
13218
|
-
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
13219
|
-
var _yield$tx$paymentInfo, partialFee;
|
|
13220
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
13221
|
-
while (1) switch (_context.prev = _context.next) {
|
|
13222
|
-
case 0:
|
|
13223
|
-
_context.next = 2;
|
|
13224
|
-
return tx.paymentInfo(address);
|
|
13225
|
-
case 2:
|
|
13226
|
-
_yield$tx$paymentInfo = _context.sent;
|
|
13227
|
-
partialFee = _yield$tx$paymentInfo.partialFee;
|
|
13228
|
-
return _context.abrupt("return", partialFee.toBn());
|
|
13229
|
-
case 5:
|
|
13230
|
-
case "end":
|
|
13231
|
-
return _context.stop();
|
|
13232
|
-
}
|
|
13233
|
-
}, _callee);
|
|
13234
|
-
}));
|
|
13235
|
-
};
|
|
13236
|
-
|
|
13237
13231
|
var createTx = function createTx(originApi, destApi, address, amount, currencySymbol, originNode, destNode) {
|
|
13238
13232
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
13239
13233
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -13804,4 +13798,4 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
13804
13798
|
transferRelayToParaSerializedApiCall: transferRelayToParaSerializedApiCall
|
|
13805
13799
|
});
|
|
13806
13800
|
|
|
13807
|
-
export { BatchMode, Builder, DuplicateAssetError, DuplicateAssetIdError, EvmBuilder, GeneralBuilder, IncompatibleNodesError, InvalidCurrencyError, NODES_WITH_RELAY_CHAINS, NODES_WITH_RELAY_CHAINS_DOT_KSM, NODE_NAMES, NODE_NAMES_DOT_KSM, NoXCMSupportImplementedError, NodeNotSupportedError, Parents, SUPPORTED_PALLETS, ScenarioNotSupportedError, Version, index$1 as assets, buildEthTransferOptions, createApiInstanceForNode, determineRelayChain, getAllAssetsSymbols, getAllNodeProviders, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getBalanceForeign, getBalanceNative, getDefaultPallet, getExistentialDeposit$1 as getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getNode, getNodeEndpointOption, getNodeProvider, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedAssets, getSupportedPallets, getTNode, getTransferInfo, hasSupportForAsset, isRelayChain, send, sendSerializedApiCall, transferRelayToPara, transferRelayToParaCommon, transferRelayToParaSerializedApiCall, index as xcmPallet };
|
|
13801
|
+
export { BatchMode, Builder, DuplicateAssetError, DuplicateAssetIdError, EvmBuilder, GeneralBuilder, IncompatibleNodesError, InvalidCurrencyError, NODES_WITH_RELAY_CHAINS, NODES_WITH_RELAY_CHAINS_DOT_KSM, NODE_NAMES, NODE_NAMES_DOT_KSM, NoXCMSupportImplementedError, NodeNotSupportedError, Parents, SUPPORTED_PALLETS, ScenarioNotSupportedError, Version, index$1 as assets, buildEthTransferOptions, createApiInstanceForNode, determineRelayChain, getAllAssetsSymbols, getAllNodeProviders, getAssetDecimals, getAssetId, getAssets, getAssetsObject, getBalanceForeign, getBalanceNative, getDefaultPallet, getExistentialDeposit$1 as getExistentialDeposit, getNativeAssetSymbol, getNativeAssets, getNode, getNodeEndpointOption, getNodeProvider, getOriginFeeDetails, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedAssets, getSupportedPallets, getTNode, getTransferInfo, hasSupportForAsset, isRelayChain, send, sendSerializedApiCall, transferRelayToPara, transferRelayToParaCommon, transferRelayToParaSerializedApiCall, index as xcmPallet };
|