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