@paraspell/sdk-core 11.14.0 → 11.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +424 -338
- package/dist/index.d.ts +23 -10
- package/dist/index.mjs +423 -340
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { base58 } from '@scure/base';
|
|
|
5
5
|
import { isAddress, parseUnits as parseUnits$1, formatUnits as formatUnits$1, createPublicClient, http, getContract, pad, toHex, getAddress, concat, keccak256 } from 'viem';
|
|
6
6
|
import { getSupportedPalletsDetails, getDefaultPallet, getSupportedPallets, getNativeAssetsPallet, getOtherAssetsPallets } from '@paraspell/pallets';
|
|
7
7
|
export * from '@paraspell/pallets';
|
|
8
|
-
import { replaceBigInt, isTLocation, Version, hasJunction, getJunctionValue, isRelayChain, Parents, isExternalChain,
|
|
8
|
+
import { replaceBigInt, isTLocation, Version, hasJunction, getJunctionValue, isRelayChain, deepEqual, Parents, isExternalChain, PARACHAINS, isSubstrateBridge, isTrustedChain, isSystemChain } from '@paraspell/sdk-common';
|
|
9
9
|
export * from '@paraspell/sdk-common';
|
|
10
10
|
import { moonbeam, moonriver, mainnet } from 'viem/chains';
|
|
11
11
|
|
|
@@ -772,11 +772,11 @@ var createVersionedAssets = function createVersionedAssets(version, amount, loca
|
|
|
772
772
|
return addXcmVersionHeader([asset], version);
|
|
773
773
|
};
|
|
774
774
|
|
|
775
|
-
var getCurrencySelection = function getCurrencySelection(asset) {
|
|
775
|
+
var getCurrencySelection = function getCurrencySelection(chain, asset) {
|
|
776
776
|
if (asset.location) return {
|
|
777
777
|
location: asset.location
|
|
778
778
|
};
|
|
779
|
-
if (isForeignAsset(asset) && asset.assetId) {
|
|
779
|
+
if (isForeignAsset(asset) && asset.assetId && !chain.startsWith('Bifrost')) {
|
|
780
780
|
return {
|
|
781
781
|
id: asset.assetId
|
|
782
782
|
};
|
|
@@ -790,7 +790,7 @@ var maybeOverrideAssets = function maybeOverrideAssets(version, amount, assets,
|
|
|
790
790
|
if (!overriddenCurrency) {
|
|
791
791
|
return assets;
|
|
792
792
|
}
|
|
793
|
-
return isTLocation(overriddenCurrency) ?
|
|
793
|
+
return isTLocation(overriddenCurrency) ? createAsset(version, amount, overriddenCurrency) : overriddenCurrency;
|
|
794
794
|
};
|
|
795
795
|
var maybeOverrideAsset = function maybeOverrideAsset(version, amount, asset, overriddenCurrency) {
|
|
796
796
|
if (!overriddenCurrency) {
|
|
@@ -918,6 +918,33 @@ var createTx = /*#__PURE__*/function () {
|
|
|
918
918
|
};
|
|
919
919
|
}();
|
|
920
920
|
|
|
921
|
+
var getAssetReserveChain = function getAssetReserveChain(chain, assetLocation) {
|
|
922
|
+
var hasGlobalConsensusJunction = hasJunction(assetLocation, 'GlobalConsensus');
|
|
923
|
+
var paraId = getJunctionValue(assetLocation, 'Parachain');
|
|
924
|
+
if (paraId) {
|
|
925
|
+
var resolvedChain = getTChain(paraId, getRelayChainOf(chain));
|
|
926
|
+
if (!resolvedChain) {
|
|
927
|
+
throw new InvalidParameterError("Chain with paraId ".concat(paraId, " not found"));
|
|
928
|
+
}
|
|
929
|
+
return resolvedChain;
|
|
930
|
+
}
|
|
931
|
+
if (isRelayChain(chain)) return chain;
|
|
932
|
+
var relaychain = getRelayChainOf(chain);
|
|
933
|
+
var ahChain = "AssetHub".concat(relaychain);
|
|
934
|
+
if (hasGlobalConsensusJunction) {
|
|
935
|
+
return ahChain;
|
|
936
|
+
}
|
|
937
|
+
if (deepEqual(assetLocation, {
|
|
938
|
+
parents: Parents.ONE,
|
|
939
|
+
interior: {
|
|
940
|
+
Here: null
|
|
941
|
+
}
|
|
942
|
+
})) {
|
|
943
|
+
return ahChain;
|
|
944
|
+
}
|
|
945
|
+
return chain;
|
|
946
|
+
};
|
|
947
|
+
|
|
921
948
|
/**
|
|
922
949
|
* Retrieves the chain instance for a given chain.
|
|
923
950
|
*
|
|
@@ -3230,27 +3257,22 @@ var constructRelayToParaParameters = function constructRelayToParaParameters(_re
|
|
|
3230
3257
|
asset = _ref.assetInfo,
|
|
3231
3258
|
address = _ref.address,
|
|
3232
3259
|
paraIdTo = _ref.paraIdTo;
|
|
3233
|
-
var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
3234
|
-
includeFee: false
|
|
3235
|
-
},
|
|
3236
|
-
includeFee = _ref2.includeFee;
|
|
3237
3260
|
var paraId = resolveParaId(paraIdTo, destination);
|
|
3238
3261
|
var beneficiaryLocation = createBeneficiaryLocation({
|
|
3239
3262
|
api: api,
|
|
3240
3263
|
address: address,
|
|
3241
3264
|
version: version
|
|
3242
3265
|
});
|
|
3243
|
-
return
|
|
3266
|
+
return {
|
|
3244
3267
|
dest: createVersionedDestination(version, origin, destination, paraId),
|
|
3245
3268
|
beneficiary: addXcmVersionHeader(beneficiaryLocation, version),
|
|
3246
3269
|
assets: createVersionedAssets(version, asset.amount, {
|
|
3247
3270
|
parents: Parents.ZERO,
|
|
3248
3271
|
interior: 'Here'
|
|
3249
3272
|
}),
|
|
3250
|
-
fee_asset_item: DEFAULT_FEE_ASSET
|
|
3251
|
-
}, includeFee && {
|
|
3273
|
+
fee_asset_item: DEFAULT_FEE_ASSET,
|
|
3252
3274
|
weight_limit: 'Unlimited'
|
|
3253
|
-
}
|
|
3275
|
+
};
|
|
3254
3276
|
};
|
|
3255
3277
|
|
|
3256
3278
|
var createDestination = function createDestination(version, origin, destination, chainId, junction, parents) {
|
|
@@ -3307,33 +3329,6 @@ var throwUnsupportedCurrency = function throwUnsupportedCurrency(currency, chain
|
|
|
3307
3329
|
throw new InvalidCurrencyError("".concat(isDestination ? 'Destination' : 'Origin', " chain ").concat(chain, " does not support currency ").concat(JSON.stringify(currency, replaceBigInt), "."));
|
|
3308
3330
|
};
|
|
3309
3331
|
|
|
3310
|
-
var getAssetReserveChain = function getAssetReserveChain(chain, assetLocation) {
|
|
3311
|
-
var hasGlobalConsensusJunction = hasJunction(assetLocation, 'GlobalConsensus');
|
|
3312
|
-
var paraId = getJunctionValue(assetLocation, 'Parachain');
|
|
3313
|
-
if (paraId) {
|
|
3314
|
-
var resolvedChain = getTChain(paraId, getRelayChainOf(chain));
|
|
3315
|
-
if (!resolvedChain) {
|
|
3316
|
-
throw new InvalidParameterError("Chain with paraId ".concat(paraId, " not found"));
|
|
3317
|
-
}
|
|
3318
|
-
return resolvedChain;
|
|
3319
|
-
}
|
|
3320
|
-
if (isRelayChain(chain)) return chain;
|
|
3321
|
-
var relaychain = getRelayChainOf(chain);
|
|
3322
|
-
var ahChain = "AssetHub".concat(relaychain);
|
|
3323
|
-
if (hasGlobalConsensusJunction) {
|
|
3324
|
-
return ahChain;
|
|
3325
|
-
}
|
|
3326
|
-
if (deepEqual(assetLocation, {
|
|
3327
|
-
parents: Parents.ONE,
|
|
3328
|
-
interior: {
|
|
3329
|
-
Here: null
|
|
3330
|
-
}
|
|
3331
|
-
})) {
|
|
3332
|
-
return ahChain;
|
|
3333
|
-
}
|
|
3334
|
-
return chain;
|
|
3335
|
-
};
|
|
3336
|
-
|
|
3337
3332
|
var prepareExecuteContext = function prepareExecuteContext(_ref) {
|
|
3338
3333
|
var chain = _ref.chain,
|
|
3339
3334
|
destChain = _ref.destChain,
|
|
@@ -3650,21 +3645,26 @@ var getReserveFeeFromHops = function getReserveFeeFromHops(hops) {
|
|
|
3650
3645
|
}
|
|
3651
3646
|
return hops[0].result.fee;
|
|
3652
3647
|
};
|
|
3653
|
-
var FEE_PADDING_PERCENTAGE$
|
|
3648
|
+
var FEE_PADDING_PERCENTAGE$1 = 40;
|
|
3654
3649
|
var handleExecuteTransfer = /*#__PURE__*/function () {
|
|
3655
3650
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options) {
|
|
3656
|
-
var api, senderAddress, paraIdTo, assetInfo, currency, feeCurrency, address, feeAssetInfo, version, checkAmount,
|
|
3651
|
+
var api, senderAddress, paraIdTo, destChain, assetInfo, currency, feeCurrency, address, feeAssetInfo, version, checkAmount, internalOptions, FEE_ASSET_AMOUNT, feeAssetAmount, call, dryRunResult, originFeeEstimate, originFee, reserveFeeEstimate, reserveFee, xcm, weight;
|
|
3657
3652
|
return _regenerator().w(function (_context) {
|
|
3658
3653
|
while (1) switch (_context.n) {
|
|
3659
3654
|
case 0:
|
|
3660
|
-
api = options.api, senderAddress = options.senderAddress, paraIdTo = options.paraIdTo, assetInfo = options.assetInfo, currency = options.currency, feeCurrency = options.feeCurrency, address = options.address, feeAssetInfo = options.feeAssetInfo, version = options.version;
|
|
3655
|
+
api = options.api, senderAddress = options.senderAddress, paraIdTo = options.paraIdTo, destChain = options.destChain, assetInfo = options.assetInfo, currency = options.currency, feeCurrency = options.feeCurrency, address = options.address, feeAssetInfo = options.feeAssetInfo, version = options.version;
|
|
3661
3656
|
assertSenderAddress(senderAddress);
|
|
3662
3657
|
assertAddressIsString(address);
|
|
3663
3658
|
checkAmount = function checkAmount(fee) {
|
|
3664
3659
|
if (assetInfo.amount <= fee) throw new AmountTooLowError();
|
|
3665
3660
|
};
|
|
3666
3661
|
checkAmount(MIN_FEE);
|
|
3667
|
-
destChain
|
|
3662
|
+
if (!(destChain === undefined)) {
|
|
3663
|
+
_context.n = 1;
|
|
3664
|
+
break;
|
|
3665
|
+
}
|
|
3666
|
+
throw new InvalidParameterError('Could not determine destination chain for execute transfer');
|
|
3667
|
+
case 1:
|
|
3668
3668
|
internalOptions = {
|
|
3669
3669
|
api: api,
|
|
3670
3670
|
chain: chain,
|
|
@@ -3687,7 +3687,7 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
|
|
|
3687
3687
|
reserveFee: MIN_FEE
|
|
3688
3688
|
}
|
|
3689
3689
|
})), MAX_WEIGHT);
|
|
3690
|
-
_context.n =
|
|
3690
|
+
_context.n = 2;
|
|
3691
3691
|
return dryRunInternal({
|
|
3692
3692
|
api: api,
|
|
3693
3693
|
tx: api.callTxMethod(call),
|
|
@@ -3699,18 +3699,18 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
|
|
|
3699
3699
|
feeAsset: feeCurrency,
|
|
3700
3700
|
useRootOrigin: true
|
|
3701
3701
|
});
|
|
3702
|
-
case
|
|
3702
|
+
case 2:
|
|
3703
3703
|
dryRunResult = _context.v;
|
|
3704
3704
|
if (dryRunResult.origin.success) {
|
|
3705
|
-
_context.n =
|
|
3705
|
+
_context.n = 3;
|
|
3706
3706
|
break;
|
|
3707
3707
|
}
|
|
3708
3708
|
throw new DryRunFailedError(dryRunResult.failureReason);
|
|
3709
|
-
case
|
|
3709
|
+
case 3:
|
|
3710
3710
|
originFeeEstimate = dryRunResult.origin.fee;
|
|
3711
|
-
originFee = padValueBy(originFeeEstimate, FEE_PADDING_PERCENTAGE$
|
|
3711
|
+
originFee = padValueBy(originFeeEstimate, FEE_PADDING_PERCENTAGE$1);
|
|
3712
3712
|
reserveFeeEstimate = getReserveFeeFromHops(dryRunResult.hops);
|
|
3713
|
-
reserveFee = padValueBy(reserveFeeEstimate, FEE_PADDING_PERCENTAGE$
|
|
3713
|
+
reserveFee = padValueBy(reserveFeeEstimate, FEE_PADDING_PERCENTAGE$1);
|
|
3714
3714
|
checkAmount(feeAssetInfo && !isAssetEqual(assetInfo, feeAssetInfo) ? reserveFee : originFee + reserveFee);
|
|
3715
3715
|
xcm = createDirectExecuteXcm(_objectSpread2(_objectSpread2({}, internalOptions), {}, {
|
|
3716
3716
|
fees: {
|
|
@@ -3718,9 +3718,9 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
|
|
|
3718
3718
|
reserveFee: reserveFee
|
|
3719
3719
|
}
|
|
3720
3720
|
}));
|
|
3721
|
-
_context.n =
|
|
3721
|
+
_context.n = 4;
|
|
3722
3722
|
return api.getXcmWeight(xcm);
|
|
3723
|
-
case
|
|
3723
|
+
case 4:
|
|
3724
3724
|
weight = _context.v;
|
|
3725
3725
|
return _context.a(2, createExecuteCall(chain, xcm, weight));
|
|
3726
3726
|
}
|
|
@@ -3786,21 +3786,27 @@ var determineAddress = function determineAddress(chain, address, senderAddress)
|
|
|
3786
3786
|
};
|
|
3787
3787
|
var getReverseTxFee = /*#__PURE__*/function () {
|
|
3788
3788
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, currencyInput) {
|
|
3789
|
-
var api, origin, destination, senderAddress, address, toAddress, fromAddress, _yield$Builder$from$t, tx, rawFee;
|
|
3789
|
+
var api, origin, destination, senderAddress, address, skipReverseFeeCalculation, toAddress, fromAddress, _yield$Builder$from$t, tx, rawFee;
|
|
3790
3790
|
return _regenerator().w(function (_context) {
|
|
3791
3791
|
while (1) switch (_context.n) {
|
|
3792
3792
|
case 0:
|
|
3793
|
-
api = _ref.api, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, address = _ref.address;
|
|
3793
|
+
api = _ref.api, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, address = _ref.address, skipReverseFeeCalculation = _ref.skipReverseFeeCalculation;
|
|
3794
|
+
if (!skipReverseFeeCalculation) {
|
|
3795
|
+
_context.n = 1;
|
|
3796
|
+
break;
|
|
3797
|
+
}
|
|
3798
|
+
return _context.a(2, 0n);
|
|
3799
|
+
case 1:
|
|
3794
3800
|
toAddress = determineAddress(origin, address, senderAddress);
|
|
3795
3801
|
fromAddress = determineAddress(destination, address, senderAddress);
|
|
3796
|
-
_context.n =
|
|
3802
|
+
_context.n = 2;
|
|
3797
3803
|
return Builder(api).from(destination).to(origin).address(toAddress).senderAddress(fromAddress).currency(currencyInput)['buildInternal']();
|
|
3798
|
-
case
|
|
3804
|
+
case 2:
|
|
3799
3805
|
_yield$Builder$from$t = _context.v;
|
|
3800
3806
|
tx = _yield$Builder$from$t.tx;
|
|
3801
|
-
_context.n =
|
|
3807
|
+
_context.n = 3;
|
|
3802
3808
|
return api.calculateTransactionFee(tx, fromAddress);
|
|
3803
|
-
case
|
|
3809
|
+
case 3:
|
|
3804
3810
|
rawFee = _context.v;
|
|
3805
3811
|
return _context.a(2, padFee(rawFee, origin, destination, 'destination'));
|
|
3806
3812
|
}
|
|
@@ -3912,7 +3918,7 @@ var getBalanceForeignXTokens = /*#__PURE__*/function () {
|
|
|
3912
3918
|
return _regenerator().w(function (_context) {
|
|
3913
3919
|
while (1) switch (_context.n) {
|
|
3914
3920
|
case 0:
|
|
3915
|
-
if (!(chain === 'Astar' || chain === 'Shiden' || chain.startsWith('Integritee'))) {
|
|
3921
|
+
if (!(chain === 'Astar' || chain === 'Shiden' || chain === 'CrustShadow' || chain.startsWith('Integritee'))) {
|
|
3916
3922
|
_context.n = 1;
|
|
3917
3923
|
break;
|
|
3918
3924
|
}
|
|
@@ -5796,7 +5802,7 @@ var createSwapExecuteXcm = /*#__PURE__*/function () {
|
|
|
5796
5802
|
};
|
|
5797
5803
|
}();
|
|
5798
5804
|
|
|
5799
|
-
var FEE_PADDING_PERCENTAGE
|
|
5805
|
+
var FEE_PADDING_PERCENTAGE = 20;
|
|
5800
5806
|
var validateAmount = function validateAmount(amount, requiredFee) {
|
|
5801
5807
|
if (amount <= requiredFee) {
|
|
5802
5808
|
throw new AmountTooLowError("Asset amount is too low, please increase the amount or use a different fee asset.");
|
|
@@ -5862,7 +5868,7 @@ var extractFeesFromDryRun = function extractFeesFromDryRun(chain, dryRunResult,
|
|
|
5862
5868
|
throw new DryRunFailedError("Exchange (destination) failed: ".concat(dryRunResult.destination.failureReason || 'Unknown reason'));
|
|
5863
5869
|
}
|
|
5864
5870
|
if (dryRunResult.destination && dryRunResult.destination.success) {
|
|
5865
|
-
fees.exchangeFee = padValueBy(dryRunResult.destination.fee, FEE_PADDING_PERCENTAGE
|
|
5871
|
+
fees.exchangeFee = padValueBy(dryRunResult.destination.fee, FEE_PADDING_PERCENTAGE);
|
|
5866
5872
|
}
|
|
5867
5873
|
} else {
|
|
5868
5874
|
// Normal case: exchange is an intermediate hop
|
|
@@ -5871,7 +5877,7 @@ var extractFeesFromDryRun = function extractFeesFromDryRun(chain, dryRunResult,
|
|
|
5871
5877
|
throw new DryRunFailedError("Exchange hop failed: ".concat(exchangeHop.result.failureReason || 'Unknown reason'));
|
|
5872
5878
|
}
|
|
5873
5879
|
if (exchangeHop.result.success) {
|
|
5874
|
-
fees.exchangeFee = padValueBy(exchangeHop.result.fee, FEE_PADDING_PERCENTAGE
|
|
5880
|
+
fees.exchangeFee = padValueBy(exchangeHop.result.fee, FEE_PADDING_PERCENTAGE);
|
|
5875
5881
|
}
|
|
5876
5882
|
}
|
|
5877
5883
|
} else {
|
|
@@ -5888,7 +5894,7 @@ var extractFeesFromDryRun = function extractFeesFromDryRun(chain, dryRunResult,
|
|
|
5888
5894
|
throw new DryRunFailedError("Hop before exchange failed: ".concat(hopBeforeExchange.result.failureReason || 'Unknown reason'));
|
|
5889
5895
|
}
|
|
5890
5896
|
if (hopBeforeExchange.result.success) {
|
|
5891
|
-
fees.originReserveFee = padValueBy(hopBeforeExchange.result.fee, FEE_PADDING_PERCENTAGE
|
|
5897
|
+
fees.originReserveFee = padValueBy(hopBeforeExchange.result.fee, FEE_PADDING_PERCENTAGE);
|
|
5892
5898
|
}
|
|
5893
5899
|
} else if (!destChain && hops.length > 0) {
|
|
5894
5900
|
// Special case: when destChain is undefined and we have hops,
|
|
@@ -5898,7 +5904,7 @@ var extractFeesFromDryRun = function extractFeesFromDryRun(chain, dryRunResult,
|
|
|
5898
5904
|
throw new DryRunFailedError("Origin reserve hop failed: ".concat(lastHop.result.failureReason || 'Unknown reason'));
|
|
5899
5905
|
}
|
|
5900
5906
|
if (lastHop.result.success) {
|
|
5901
|
-
fees.originReserveFee = padValueBy(lastHop.result.fee, FEE_PADDING_PERCENTAGE
|
|
5907
|
+
fees.originReserveFee = padValueBy(lastHop.result.fee, FEE_PADDING_PERCENTAGE);
|
|
5902
5908
|
}
|
|
5903
5909
|
}
|
|
5904
5910
|
// Handle destination reserve fee (hop after exchange)
|
|
@@ -5909,7 +5915,7 @@ var extractFeesFromDryRun = function extractFeesFromDryRun(chain, dryRunResult,
|
|
|
5909
5915
|
throw new DryRunFailedError("Hop after exchange failed: ".concat(hopAfterExchange.result.failureReason || 'Unknown reason'));
|
|
5910
5916
|
}
|
|
5911
5917
|
if (hopAfterExchange.result.success) {
|
|
5912
|
-
fees.destReserveFee = padValueBy(hopAfterExchange.result.fee, FEE_PADDING_PERCENTAGE
|
|
5918
|
+
fees.destReserveFee = padValueBy(hopAfterExchange.result.fee, FEE_PADDING_PERCENTAGE);
|
|
5913
5919
|
}
|
|
5914
5920
|
}
|
|
5915
5921
|
return fees;
|
|
@@ -6095,7 +6101,7 @@ var handleToAhTeleport = /*#__PURE__*/function () {
|
|
|
6095
6101
|
// Enter dummy fee values just to get the dry run to pass
|
|
6096
6102
|
asset.amount, asset.amount / 2n);
|
|
6097
6103
|
_context.n = 4;
|
|
6098
|
-
return
|
|
6104
|
+
return getXcmFeeOnce({
|
|
6099
6105
|
api: api,
|
|
6100
6106
|
tx: dummyTx,
|
|
6101
6107
|
origin: origin,
|
|
@@ -6664,28 +6670,26 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6664
6670
|
key: "getRelayToParaOverrides",
|
|
6665
6671
|
value: function getRelayToParaOverrides() {
|
|
6666
6672
|
return {
|
|
6667
|
-
|
|
6668
|
-
includeFee: true
|
|
6673
|
+
transferType: 'typeAndThen'
|
|
6669
6674
|
};
|
|
6670
6675
|
}
|
|
6671
6676
|
}, {
|
|
6672
6677
|
key: "transferRelayToPara",
|
|
6673
6678
|
value: function () {
|
|
6674
6679
|
var _transferRelayToPara = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
6675
|
-
var api, version, pallet, assetInfo, address, senderAddress, destination, paraIdTo,
|
|
6680
|
+
var api, version, pallet, assetInfo, address, senderAddress, destination, paraIdTo, method, _this$getRelayToParaO, transferType, paraId, destChain, scenario;
|
|
6676
6681
|
return _regenerator().w(function (_context2) {
|
|
6677
6682
|
while (1) switch (_context2.n) {
|
|
6678
6683
|
case 0:
|
|
6679
|
-
api = options.api, version = options.version, pallet = options.pallet, assetInfo = options.assetInfo, address = options.address, senderAddress = options.senderAddress, destination = options.destination, paraIdTo = options.paraIdTo,
|
|
6680
|
-
_this$getRelayToParaO = this.getRelayToParaOverrides(),
|
|
6684
|
+
api = options.api, version = options.version, pallet = options.pallet, assetInfo = options.assetInfo, address = options.address, senderAddress = options.senderAddress, destination = options.destination, paraIdTo = options.paraIdTo, method = options.method;
|
|
6685
|
+
_this$getRelayToParaO = this.getRelayToParaOverrides(), transferType = _this$getRelayToParaO.transferType;
|
|
6681
6686
|
if (!this.isReceivingTempDisabled('RelayToPara')) {
|
|
6682
6687
|
_context2.n = 1;
|
|
6683
6688
|
break;
|
|
6684
6689
|
}
|
|
6685
6690
|
throw new InvalidParameterError("Receiving on ".concat(this.chain, " is temporarily disabled"));
|
|
6686
6691
|
case 1:
|
|
6687
|
-
|
|
6688
|
-
if (!(customMethod === 'transfer_assets_using_type_and_then')) {
|
|
6692
|
+
if (!(transferType === 'typeAndThen')) {
|
|
6689
6693
|
_context2.n = 3;
|
|
6690
6694
|
break;
|
|
6691
6695
|
}
|
|
@@ -6698,7 +6702,7 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6698
6702
|
}
|
|
6699
6703
|
throw new InvalidParameterError('Cannot override destination when using type and then transfer.');
|
|
6700
6704
|
case 2:
|
|
6701
|
-
return _context2.a(2,
|
|
6705
|
+
return _context2.a(2, createTypeThenAutoReserve(getRelayChainOf(destChain), _objectSpread2(_objectSpread2({}, options), {}, {
|
|
6702
6706
|
beneficiaryLocation: createBeneficiaryLocation({
|
|
6703
6707
|
api: api,
|
|
6704
6708
|
address: address,
|
|
@@ -6714,10 +6718,8 @@ var Parachain = /*#__PURE__*/function () {
|
|
|
6714
6718
|
case 3:
|
|
6715
6719
|
return _context2.a(2, {
|
|
6716
6720
|
module: pallet !== null && pallet !== void 0 ? pallet : 'XcmPallet',
|
|
6717
|
-
method:
|
|
6718
|
-
parameters: constructRelayToParaParameters(options, version
|
|
6719
|
-
includeFee: includeFee
|
|
6720
|
-
})
|
|
6721
|
+
method: method !== null && method !== void 0 ? method : 'limited_teleport_assets',
|
|
6722
|
+
parameters: constructRelayToParaParameters(options, version)
|
|
6721
6723
|
});
|
|
6722
6724
|
}
|
|
6723
6725
|
}, _callee2, this);
|
|
@@ -7012,6 +7014,11 @@ var Acala = /*#__PURE__*/function (_Parachain) {
|
|
|
7012
7014
|
var currencySelection = this.getCurrencySelection(asset);
|
|
7013
7015
|
return transferXTokens(input, currencySelection);
|
|
7014
7016
|
}
|
|
7017
|
+
}, {
|
|
7018
|
+
key: "transferRelayToPara",
|
|
7019
|
+
value: function transferRelayToPara() {
|
|
7020
|
+
throw new ChainNotSupportedError();
|
|
7021
|
+
}
|
|
7015
7022
|
}, {
|
|
7016
7023
|
key: "transferLocalNativeAsset",
|
|
7017
7024
|
value: function () {
|
|
@@ -7312,8 +7319,7 @@ var AssetHubKusama = /*#__PURE__*/function (_Parachain) {
|
|
|
7312
7319
|
key: "getRelayToParaOverrides",
|
|
7313
7320
|
value: function getRelayToParaOverrides() {
|
|
7314
7321
|
return {
|
|
7315
|
-
|
|
7316
|
-
includeFee: true
|
|
7322
|
+
transferType: 'teleport'
|
|
7317
7323
|
};
|
|
7318
7324
|
}
|
|
7319
7325
|
}, {
|
|
@@ -7563,23 +7569,17 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
|
|
|
7563
7569
|
_call = _context3.v;
|
|
7564
7570
|
return _context3.a(2, api.callTxMethod(_call));
|
|
7565
7571
|
case 9:
|
|
7566
|
-
if (!(scenario === 'ParaToPara' && assetInfo.symbol === 'KSM' && !isForeignAsset(assetInfo))) {
|
|
7567
|
-
_context3.n = 10;
|
|
7568
|
-
break;
|
|
7569
|
-
}
|
|
7570
|
-
throw new ScenarioNotSupportedError(this.chain, scenario, 'Bridged KSM cannot currently be transfered from AssetHubPolkadot, if you are sending different KSM asset, please specify {id: <KSMID>}.');
|
|
7571
|
-
case 10:
|
|
7572
7572
|
method = this.getMethod(scenario, destination); // Patch transfer_assets to use type_and_then transfer
|
|
7573
7573
|
if (!(method === 'transfer_assets' && isSymbolMatch(assetInfo.symbol, getRelayChainSymbol(this.chain)))) {
|
|
7574
|
-
_context3.n =
|
|
7574
|
+
_context3.n = 11;
|
|
7575
7575
|
break;
|
|
7576
7576
|
}
|
|
7577
7577
|
_t2 = api;
|
|
7578
|
-
_context3.n =
|
|
7578
|
+
_context3.n = 10;
|
|
7579
7579
|
return createTypeAndThenCall(this.chain, options);
|
|
7580
|
-
case
|
|
7580
|
+
case 10:
|
|
7581
7581
|
return _context3.a(2, _t2.callTxMethod.call(_t2, _context3.v));
|
|
7582
|
-
case
|
|
7582
|
+
case 11:
|
|
7583
7583
|
modifiedInput = this.patchInput(options);
|
|
7584
7584
|
return _context3.a(2, transferPolkadotXcm(modifiedInput, method, 'Unlimited'));
|
|
7585
7585
|
}
|
|
@@ -7594,8 +7594,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
|
|
|
7594
7594
|
key: "getRelayToParaOverrides",
|
|
7595
7595
|
value: function getRelayToParaOverrides() {
|
|
7596
7596
|
return {
|
|
7597
|
-
|
|
7598
|
-
includeFee: true
|
|
7597
|
+
transferType: 'teleport'
|
|
7599
7598
|
};
|
|
7600
7599
|
}
|
|
7601
7600
|
}, {
|
|
@@ -7704,6 +7703,11 @@ var Astar = /*#__PURE__*/function (_Parachain) {
|
|
|
7704
7703
|
var assetInfo = _ref.assetInfo;
|
|
7705
7704
|
return assetInfo.symbol !== this.getNativeAssetSymbol();
|
|
7706
7705
|
}
|
|
7706
|
+
}, {
|
|
7707
|
+
key: "transferRelayToPara",
|
|
7708
|
+
value: function transferRelayToPara() {
|
|
7709
|
+
throw new ChainNotSupportedError();
|
|
7710
|
+
}
|
|
7707
7711
|
}, {
|
|
7708
7712
|
key: "transferLocalNonNativeAsset",
|
|
7709
7713
|
value: function transferLocalNonNativeAsset(options) {
|
|
@@ -7905,8 +7909,7 @@ var BridgeHubKusama = /*#__PURE__*/function (_Parachain) {
|
|
|
7905
7909
|
key: "getRelayToParaOverrides",
|
|
7906
7910
|
value: function getRelayToParaOverrides() {
|
|
7907
7911
|
return {
|
|
7908
|
-
|
|
7909
|
-
includeFee: true
|
|
7912
|
+
transferType: 'teleport'
|
|
7910
7913
|
};
|
|
7911
7914
|
}
|
|
7912
7915
|
}]);
|
|
@@ -7936,8 +7939,7 @@ var BridgeHubPolkadot = /*#__PURE__*/function (_Parachain) {
|
|
|
7936
7939
|
key: "getRelayToParaOverrides",
|
|
7937
7940
|
value: function getRelayToParaOverrides() {
|
|
7938
7941
|
return {
|
|
7939
|
-
|
|
7940
|
-
includeFee: true
|
|
7942
|
+
transferType: 'teleport'
|
|
7941
7943
|
};
|
|
7942
7944
|
}
|
|
7943
7945
|
}]);
|
|
@@ -8042,8 +8044,7 @@ var Collectives = /*#__PURE__*/function (_Parachain) {
|
|
|
8042
8044
|
key: "getRelayToParaOverrides",
|
|
8043
8045
|
value: function getRelayToParaOverrides() {
|
|
8044
8046
|
return {
|
|
8045
|
-
|
|
8046
|
-
includeFee: true
|
|
8047
|
+
transferType: 'teleport'
|
|
8047
8048
|
};
|
|
8048
8049
|
}
|
|
8049
8050
|
}]);
|
|
@@ -8077,8 +8078,7 @@ var CoretimeKusama = /*#__PURE__*/function (_Parachain) {
|
|
|
8077
8078
|
key: "getRelayToParaOverrides",
|
|
8078
8079
|
value: function getRelayToParaOverrides() {
|
|
8079
8080
|
return {
|
|
8080
|
-
|
|
8081
|
-
includeFee: true
|
|
8081
|
+
transferType: 'teleport'
|
|
8082
8082
|
};
|
|
8083
8083
|
}
|
|
8084
8084
|
}]);
|
|
@@ -8112,8 +8112,7 @@ var CoretimePolkadot = /*#__PURE__*/function (_Parachain) {
|
|
|
8112
8112
|
key: "getRelayToParaOverrides",
|
|
8113
8113
|
value: function getRelayToParaOverrides() {
|
|
8114
8114
|
return {
|
|
8115
|
-
|
|
8116
|
-
includeFee: true
|
|
8115
|
+
transferType: 'teleport'
|
|
8117
8116
|
};
|
|
8118
8117
|
}
|
|
8119
8118
|
}]);
|
|
@@ -8358,8 +8357,7 @@ var Encointer = /*#__PURE__*/function (_Parachain) {
|
|
|
8358
8357
|
key: "getRelayToParaOverrides",
|
|
8359
8358
|
value: function getRelayToParaOverrides() {
|
|
8360
8359
|
return {
|
|
8361
|
-
|
|
8362
|
-
includeFee: true
|
|
8360
|
+
transferType: 'teleport'
|
|
8363
8361
|
};
|
|
8364
8362
|
}
|
|
8365
8363
|
}]);
|
|
@@ -9363,8 +9361,7 @@ var PeoplePolkadot = /*#__PURE__*/function (_Parachain) {
|
|
|
9363
9361
|
key: "getRelayToParaOverrides",
|
|
9364
9362
|
value: function getRelayToParaOverrides() {
|
|
9365
9363
|
return {
|
|
9366
|
-
|
|
9367
|
-
includeFee: true
|
|
9364
|
+
transferType: 'teleport'
|
|
9368
9365
|
};
|
|
9369
9366
|
}
|
|
9370
9367
|
}]);
|
|
@@ -9519,8 +9516,7 @@ var PeopleKusama = /*#__PURE__*/function (_Parachain) {
|
|
|
9519
9516
|
key: "getRelayToParaOverrides",
|
|
9520
9517
|
value: function getRelayToParaOverrides() {
|
|
9521
9518
|
return {
|
|
9522
|
-
|
|
9523
|
-
includeFee: true
|
|
9519
|
+
transferType: 'teleport'
|
|
9524
9520
|
};
|
|
9525
9521
|
}
|
|
9526
9522
|
}]);
|
|
@@ -9761,6 +9757,11 @@ var Shiden = /*#__PURE__*/function (_Parachain) {
|
|
|
9761
9757
|
var assetInfo = _ref.assetInfo;
|
|
9762
9758
|
return assetInfo.symbol !== this.getNativeAssetSymbol();
|
|
9763
9759
|
}
|
|
9760
|
+
}, {
|
|
9761
|
+
key: "transferRelayToPara",
|
|
9762
|
+
value: function transferRelayToPara() {
|
|
9763
|
+
throw new ChainNotSupportedError();
|
|
9764
|
+
}
|
|
9764
9765
|
}, {
|
|
9765
9766
|
key: "transferLocalNonNativeAsset",
|
|
9766
9767
|
value: function transferLocalNonNativeAsset(options) {
|
|
@@ -10577,7 +10578,7 @@ var wrapTxBypass = /*#__PURE__*/function () {
|
|
|
10577
10578
|
api: api,
|
|
10578
10579
|
chain: chain,
|
|
10579
10580
|
address: address,
|
|
10580
|
-
currency: getCurrencySelection(asset)
|
|
10581
|
+
currency: getCurrencySelection(chain, asset)
|
|
10581
10582
|
});
|
|
10582
10583
|
case 9:
|
|
10583
10584
|
balance = _context.v;
|
|
@@ -11061,13 +11062,13 @@ var getFailureInfo = function getFailureInfo(chains, hops) {
|
|
|
11061
11062
|
}
|
|
11062
11063
|
return {};
|
|
11063
11064
|
};
|
|
11064
|
-
var
|
|
11065
|
+
var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
11065
11066
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
|
|
11066
|
-
var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, swapConfig, useRootOrigin, asset, amount, _yield$getOriginXcmFe, originFeeRaw,
|
|
11067
|
+
var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, swapConfig, useRootOrigin, skipReverseFeeCalculation, asset, amount, _yield$getOriginXcmFe, originFeeRaw, originAsset, originFeeType, originDryRunError, originDryRunSubError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, isMythosToEthereum, originFee, destApi, destFeeRes, _result, _getFailureInfo, _failureChain, _failureReason, processHop, traversalResult, destFee, destCurrency, destAsset, destFeeType, destDryRunError, destDryRunSubError, destSufficient, destResult, _destApi, destFallback, assetHubChain, processedBridgeHub, bridgeHubChain, bridgeHubHopIndex, convertToFeeDetail, result, _getFailureInfo2, failureChain, failureReason, _t, _t2, _t3, _t4;
|
|
11067
11068
|
return _regenerator().w(function (_context2) {
|
|
11068
11069
|
while (1) switch (_context2.p = _context2.n) {
|
|
11069
11070
|
case 0:
|
|
11070
|
-
api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, address = _ref.address, currency = _ref.currency, feeAsset = _ref.feeAsset, disableFallback = _ref.disableFallback, swapConfig = _ref.swapConfig, useRootOrigin = _ref.useRootOrigin;
|
|
11071
|
+
api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, address = _ref.address, currency = _ref.currency, feeAsset = _ref.feeAsset, disableFallback = _ref.disableFallback, swapConfig = _ref.swapConfig, useRootOrigin = _ref.useRootOrigin, skipReverseFeeCalculation = _ref.skipReverseFeeCalculation;
|
|
11071
11072
|
asset = findAssetInfoOrThrow(origin, currency, destination);
|
|
11072
11073
|
amount = abstractDecimals(currency.amount, asset.decimals, api);
|
|
11073
11074
|
_context2.n = 1;
|
|
@@ -11085,7 +11086,6 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
11085
11086
|
case 1:
|
|
11086
11087
|
_yield$getOriginXcmFe = _context2.v;
|
|
11087
11088
|
originFeeRaw = _yield$getOriginXcmFe.fee;
|
|
11088
|
-
originCurrency = _yield$getOriginXcmFe.currency;
|
|
11089
11089
|
originAsset = _yield$getOriginXcmFe.asset;
|
|
11090
11090
|
originFeeType = _yield$getOriginXcmFe.feeType;
|
|
11091
11091
|
originDryRunError = _yield$getOriginXcmFe.dryRunError;
|
|
@@ -11138,7 +11138,8 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
11138
11138
|
originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
|
|
11139
11139
|
senderAddress: senderAddress,
|
|
11140
11140
|
disableFallback: disableFallback,
|
|
11141
|
-
swapConfig: swapConfig
|
|
11141
|
+
swapConfig: swapConfig,
|
|
11142
|
+
skipReverseFeeCalculation: skipReverseFeeCalculation
|
|
11142
11143
|
});
|
|
11143
11144
|
case 7:
|
|
11144
11145
|
destFeeRes = _context2.v;
|
|
@@ -11149,7 +11150,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
11149
11150
|
feeType: originFeeType
|
|
11150
11151
|
}), {}, {
|
|
11151
11152
|
sufficient: sufficientOriginFee,
|
|
11152
|
-
currency:
|
|
11153
|
+
currency: originAsset.symbol,
|
|
11153
11154
|
asset: originAsset
|
|
11154
11155
|
}, originDryRunError && {
|
|
11155
11156
|
dryRunError: originDryRunError
|
|
@@ -11222,7 +11223,8 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
11222
11223
|
originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
|
|
11223
11224
|
disableFallback: disableFallback,
|
|
11224
11225
|
hasPassedExchange: hasPassedExchange,
|
|
11225
|
-
swapConfig: swapConfig
|
|
11226
|
+
swapConfig: swapConfig,
|
|
11227
|
+
skipReverseFeeCalculation: skipReverseFeeCalculation
|
|
11226
11228
|
});
|
|
11227
11229
|
case 1:
|
|
11228
11230
|
hopResult = _context.v;
|
|
@@ -11300,7 +11302,8 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
11300
11302
|
originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
|
|
11301
11303
|
senderAddress: senderAddress,
|
|
11302
11304
|
disableFallback: disableFallback,
|
|
11303
|
-
swapConfig: swapConfig
|
|
11305
|
+
swapConfig: swapConfig,
|
|
11306
|
+
skipReverseFeeCalculation: skipReverseFeeCalculation
|
|
11304
11307
|
});
|
|
11305
11308
|
case 14:
|
|
11306
11309
|
destFallback = _context2.v;
|
|
@@ -11372,7 +11375,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
11372
11375
|
}), sufficientOriginFee !== undefined && {
|
|
11373
11376
|
sufficient: sufficientOriginFee
|
|
11374
11377
|
}), {}, {
|
|
11375
|
-
currency:
|
|
11378
|
+
currency: originAsset.symbol,
|
|
11376
11379
|
asset: originAsset
|
|
11377
11380
|
}, originDryRunError && {
|
|
11378
11381
|
dryRunError: originDryRunError
|
|
@@ -11417,32 +11420,32 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
11417
11420
|
}
|
|
11418
11421
|
}, _callee2, null, [[5,, 8, 10]]);
|
|
11419
11422
|
}));
|
|
11420
|
-
return function
|
|
11423
|
+
return function getXcmFeeOnce(_x) {
|
|
11421
11424
|
return _ref2.apply(this, arguments);
|
|
11422
11425
|
};
|
|
11423
11426
|
}();
|
|
11424
11427
|
|
|
11425
|
-
var
|
|
11428
|
+
var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
11426
11429
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
11427
|
-
var buildTx,
|
|
11430
|
+
var buildTx, _real$assetHub, _real$bridgeHub, tx, real, forced, _forced, _t;
|
|
11428
11431
|
return _regenerator().w(function (_context) {
|
|
11429
11432
|
while (1) switch (_context.p = _context.n) {
|
|
11430
11433
|
case 0:
|
|
11431
|
-
buildTx = options.buildTx
|
|
11434
|
+
buildTx = options.buildTx;
|
|
11432
11435
|
_context.p = 1;
|
|
11433
11436
|
_context.n = 2;
|
|
11434
11437
|
return buildTx();
|
|
11435
11438
|
case 2:
|
|
11436
11439
|
tx = _context.v;
|
|
11437
11440
|
_context.n = 3;
|
|
11438
|
-
return
|
|
11441
|
+
return getXcmFeeOnce(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
11439
11442
|
tx: tx,
|
|
11440
11443
|
useRootOrigin: false
|
|
11441
11444
|
}));
|
|
11442
11445
|
case 3:
|
|
11443
11446
|
real = _context.v;
|
|
11444
11447
|
_context.n = 4;
|
|
11445
|
-
return getBypassResultWithRetries(options,
|
|
11448
|
+
return getBypassResultWithRetries(options, getXcmFeeOnce, tx);
|
|
11446
11449
|
case 4:
|
|
11447
11450
|
forced = _context.v;
|
|
11448
11451
|
return _context.a(2, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, forced), {}, {
|
|
@@ -11480,7 +11483,7 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
11480
11483
|
throw _t;
|
|
11481
11484
|
case 6:
|
|
11482
11485
|
_context.n = 7;
|
|
11483
|
-
return getBypassResultWithRetries(options,
|
|
11486
|
+
return getBypassResultWithRetries(options, getXcmFeeOnce);
|
|
11484
11487
|
case 7:
|
|
11485
11488
|
_forced = _context.v;
|
|
11486
11489
|
return _context.a(2, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, _forced), {}, {
|
|
@@ -11507,21 +11510,40 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
11507
11510
|
});
|
|
11508
11511
|
})
|
|
11509
11512
|
}));
|
|
11510
|
-
case 8:
|
|
11511
|
-
_context.p = 8;
|
|
11512
|
-
_context.n = 9;
|
|
11513
|
-
return api.disconnect();
|
|
11514
|
-
case 9:
|
|
11515
|
-
return _context.f(8);
|
|
11516
|
-
case 10:
|
|
11517
|
-
return _context.a(2);
|
|
11518
11513
|
}
|
|
11519
|
-
}, _callee, null, [[1, 5
|
|
11514
|
+
}, _callee, null, [[1, 5]]);
|
|
11520
11515
|
}));
|
|
11521
|
-
return function
|
|
11516
|
+
return function getXcmFeeInternal(_x) {
|
|
11522
11517
|
return _ref.apply(this, arguments);
|
|
11523
11518
|
};
|
|
11524
11519
|
}();
|
|
11520
|
+
var getXcmFee = /*#__PURE__*/function () {
|
|
11521
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
11522
|
+
var api;
|
|
11523
|
+
return _regenerator().w(function (_context2) {
|
|
11524
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
11525
|
+
case 0:
|
|
11526
|
+
api = options.api;
|
|
11527
|
+
_context2.p = 1;
|
|
11528
|
+
_context2.n = 2;
|
|
11529
|
+
return getXcmFeeInternal(options);
|
|
11530
|
+
case 2:
|
|
11531
|
+
return _context2.a(2, _context2.v);
|
|
11532
|
+
case 3:
|
|
11533
|
+
_context2.p = 3;
|
|
11534
|
+
_context2.n = 4;
|
|
11535
|
+
return api.disconnect();
|
|
11536
|
+
case 4:
|
|
11537
|
+
return _context2.f(3);
|
|
11538
|
+
case 5:
|
|
11539
|
+
return _context2.a(2);
|
|
11540
|
+
}
|
|
11541
|
+
}, _callee2, null, [[1,, 3, 5]]);
|
|
11542
|
+
}));
|
|
11543
|
+
return function getXcmFee(_x2) {
|
|
11544
|
+
return _ref2.apply(this, arguments);
|
|
11545
|
+
};
|
|
11546
|
+
}();
|
|
11525
11547
|
|
|
11526
11548
|
var BRIDGE_FEE_DOT = 682395810n; // 0.068239581 DOT
|
|
11527
11549
|
var BRIDGE_FEE_KSM = 12016807000n; // 0.012016807 KSM
|
|
@@ -11749,9 +11771,18 @@ var send = /*#__PURE__*/function () {
|
|
|
11749
11771
|
resolvedAsset = asset !== null && asset !== void 0 ? asset : {
|
|
11750
11772
|
symbol: 'symbol' in currency ? currency.symbol : undefined
|
|
11751
11773
|
};
|
|
11752
|
-
finalAsset = Array.isArray(currency) ?
|
|
11774
|
+
finalAsset = Array.isArray(currency) ? // TODO: Refactor this
|
|
11775
|
+
// We use a dummy values when overriding with multi-assets
|
|
11776
|
+
// since these values won't be used but need to pass checks
|
|
11777
|
+
_objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
|
|
11753
11778
|
amount: 0n,
|
|
11754
|
-
assetId: '1'
|
|
11779
|
+
assetId: '1',
|
|
11780
|
+
location: {
|
|
11781
|
+
parents: Parents.ZERO,
|
|
11782
|
+
interior: {
|
|
11783
|
+
Here: null
|
|
11784
|
+
}
|
|
11785
|
+
}
|
|
11755
11786
|
}) : _objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
|
|
11756
11787
|
amount: finalAmount
|
|
11757
11788
|
});
|
|
@@ -11946,7 +11977,7 @@ var buildHopInfo = /*#__PURE__*/function () {
|
|
|
11946
11977
|
|
|
11947
11978
|
var getTransferInfo = /*#__PURE__*/function () {
|
|
11948
11979
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
|
|
11949
|
-
var api, buildTx, origin, destination, senderAddress, ahAddress, address, currency, feeAsset, resolvedFeeAsset, originAsset, amount, originBalanceFee, originBalance, edOrigin, _yield$
|
|
11980
|
+
var api, buildTx, origin, destination, senderAddress, ahAddress, address, currency, feeAsset, resolvedFeeAsset, originAsset, amount, originBalanceFee, originBalance, edOrigin, _yield$getXcmFeeInter, _yield$getXcmFeeInter2, originFee, originFeeCurrency, originFeeAsset, assetHubFeeResult, bridgeHubFeeResult, destFeeDetail, hops, isFeeAssetAh, originBalanceAfter, originBalanceFeeAfter, originBalanceNativeSufficient, originBalanceSufficient, assetHub, bridgeHub, bridgeHubChain, builtHops, totalHopFee, destinationInfo, _t;
|
|
11950
11981
|
return _regenerator().w(function (_context2) {
|
|
11951
11982
|
while (1) switch (_context2.p = _context2.n) {
|
|
11952
11983
|
case 0:
|
|
@@ -12014,15 +12045,15 @@ var getTransferInfo = /*#__PURE__*/function () {
|
|
|
12014
12045
|
disableFallback: false
|
|
12015
12046
|
});
|
|
12016
12047
|
case 9:
|
|
12017
|
-
_yield$
|
|
12018
|
-
_yield$
|
|
12019
|
-
originFee = _yield$
|
|
12020
|
-
originFeeCurrency = _yield$
|
|
12021
|
-
originFeeAsset = _yield$
|
|
12022
|
-
assetHubFeeResult = _yield$
|
|
12023
|
-
bridgeHubFeeResult = _yield$
|
|
12024
|
-
destFeeDetail = _yield$
|
|
12025
|
-
hops = _yield$
|
|
12048
|
+
_yield$getXcmFeeInter = _context2.v;
|
|
12049
|
+
_yield$getXcmFeeInter2 = _yield$getXcmFeeInter.origin;
|
|
12050
|
+
originFee = _yield$getXcmFeeInter2.fee;
|
|
12051
|
+
originFeeCurrency = _yield$getXcmFeeInter2.currency;
|
|
12052
|
+
originFeeAsset = _yield$getXcmFeeInter2.asset;
|
|
12053
|
+
assetHubFeeResult = _yield$getXcmFeeInter.assetHub;
|
|
12054
|
+
bridgeHubFeeResult = _yield$getXcmFeeInter.bridgeHub;
|
|
12055
|
+
destFeeDetail = _yield$getXcmFeeInter.destination;
|
|
12056
|
+
hops = _yield$getXcmFeeInter.hops;
|
|
12026
12057
|
isFeeAssetAh = origin === 'AssetHubPolkadot' && resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, originAsset);
|
|
12027
12058
|
originBalanceAfter = originBalance - amount;
|
|
12028
12059
|
originBalanceFeeAfter = isFeeAssetAh ? originBalanceFee - amount : originBalanceFee - originFee;
|
|
@@ -12392,15 +12423,20 @@ var buildTypeAndThenCall = function buildTypeAndThenCall(_ref, isDotAsset, custo
|
|
|
12392
12423
|
reserve = _ref.reserve,
|
|
12393
12424
|
dest = _ref.dest,
|
|
12394
12425
|
assetInfo = _ref.assetInfo,
|
|
12395
|
-
|
|
12426
|
+
_ref$options = _ref.options,
|
|
12427
|
+
version = _ref$options.version,
|
|
12428
|
+
pallet = _ref$options.pallet,
|
|
12429
|
+
method = _ref$options.method;
|
|
12396
12430
|
var feeAssetLocation = !isDotAsset ? RELAY_LOCATION : assetInfo.location;
|
|
12397
12431
|
var finalDest = origin.chain === reserve.chain ? dest.chain : reserve.chain;
|
|
12398
12432
|
var destLocation = createDestination(version, origin.chain, finalDest, getParaId(finalDest));
|
|
12399
12433
|
var reserveType = origin.chain === reserve.chain ? 'LocalReserve' : 'DestinationReserve';
|
|
12400
12434
|
var feeMultiAsset = createAsset(version, assetInfo.amount, isRelayChain(origin.chain) ? localizeLocation(origin.chain, feeAssetLocation) : feeAssetLocation);
|
|
12435
|
+
var module = pallet !== null && pallet !== void 0 ? pallet : isRelayChain(origin.chain) ? 'XcmPallet' : 'PolkadotXcm';
|
|
12436
|
+
var methodName = method !== null && method !== void 0 ? method : 'transfer_assets_using_type_and_then';
|
|
12401
12437
|
return {
|
|
12402
|
-
module:
|
|
12403
|
-
method:
|
|
12438
|
+
module: module,
|
|
12439
|
+
method: methodName,
|
|
12404
12440
|
parameters: {
|
|
12405
12441
|
dest: addXcmVersionHeader(destLocation, version),
|
|
12406
12442
|
assets: addXcmVersionHeader(assets, version),
|
|
@@ -12413,130 +12449,76 @@ var buildTypeAndThenCall = function buildTypeAndThenCall(_ref, isDotAsset, custo
|
|
|
12413
12449
|
};
|
|
12414
12450
|
};
|
|
12415
12451
|
|
|
12416
|
-
var
|
|
12417
|
-
var
|
|
12418
|
-
|
|
12419
|
-
|
|
12420
|
-
|
|
12421
|
-
|
|
12422
|
-
|
|
12423
|
-
|
|
12424
|
-
|
|
12425
|
-
|
|
12426
|
-
};
|
|
12427
|
-
var computeInstructionFee = /*#__PURE__*/function () {
|
|
12428
|
-
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref2, version, xcm, context) {
|
|
12429
|
-
var chain, api, padding, _t;
|
|
12452
|
+
var FEE_PADDING = 30;
|
|
12453
|
+
var sumHopFees = function sumHopFees(result, asset) {
|
|
12454
|
+
return result.hops.reduce(function (acc, hop) {
|
|
12455
|
+
// only add if asset is equal
|
|
12456
|
+
return isAssetEqual(hop.result.asset, asset) ? acc + hop.result.fee : acc;
|
|
12457
|
+
}, 0n);
|
|
12458
|
+
};
|
|
12459
|
+
var computeAllFees = /*#__PURE__*/function () {
|
|
12460
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, buildTx) {
|
|
12461
|
+
var origin, dest, assetInfo, _context$options, senderAddress, address, currency, feeCurrency, result, hopFees, destFee;
|
|
12430
12462
|
return _regenerator().w(function (_context) {
|
|
12431
12463
|
while (1) switch (_context.n) {
|
|
12432
12464
|
case 0:
|
|
12433
|
-
|
|
12434
|
-
|
|
12435
|
-
|
|
12436
|
-
|
|
12437
|
-
|
|
12438
|
-
location: DOT_LOCATION
|
|
12439
|
-
}, true);
|
|
12440
|
-
case 1:
|
|
12441
|
-
return _context.a(2, _t(_context.v, padding));
|
|
12442
|
-
}
|
|
12443
|
-
}, _callee);
|
|
12444
|
-
}));
|
|
12445
|
-
return function computeInstructionFee(_x, _x2, _x3, _x4) {
|
|
12446
|
-
return _ref3.apply(this, arguments);
|
|
12447
|
-
};
|
|
12448
|
-
}();
|
|
12449
|
-
var computeAllFees = /*#__PURE__*/function () {
|
|
12450
|
-
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(context, customXcm, isDotAsset, refundInstruction) {
|
|
12451
|
-
var reserve, dest, version, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0;
|
|
12452
|
-
return _regenerator().w(function (_context2) {
|
|
12453
|
-
while (1) switch (_context2.n) {
|
|
12454
|
-
case 0:
|
|
12455
|
-
reserve = context.reserve, dest = context.dest, version = context.options.version;
|
|
12456
|
-
if (!customXcm.some(function (x) {
|
|
12457
|
-
return 'DepositReserveAsset' in x || 'InitiateTeleport' in x;
|
|
12458
|
-
})) {
|
|
12459
|
-
_context2.n = 6;
|
|
12465
|
+
origin = context.origin, dest = context.dest, assetInfo = context.assetInfo, _context$options = context.options, senderAddress = _context$options.senderAddress, address = _context$options.address, currency = _context$options.currency, feeCurrency = _context$options.feeCurrency;
|
|
12466
|
+
assertSenderAddress(senderAddress);
|
|
12467
|
+
assertAddressIsString(address);
|
|
12468
|
+
if (hasDryRunSupport(context.origin.chain)) {
|
|
12469
|
+
_context.n = 1;
|
|
12460
12470
|
break;
|
|
12461
12471
|
}
|
|
12462
|
-
|
|
12463
|
-
return computeInstructionFee(reserve, version, customXcm, context);
|
|
12472
|
+
return _context.a(2, null);
|
|
12464
12473
|
case 1:
|
|
12465
|
-
|
|
12466
|
-
|
|
12467
|
-
|
|
12468
|
-
|
|
12469
|
-
|
|
12470
|
-
|
|
12471
|
-
|
|
12474
|
+
_context.n = 2;
|
|
12475
|
+
return getXcmFeeInternal({
|
|
12476
|
+
api: origin.api,
|
|
12477
|
+
buildTx: buildTx,
|
|
12478
|
+
origin: origin.chain,
|
|
12479
|
+
destination: dest.chain,
|
|
12480
|
+
senderAddress: senderAddress,
|
|
12481
|
+
address: address,
|
|
12482
|
+
currency: currency,
|
|
12483
|
+
feeAsset: feeCurrency,
|
|
12484
|
+
disableFallback: false,
|
|
12485
|
+
skipReverseFeeCalculation: true
|
|
12486
|
+
});
|
|
12472
12487
|
case 2:
|
|
12473
|
-
|
|
12474
|
-
|
|
12475
|
-
|
|
12476
|
-
|
|
12477
|
-
|
|
12478
|
-
|
|
12479
|
-
|
|
12480
|
-
_context2.n = 5;
|
|
12481
|
-
return computeInstructionFee(hasXcmPaymentApiSupport(dest.chain) ? dest : reserve, version, function () {
|
|
12482
|
-
var instr = customXcm.find(function (j) {
|
|
12483
|
-
return 'DepositReserveAsset' in j || 'InitiateTeleport' in j;
|
|
12484
|
-
});
|
|
12485
|
-
return instr ? 'DepositReserveAsset' in instr ? instr.DepositReserveAsset.xcm : instr.InitiateTeleport.xcm : undefined;
|
|
12486
|
-
}(), context);
|
|
12487
|
-
case 5:
|
|
12488
|
-
_t6 = _context2.v;
|
|
12489
|
-
_t2 = {
|
|
12490
|
-
reserveFee: _t3,
|
|
12491
|
-
refundFee: _t5,
|
|
12492
|
-
destFee: _t6
|
|
12493
|
-
};
|
|
12494
|
-
_context2.n = 13;
|
|
12495
|
-
break;
|
|
12496
|
-
case 6:
|
|
12497
|
-
if (isDotAsset) {
|
|
12498
|
-
_context2.n = 8;
|
|
12499
|
-
break;
|
|
12500
|
-
}
|
|
12501
|
-
_context2.n = 7;
|
|
12502
|
-
return computeInstructionFee(hasXcmPaymentApiSupport(dest.chain) ? dest : reserve, version, customXcm, context);
|
|
12503
|
-
case 7:
|
|
12504
|
-
_t7 = _context2.v;
|
|
12505
|
-
_context2.n = 9;
|
|
12506
|
-
break;
|
|
12507
|
-
case 8:
|
|
12508
|
-
_t7 = 0n;
|
|
12509
|
-
case 9:
|
|
12510
|
-
_t8 = _t7;
|
|
12511
|
-
if (isDotAsset) {
|
|
12512
|
-
_context2.n = 11;
|
|
12513
|
-
break;
|
|
12514
|
-
}
|
|
12515
|
-
_context2.n = 10;
|
|
12516
|
-
return computeInstructionFee(hasXcmPaymentApiSupport(reserve.chain) ? reserve : dest, version, [refundInstruction], context);
|
|
12517
|
-
case 10:
|
|
12518
|
-
_t9 = _context2.v;
|
|
12519
|
-
_context2.n = 12;
|
|
12520
|
-
break;
|
|
12521
|
-
case 11:
|
|
12522
|
-
_t9 = 0n;
|
|
12523
|
-
case 12:
|
|
12524
|
-
_t0 = _t9;
|
|
12525
|
-
_t2 = {
|
|
12526
|
-
reserveFee: 0n,
|
|
12527
|
-
destFee: _t8,
|
|
12528
|
-
refundFee: _t0
|
|
12529
|
-
};
|
|
12530
|
-
case 13:
|
|
12531
|
-
return _context2.a(2, _t2);
|
|
12488
|
+
result = _context.v;
|
|
12489
|
+
hopFees = sumHopFees(result, assetInfo);
|
|
12490
|
+
destFee = result.destination.fee;
|
|
12491
|
+
return _context.a(2, {
|
|
12492
|
+
hopFees: padValueBy(hopFees, FEE_PADDING),
|
|
12493
|
+
destFee: padValueBy(destFee, FEE_PADDING)
|
|
12494
|
+
});
|
|
12532
12495
|
}
|
|
12533
|
-
},
|
|
12496
|
+
}, _callee);
|
|
12534
12497
|
}));
|
|
12535
|
-
return function computeAllFees(
|
|
12536
|
-
return
|
|
12498
|
+
return function computeAllFees(_x, _x2) {
|
|
12499
|
+
return _ref.apply(this, arguments);
|
|
12537
12500
|
};
|
|
12538
12501
|
}();
|
|
12539
12502
|
|
|
12503
|
+
var RELAY_ASSET_LOCATIONS = [RELAY_LOCATION, {
|
|
12504
|
+
parents: 2,
|
|
12505
|
+
interior: {
|
|
12506
|
+
X1: [{
|
|
12507
|
+
GlobalConsensus: {
|
|
12508
|
+
Kusama: null
|
|
12509
|
+
}
|
|
12510
|
+
}]
|
|
12511
|
+
}
|
|
12512
|
+
}, {
|
|
12513
|
+
parents: 2,
|
|
12514
|
+
interior: {
|
|
12515
|
+
X1: [{
|
|
12516
|
+
GlobalConsensus: {
|
|
12517
|
+
Polkadot: null
|
|
12518
|
+
}
|
|
12519
|
+
}]
|
|
12520
|
+
}
|
|
12521
|
+
}];
|
|
12540
12522
|
var getSubBridgeReserve = function getSubBridgeReserve(chain, destination, location) {
|
|
12541
12523
|
if (deepEqual(location, RELAY_LOCATION)) return chain;
|
|
12542
12524
|
return destination;
|
|
@@ -12552,29 +12534,27 @@ var resolveReserveChain = function resolveReserveChain(chain, destination, asset
|
|
|
12552
12534
|
};
|
|
12553
12535
|
var createTypeAndThenCallContext = /*#__PURE__*/function () {
|
|
12554
12536
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options, overrideReserve) {
|
|
12555
|
-
var api, destination, assetInfo, destinationChain, isSubBridge, reserveChain, destApi, reserveApi;
|
|
12537
|
+
var api, destination, assetInfo, destinationChain, isSubBridge, reserveChain, isRelayAsset, destApi, reserveApi;
|
|
12556
12538
|
return _regenerator().w(function (_context) {
|
|
12557
12539
|
while (1) switch (_context.n) {
|
|
12558
12540
|
case 0:
|
|
12559
12541
|
api = options.api, destination = options.destination, assetInfo = options.assetInfo;
|
|
12560
12542
|
assertHasLocation(assetInfo);
|
|
12561
|
-
|
|
12562
|
-
_context.n = 1;
|
|
12563
|
-
break;
|
|
12564
|
-
}
|
|
12565
|
-
throw new InvalidParameterError('Cannot override destination when using type and then transfer.');
|
|
12566
|
-
case 1:
|
|
12543
|
+
assertToIsString(destination);
|
|
12567
12544
|
destinationChain = destination;
|
|
12568
12545
|
isSubBridge = isSubstrateBridge(chain, destinationChain);
|
|
12569
12546
|
reserveChain = resolveReserveChain(chain, destinationChain, assetInfo.location, isSubBridge, overrideReserve);
|
|
12547
|
+
isRelayAsset = RELAY_ASSET_LOCATIONS.some(function (loc) {
|
|
12548
|
+
return deepEqual(assetInfo.location, loc);
|
|
12549
|
+
});
|
|
12570
12550
|
destApi = api.clone();
|
|
12571
|
-
_context.n =
|
|
12551
|
+
_context.n = 1;
|
|
12572
12552
|
return destApi.init(destinationChain);
|
|
12573
|
-
case
|
|
12553
|
+
case 1:
|
|
12574
12554
|
reserveApi = reserveChain === chain ? api : reserveChain === destinationChain ? destApi : api.clone();
|
|
12575
|
-
_context.n =
|
|
12555
|
+
_context.n = 2;
|
|
12576
12556
|
return reserveApi.init(reserveChain);
|
|
12577
|
-
case
|
|
12557
|
+
case 2:
|
|
12578
12558
|
return _context.a(2, {
|
|
12579
12559
|
origin: {
|
|
12580
12560
|
api: api,
|
|
@@ -12589,6 +12569,7 @@ var createTypeAndThenCallContext = /*#__PURE__*/function () {
|
|
|
12589
12569
|
chain: reserveChain
|
|
12590
12570
|
},
|
|
12591
12571
|
isSubBridge: isSubBridge,
|
|
12572
|
+
isRelayAsset: isRelayAsset,
|
|
12592
12573
|
assetInfo: assetInfo,
|
|
12593
12574
|
options: options
|
|
12594
12575
|
});
|
|
@@ -12600,26 +12581,37 @@ var createTypeAndThenCallContext = /*#__PURE__*/function () {
|
|
|
12600
12581
|
};
|
|
12601
12582
|
}();
|
|
12602
12583
|
|
|
12603
|
-
var
|
|
12604
|
-
var
|
|
12605
|
-
|
|
12606
|
-
|
|
12607
|
-
|
|
12608
|
-
|
|
12609
|
-
|
|
12584
|
+
var resolveBuyExecutionAmount = function resolveBuyExecutionAmount(_ref, isForFeeCalc, _ref2, systemAssetAmount) {
|
|
12585
|
+
var isRelayAsset = _ref.isRelayAsset,
|
|
12586
|
+
assetInfo = _ref.assetInfo;
|
|
12587
|
+
var hopFees = _ref2.hopFees,
|
|
12588
|
+
destFee = _ref2.destFee;
|
|
12589
|
+
if (isForFeeCalc) {
|
|
12590
|
+
// Rough estimates for dummy XCM call, that is later dryRunned
|
|
12591
|
+
return isRelayAsset ? assetInfo.amount / 2n : systemAssetAmount / 2n;
|
|
12592
|
+
}
|
|
12593
|
+
// We have actual fees, calculate exact buy execution amount
|
|
12594
|
+
return isRelayAsset ? assetInfo.amount - hopFees : destFee;
|
|
12595
|
+
};
|
|
12596
|
+
var createCustomXcm = function createCustomXcm(context, assetCount, isForFeeCalc, systemAssetAmount) {
|
|
12610
12597
|
var fees = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
|
|
12611
|
-
|
|
12612
|
-
refundFee: 0n,
|
|
12598
|
+
hopFees: 0n,
|
|
12613
12599
|
destFee: 0n
|
|
12614
12600
|
};
|
|
12601
|
+
var origin = context.origin,
|
|
12602
|
+
dest = context.dest,
|
|
12603
|
+
reserve = context.reserve,
|
|
12604
|
+
isSubBridge = context.isSubBridge,
|
|
12605
|
+
isRelayAsset = context.isRelayAsset,
|
|
12606
|
+
assetInfo = context.assetInfo,
|
|
12607
|
+
options = context.options;
|
|
12615
12608
|
var destination = options.destination,
|
|
12616
12609
|
version = options.version,
|
|
12617
12610
|
address = options.address,
|
|
12618
12611
|
paraIdTo = options.paraIdTo;
|
|
12619
|
-
var
|
|
12620
|
-
refundFee = fees.refundFee,
|
|
12612
|
+
var hopFees = fees.hopFees,
|
|
12621
12613
|
destFee = fees.destFee;
|
|
12622
|
-
var feeAssetLocation = !
|
|
12614
|
+
var feeAssetLocation = !isRelayAsset ? RELAY_LOCATION : assetInfo.location;
|
|
12623
12615
|
var feeLocLocalized = localizeLocation(dest.chain, feeAssetLocation, origin.chain);
|
|
12624
12616
|
var asset = createAsset(version, assetInfo.amount, localizeLocation(dest.chain, assetInfo.location, origin.chain));
|
|
12625
12617
|
var depositInstruction = {
|
|
@@ -12642,10 +12634,10 @@ var createCustomXcm = function createCustomXcm(_ref, isDotAsset, assetCount, isF
|
|
|
12642
12634
|
}
|
|
12643
12635
|
};
|
|
12644
12636
|
var assetsFilter = [];
|
|
12645
|
-
if (!
|
|
12637
|
+
if (!isRelayAsset) assetsFilter.push(createAsset(version, hopFees + destFee, localizeLocation(reserve.chain, RELAY_LOCATION)));
|
|
12646
12638
|
assetsFilter.push(createAsset(version, assetInfo.amount, localizeLocation(reserve.chain, assetInfo.location)));
|
|
12647
12639
|
if (isSubBridge || origin.chain !== reserve.chain && dest.chain !== reserve.chain) {
|
|
12648
|
-
var buyExecutionAmount =
|
|
12640
|
+
var buyExecutionAmount = resolveBuyExecutionAmount(context, isForFeeCalc, fees, systemAssetAmount);
|
|
12649
12641
|
if (buyExecutionAmount < 0n && !isForFeeCalc) throw new AmountTooLowError();
|
|
12650
12642
|
var filter = isForFeeCalc ? {
|
|
12651
12643
|
Wild: 'All'
|
|
@@ -12710,63 +12702,166 @@ var buildAssets = function buildAssets(chain, asset, feeAmount, isDotAsset, vers
|
|
|
12710
12702
|
assets.push(createAsset(version, asset.amount, isRelayChain(chain) ? localizeLocation(chain, asset.location) : asset.location));
|
|
12711
12703
|
return assets;
|
|
12712
12704
|
};
|
|
12705
|
+
var DEFAULT_SYSTEM_ASSET_AMOUNT = '1';
|
|
12706
|
+
var resolveSystemAssetAmount = function resolveSystemAssetAmount(_ref, isForFeeCalc, fees) {
|
|
12707
|
+
var origin = _ref.origin;
|
|
12708
|
+
if (isForFeeCalc) {
|
|
12709
|
+
var systemAsset = findNativeAssetInfoOrThrow(getRelayChainOf(origin.chain));
|
|
12710
|
+
return parseUnits(DEFAULT_SYSTEM_ASSET_AMOUNT, systemAsset.decimals);
|
|
12711
|
+
}
|
|
12712
|
+
return fees.destFee + fees.hopFees;
|
|
12713
|
+
};
|
|
12714
|
+
var constructTypeAndThenCall = function constructTypeAndThenCall(context) {
|
|
12715
|
+
var fees = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
12716
|
+
var origin = context.origin,
|
|
12717
|
+
assetInfo = context.assetInfo,
|
|
12718
|
+
isSubBridge = context.isSubBridge,
|
|
12719
|
+
isRelayAsset = context.isRelayAsset,
|
|
12720
|
+
_context$options = context.options,
|
|
12721
|
+
senderAddress = _context$options.senderAddress,
|
|
12722
|
+
version = _context$options.version;
|
|
12723
|
+
var assetCount = isRelayAsset ? 1 : 2;
|
|
12724
|
+
var refundInstruction = senderAddress ? createRefundInstruction(origin.api, senderAddress, version, assetCount) : null;
|
|
12725
|
+
var finalCustomXcm = [];
|
|
12726
|
+
if (refundInstruction && !isSubBridge) finalCustomXcm.push(refundInstruction);
|
|
12727
|
+
var resolvedFees = fees !== null && fees !== void 0 ? fees : {
|
|
12728
|
+
hopFees: 0n,
|
|
12729
|
+
destFee: 0n
|
|
12730
|
+
};
|
|
12731
|
+
var isForFeeCalc = fees === null;
|
|
12732
|
+
var systemAssetAmount = resolveSystemAssetAmount(context, isForFeeCalc, resolvedFees);
|
|
12733
|
+
finalCustomXcm.push.apply(finalCustomXcm, _toConsumableArray(createCustomXcm(context, assetCount, isForFeeCalc, systemAssetAmount, resolvedFees)));
|
|
12734
|
+
var assets = buildAssets(origin.chain, assetInfo, systemAssetAmount, isRelayAsset, version);
|
|
12735
|
+
return buildTypeAndThenCall(context, isRelayAsset, finalCustomXcm, assets);
|
|
12736
|
+
};
|
|
12713
12737
|
/**
|
|
12714
12738
|
* Creates a type and then call for transferring assets using XCM. Works only for DOT and snowbridge assets so far.
|
|
12715
12739
|
*/
|
|
12716
12740
|
var createTypeAndThenCall = /*#__PURE__*/function () {
|
|
12717
|
-
var
|
|
12718
|
-
var
|
|
12741
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options, overrideReserve) {
|
|
12742
|
+
var context, origin, assetInfo, fees;
|
|
12719
12743
|
return _regenerator().w(function (_context) {
|
|
12720
12744
|
while (1) switch (_context.n) {
|
|
12721
12745
|
case 0:
|
|
12722
|
-
api = options.api, senderAddress = options.senderAddress, version = options.version;
|
|
12723
12746
|
_context.n = 1;
|
|
12724
12747
|
return createTypeAndThenCallContext(chain, options, overrideReserve);
|
|
12725
12748
|
case 1:
|
|
12726
12749
|
context = _context.v;
|
|
12727
|
-
|
|
12728
|
-
LOCATIONS = [RELAY_LOCATION, {
|
|
12729
|
-
parents: 2,
|
|
12730
|
-
interior: {
|
|
12731
|
-
X1: [{
|
|
12732
|
-
GlobalConsensus: {
|
|
12733
|
-
Kusama: null
|
|
12734
|
-
}
|
|
12735
|
-
}]
|
|
12736
|
-
}
|
|
12737
|
-
}, {
|
|
12738
|
-
parents: 2,
|
|
12739
|
-
interior: {
|
|
12740
|
-
X1: [{
|
|
12741
|
-
GlobalConsensus: {
|
|
12742
|
-
Polkadot: null
|
|
12743
|
-
}
|
|
12744
|
-
}]
|
|
12745
|
-
}
|
|
12746
|
-
}];
|
|
12747
|
-
isRelayAsset = LOCATIONS.some(function (loc) {
|
|
12748
|
-
return deepEqual(assetInfo.location, loc);
|
|
12749
|
-
});
|
|
12750
|
-
assetCount = isRelayAsset ? 1 : 2;
|
|
12751
|
-
customXcm = createCustomXcm(context, isRelayAsset, assetCount, true);
|
|
12752
|
-
refundInstruction = senderAddress ? createRefundInstruction(api, senderAddress, version, assetCount) : null;
|
|
12750
|
+
origin = context.origin, assetInfo = context.assetInfo;
|
|
12753
12751
|
_context.n = 2;
|
|
12754
|
-
return computeAllFees(context,
|
|
12752
|
+
return computeAllFees(context, function (amount, relative) {
|
|
12753
|
+
var overridenAmount = amount ? relative ? assetInfo.amount + parseUnits(amount, assetInfo.decimals) : parseUnits(amount, assetInfo.decimals) : assetInfo.amount;
|
|
12754
|
+
return Promise.resolve(origin.api.callTxMethod(constructTypeAndThenCall(_objectSpread2(_objectSpread2({}, context), {}, {
|
|
12755
|
+
assetInfo: _objectSpread2(_objectSpread2({}, assetInfo), {}, {
|
|
12756
|
+
amount: overridenAmount
|
|
12757
|
+
})
|
|
12758
|
+
}))));
|
|
12759
|
+
});
|
|
12755
12760
|
case 2:
|
|
12756
12761
|
fees = _context.v;
|
|
12757
|
-
|
|
12758
|
-
if (refundInstruction && !isSubBridge) finalCustomXcm.push(refundInstruction);
|
|
12759
|
-
finalCustomXcm.push.apply(finalCustomXcm, _toConsumableArray(createCustomXcm(context, isRelayAsset, assetCount, false, fees)));
|
|
12760
|
-
totalFee = fees.reserveFee + fees.destFee + fees.refundFee;
|
|
12761
|
-
assets = buildAssets(chain, assetInfo, totalFee, isRelayAsset, version);
|
|
12762
|
-
return _context.a(2, buildTypeAndThenCall(context, isRelayAsset, finalCustomXcm, assets));
|
|
12762
|
+
return _context.a(2, constructTypeAndThenCall(context, fees));
|
|
12763
12763
|
}
|
|
12764
12764
|
}, _callee);
|
|
12765
12765
|
}));
|
|
12766
12766
|
return function createTypeAndThenCall(_x, _x2, _x3) {
|
|
12767
|
+
return _ref2.apply(this, arguments);
|
|
12768
|
+
};
|
|
12769
|
+
}();
|
|
12770
|
+
|
|
12771
|
+
var createCallForReserve = /*#__PURE__*/function () {
|
|
12772
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, reserveChain, options) {
|
|
12773
|
+
var api, destination, address, senderAddress, currency, feeCurrency, serialized, tx, dryRunResult, success;
|
|
12774
|
+
return _regenerator().w(function (_context) {
|
|
12775
|
+
while (1) switch (_context.n) {
|
|
12776
|
+
case 0:
|
|
12777
|
+
api = options.api, destination = options.destination, address = options.address, senderAddress = options.senderAddress, currency = options.currency, feeCurrency = options.feeCurrency;
|
|
12778
|
+
_context.n = 1;
|
|
12779
|
+
return createTypeAndThenCall(chain, options, reserveChain);
|
|
12780
|
+
case 1:
|
|
12781
|
+
serialized = _context.v;
|
|
12782
|
+
assertAddressIsString(address);
|
|
12783
|
+
assertToIsString(destination, 'Location destination is not supported for reserve auto-selection.');
|
|
12784
|
+
assertSenderAddress(senderAddress);
|
|
12785
|
+
tx = api.callTxMethod(serialized);
|
|
12786
|
+
_context.n = 2;
|
|
12787
|
+
return dryRunInternal({
|
|
12788
|
+
api: api,
|
|
12789
|
+
tx: tx,
|
|
12790
|
+
origin: chain,
|
|
12791
|
+
destination: destination,
|
|
12792
|
+
address: address,
|
|
12793
|
+
senderAddress: senderAddress,
|
|
12794
|
+
currency: currency,
|
|
12795
|
+
feeAsset: feeCurrency,
|
|
12796
|
+
useRootOrigin: true
|
|
12797
|
+
});
|
|
12798
|
+
case 2:
|
|
12799
|
+
dryRunResult = _context.v;
|
|
12800
|
+
success = !dryRunResult.failureReason;
|
|
12801
|
+
return _context.a(2, {
|
|
12802
|
+
call: serialized,
|
|
12803
|
+
success: success
|
|
12804
|
+
});
|
|
12805
|
+
}
|
|
12806
|
+
}, _callee);
|
|
12807
|
+
}));
|
|
12808
|
+
return function createCallForReserve(_x, _x2, _x3) {
|
|
12767
12809
|
return _ref.apply(this, arguments);
|
|
12768
12810
|
};
|
|
12769
12811
|
}();
|
|
12812
|
+
/**
|
|
12813
|
+
* Creates a type-and-then call but auto-selects the asset reserve between AssetHub and the Relay chain
|
|
12814
|
+
* by dry-running both variants and preferring the one that succeeds. If both fail, returns the
|
|
12815
|
+
* AssetHub variant. Supports only relaychain assets.
|
|
12816
|
+
*/
|
|
12817
|
+
var createTypeThenAutoReserve = /*#__PURE__*/function () {
|
|
12818
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(chain, options) {
|
|
12819
|
+
var originSupports, destSupports, relay, assetHubReserve, ahResult, relayResult;
|
|
12820
|
+
return _regenerator().w(function (_context2) {
|
|
12821
|
+
while (1) switch (_context2.n) {
|
|
12822
|
+
case 0:
|
|
12823
|
+
// Use dry-run path only when BOTH origin and destination support it
|
|
12824
|
+
originSupports = hasDryRunSupport(chain);
|
|
12825
|
+
destSupports = options.destChain ? hasDryRunSupport(options.destChain) : false;
|
|
12826
|
+
if (originSupports && destSupports) {
|
|
12827
|
+
_context2.n = 2;
|
|
12828
|
+
break;
|
|
12829
|
+
}
|
|
12830
|
+
_context2.n = 1;
|
|
12831
|
+
return createTypeAndThenCall(chain, options);
|
|
12832
|
+
case 1:
|
|
12833
|
+
return _context2.a(2, _context2.v);
|
|
12834
|
+
case 2:
|
|
12835
|
+
relay = getRelayChainOf(chain);
|
|
12836
|
+
assetHubReserve = "AssetHub".concat(relay);
|
|
12837
|
+
_context2.n = 3;
|
|
12838
|
+
return createCallForReserve(chain, assetHubReserve, options);
|
|
12839
|
+
case 3:
|
|
12840
|
+
ahResult = _context2.v;
|
|
12841
|
+
if (!ahResult.success) {
|
|
12842
|
+
_context2.n = 4;
|
|
12843
|
+
break;
|
|
12844
|
+
}
|
|
12845
|
+
return _context2.a(2, ahResult.call);
|
|
12846
|
+
case 4:
|
|
12847
|
+
_context2.n = 5;
|
|
12848
|
+
return createCallForReserve(chain, relay, options);
|
|
12849
|
+
case 5:
|
|
12850
|
+
relayResult = _context2.v;
|
|
12851
|
+
if (!relayResult.success) {
|
|
12852
|
+
_context2.n = 6;
|
|
12853
|
+
break;
|
|
12854
|
+
}
|
|
12855
|
+
return _context2.a(2, relayResult.call);
|
|
12856
|
+
case 6:
|
|
12857
|
+
return _context2.a(2, ahResult.call);
|
|
12858
|
+
}
|
|
12859
|
+
}, _callee2);
|
|
12860
|
+
}));
|
|
12861
|
+
return function createTypeThenAutoReserve(_x4, _x5) {
|
|
12862
|
+
return _ref2.apply(this, arguments);
|
|
12863
|
+
};
|
|
12864
|
+
}();
|
|
12770
12865
|
|
|
12771
12866
|
var calculateTotalXcmFee = function calculateTotalXcmFee(feeResult) {
|
|
12772
12867
|
var _feeResult$assetHub;
|
|
@@ -12827,7 +12922,7 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
|
12827
12922
|
case 5:
|
|
12828
12923
|
balance = _context.v;
|
|
12829
12924
|
_context.n = 6;
|
|
12830
|
-
return
|
|
12925
|
+
return getXcmFeeInternal({
|
|
12831
12926
|
api: api,
|
|
12832
12927
|
buildTx: buildTx,
|
|
12833
12928
|
origin: origin,
|
|
@@ -13571,7 +13666,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
13571
13666
|
var _options$disableFallb;
|
|
13572
13667
|
var disableFallback, _yield$this$prepareNo2, normalizedOptions, buildTx, api, from, to, senderAddress, address, currency, feeAsset;
|
|
13573
13668
|
return _regenerator().w(function (_context8) {
|
|
13574
|
-
while (1) switch (_context8.
|
|
13669
|
+
while (1) switch (_context8.n) {
|
|
13575
13670
|
case 0:
|
|
13576
13671
|
disableFallback = (_options$disableFallb = options === null || options === void 0 ? void 0 : options.disableFallback) !== null && _options$disableFallb !== void 0 ? _options$disableFallb : false;
|
|
13577
13672
|
_context8.n = 1;
|
|
@@ -13583,9 +13678,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
13583
13678
|
api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, senderAddress = normalizedOptions.senderAddress, address = normalizedOptions.address, currency = normalizedOptions.currency, feeAsset = normalizedOptions.feeAsset;
|
|
13584
13679
|
assertToIsString(to);
|
|
13585
13680
|
assertAddressIsString(address);
|
|
13586
|
-
_context8.
|
|
13587
|
-
_context8.n = 3;
|
|
13588
|
-
return getXcmFee({
|
|
13681
|
+
return _context8.a(2, getXcmFee({
|
|
13589
13682
|
api: api,
|
|
13590
13683
|
buildTx: buildTx,
|
|
13591
13684
|
origin: from,
|
|
@@ -13595,19 +13688,9 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
13595
13688
|
currency: currency,
|
|
13596
13689
|
feeAsset: feeAsset,
|
|
13597
13690
|
disableFallback: disableFallback
|
|
13598
|
-
});
|
|
13599
|
-
case 3:
|
|
13600
|
-
return _context8.a(2, _context8.v);
|
|
13601
|
-
case 4:
|
|
13602
|
-
_context8.p = 4;
|
|
13603
|
-
_context8.n = 5;
|
|
13604
|
-
return this.api.disconnect();
|
|
13605
|
-
case 5:
|
|
13606
|
-
return _context8.f(4);
|
|
13607
|
-
case 6:
|
|
13608
|
-
return _context8.a(2);
|
|
13691
|
+
}));
|
|
13609
13692
|
}
|
|
13610
|
-
}, _callee8, this
|
|
13693
|
+
}, _callee8, this);
|
|
13611
13694
|
}));
|
|
13612
13695
|
function getXcmFee$1(_x7) {
|
|
13613
13696
|
return _getXcmFee2.apply(this, arguments);
|
|
@@ -14022,4 +14105,4 @@ var Builder = function Builder(api) {
|
|
|
14022
14105
|
return new GeneralBuilder(api, new BatchTransactionManager());
|
|
14023
14106
|
};
|
|
14024
14107
|
|
|
14025
|
-
export { AmountTooLowError, AssetClaimBuilder, AssetsPallet, BatchMode, BridgeHaltedError, Builder, ChainNotSupportedError, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleChainsError, InvalidAddressError, InvalidParameterError, MissingChainApiError, NoXCMSupportImplementedError, PolkadotXcmError, PolkadotXcmExecutionError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertHasId, assertHasLocation, assertIsForeign, assertSenderAddress, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, computeOverridenAmount, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createTx, createTypeAndThenCall, createVersionedAssets, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, formatUnits, getAssetBalance, getAssetBalanceInternal, getAssetReserveChain, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getCurrencySelection, getFailureInfo$1 as getFailureInfo, getMinTransferableAmount, getMinTransferableAmountInternal, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, getXcmFeeInternal, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, overrideTxAmount, padFee, padValueBy, parseUnits, resolveDestChain, resolveModuleError, resolveParaId, reverseTransformLocation, send, sortAssets, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, verifyEdOnDestination, wrapTxBypass };
|
|
14108
|
+
export { AmountTooLowError, AssetClaimBuilder, AssetsPallet, BatchMode, BridgeHaltedError, Builder, ChainNotSupportedError, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleChainsError, InvalidAddressError, InvalidParameterError, MissingChainApiError, NoXCMSupportImplementedError, PolkadotXcmError, PolkadotXcmExecutionError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertHasId, assertHasLocation, assertIsForeign, assertSenderAddress, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, computeOverridenAmount, constructTypeAndThenCall, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createTx, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, formatUnits, getAssetBalance, getAssetBalanceInternal, getAssetReserveChain, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getCurrencySelection, getFailureInfo$1 as getFailureInfo, getMinTransferableAmount, getMinTransferableAmountInternal, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, overrideTxAmount, padFee, padValueBy, parseUnits, resolveDestChain, resolveModuleError, resolveParaId, reverseTransformLocation, send, sortAssets, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, verifyEdOnDestination, wrapTxBypass };
|