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