@paraspell/sdk-core 10.4.6 → 10.4.8
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 +291 -323
- package/dist/index.d.ts +3 -5
- package/dist/index.mjs +294 -325
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { blake2b } from '@noble/hashes/blake2';
|
|
2
|
-
import { isNodeEvm, getAssetsObject, getNativeAssetSymbol, getOtherAssets, getRelayChainSymbol, InvalidCurrencyError, isForeignAsset, findAssetForNodeOrThrow,
|
|
2
|
+
import { isNodeEvm, getAssetsObject, getNativeAssetSymbol, getOtherAssets, getRelayChainSymbol, InvalidCurrencyError, isForeignAsset, findAssetForNodeOrThrow, isOverrideMultiLocationSpecifier, findAssetByMultiLocation, findAsset, isTMultiAsset, getExistentialDeposit, getExistentialDepositOrThrow, isAssetEqual, findAssetOnDestOrThrow, normalizeSymbol, hasDryRunSupport, hasSupportForAsset, extractMultiAssetLoc, isSymbolSpecifier, normalizeMultiLocation, getAssetId } from '@paraspell/assets';
|
|
3
3
|
export * from '@paraspell/assets';
|
|
4
4
|
import { base58 } from '@scure/base';
|
|
5
5
|
import { isAddress, createPublicClient, http, getContract } from 'viem';
|
|
6
|
-
import { Parents, Version, isTMultiLocation, isRelayChain, NODE_NAMES_DOT_KSM, hasJunction, deepEqual, isDotKsmBridge } from '@paraspell/sdk-common';
|
|
6
|
+
import { Parents, Version, isTMultiLocation, isRelayChain, replaceBigInt, NODE_NAMES_DOT_KSM, hasJunction, deepEqual, isDotKsmBridge } from '@paraspell/sdk-common';
|
|
7
7
|
export * from '@paraspell/sdk-common';
|
|
8
8
|
import { getSupportedPalletsDetails, getDefaultPallet } from '@paraspell/pallets';
|
|
9
9
|
export * from '@paraspell/pallets';
|
|
@@ -2400,10 +2400,6 @@ var getNode = function getNode(node) {
|
|
|
2400
2400
|
return nodeMap[node];
|
|
2401
2401
|
};
|
|
2402
2402
|
|
|
2403
|
-
var replaceBigInt = function replaceBigInt(_key, value) {
|
|
2404
|
-
return typeof value === 'bigint' ? value.toString() : value;
|
|
2405
|
-
};
|
|
2406
|
-
|
|
2407
2403
|
var resolveParaId = function resolveParaId(paraId, destination) {
|
|
2408
2404
|
if (isTMultiLocation(destination) || isRelayChain(destination) || destination === 'Ethereum') {
|
|
2409
2405
|
return undefined;
|
|
@@ -2592,7 +2588,7 @@ var throwUnsupportedCurrency = function throwUnsupportedCurrency(currency, node)
|
|
|
2592
2588
|
if ('multilocation' in currency) {
|
|
2593
2589
|
throw new InvalidCurrencyError("\n Selected chain doesn't support multilocation you provided. Maybe you meant custom multilocation. If so, you need to use override option. Your selection should look like this: {multilocation: Override(".concat(JSON.stringify(currency.multilocation), ")}."));
|
|
2594
2590
|
}
|
|
2595
|
-
throw new InvalidCurrencyError("".concat(isDestination ? 'Destination' : 'Origin', " node ").concat(node, " does not support currency ").concat(JSON.stringify(currency), "."));
|
|
2591
|
+
throw new InvalidCurrencyError("".concat(isDestination ? 'Destination' : 'Origin', " node ").concat(node, " does not support currency ").concat(JSON.stringify(currency, replaceBigInt), "."));
|
|
2596
2592
|
};
|
|
2597
2593
|
|
|
2598
2594
|
var resolveMultiLocationFromDest = function resolveMultiLocationFromDest(destination, asset) {
|
|
@@ -3373,29 +3369,23 @@ var transferMoonbeamEvm = /*#__PURE__*/function () {
|
|
|
3373
3369
|
wallet: signer
|
|
3374
3370
|
}
|
|
3375
3371
|
});
|
|
3376
|
-
foundAsset =
|
|
3377
|
-
if (!(foundAsset === null)) {
|
|
3378
|
-
_context.n = 3;
|
|
3379
|
-
break;
|
|
3380
|
-
}
|
|
3381
|
-
throw new InvalidCurrencyError("Origin node ".concat(from, " does not support currency ").concat(JSON.stringify(currency), "."));
|
|
3382
|
-
case 3:
|
|
3372
|
+
foundAsset = findAssetForNodeOrThrow(from, currency, to);
|
|
3383
3373
|
if (!(foundAsset.symbol === getNativeAssetSymbol(from))) {
|
|
3384
|
-
_context.n =
|
|
3374
|
+
_context.n = 3;
|
|
3385
3375
|
break;
|
|
3386
3376
|
}
|
|
3387
3377
|
asset = NATIVE_ASSET_ID;
|
|
3388
|
-
_context.n =
|
|
3378
|
+
_context.n = 5;
|
|
3389
3379
|
break;
|
|
3390
|
-
case
|
|
3380
|
+
case 3:
|
|
3391
3381
|
if (!(!isForeignAsset(foundAsset) || !foundAsset.assetId)) {
|
|
3392
|
-
_context.n =
|
|
3382
|
+
_context.n = 4;
|
|
3393
3383
|
break;
|
|
3394
3384
|
}
|
|
3395
3385
|
throw new InvalidCurrencyError('Currency must be a foreign asset with valid assetId');
|
|
3396
|
-
case
|
|
3386
|
+
case 4:
|
|
3397
3387
|
asset = formatAssetIdToERC20(foundAsset.assetId);
|
|
3398
|
-
case
|
|
3388
|
+
case 5:
|
|
3399
3389
|
destMultiLocation = getDestinationMultilocation(api, address, to);
|
|
3400
3390
|
weight = U_64_MAX; // Partially inspired by Moonbeam XCM-SDK
|
|
3401
3391
|
// https://github.com/moonbeam-foundation/xcm-sdk/blob/ab835c15bf41612604b1c858d956a9f07705ed65/packages/sdk/src/contract/contracts/Xtokens/Xtokens.ts#L53
|
|
@@ -3405,27 +3395,27 @@ var transferMoonbeamEvm = /*#__PURE__*/function () {
|
|
|
3405
3395
|
};
|
|
3406
3396
|
multiCurrencySymbols = ['xcPINK', 'xcDED', 'xcSTINK', 'xcWIFD', 'xcNCTR'];
|
|
3407
3397
|
useMultiAssets = from === 'Moonbeam' && to === 'AssetHubPolkadot' && multiCurrencySymbols.includes(foundAsset.symbol);
|
|
3408
|
-
usdtAsset =
|
|
3398
|
+
usdtAsset = findAssetForNodeOrThrow(from, {
|
|
3409
3399
|
symbol: 'xcUSDT'
|
|
3410
3400
|
}, to);
|
|
3411
3401
|
if (!useMultiAssets) {
|
|
3412
|
-
_context.n =
|
|
3402
|
+
_context.n = 7;
|
|
3413
3403
|
break;
|
|
3414
3404
|
}
|
|
3415
|
-
_context.n =
|
|
3405
|
+
_context.n = 6;
|
|
3416
3406
|
return createTx('transferMultiCurrencies', [[[asset, currency.amount], [formatAssetIdToERC20((_usdtAsset$assetId = usdtAsset.assetId) !== null && _usdtAsset$assetId !== void 0 ? _usdtAsset$assetId : ''), '200000']], 1,
|
|
3417
3407
|
// index of the fee asset
|
|
3418
3408
|
destMultiLocation, weight]);
|
|
3419
|
-
case
|
|
3409
|
+
case 6:
|
|
3420
3410
|
_t = _context.v;
|
|
3421
|
-
_context.n = 10;
|
|
3422
|
-
break;
|
|
3423
|
-
case 8:
|
|
3424
3411
|
_context.n = 9;
|
|
3412
|
+
break;
|
|
3413
|
+
case 7:
|
|
3414
|
+
_context.n = 8;
|
|
3425
3415
|
return createTx('transfer', [asset, currency.amount, destMultiLocation, weight]);
|
|
3426
|
-
case
|
|
3416
|
+
case 8:
|
|
3427
3417
|
_t = _context.v;
|
|
3428
|
-
case
|
|
3418
|
+
case 9:
|
|
3429
3419
|
tx = _t;
|
|
3430
3420
|
return _context.a(2, tx);
|
|
3431
3421
|
}
|
|
@@ -3697,26 +3687,20 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
|
|
|
3697
3687
|
}
|
|
3698
3688
|
throw new InvalidParameterError('Override multilocation is not supported for Evm transfers');
|
|
3699
3689
|
case 5:
|
|
3700
|
-
foundAsset =
|
|
3701
|
-
if (!(foundAsset === null)) {
|
|
3702
|
-
_context.n = 6;
|
|
3703
|
-
break;
|
|
3704
|
-
}
|
|
3705
|
-
throw new InvalidCurrencyError("Origin node ".concat(from, " does not support currency ").concat(JSON.stringify(currency), "."));
|
|
3706
|
-
case 6:
|
|
3690
|
+
foundAsset = findAssetForNodeOrThrow(from, currency, to);
|
|
3707
3691
|
if (!(!isForeignAsset(foundAsset) || !foundAsset.multiLocation)) {
|
|
3708
|
-
_context.n =
|
|
3692
|
+
_context.n = 6;
|
|
3709
3693
|
break;
|
|
3710
3694
|
}
|
|
3711
3695
|
throw new InvalidCurrencyError('Currency must be a foreign asset with valid multi-location');
|
|
3712
|
-
case
|
|
3696
|
+
case 6:
|
|
3713
3697
|
ethAsset = findAssetByMultiLocation(getOtherAssets('Ethereum'), foundAsset.multiLocation);
|
|
3714
3698
|
if (!(!ethAsset || !ethAsset.assetId)) {
|
|
3715
|
-
_context.n =
|
|
3699
|
+
_context.n = 7;
|
|
3716
3700
|
break;
|
|
3717
3701
|
}
|
|
3718
3702
|
throw new InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(foundAsset)));
|
|
3719
|
-
case
|
|
3703
|
+
case 7:
|
|
3720
3704
|
contract = getContract({
|
|
3721
3705
|
abi: abi,
|
|
3722
3706
|
address: xcmInterfacePrecompile,
|
|
@@ -3730,17 +3714,17 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
|
|
|
3730
3714
|
});
|
|
3731
3715
|
senderAddress = (_signer$account = signer.account) === null || _signer$account === void 0 ? void 0 : _signer$account.address;
|
|
3732
3716
|
if (senderAddress) {
|
|
3733
|
-
_context.n =
|
|
3717
|
+
_context.n = 8;
|
|
3734
3718
|
break;
|
|
3735
3719
|
}
|
|
3736
3720
|
throw new InvalidParameterError('Unable to get sender address');
|
|
3721
|
+
case 8:
|
|
3722
|
+
_context.n = 9;
|
|
3723
|
+
return api.init(from, TX_CLIENT_TIMEOUT_MS);
|
|
3737
3724
|
case 9:
|
|
3738
3725
|
_context.n = 10;
|
|
3739
|
-
return api.init(from, TX_CLIENT_TIMEOUT_MS);
|
|
3740
|
-
case 10:
|
|
3741
|
-
_context.n = 11;
|
|
3742
3726
|
return generateMessageId(api, senderAddress, getParaId(from), ethAsset.assetId, address, currency.amount);
|
|
3743
|
-
case
|
|
3727
|
+
case 10:
|
|
3744
3728
|
messageId = _context.v;
|
|
3745
3729
|
customXcm = createCustomXcmOnDest({
|
|
3746
3730
|
api: api,
|
|
@@ -3753,17 +3737,17 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
|
|
|
3753
3737
|
}),
|
|
3754
3738
|
version: Version.V4
|
|
3755
3739
|
}, from, messageId);
|
|
3756
|
-
_context.n =
|
|
3740
|
+
_context.n = 11;
|
|
3757
3741
|
return api.objectToHex(customXcm, 'XcmVersionedXcm');
|
|
3758
|
-
case
|
|
3742
|
+
case 11:
|
|
3759
3743
|
customXcmOnDest = _context.v;
|
|
3760
|
-
_context.n =
|
|
3744
|
+
_context.n = 12;
|
|
3761
3745
|
return api.createApiForNode('AssetHubPolkadot');
|
|
3762
|
-
case
|
|
3746
|
+
case 12:
|
|
3763
3747
|
assetHubApi = _context.v;
|
|
3764
|
-
_context.n =
|
|
3748
|
+
_context.n = 13;
|
|
3765
3749
|
return getParaEthTransferFees(assetHubApi);
|
|
3766
|
-
case
|
|
3750
|
+
case 13:
|
|
3767
3751
|
_yield$getParaEthTran = _context.v;
|
|
3768
3752
|
_yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
|
|
3769
3753
|
bridgeFee = _yield$getParaEthTran2[0];
|
|
@@ -3778,7 +3762,7 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
|
|
|
3778
3762
|
throw new InvalidParameterError('Input must be a valid number');
|
|
3779
3763
|
}() : "0x".concat((num >>> 0).toString(16).padStart(8, '0'));
|
|
3780
3764
|
}; // Execute the custom XCM message with the precompile
|
|
3781
|
-
_context.n =
|
|
3765
|
+
_context.n = 14;
|
|
3782
3766
|
return createTx('transferAssetsUsingTypeAndThenAddress', [
|
|
3783
3767
|
// This represents (1,X1(Parachain(1000)))
|
|
3784
3768
|
[1, ['0x00' + numberToHex32(getParaId('AssetHubPolkadot')).slice(2)]],
|
|
@@ -3790,7 +3774,7 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
|
|
|
3790
3774
|
0,
|
|
3791
3775
|
// The TransferType corresponding to fee asset
|
|
3792
3776
|
2, customXcmOnDest]);
|
|
3793
|
-
case
|
|
3777
|
+
case 14:
|
|
3794
3778
|
tx = _context.v;
|
|
3795
3779
|
return _context.a(2, tx);
|
|
3796
3780
|
}
|
|
@@ -3949,7 +3933,7 @@ var getOriginFeeDetails = /*#__PURE__*/function () {
|
|
|
3949
3933
|
|
|
3950
3934
|
var getTransferableAmountInternal = /*#__PURE__*/function () {
|
|
3951
3935
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
3952
|
-
var api, senderAddress, node, destination, currency, tx, feeAsset, resolvedFeeAsset, asset, balance, ed,
|
|
3936
|
+
var api, senderAddress, node, destination, currency, tx, feeAsset, resolvedFeeAsset, asset, balance, ed, isNativeAsset, shouldSubstractFee, feeToSubtract, _yield$getOriginXcmFe, fee, transferable;
|
|
3953
3937
|
return _regenerator().w(function (_context) {
|
|
3954
3938
|
while (1) switch (_context.n) {
|
|
3955
3939
|
case 0:
|
|
@@ -3966,22 +3950,15 @@ var getTransferableAmountInternal = /*#__PURE__*/function () {
|
|
|
3966
3950
|
});
|
|
3967
3951
|
case 1:
|
|
3968
3952
|
balance = _context.v;
|
|
3969
|
-
ed =
|
|
3970
|
-
if (!(ed === null)) {
|
|
3971
|
-
_context.n = 2;
|
|
3972
|
-
break;
|
|
3973
|
-
}
|
|
3974
|
-
throw new InvalidParameterError("Cannot get existential deposit for currency ".concat(JSON.stringify(currency), "."));
|
|
3975
|
-
case 2:
|
|
3976
|
-
edBN = BigInt(ed);
|
|
3953
|
+
ed = getExistentialDepositOrThrow(node, currency);
|
|
3977
3954
|
isNativeAsset = getNativeAssetSymbol(node) === asset.symbol;
|
|
3978
3955
|
shouldSubstractFee = isNativeAsset || node === 'AssetHubPolkadot' && resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, asset);
|
|
3979
3956
|
feeToSubtract = 0n;
|
|
3980
3957
|
if (!shouldSubstractFee) {
|
|
3981
|
-
_context.n =
|
|
3958
|
+
_context.n = 4;
|
|
3982
3959
|
break;
|
|
3983
3960
|
}
|
|
3984
|
-
_context.n =
|
|
3961
|
+
_context.n = 2;
|
|
3985
3962
|
return getOriginXcmFee({
|
|
3986
3963
|
api: api,
|
|
3987
3964
|
tx: tx,
|
|
@@ -3992,18 +3969,18 @@ var getTransferableAmountInternal = /*#__PURE__*/function () {
|
|
|
3992
3969
|
currency: currency,
|
|
3993
3970
|
disableFallback: false
|
|
3994
3971
|
});
|
|
3995
|
-
case
|
|
3972
|
+
case 2:
|
|
3996
3973
|
_yield$getOriginXcmFe = _context.v;
|
|
3997
3974
|
fee = _yield$getOriginXcmFe.fee;
|
|
3998
3975
|
if (!(fee === undefined)) {
|
|
3999
|
-
_context.n =
|
|
3976
|
+
_context.n = 3;
|
|
4000
3977
|
break;
|
|
4001
3978
|
}
|
|
4002
|
-
throw new InvalidParameterError("Cannot get origin xcm fee for currency ".concat(JSON.stringify(currency), " on node ").concat(node, "."));
|
|
4003
|
-
case
|
|
3979
|
+
throw new InvalidParameterError("Cannot get origin xcm fee for currency ".concat(JSON.stringify(currency, replaceBigInt), " on node ").concat(node, "."));
|
|
3980
|
+
case 3:
|
|
4004
3981
|
feeToSubtract = fee;
|
|
4005
|
-
case
|
|
4006
|
-
transferable = balance -
|
|
3982
|
+
case 4:
|
|
3983
|
+
transferable = balance - ed - feeToSubtract;
|
|
4007
3984
|
return _context.a(2, transferable > 0n ? transferable : 0n);
|
|
4008
3985
|
}
|
|
4009
3986
|
}, _callee);
|
|
@@ -4063,7 +4040,7 @@ var buildDestInfo = /*#__PURE__*/function () {
|
|
|
4063
4040
|
_context.n = 2;
|
|
4064
4041
|
break;
|
|
4065
4042
|
}
|
|
4066
|
-
throw new InvalidParameterError("Existential deposit not found for ".concat(destination, " with currency ").concat(JSON.stringify(currency)));
|
|
4043
|
+
throw new InvalidParameterError("Existential deposit not found for ".concat(destination, " with currency ").concat(JSON.stringify(currency, replaceBigInt)));
|
|
4067
4044
|
case 2:
|
|
4068
4045
|
edDestBn = BigInt(edDest);
|
|
4069
4046
|
destCurrency = destAsset.multiLocation ? {
|
|
@@ -4241,7 +4218,7 @@ var buildHopInfo = /*#__PURE__*/function () {
|
|
|
4241
4218
|
|
|
4242
4219
|
var getTransferInfo = /*#__PURE__*/function () {
|
|
4243
4220
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
4244
|
-
var api, tx, origin, destination, senderAddress, ahAddress, address, currency, feeAsset, resolvedFeeAsset, originAsset, originBalanceFee, originBalance, edOrigin,
|
|
4221
|
+
var api, tx, origin, destination, senderAddress, ahAddress, address, currency, feeAsset, resolvedFeeAsset, originAsset, originBalanceFee, originBalance, edOrigin, _yield$getXcmFee, _yield$getXcmFee$orig, originFee, originFeeCurrency, assetHubFeeResult, bridgeHubFeeResult, destFeeDetail, isFeeAssetAh, originBalanceAfter, originBalanceFeeAfter, originBalanceNativeSufficient, originBalanceSufficient, assetHub, bridgeHub, bridgeHubNode, destinationInfo, _t;
|
|
4245
4222
|
return _regenerator().w(function (_context) {
|
|
4246
4223
|
while (1) switch (_context.n) {
|
|
4247
4224
|
case 0:
|
|
@@ -4294,15 +4271,8 @@ var getTransferInfo = /*#__PURE__*/function () {
|
|
|
4294
4271
|
});
|
|
4295
4272
|
case 8:
|
|
4296
4273
|
originBalance = _context.v;
|
|
4297
|
-
edOrigin =
|
|
4298
|
-
|
|
4299
|
-
_context.n = 9;
|
|
4300
|
-
break;
|
|
4301
|
-
}
|
|
4302
|
-
throw new InvalidParameterError("Existential deposit not found for ".concat(origin, " with currency ").concat(JSON.stringify(currency)));
|
|
4303
|
-
case 9:
|
|
4304
|
-
edOriginBn = BigInt(edOrigin);
|
|
4305
|
-
_context.n = 10;
|
|
4274
|
+
edOrigin = getExistentialDepositOrThrow(origin, currency);
|
|
4275
|
+
_context.n = 9;
|
|
4306
4276
|
return getXcmFee({
|
|
4307
4277
|
api: api,
|
|
4308
4278
|
tx: tx,
|
|
@@ -4314,7 +4284,7 @@ var getTransferInfo = /*#__PURE__*/function () {
|
|
|
4314
4284
|
feeAsset: feeAsset,
|
|
4315
4285
|
disableFallback: false
|
|
4316
4286
|
});
|
|
4317
|
-
case
|
|
4287
|
+
case 9:
|
|
4318
4288
|
_yield$getXcmFee = _context.v;
|
|
4319
4289
|
_yield$getXcmFee$orig = _yield$getXcmFee.origin;
|
|
4320
4290
|
originFee = _yield$getXcmFee$orig.fee;
|
|
@@ -4323,21 +4293,21 @@ var getTransferInfo = /*#__PURE__*/function () {
|
|
|
4323
4293
|
bridgeHubFeeResult = _yield$getXcmFee.bridgeHub;
|
|
4324
4294
|
destFeeDetail = _yield$getXcmFee.destination;
|
|
4325
4295
|
if (!(originFee === undefined)) {
|
|
4326
|
-
_context.n =
|
|
4296
|
+
_context.n = 10;
|
|
4327
4297
|
break;
|
|
4328
4298
|
}
|
|
4329
|
-
throw new InvalidParameterError("Cannot get origin xcm fee for currency ".concat(JSON.stringify(currency), " on node ").concat(origin, "."));
|
|
4330
|
-
case
|
|
4299
|
+
throw new InvalidParameterError("Cannot get origin xcm fee for currency ".concat(JSON.stringify(currency, replaceBigInt), " on node ").concat(origin, "."));
|
|
4300
|
+
case 10:
|
|
4331
4301
|
isFeeAssetAh = origin === 'AssetHubPolkadot' && resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, originAsset);
|
|
4332
4302
|
originBalanceAfter = originBalance - BigInt(currency.amount);
|
|
4333
4303
|
originBalanceFeeAfter = isFeeAssetAh ? originBalanceFee - BigInt(currency.amount) : originBalanceFee - originFee;
|
|
4334
4304
|
originBalanceNativeSufficient = originBalanceFee >= originFee;
|
|
4335
|
-
originBalanceSufficient = originBalanceAfter >=
|
|
4305
|
+
originBalanceSufficient = originBalanceAfter >= edOrigin;
|
|
4336
4306
|
if (!assetHubFeeResult) {
|
|
4337
|
-
_context.n =
|
|
4307
|
+
_context.n = 12;
|
|
4338
4308
|
break;
|
|
4339
4309
|
}
|
|
4340
|
-
_context.n =
|
|
4310
|
+
_context.n = 11;
|
|
4341
4311
|
return buildHopInfo({
|
|
4342
4312
|
api: api,
|
|
4343
4313
|
node: determineRelayChain(origin) === 'Polkadot' ? 'AssetHubPolkadot' : 'AssetHubKusama',
|
|
@@ -4347,15 +4317,15 @@ var getTransferInfo = /*#__PURE__*/function () {
|
|
|
4347
4317
|
senderAddress: senderAddress,
|
|
4348
4318
|
ahAddress: ahAddress
|
|
4349
4319
|
});
|
|
4350
|
-
case
|
|
4320
|
+
case 11:
|
|
4351
4321
|
assetHub = _context.v;
|
|
4352
|
-
case
|
|
4322
|
+
case 12:
|
|
4353
4323
|
if (!bridgeHubFeeResult) {
|
|
4354
|
-
_context.n =
|
|
4324
|
+
_context.n = 14;
|
|
4355
4325
|
break;
|
|
4356
4326
|
}
|
|
4357
4327
|
bridgeHubNode = determineRelayChain(origin) === 'Polkadot' ? 'BridgeHubPolkadot' : 'BridgeHubKusama';
|
|
4358
|
-
_context.n =
|
|
4328
|
+
_context.n = 13;
|
|
4359
4329
|
return buildHopInfo({
|
|
4360
4330
|
api: api,
|
|
4361
4331
|
node: bridgeHubNode,
|
|
@@ -4365,10 +4335,10 @@ var getTransferInfo = /*#__PURE__*/function () {
|
|
|
4365
4335
|
senderAddress: senderAddress,
|
|
4366
4336
|
ahAddress: ahAddress
|
|
4367
4337
|
});
|
|
4368
|
-
case
|
|
4338
|
+
case 13:
|
|
4369
4339
|
bridgeHub = _context.v;
|
|
4370
|
-
case
|
|
4371
|
-
_context.n =
|
|
4340
|
+
case 14:
|
|
4341
|
+
_context.n = 15;
|
|
4372
4342
|
return buildDestInfo({
|
|
4373
4343
|
api: api,
|
|
4374
4344
|
origin: origin,
|
|
@@ -4381,7 +4351,7 @@ var getTransferInfo = /*#__PURE__*/function () {
|
|
|
4381
4351
|
assetHubFee: assetHubFeeResult === null || assetHubFeeResult === void 0 ? void 0 : assetHubFeeResult.fee,
|
|
4382
4352
|
bridgeFee: bridgeHubFeeResult === null || bridgeHubFeeResult === void 0 ? void 0 : bridgeHubFeeResult.fee
|
|
4383
4353
|
});
|
|
4384
|
-
case
|
|
4354
|
+
case 15:
|
|
4385
4355
|
destinationInfo = _context.v;
|
|
4386
4356
|
return _context.a(2, {
|
|
4387
4357
|
chain: {
|
|
@@ -4395,7 +4365,7 @@ var getTransferInfo = /*#__PURE__*/function () {
|
|
|
4395
4365
|
balance: originBalance,
|
|
4396
4366
|
balanceAfter: originBalanceAfter,
|
|
4397
4367
|
currencySymbol: originAsset.symbol,
|
|
4398
|
-
existentialDeposit:
|
|
4368
|
+
existentialDeposit: edOrigin
|
|
4399
4369
|
},
|
|
4400
4370
|
xcmFee: {
|
|
4401
4371
|
sufficient: originBalanceNativeSufficient,
|
|
@@ -4409,17 +4379,17 @@ var getTransferInfo = /*#__PURE__*/function () {
|
|
|
4409
4379
|
bridgeHub: bridgeHub,
|
|
4410
4380
|
destination: destinationInfo
|
|
4411
4381
|
});
|
|
4412
|
-
case
|
|
4413
|
-
_context.p =
|
|
4382
|
+
case 16:
|
|
4383
|
+
_context.p = 16;
|
|
4414
4384
|
api.setDisconnectAllowed(true);
|
|
4415
|
-
_context.n =
|
|
4385
|
+
_context.n = 17;
|
|
4416
4386
|
return api.disconnect();
|
|
4387
|
+
case 17:
|
|
4388
|
+
return _context.f(16);
|
|
4417
4389
|
case 18:
|
|
4418
|
-
return _context.f(17);
|
|
4419
|
-
case 19:
|
|
4420
4390
|
return _context.a(2);
|
|
4421
4391
|
}
|
|
4422
|
-
}, _callee, null, [[3,,
|
|
4392
|
+
}, _callee, null, [[3,, 16, 18]]);
|
|
4423
4393
|
}));
|
|
4424
4394
|
return function getTransferInfo(_x) {
|
|
4425
4395
|
return _ref2.apply(this, arguments);
|
|
@@ -4439,7 +4409,7 @@ var calculateTotalXcmFee = function calculateTotalXcmFee(feeResult) {
|
|
|
4439
4409
|
};
|
|
4440
4410
|
var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
4441
4411
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
4442
|
-
var api, tx, origin, destination, address, senderAddress, feeAsset, currency, destApi, asset, destCurrency, ed,
|
|
4412
|
+
var api, tx, origin, destination, address, senderAddress, feeAsset, currency, destApi, asset, destCurrency, ed, balance, xcmFeeResult, dryRunError, assetHubFeeResult, bridgeHubFeeResult, _xcmFeeResult$destina, destFee, destFeeCurrency, destDryRunError, hopDryRunError, totalFee, method, feeToSubtract;
|
|
4443
4413
|
return _regenerator().w(function (_context) {
|
|
4444
4414
|
while (1) switch (_context.n) {
|
|
4445
4415
|
case 0:
|
|
@@ -4473,24 +4443,17 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
|
4473
4443
|
} : {
|
|
4474
4444
|
symbol: asset.symbol
|
|
4475
4445
|
};
|
|
4476
|
-
ed =
|
|
4477
|
-
|
|
4478
|
-
_context.n = 5;
|
|
4479
|
-
break;
|
|
4480
|
-
}
|
|
4481
|
-
throw new InvalidParameterError("Cannot get existential deposit for currency ".concat(JSON.stringify(currency)));
|
|
4482
|
-
case 5:
|
|
4483
|
-
edBN = BigInt(ed);
|
|
4484
|
-
_context.n = 6;
|
|
4446
|
+
ed = getExistentialDepositOrThrow(destination, destCurrency);
|
|
4447
|
+
_context.n = 5;
|
|
4485
4448
|
return getAssetBalanceInternal({
|
|
4486
4449
|
address: address,
|
|
4487
4450
|
node: destination,
|
|
4488
4451
|
api: destApi,
|
|
4489
4452
|
currency: destCurrency
|
|
4490
4453
|
});
|
|
4491
|
-
case
|
|
4454
|
+
case 5:
|
|
4492
4455
|
balance = _context.v;
|
|
4493
|
-
_context.n =
|
|
4456
|
+
_context.n = 6;
|
|
4494
4457
|
return getXcmFee({
|
|
4495
4458
|
api: api,
|
|
4496
4459
|
tx: tx,
|
|
@@ -4502,40 +4465,40 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
|
4502
4465
|
feeAsset: feeAsset,
|
|
4503
4466
|
disableFallback: false
|
|
4504
4467
|
});
|
|
4505
|
-
case
|
|
4468
|
+
case 6:
|
|
4506
4469
|
xcmFeeResult = _context.v;
|
|
4507
4470
|
dryRunError = xcmFeeResult.origin.dryRunError, assetHubFeeResult = xcmFeeResult.assetHub, bridgeHubFeeResult = xcmFeeResult.bridgeHub, _xcmFeeResult$destina = xcmFeeResult.destination, destFee = _xcmFeeResult$destina.fee, destFeeCurrency = _xcmFeeResult$destina.currency, destDryRunError = _xcmFeeResult$destina.dryRunError;
|
|
4508
4471
|
if (!(destFee === undefined)) {
|
|
4509
|
-
_context.n =
|
|
4472
|
+
_context.n = 7;
|
|
4510
4473
|
break;
|
|
4511
4474
|
}
|
|
4512
|
-
throw new InvalidParameterError("Cannot get destination xcm fee for currency ".concat(JSON.stringify(currency), " on node ").concat(destination, "."));
|
|
4513
|
-
case
|
|
4475
|
+
throw new InvalidParameterError("Cannot get destination xcm fee for currency ".concat(JSON.stringify(currency, replaceBigInt), " on node ").concat(destination, "."));
|
|
4476
|
+
case 7:
|
|
4514
4477
|
if (!dryRunError) {
|
|
4515
|
-
_context.n =
|
|
4478
|
+
_context.n = 8;
|
|
4516
4479
|
break;
|
|
4517
4480
|
}
|
|
4518
4481
|
throw new DryRunFailedError(dryRunError, 'origin');
|
|
4519
|
-
case
|
|
4482
|
+
case 8:
|
|
4520
4483
|
hopDryRunError = (assetHubFeeResult === null || assetHubFeeResult === void 0 ? void 0 : assetHubFeeResult.dryRunError) || (bridgeHubFeeResult === null || bridgeHubFeeResult === void 0 ? void 0 : bridgeHubFeeResult.dryRunError);
|
|
4521
4484
|
if (!hopDryRunError) {
|
|
4522
|
-
_context.n =
|
|
4485
|
+
_context.n = 9;
|
|
4523
4486
|
break;
|
|
4524
4487
|
}
|
|
4525
4488
|
throw new DryRunFailedError(hopDryRunError, assetHubFeeResult !== null && assetHubFeeResult !== void 0 && assetHubFeeResult.dryRunError ? 'assetHub' : 'bridgeHub');
|
|
4526
|
-
case
|
|
4489
|
+
case 9:
|
|
4527
4490
|
if (!destDryRunError) {
|
|
4528
|
-
_context.n =
|
|
4491
|
+
_context.n = 10;
|
|
4529
4492
|
break;
|
|
4530
4493
|
}
|
|
4531
4494
|
throw new UnableToComputeError("Unable to compute fee for the destination asset. Destination dry run error: ".concat(destDryRunError));
|
|
4532
|
-
case
|
|
4495
|
+
case 10:
|
|
4533
4496
|
if (!(normalizeSymbol(asset.symbol) !== normalizeSymbol(destFeeCurrency))) {
|
|
4534
|
-
_context.n =
|
|
4497
|
+
_context.n = 11;
|
|
4535
4498
|
break;
|
|
4536
4499
|
}
|
|
4537
4500
|
throw new UnableToComputeError("The XCM fee could not be calculated because the origin or destination chain does not support DryRun.\n As a result, fee estimation is only available through PaymentInfo, which provides the cost in the native asset.\n This limitation restricts support to transfers involving the native asset of the Destination chain only.");
|
|
4538
|
-
case
|
|
4501
|
+
case 11:
|
|
4539
4502
|
totalFee = calculateTotalXcmFee(xcmFeeResult);
|
|
4540
4503
|
method = api.getMethod(tx);
|
|
4541
4504
|
if (method === 'transfer_assets_using_type_and_then' || method === 'transferAssetsUsingTypeAndThen') {
|
|
@@ -4543,7 +4506,7 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
|
4543
4506
|
} else {
|
|
4544
4507
|
feeToSubtract = destFee;
|
|
4545
4508
|
}
|
|
4546
|
-
return _context.a(2, BigInt(currency.amount) - feeToSubtract > (balance <
|
|
4509
|
+
return _context.a(2, BigInt(currency.amount) - feeToSubtract > (balance < ed ? ed : 0));
|
|
4547
4510
|
}
|
|
4548
4511
|
}, _callee);
|
|
4549
4512
|
}));
|
|
@@ -4581,25 +4544,31 @@ var verifyEdOnDestination = /*#__PURE__*/function () {
|
|
|
4581
4544
|
}();
|
|
4582
4545
|
|
|
4583
4546
|
var isSufficientOrigin = /*#__PURE__*/function () {
|
|
4584
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, node, senderAddress, fee) {
|
|
4547
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, node, senderAddress, fee, feeAsset) {
|
|
4585
4548
|
var existentialDeposit, nativeBalance;
|
|
4586
4549
|
return _regenerator().w(function (_context) {
|
|
4587
4550
|
while (1) switch (_context.n) {
|
|
4588
4551
|
case 0:
|
|
4552
|
+
if (!feeAsset) {
|
|
4553
|
+
_context.n = 1;
|
|
4554
|
+
break;
|
|
4555
|
+
}
|
|
4556
|
+
return _context.a(2, undefined);
|
|
4557
|
+
case 1:
|
|
4589
4558
|
existentialDeposit = getExistentialDepositOrThrow(node);
|
|
4590
|
-
_context.n =
|
|
4559
|
+
_context.n = 2;
|
|
4591
4560
|
return getBalanceNativeInternal({
|
|
4592
4561
|
api: api,
|
|
4593
4562
|
node: node,
|
|
4594
4563
|
address: senderAddress
|
|
4595
4564
|
});
|
|
4596
|
-
case
|
|
4565
|
+
case 2:
|
|
4597
4566
|
nativeBalance = _context.v;
|
|
4598
4567
|
return _context.a(2, nativeBalance - existentialDeposit - fee > 0n);
|
|
4599
4568
|
}
|
|
4600
4569
|
}, _callee);
|
|
4601
4570
|
}));
|
|
4602
|
-
return function isSufficientOrigin(_x, _x2, _x3, _x4) {
|
|
4571
|
+
return function isSufficientOrigin(_x, _x2, _x3, _x4, _x5) {
|
|
4603
4572
|
return _ref.apply(this, arguments);
|
|
4604
4573
|
};
|
|
4605
4574
|
}();
|
|
@@ -4628,7 +4597,7 @@ var isSufficientDestination = /*#__PURE__*/function () {
|
|
|
4628
4597
|
}
|
|
4629
4598
|
}, _callee2);
|
|
4630
4599
|
}));
|
|
4631
|
-
return function isSufficientDestination(
|
|
4600
|
+
return function isSufficientDestination(_x6, _x7, _x8, _x9, _x0) {
|
|
4632
4601
|
return _ref2.apply(this, arguments);
|
|
4633
4602
|
};
|
|
4634
4603
|
}();
|
|
@@ -4664,54 +4633,48 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4664
4633
|
}
|
|
4665
4634
|
return _context.a(2, 0n);
|
|
4666
4635
|
case 1:
|
|
4667
|
-
originAsset =
|
|
4668
|
-
if (originAsset) {
|
|
4669
|
-
_context.n = 2;
|
|
4670
|
-
break;
|
|
4671
|
-
}
|
|
4672
|
-
throw new InvalidCurrencyError("Currency ".concat(JSON.stringify(currency, replaceBigInt), " not found in ").concat(origin));
|
|
4673
|
-
case 2:
|
|
4636
|
+
originAsset = findAssetForNodeOrThrow(origin, currency, destination);
|
|
4674
4637
|
if (!originAsset.multiLocation) {
|
|
4675
|
-
_context.n =
|
|
4638
|
+
_context.n = 7;
|
|
4676
4639
|
break;
|
|
4677
4640
|
}
|
|
4678
|
-
_context.p =
|
|
4679
|
-
_context.n =
|
|
4641
|
+
_context.p = 2;
|
|
4642
|
+
_context.n = 3;
|
|
4680
4643
|
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4681
4644
|
destination: destination
|
|
4682
4645
|
}), {
|
|
4683
4646
|
multilocation: originAsset.multiLocation
|
|
4684
4647
|
});
|
|
4685
|
-
case
|
|
4648
|
+
case 3:
|
|
4686
4649
|
return _context.a(2, _context.v);
|
|
4687
|
-
case
|
|
4688
|
-
_context.p =
|
|
4650
|
+
case 4:
|
|
4651
|
+
_context.p = 4;
|
|
4689
4652
|
_t = _context.v;
|
|
4690
4653
|
if (!(_t instanceof InvalidCurrencyError)) {
|
|
4691
|
-
_context.n =
|
|
4654
|
+
_context.n = 6;
|
|
4692
4655
|
break;
|
|
4693
4656
|
}
|
|
4694
|
-
_context.n =
|
|
4657
|
+
_context.n = 5;
|
|
4695
4658
|
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4696
4659
|
destination: destination
|
|
4697
4660
|
}), {
|
|
4698
4661
|
symbol: originAsset.symbol
|
|
4699
4662
|
});
|
|
4700
|
-
case
|
|
4663
|
+
case 5:
|
|
4701
4664
|
return _context.a(2, _context.v);
|
|
4702
|
-
case
|
|
4665
|
+
case 6:
|
|
4703
4666
|
throw _t;
|
|
4704
|
-
case
|
|
4705
|
-
_context.n =
|
|
4667
|
+
case 7:
|
|
4668
|
+
_context.n = 8;
|
|
4706
4669
|
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4707
4670
|
destination: destination
|
|
4708
4671
|
}), {
|
|
4709
4672
|
symbol: originAsset.symbol
|
|
4710
4673
|
});
|
|
4711
|
-
case
|
|
4674
|
+
case 8:
|
|
4712
4675
|
return _context.a(2, _context.v);
|
|
4713
4676
|
}
|
|
4714
|
-
}, _callee, null, [[
|
|
4677
|
+
}, _callee, null, [[2, 4]]);
|
|
4715
4678
|
}));
|
|
4716
4679
|
return function calcPaymentInfoFee() {
|
|
4717
4680
|
return _ref2.apply(this, arguments);
|
|
@@ -4782,6 +4745,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4782
4745
|
return _context2.a(2, {
|
|
4783
4746
|
fee: fee,
|
|
4784
4747
|
feeType: 'dryRun',
|
|
4748
|
+
sufficient: true,
|
|
4785
4749
|
forwardedXcms: newForwardedXcms,
|
|
4786
4750
|
destParaId: destParaId
|
|
4787
4751
|
});
|
|
@@ -5034,7 +4998,7 @@ var dryRunOrigin = /*#__PURE__*/function () {
|
|
|
5034
4998
|
|
|
5035
4999
|
var getOriginXcmFee = /*#__PURE__*/function () {
|
|
5036
5000
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
5037
|
-
var api, tx, origin, destination, senderAddress, disableFallback, feeAsset, currency, resolvedFeeAsset,
|
|
5001
|
+
var api, tx, origin, destination, senderAddress, disableFallback, feeAsset, currency, resolvedFeeAsset, nativeAssetSymbol, rawFee, paddedFee, sufficient, dryRunResult, _rawFee, _paddedFee, _sufficient, fee, forwardedXcms, destParaId, weight, currencySymbol;
|
|
5038
5002
|
return _regenerator().w(function (_context) {
|
|
5039
5003
|
while (1) switch (_context.n) {
|
|
5040
5004
|
case 0:
|
|
@@ -5043,7 +5007,7 @@ var getOriginXcmFee = /*#__PURE__*/function () {
|
|
|
5043
5007
|
_context.n = 1;
|
|
5044
5008
|
return api.init(origin, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
5045
5009
|
case 1:
|
|
5046
|
-
|
|
5010
|
+
nativeAssetSymbol = getNativeAssetSymbol(origin);
|
|
5047
5011
|
if (hasDryRunSupport(origin)) {
|
|
5048
5012
|
_context.n = 4;
|
|
5049
5013
|
break;
|
|
@@ -5054,12 +5018,12 @@ var getOriginXcmFee = /*#__PURE__*/function () {
|
|
|
5054
5018
|
rawFee = _context.v;
|
|
5055
5019
|
paddedFee = padFee(rawFee, origin, destination, 'origin');
|
|
5056
5020
|
_context.n = 3;
|
|
5057
|
-
return isSufficientOrigin(api, origin, senderAddress, paddedFee);
|
|
5021
|
+
return isSufficientOrigin(api, origin, senderAddress, paddedFee, resolvedFeeAsset);
|
|
5058
5022
|
case 3:
|
|
5059
5023
|
sufficient = _context.v;
|
|
5060
5024
|
return _context.a(2, {
|
|
5061
5025
|
fee: paddedFee,
|
|
5062
|
-
currency:
|
|
5026
|
+
currency: nativeAssetSymbol,
|
|
5063
5027
|
feeType: 'paymentInfo',
|
|
5064
5028
|
sufficient: sufficient
|
|
5065
5029
|
});
|
|
@@ -5091,21 +5055,23 @@ var getOriginXcmFee = /*#__PURE__*/function () {
|
|
|
5091
5055
|
_rawFee = _context.v;
|
|
5092
5056
|
_paddedFee = padFee(_rawFee, origin, destination, 'origin');
|
|
5093
5057
|
_context.n = 8;
|
|
5094
|
-
return isSufficientOrigin(api, origin, senderAddress, _paddedFee);
|
|
5058
|
+
return isSufficientOrigin(api, origin, senderAddress, _paddedFee, resolvedFeeAsset);
|
|
5095
5059
|
case 8:
|
|
5096
5060
|
_sufficient = _context.v;
|
|
5097
5061
|
return _context.a(2, {
|
|
5098
5062
|
fee: _paddedFee,
|
|
5099
|
-
currency:
|
|
5063
|
+
currency: nativeAssetSymbol,
|
|
5100
5064
|
feeType: 'paymentInfo',
|
|
5101
5065
|
dryRunError: dryRunResult.failureReason,
|
|
5102
5066
|
sufficient: _sufficient
|
|
5103
5067
|
});
|
|
5104
5068
|
case 9:
|
|
5105
5069
|
fee = dryRunResult.fee, forwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId, weight = dryRunResult.weight;
|
|
5070
|
+
currencySymbol = resolvedFeeAsset ? resolvedFeeAsset.symbol : nativeAssetSymbol;
|
|
5106
5071
|
return _context.a(2, {
|
|
5107
5072
|
fee: fee,
|
|
5108
5073
|
feeType: 'dryRun',
|
|
5074
|
+
sufficient: true,
|
|
5109
5075
|
currency: currencySymbol,
|
|
5110
5076
|
forwardedXcms: forwardedXcms,
|
|
5111
5077
|
destParaId: destParaId,
|
|
@@ -5119,20 +5085,176 @@ var getOriginXcmFee = /*#__PURE__*/function () {
|
|
|
5119
5085
|
};
|
|
5120
5086
|
}();
|
|
5121
5087
|
|
|
5088
|
+
var resolveAsset = function resolveAsset(currency, origin, destination, assetCheckEnabled) {
|
|
5089
|
+
return assetCheckEnabled ? findAsset(origin, currency, !isTMultiLocation(destination) ? destination : null) : null;
|
|
5090
|
+
};
|
|
5091
|
+
|
|
5092
|
+
var validateAssetSupport = function validateAssetSupport(_ref, assetCheckEnabled, isBridge, asset) {
|
|
5093
|
+
var origin = _ref.from,
|
|
5094
|
+
destination = _ref.to,
|
|
5095
|
+
currency = _ref.currency;
|
|
5096
|
+
var isDestAssetHub = destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama';
|
|
5097
|
+
var allowedChainsToAh = ['AssetHubPolkadot', 'BifrostPolkadot', 'BifrostKusama', 'Hydration', 'Moonbeam', 'Ajuna', 'Polimec'];
|
|
5098
|
+
if (!isRelayChain(origin) && !isBridge && isDestAssetHub && !allowedChainsToAh.includes(origin) && (asset === null || asset === void 0 ? void 0 : asset.symbol) === 'DOT') {
|
|
5099
|
+
throw new TransferToAhNotSupported("Node ".concat(origin, " does not support DOT transfer to AssetHub"));
|
|
5100
|
+
}
|
|
5101
|
+
var isRelayDestination = !isTMultiLocation(destination) && isRelayChain(destination);
|
|
5102
|
+
var isMultiLocationDestination = _typeof(destination) === 'object';
|
|
5103
|
+
if (!isBridge && !isRelayDestination && !isMultiLocationDestination && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== undefined && assetCheckEnabled && !('id' in currency) && !hasSupportForAsset(destination, asset.symbol)) {
|
|
5104
|
+
throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency ").concat(JSON.stringify(currency, replaceBigInt), "."));
|
|
5105
|
+
}
|
|
5106
|
+
if (!isBridge && asset === null && assetCheckEnabled) {
|
|
5107
|
+
throwUnsupportedCurrency(currency, origin);
|
|
5108
|
+
}
|
|
5109
|
+
};
|
|
5110
|
+
|
|
5111
|
+
var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge, assetCheckEnabled, resolvedFeeAsset) {
|
|
5112
|
+
var currency = options.currency,
|
|
5113
|
+
feeAsset = options.feeAsset,
|
|
5114
|
+
origin = options.from,
|
|
5115
|
+
destination = options.to;
|
|
5116
|
+
if ('multilocation' in currency && isOverrideMultiLocationSpecifier(currency.multilocation)) {
|
|
5117
|
+
return currency.multilocation.value;
|
|
5118
|
+
}
|
|
5119
|
+
if ('multiasset' in currency) {
|
|
5120
|
+
if (!feeAsset) {
|
|
5121
|
+
throw new InvalidCurrencyError('Overridden multi assets cannot be used without specifying fee asset');
|
|
5122
|
+
}
|
|
5123
|
+
if ('multilocation' in feeAsset && isOverrideMultiLocationSpecifier(feeAsset.multilocation)) {
|
|
5124
|
+
throw new InvalidCurrencyError('Fee asset cannot be an overridden multi location specifier');
|
|
5125
|
+
}
|
|
5126
|
+
if (currency.multiasset.every(function (asset) {
|
|
5127
|
+
return isTMultiAsset(asset);
|
|
5128
|
+
})) {
|
|
5129
|
+
if (!feeAsset) {
|
|
5130
|
+
throw new InvalidCurrencyError('Fee asset not provided');
|
|
5131
|
+
}
|
|
5132
|
+
if (!('multilocation' in feeAsset)) {
|
|
5133
|
+
throw new InvalidCurrencyError('Fee asset must be specified by multilocation when using raw overridden multi assets');
|
|
5134
|
+
}
|
|
5135
|
+
return currency.multiasset.map(function (multiAsset) {
|
|
5136
|
+
var ml = extractMultiAssetLoc(multiAsset);
|
|
5137
|
+
return _objectSpread2(_objectSpread2({}, multiAsset), {}, {
|
|
5138
|
+
isFeeAsset: deepEqual(ml, feeAsset.multilocation)
|
|
5139
|
+
});
|
|
5140
|
+
});
|
|
5141
|
+
}
|
|
5142
|
+
// MultiAsset is an array of TCurrencyCore, search for assets
|
|
5143
|
+
var assets = currency.multiasset.map(function (currency) {
|
|
5144
|
+
var asset = findAsset(origin, currency, !isTMultiLocation(destination) ? destination : null);
|
|
5145
|
+
if (asset && !asset.multiLocation) {
|
|
5146
|
+
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency, replaceBigInt), " does not have a multiLocation"));
|
|
5147
|
+
}
|
|
5148
|
+
if (!asset) {
|
|
5149
|
+
throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency ").concat(JSON.stringify(currency)));
|
|
5150
|
+
}
|
|
5151
|
+
if (!resolvedFeeAsset) {
|
|
5152
|
+
throw new InvalidCurrencyError('Fee asset not found');
|
|
5153
|
+
}
|
|
5154
|
+
validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
|
|
5155
|
+
var originTyped = origin;
|
|
5156
|
+
var originNode = getNode(originTyped);
|
|
5157
|
+
return _objectSpread2({
|
|
5158
|
+
isFeeAsset: isAssetEqual(resolvedFeeAsset, asset)
|
|
5159
|
+
}, createMultiAsset(originNode.version, currency.amount, asset.multiLocation));
|
|
5160
|
+
});
|
|
5161
|
+
if (assets.filter(function (asset) {
|
|
5162
|
+
return asset.isFeeAsset;
|
|
5163
|
+
}).length > 1) {
|
|
5164
|
+
throw new InvalidCurrencyError("Fee asset matches multiple assets in multiassets");
|
|
5165
|
+
}
|
|
5166
|
+
if (assets.filter(function (asset) {
|
|
5167
|
+
return asset.isFeeAsset;
|
|
5168
|
+
}).length === 0) {
|
|
5169
|
+
throw new InvalidCurrencyError("Fee asset not found in multiassets");
|
|
5170
|
+
}
|
|
5171
|
+
return assets;
|
|
5172
|
+
}
|
|
5173
|
+
return undefined;
|
|
5174
|
+
};
|
|
5175
|
+
|
|
5176
|
+
var selectXcmVersion = function selectXcmVersion(forcedVersion, originVersion, destMaxVersion) {
|
|
5177
|
+
if (forcedVersion) {
|
|
5178
|
+
return forcedVersion;
|
|
5179
|
+
}
|
|
5180
|
+
var destVersion = destMaxVersion !== null && destMaxVersion !== void 0 ? destMaxVersion : originVersion;
|
|
5181
|
+
if (originVersion === Version.V4 && destVersion === Version.V3) {
|
|
5182
|
+
return Version.V3;
|
|
5183
|
+
}
|
|
5184
|
+
return originVersion;
|
|
5185
|
+
};
|
|
5186
|
+
|
|
5187
|
+
var shouldPerformAssetCheck = function shouldPerformAssetCheck(origin, currency) {
|
|
5188
|
+
if (isRelayChain(origin)) return true;
|
|
5189
|
+
var hasMultiAsset = 'multiasset' in currency;
|
|
5190
|
+
var hasOverriddenMultilocation = 'multilocation' in currency && isOverrideMultiLocationSpecifier(currency.multilocation);
|
|
5191
|
+
return !(hasMultiAsset || hasOverriddenMultilocation);
|
|
5192
|
+
};
|
|
5193
|
+
|
|
5194
|
+
var validateDestinationAddress = function validateDestinationAddress(address, destination) {
|
|
5195
|
+
if (typeof address === 'string' && !isTMultiLocation(destination)) {
|
|
5196
|
+
validateAddress(address, destination);
|
|
5197
|
+
}
|
|
5198
|
+
};
|
|
5199
|
+
|
|
5200
|
+
var validateCurrency = function validateCurrency(currency, feeAsset) {
|
|
5201
|
+
if ('multiasset' in currency) {
|
|
5202
|
+
if (currency.multiasset.length === 0) {
|
|
5203
|
+
throw new InvalidCurrencyError('Overridden multi assets cannot be empty');
|
|
5204
|
+
}
|
|
5205
|
+
if (currency.multiasset.length === 1) {
|
|
5206
|
+
throw new InvalidCurrencyError('Please provide more than one multi asset');
|
|
5207
|
+
}
|
|
5208
|
+
if (currency.multiasset.length > 1 && !currency.multiasset.every(function (asset) {
|
|
5209
|
+
return isTMultiAsset(asset);
|
|
5210
|
+
}) && !feeAsset) {
|
|
5211
|
+
throw new InvalidCurrencyError('Overridden multi assets cannot be used without specifying fee asset');
|
|
5212
|
+
}
|
|
5213
|
+
}
|
|
5214
|
+
};
|
|
5215
|
+
var validateDestination = function validateDestination(origin, destination) {
|
|
5216
|
+
if (isRelayChain(origin) && !isTMultiLocation(destination) && isRelayChain(destination) && origin !== destination) {
|
|
5217
|
+
throw new IncompatibleNodesError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
|
|
5218
|
+
}
|
|
5219
|
+
var allowedChainsToEthereum = ['AssetHubPolkadot', 'Hydration', 'BifrostPolkadot', 'Moonbeam'];
|
|
5220
|
+
if (destination === 'Ethereum' && !allowedChainsToEthereum.includes(origin)) {
|
|
5221
|
+
throw new IncompatibleNodesError("Transfers to Ethereum are only supported from: ".concat(allowedChainsToEthereum.join(', ')));
|
|
5222
|
+
}
|
|
5223
|
+
var isMultiLocationDestination = _typeof(destination) === 'object';
|
|
5224
|
+
var isBridge = !isTMultiLocation(destination) && isDotKsmBridge(origin, destination);
|
|
5225
|
+
var isRelayDestination = !isTMultiLocation(destination) && isRelayChain(destination);
|
|
5226
|
+
if (!isRelayDestination && !isMultiLocationDestination) {
|
|
5227
|
+
var originRelayChainSymbol = getRelayChainSymbol(origin);
|
|
5228
|
+
var destinationRelayChainSymbol = getRelayChainSymbol(destination);
|
|
5229
|
+
if (!isBridge && originRelayChainSymbol !== destinationRelayChainSymbol) {
|
|
5230
|
+
throw new IncompatibleNodesError();
|
|
5231
|
+
}
|
|
5232
|
+
}
|
|
5233
|
+
};
|
|
5234
|
+
var validateAssetSpecifiers = function validateAssetSpecifiers(assetCheckEnabled, currency) {
|
|
5235
|
+
if (!assetCheckEnabled && 'symbol' in currency && isSymbolSpecifier(currency.symbol)) {
|
|
5236
|
+
throw new InvalidCurrencyError('Symbol specifier is not supported when asset check is disabled. Please use normal symbol instead.');
|
|
5237
|
+
}
|
|
5238
|
+
if (!assetCheckEnabled && 'id' in currency) {
|
|
5239
|
+
throw new InvalidCurrencyError('Asset ID is not supported when asset check is disabled. Please use normal symbol instead');
|
|
5240
|
+
}
|
|
5241
|
+
};
|
|
5242
|
+
|
|
5122
5243
|
var getOriginXcmFeeEstimate = /*#__PURE__*/function () {
|
|
5123
5244
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
5124
|
-
var api, tx, origin, destination, senderAddress, rawOriginFee, originFee, sufficient;
|
|
5245
|
+
var api, tx, origin, destination, currency, senderAddress, feeAsset, rawOriginFee, originFee, resolvedFeeAsset, sufficient;
|
|
5125
5246
|
return _regenerator().w(function (_context) {
|
|
5126
5247
|
while (1) switch (_context.n) {
|
|
5127
5248
|
case 0:
|
|
5128
|
-
api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress;
|
|
5249
|
+
api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, currency = _ref.currency, senderAddress = _ref.senderAddress, feeAsset = _ref.feeAsset;
|
|
5129
5250
|
_context.n = 1;
|
|
5130
5251
|
return api.calculateTransactionFee(tx, senderAddress);
|
|
5131
5252
|
case 1:
|
|
5132
5253
|
rawOriginFee = _context.v;
|
|
5133
5254
|
originFee = padFee(rawOriginFee, origin, destination, 'origin');
|
|
5255
|
+
resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
|
|
5134
5256
|
_context.n = 2;
|
|
5135
|
-
return isSufficientOrigin(api, origin, senderAddress, originFee);
|
|
5257
|
+
return isSufficientOrigin(api, origin, senderAddress, originFee, resolvedFeeAsset);
|
|
5136
5258
|
case 2:
|
|
5137
5259
|
sufficient = _context.v;
|
|
5138
5260
|
return _context.a(2, {
|
|
@@ -5469,12 +5591,13 @@ var BRIDGE_FEE_DOT = 682395810n; // 0.068239581 DOT
|
|
|
5469
5591
|
var BRIDGE_FEE_KSM = 12016807000n; // 0.012016807 KSM
|
|
5470
5592
|
var getXcmFeeEstimate = /*#__PURE__*/function () {
|
|
5471
5593
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
5472
|
-
var api, origin, destination, currency, address, senderAddress, originAsset, destApi, _ref2, _ref3, fixedOriginFee, fixedDestinationFee, originSufficient, _destinationSufficient, originFeeDetails, currencyInput, destinationFee, destinationSufficient, destFeeDetails, _t;
|
|
5594
|
+
var api, origin, destination, currency, feeAsset, address, senderAddress, originAsset, resolvedFeeAsset, destApi, _ref2, _ref3, fixedOriginFee, fixedDestinationFee, originSufficient, _destinationSufficient, originFeeDetails, currencyInput, destinationFee, destinationSufficient, destFeeDetails, _t;
|
|
5473
5595
|
return _regenerator().w(function (_context) {
|
|
5474
5596
|
while (1) switch (_context.n) {
|
|
5475
5597
|
case 0:
|
|
5476
|
-
api = options.api, origin = options.origin, destination = options.destination, currency = options.currency, address = options.address, senderAddress = options.senderAddress;
|
|
5598
|
+
api = options.api, origin = options.origin, destination = options.destination, currency = options.currency, feeAsset = options.feeAsset, address = options.address, senderAddress = options.senderAddress;
|
|
5477
5599
|
originAsset = findAssetForNodeOrThrow(origin, currency, destination);
|
|
5600
|
+
resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
|
|
5478
5601
|
_context.n = 1;
|
|
5479
5602
|
return api.init(origin, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
5480
5603
|
case 1:
|
|
@@ -5488,7 +5611,7 @@ var getXcmFeeEstimate = /*#__PURE__*/function () {
|
|
|
5488
5611
|
}
|
|
5489
5612
|
_ref2 = origin === 'AssetHubPolkadot' ? [BRIDGE_FEE_DOT, BRIDGE_FEE_KSM] : [BRIDGE_FEE_KSM, BRIDGE_FEE_DOT], _ref3 = _slicedToArray(_ref2, 2), fixedOriginFee = _ref3[0], fixedDestinationFee = _ref3[1];
|
|
5490
5613
|
_context.n = 3;
|
|
5491
|
-
return isSufficientOrigin(api, origin, senderAddress, fixedOriginFee);
|
|
5614
|
+
return isSufficientOrigin(api, origin, senderAddress, fixedOriginFee, resolvedFeeAsset);
|
|
5492
5615
|
case 3:
|
|
5493
5616
|
originSufficient = _context.v;
|
|
5494
5617
|
_context.n = 4;
|
|
@@ -5592,161 +5715,6 @@ var transferRelayToPara = /*#__PURE__*/function () {
|
|
|
5592
5715
|
};
|
|
5593
5716
|
}();
|
|
5594
5717
|
|
|
5595
|
-
var resolveAsset = function resolveAsset(currency, origin, destination, assetCheckEnabled) {
|
|
5596
|
-
return assetCheckEnabled ? findAsset(origin, currency, !isTMultiLocation(destination) ? destination : null) : null;
|
|
5597
|
-
};
|
|
5598
|
-
|
|
5599
|
-
var validateAssetSupport = function validateAssetSupport(_ref, assetCheckEnabled, isBridge, asset) {
|
|
5600
|
-
var origin = _ref.from,
|
|
5601
|
-
destination = _ref.to,
|
|
5602
|
-
currency = _ref.currency;
|
|
5603
|
-
var isDestAssetHub = destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama';
|
|
5604
|
-
var allowedChainsToAh = ['AssetHubPolkadot', 'BifrostPolkadot', 'BifrostKusama', 'Hydration', 'Moonbeam', 'Ajuna', 'Polimec'];
|
|
5605
|
-
if (!isRelayChain(origin) && !isBridge && isDestAssetHub && !allowedChainsToAh.includes(origin) && (asset === null || asset === void 0 ? void 0 : asset.symbol) === 'DOT') {
|
|
5606
|
-
throw new TransferToAhNotSupported("Node ".concat(origin, " does not support DOT transfer to AssetHub"));
|
|
5607
|
-
}
|
|
5608
|
-
var isRelayDestination = !isTMultiLocation(destination) && isRelayChain(destination);
|
|
5609
|
-
var isMultiLocationDestination = _typeof(destination) === 'object';
|
|
5610
|
-
if (!isBridge && !isRelayDestination && !isMultiLocationDestination && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== undefined && assetCheckEnabled && !('id' in currency) && !hasSupportForAsset(destination, asset.symbol)) {
|
|
5611
|
-
throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency ").concat(JSON.stringify(currency), "."));
|
|
5612
|
-
}
|
|
5613
|
-
if (!isBridge && asset === null && assetCheckEnabled) {
|
|
5614
|
-
throwUnsupportedCurrency(currency, origin);
|
|
5615
|
-
}
|
|
5616
|
-
};
|
|
5617
|
-
|
|
5618
|
-
var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge, assetCheckEnabled, resolvedFeeAsset) {
|
|
5619
|
-
var currency = options.currency,
|
|
5620
|
-
feeAsset = options.feeAsset,
|
|
5621
|
-
origin = options.from,
|
|
5622
|
-
destination = options.to;
|
|
5623
|
-
if ('multilocation' in currency && isOverrideMultiLocationSpecifier(currency.multilocation)) {
|
|
5624
|
-
return currency.multilocation.value;
|
|
5625
|
-
}
|
|
5626
|
-
if ('multiasset' in currency) {
|
|
5627
|
-
if (!feeAsset) {
|
|
5628
|
-
throw new InvalidCurrencyError('Overridden multi assets cannot be used without specifying fee asset');
|
|
5629
|
-
}
|
|
5630
|
-
if ('multilocation' in feeAsset && isOverrideMultiLocationSpecifier(feeAsset.multilocation)) {
|
|
5631
|
-
throw new InvalidCurrencyError('Fee asset cannot be an overridden multi location specifier');
|
|
5632
|
-
}
|
|
5633
|
-
if (currency.multiasset.every(function (asset) {
|
|
5634
|
-
return isTMultiAsset(asset);
|
|
5635
|
-
})) {
|
|
5636
|
-
if (!feeAsset) {
|
|
5637
|
-
throw new InvalidCurrencyError('Fee asset not provided');
|
|
5638
|
-
}
|
|
5639
|
-
if (!('multilocation' in feeAsset)) {
|
|
5640
|
-
throw new InvalidCurrencyError('Fee asset must be specified by multilocation when using raw overridden multi assets');
|
|
5641
|
-
}
|
|
5642
|
-
return currency.multiasset.map(function (multiAsset) {
|
|
5643
|
-
var ml = extractMultiAssetLoc(multiAsset);
|
|
5644
|
-
return _objectSpread2(_objectSpread2({}, multiAsset), {}, {
|
|
5645
|
-
isFeeAsset: deepEqual(ml, feeAsset.multilocation)
|
|
5646
|
-
});
|
|
5647
|
-
});
|
|
5648
|
-
}
|
|
5649
|
-
// MultiAsset is an array of TCurrencyCore, search for assets
|
|
5650
|
-
var assets = currency.multiasset.map(function (currency) {
|
|
5651
|
-
var asset = findAsset(origin, currency, !isTMultiLocation(destination) ? destination : null);
|
|
5652
|
-
if (asset && !asset.multiLocation) {
|
|
5653
|
-
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " does not have a multiLocation"));
|
|
5654
|
-
}
|
|
5655
|
-
if (!asset) {
|
|
5656
|
-
throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency ").concat(JSON.stringify(currency)));
|
|
5657
|
-
}
|
|
5658
|
-
if (!resolvedFeeAsset) {
|
|
5659
|
-
throw new InvalidCurrencyError('Fee asset not found');
|
|
5660
|
-
}
|
|
5661
|
-
validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
|
|
5662
|
-
var originTyped = origin;
|
|
5663
|
-
var originNode = getNode(originTyped);
|
|
5664
|
-
return _objectSpread2({
|
|
5665
|
-
isFeeAsset: isAssetEqual(resolvedFeeAsset, asset)
|
|
5666
|
-
}, createMultiAsset(originNode.version, currency.amount, asset.multiLocation));
|
|
5667
|
-
});
|
|
5668
|
-
if (assets.filter(function (asset) {
|
|
5669
|
-
return asset.isFeeAsset;
|
|
5670
|
-
}).length > 1) {
|
|
5671
|
-
throw new InvalidCurrencyError("Fee asset matches multiple assets in multiassets");
|
|
5672
|
-
}
|
|
5673
|
-
if (assets.filter(function (asset) {
|
|
5674
|
-
return asset.isFeeAsset;
|
|
5675
|
-
}).length === 0) {
|
|
5676
|
-
throw new InvalidCurrencyError("Fee asset not found in multiassets");
|
|
5677
|
-
}
|
|
5678
|
-
return assets;
|
|
5679
|
-
}
|
|
5680
|
-
return undefined;
|
|
5681
|
-
};
|
|
5682
|
-
|
|
5683
|
-
var selectXcmVersion = function selectXcmVersion(forcedVersion, originVersion, destMaxVersion) {
|
|
5684
|
-
if (forcedVersion) {
|
|
5685
|
-
return forcedVersion;
|
|
5686
|
-
}
|
|
5687
|
-
var destVersion = destMaxVersion !== null && destMaxVersion !== void 0 ? destMaxVersion : originVersion;
|
|
5688
|
-
if (originVersion === Version.V4 && destVersion === Version.V3) {
|
|
5689
|
-
return Version.V3;
|
|
5690
|
-
}
|
|
5691
|
-
return originVersion;
|
|
5692
|
-
};
|
|
5693
|
-
|
|
5694
|
-
var shouldPerformAssetCheck = function shouldPerformAssetCheck(origin, currency) {
|
|
5695
|
-
if (isRelayChain(origin)) return true;
|
|
5696
|
-
var hasMultiAsset = 'multiasset' in currency;
|
|
5697
|
-
var hasOverriddenMultilocation = 'multilocation' in currency && isOverrideMultiLocationSpecifier(currency.multilocation);
|
|
5698
|
-
return !(hasMultiAsset || hasOverriddenMultilocation);
|
|
5699
|
-
};
|
|
5700
|
-
|
|
5701
|
-
var validateDestinationAddress = function validateDestinationAddress(address, destination) {
|
|
5702
|
-
if (typeof address === 'string' && !isTMultiLocation(destination)) {
|
|
5703
|
-
validateAddress(address, destination);
|
|
5704
|
-
}
|
|
5705
|
-
};
|
|
5706
|
-
|
|
5707
|
-
var validateCurrency = function validateCurrency(currency, feeAsset) {
|
|
5708
|
-
if ('multiasset' in currency) {
|
|
5709
|
-
if (currency.multiasset.length === 0) {
|
|
5710
|
-
throw new InvalidCurrencyError('Overridden multi assets cannot be empty');
|
|
5711
|
-
}
|
|
5712
|
-
if (currency.multiasset.length === 1) {
|
|
5713
|
-
throw new InvalidCurrencyError('Please provide more than one multi asset');
|
|
5714
|
-
}
|
|
5715
|
-
if (currency.multiasset.length > 1 && !currency.multiasset.every(function (asset) {
|
|
5716
|
-
return isTMultiAsset(asset);
|
|
5717
|
-
}) && !feeAsset) {
|
|
5718
|
-
throw new InvalidCurrencyError('Overridden multi assets cannot be used without specifying fee asset');
|
|
5719
|
-
}
|
|
5720
|
-
}
|
|
5721
|
-
};
|
|
5722
|
-
var validateDestination = function validateDestination(origin, destination) {
|
|
5723
|
-
if (isRelayChain(origin) && !isTMultiLocation(destination) && isRelayChain(destination) && origin !== destination) {
|
|
5724
|
-
throw new IncompatibleNodesError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
|
|
5725
|
-
}
|
|
5726
|
-
var allowedChainsToEthereum = ['AssetHubPolkadot', 'Hydration', 'BifrostPolkadot', 'Moonbeam'];
|
|
5727
|
-
if (destination === 'Ethereum' && !allowedChainsToEthereum.includes(origin)) {
|
|
5728
|
-
throw new IncompatibleNodesError("Transfers to Ethereum are only supported from: ".concat(allowedChainsToEthereum.join(', ')));
|
|
5729
|
-
}
|
|
5730
|
-
var isMultiLocationDestination = _typeof(destination) === 'object';
|
|
5731
|
-
var isBridge = !isTMultiLocation(destination) && isDotKsmBridge(origin, destination);
|
|
5732
|
-
var isRelayDestination = !isTMultiLocation(destination) && isRelayChain(destination);
|
|
5733
|
-
if (!isRelayDestination && !isMultiLocationDestination) {
|
|
5734
|
-
var originRelayChainSymbol = getRelayChainSymbol(origin);
|
|
5735
|
-
var destinationRelayChainSymbol = getRelayChainSymbol(destination);
|
|
5736
|
-
if (!isBridge && originRelayChainSymbol !== destinationRelayChainSymbol) {
|
|
5737
|
-
throw new IncompatibleNodesError();
|
|
5738
|
-
}
|
|
5739
|
-
}
|
|
5740
|
-
};
|
|
5741
|
-
var validateAssetSpecifiers = function validateAssetSpecifiers(assetCheckEnabled, currency) {
|
|
5742
|
-
if (!assetCheckEnabled && 'symbol' in currency && isSymbolSpecifier(currency.symbol)) {
|
|
5743
|
-
throw new InvalidCurrencyError('Symbol specifier is not supported when asset check is disabled. Please use normal symbol instead.');
|
|
5744
|
-
}
|
|
5745
|
-
if (!assetCheckEnabled && 'id' in currency) {
|
|
5746
|
-
throw new InvalidCurrencyError('Asset ID is not supported when asset check is disabled. Please use normal symbol instead');
|
|
5747
|
-
}
|
|
5748
|
-
};
|
|
5749
|
-
|
|
5750
5718
|
var send = /*#__PURE__*/function () {
|
|
5751
5719
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
5752
5720
|
var api, origin, currency, feeAsset, address, destination, paraIdTo, version, senderAddress, ahAddress, pallet, method, isBridge, assetCheckEnabled, asset, resolvedFeeAsset, originVersion, destVersion, resolvedVersion, isLocalTransfer, overriddenAsset, resolvedAsset, finalAsset, finalVersion, normalizedAsset;
|
|
@@ -6192,7 +6160,7 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
6192
6160
|
throw new DryRunFailedError(dryRunResult.origin.failureReason);
|
|
6193
6161
|
case 5:
|
|
6194
6162
|
// Pad fee by 50%
|
|
6195
|
-
dryRunFeePadded = BigInt(dryRunResult.origin.fee) *
|
|
6163
|
+
dryRunFeePadded = BigInt(dryRunResult.origin.fee) * 3n / 2n;
|
|
6196
6164
|
dest = createDestination(scenario, version, destination, paraIdTo);
|
|
6197
6165
|
call = {
|
|
6198
6166
|
module: 'PolkadotXcm',
|
|
@@ -10099,11 +10067,11 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
10099
10067
|
key: "getOriginXcmFeeEstimate",
|
|
10100
10068
|
value: (function () {
|
|
10101
10069
|
var _getOriginXcmFeeEstimate2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
|
|
10102
|
-
var _this$_options6, from, to, senderAddress, tx;
|
|
10070
|
+
var _this$_options6, from, to, senderAddress, currency, tx;
|
|
10103
10071
|
return _regenerator().w(function (_context7) {
|
|
10104
10072
|
while (1) switch (_context7.n) {
|
|
10105
10073
|
case 0:
|
|
10106
|
-
_this$_options6 = this._options, from = _this$_options6.from, to = _this$_options6.to, senderAddress = _this$_options6.senderAddress;
|
|
10074
|
+
_this$_options6 = this._options, from = _this$_options6.from, to = _this$_options6.to, senderAddress = _this$_options6.senderAddress, currency = _this$_options6.currency;
|
|
10107
10075
|
assertToIsString(to);
|
|
10108
10076
|
_context7.n = 1;
|
|
10109
10077
|
return this.build();
|
|
@@ -10116,6 +10084,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
10116
10084
|
tx: tx,
|
|
10117
10085
|
origin: from,
|
|
10118
10086
|
destination: to,
|
|
10087
|
+
currency: currency,
|
|
10119
10088
|
senderAddress: senderAddress
|
|
10120
10089
|
});
|
|
10121
10090
|
case 3:
|
|
@@ -10287,4 +10256,4 @@ var Builder = function Builder(api) {
|
|
|
10287
10256
|
return new GeneralBuilder(api, new BatchTransactionManager());
|
|
10288
10257
|
};
|
|
10289
10258
|
|
|
10290
|
-
export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createBeneficiary, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, deriveAccountId, determineRelayChain, dryRun, dryRunOrigin, encodeSs58, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFees, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate,
|
|
10259
|
+
export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createBeneficiary, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, deriveAccountId, determineRelayChain, dryRun, dryRunOrigin, encodeSs58, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFees, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
|