@paraspell/sdk-core 14.3.0 → 14.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +462 -313
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { isChainEvm, getAssetsObject, InvalidCurrencyError, isSymbolMatch, isAss
|
|
|
3
3
|
export * from '@paraspell/assets';
|
|
4
4
|
import { base58 } from '@scure/base';
|
|
5
5
|
import { isAddress, isHex, createPublicClient, http, formatUnits as formatUnits$1, parseUnits as parseUnits$1 } from 'viem';
|
|
6
|
-
import { ParaSpellError, isTLocation, replaceBigInt, isExternalChain, CHAINS, Version, isRelayChain, isSubstrateBridge, Parents, deepEqual, isTrustedChain, isCustomChain, isSnowbridge, getJunctionValue, hasJunction, ETHEREUM_BRIDGE_ORIGINS, isBridge, RELAYCHAINS, DEFAULT_SS58_PREFIX } from '@paraspell/sdk-common';
|
|
6
|
+
import { ParaSpellError, isTLocation, replaceBigInt, isExternalChain, CHAINS, Version, isRelayChain, isSubstrateBridge, Parents, deepEqual, isTrustedChain, isCustomChain, isSnowbridge, getJunctionValue, hasJunction, ETHEREUM_BRIDGE_ORIGINS, isBridge, flattenJunctions, RELAYCHAINS, DEFAULT_SS58_PREFIX } from '@paraspell/sdk-common';
|
|
7
7
|
export * from '@paraspell/sdk-common';
|
|
8
8
|
import { getXcmPallet, getOtherAssetsPallets, getNativeAssetsPallet, getSupportedPalletsDetails, ASSETS_PALLETS, NATIVE_ASSETS_PALLET_PRIORITY, OTHER_ASSETS_PALLET_PRIORITY, hasPalletImpl, getXcmPalletImpl } from '@paraspell/pallets';
|
|
9
9
|
export * from '@paraspell/pallets';
|
|
@@ -3687,6 +3687,326 @@ var getMythosOriginFee = /*#__PURE__*/function () {
|
|
|
3687
3687
|
};
|
|
3688
3688
|
}();
|
|
3689
3689
|
|
|
3690
|
+
var createX1Payload = function createX1Payload(version, junction) {
|
|
3691
|
+
return version === Version.V3 ? {
|
|
3692
|
+
X1: junction
|
|
3693
|
+
} : {
|
|
3694
|
+
X1: [junction]
|
|
3695
|
+
};
|
|
3696
|
+
};
|
|
3697
|
+
|
|
3698
|
+
var createAccountPayload = function createAccountPayload(api, address) {
|
|
3699
|
+
return isAddress(address) ? {
|
|
3700
|
+
AccountKey20: {
|
|
3701
|
+
key: address
|
|
3702
|
+
}
|
|
3703
|
+
} : {
|
|
3704
|
+
AccountId32: {
|
|
3705
|
+
id: api.accountToHex(address)
|
|
3706
|
+
}
|
|
3707
|
+
};
|
|
3708
|
+
};
|
|
3709
|
+
var createBeneficiaryLocXTokens = function createBeneficiaryLocXTokens(_ref) {
|
|
3710
|
+
var api = _ref.api,
|
|
3711
|
+
recipient = _ref.recipient,
|
|
3712
|
+
origin = _ref.origin,
|
|
3713
|
+
destination = _ref.destination,
|
|
3714
|
+
version = _ref.version,
|
|
3715
|
+
paraId = _ref.paraId;
|
|
3716
|
+
if (isTLocation(recipient)) {
|
|
3717
|
+
return recipient;
|
|
3718
|
+
}
|
|
3719
|
+
var scenario = resolveScenario(origin, destination);
|
|
3720
|
+
var accountPayload = createAccountPayload(api, recipient);
|
|
3721
|
+
if (scenario === 'ParaToRelay') {
|
|
3722
|
+
return {
|
|
3723
|
+
parents: Parents.ONE,
|
|
3724
|
+
interior: createX1Payload(version, {
|
|
3725
|
+
AccountId32: {
|
|
3726
|
+
id: api.accountToHex(recipient)
|
|
3727
|
+
}
|
|
3728
|
+
})
|
|
3729
|
+
};
|
|
3730
|
+
} else if (scenario === 'ParaToPara') {
|
|
3731
|
+
return {
|
|
3732
|
+
parents: Parents.ONE,
|
|
3733
|
+
interior: {
|
|
3734
|
+
X2: [{
|
|
3735
|
+
Parachain: paraId
|
|
3736
|
+
}, accountPayload]
|
|
3737
|
+
}
|
|
3738
|
+
};
|
|
3739
|
+
}
|
|
3740
|
+
return {
|
|
3741
|
+
parents: Parents.ZERO,
|
|
3742
|
+
interior: createX1Payload(version, accountPayload)
|
|
3743
|
+
};
|
|
3744
|
+
};
|
|
3745
|
+
var createBeneficiaryLocation = function createBeneficiaryLocation(_ref2) {
|
|
3746
|
+
var api = _ref2.api,
|
|
3747
|
+
address = _ref2.address,
|
|
3748
|
+
version = _ref2.version;
|
|
3749
|
+
if (isTLocation(address)) return address;
|
|
3750
|
+
var accountPayload = createAccountPayload(api, address);
|
|
3751
|
+
return {
|
|
3752
|
+
parents: Parents.ZERO,
|
|
3753
|
+
interior: createX1Payload(version, accountPayload)
|
|
3754
|
+
};
|
|
3755
|
+
};
|
|
3756
|
+
|
|
3757
|
+
var createDestination = function createDestination(api, version, origin, destination, chainId, junction, parents) {
|
|
3758
|
+
var isLocDestination = isTLocation(destination);
|
|
3759
|
+
var isSubBridge = !isLocDestination && !isExternalChain(destination) && isSubstrateBridge(origin, destination);
|
|
3760
|
+
if (isSubBridge) {
|
|
3761
|
+
return {
|
|
3762
|
+
parents: Parents.TWO,
|
|
3763
|
+
interior: {
|
|
3764
|
+
X2: [{
|
|
3765
|
+
GlobalConsensus: api.getRelayChainOf(destination)
|
|
3766
|
+
}, {
|
|
3767
|
+
Parachain: chainId
|
|
3768
|
+
}]
|
|
3769
|
+
}
|
|
3770
|
+
};
|
|
3771
|
+
}
|
|
3772
|
+
var isExternalDestination = !isLocDestination && isExternalChain(destination);
|
|
3773
|
+
if (isExternalDestination) {
|
|
3774
|
+
return {
|
|
3775
|
+
parents: Parents.TWO,
|
|
3776
|
+
interior: {
|
|
3777
|
+
X1: [getEthereumJunction(api, origin)]
|
|
3778
|
+
}
|
|
3779
|
+
};
|
|
3780
|
+
}
|
|
3781
|
+
var scenario = resolveScenario(origin, destination);
|
|
3782
|
+
var parentsResolved = parents !== null && parents !== void 0 ? parents : scenario === 'RelayToPara' ? Parents.ZERO : Parents.ONE;
|
|
3783
|
+
var interior = scenario === 'ParaToRelay' ? 'Here' : createX1Payload(version, junction !== null && junction !== void 0 ? junction : {
|
|
3784
|
+
Parachain: chainId
|
|
3785
|
+
});
|
|
3786
|
+
return isLocDestination ? destination : {
|
|
3787
|
+
parents: parentsResolved,
|
|
3788
|
+
interior: interior
|
|
3789
|
+
};
|
|
3790
|
+
};
|
|
3791
|
+
var createVersionedDestination = function createVersionedDestination(api, version, origin, destination, chainId, junction, parents) {
|
|
3792
|
+
var plainDestination = createDestination(api, version, origin, destination, chainId, junction, parents);
|
|
3793
|
+
return addXcmVersionHeader(plainDestination, version);
|
|
3794
|
+
};
|
|
3795
|
+
|
|
3796
|
+
var getChainLocation = function getChainLocation(chain, destChain, customCtx) {
|
|
3797
|
+
var fromRelay = isRelayChain(chain);
|
|
3798
|
+
var toRelay = isRelayChain(destChain);
|
|
3799
|
+
var parents = fromRelay ? Parents.ZERO : Parents.ONE;
|
|
3800
|
+
var interior = toRelay ? 'Here' : {
|
|
3801
|
+
X1: [{
|
|
3802
|
+
Parachain: getParaIdImpl(destChain, customCtx)
|
|
3803
|
+
}]
|
|
3804
|
+
};
|
|
3805
|
+
return {
|
|
3806
|
+
parents: parents,
|
|
3807
|
+
interior: interior
|
|
3808
|
+
};
|
|
3809
|
+
};
|
|
3810
|
+
|
|
3811
|
+
/**
|
|
3812
|
+
* This function localizes a location by removing the `Parachain` junction
|
|
3813
|
+
* if it exists. The `parents` field is set to `0` either if a `Parachain` was removed
|
|
3814
|
+
* or if the resulting interior is `'Here'` and the chain is a relay chain.
|
|
3815
|
+
*
|
|
3816
|
+
* @param chain - The current chain
|
|
3817
|
+
* @param location - The location to localize
|
|
3818
|
+
* @returns The localized location
|
|
3819
|
+
*/
|
|
3820
|
+
var localizeLocationInner = function localizeLocationInner(chain, location, origin, resolveRelay, resolveParaId) {
|
|
3821
|
+
var _Object$keys$;
|
|
3822
|
+
var targetRelay = isExternalChain(chain) ? undefined : resolveRelay(chain).toLowerCase();
|
|
3823
|
+
var originRelay = origin && !isExternalChain(origin) ? resolveRelay(origin).toLowerCase() : undefined;
|
|
3824
|
+
var locationConsensus = getJunctionValue(location, 'GlobalConsensus');
|
|
3825
|
+
var locationRelay = locationConsensus ? (_Object$keys$ = Object.keys(locationConsensus)[0]) === null || _Object$keys$ === void 0 ? void 0 : _Object$keys$.toLowerCase() : undefined;
|
|
3826
|
+
var ecosystemDiffers = targetRelay && originRelay && originRelay !== targetRelay;
|
|
3827
|
+
var junctions = location.interior === 'Here' ? [] : flattenJunctions(location.interior);
|
|
3828
|
+
var junctionCount = junctions.length;
|
|
3829
|
+
var isLocationOnTargetRelay = targetRelay !== undefined && locationRelay === targetRelay;
|
|
3830
|
+
// Check if target is an external chain and location's GlobalConsensus matches it
|
|
3831
|
+
var isLocationOnTargetExternal = isExternalChain(chain) && locationRelay === chain.toLowerCase();
|
|
3832
|
+
var isConsensusAnchored = junctions.findIndex(function (junction) {
|
|
3833
|
+
return 'GlobalConsensus' in junction;
|
|
3834
|
+
}) === 0;
|
|
3835
|
+
if (locationRelay && targetRelay && locationRelay !== targetRelay && (!origin || !ecosystemDiffers && isConsensusAnchored)) {
|
|
3836
|
+
return location;
|
|
3837
|
+
}
|
|
3838
|
+
if (origin && ecosystemDiffers && location.parents === Parents.TWO && originRelay !== undefined && targetRelay !== undefined && deepEqual(getJunctionValue(location, 'GlobalConsensus'), _defineProperty({}, targetRelay, null)) && junctionCount === 1) {
|
|
3839
|
+
return RELAY_LOCATION;
|
|
3840
|
+
}
|
|
3841
|
+
var newInterior = location.interior;
|
|
3842
|
+
var parachainRemoved = false;
|
|
3843
|
+
if (location.interior !== 'Here') {
|
|
3844
|
+
var paraId = resolveParaId(chain);
|
|
3845
|
+
var filteredJunctions = junctions.filter(function (junction) {
|
|
3846
|
+
if ('GlobalConsensus' in junction && (isLocationOnTargetRelay || isLocationOnTargetExternal)) {
|
|
3847
|
+
return false;
|
|
3848
|
+
}
|
|
3849
|
+
if ('Parachain' in junction && (!ecosystemDiffers || isLocationOnTargetRelay)) {
|
|
3850
|
+
var paraJunctionId = getJunctionValue(location, 'Parachain');
|
|
3851
|
+
if (paraJunctionId === paraId) {
|
|
3852
|
+
parachainRemoved = true;
|
|
3853
|
+
return false;
|
|
3854
|
+
}
|
|
3855
|
+
}
|
|
3856
|
+
return true;
|
|
3857
|
+
});
|
|
3858
|
+
if (filteredJunctions.length === 0) {
|
|
3859
|
+
newInterior = 'Here';
|
|
3860
|
+
} else {
|
|
3861
|
+
newInterior = _defineProperty({}, "X".concat(filteredJunctions.length), filteredJunctions);
|
|
3862
|
+
}
|
|
3863
|
+
}
|
|
3864
|
+
var isOriginRelayHere = deepEqual(location, RELAY_LOCATION);
|
|
3865
|
+
var hasGlobalConsensus = hasJunction(location, 'GlobalConsensus');
|
|
3866
|
+
if (origin && isExternalChain(chain) && originRelay !== undefined && isOriginRelayHere && !hasGlobalConsensus) {
|
|
3867
|
+
return {
|
|
3868
|
+
parents: Parents.ONE,
|
|
3869
|
+
interior: {
|
|
3870
|
+
X1: [{
|
|
3871
|
+
GlobalConsensus: _defineProperty({}, originRelay, null)
|
|
3872
|
+
}]
|
|
3873
|
+
}
|
|
3874
|
+
};
|
|
3875
|
+
}
|
|
3876
|
+
if (isExternalChain(chain) && location.parents === Parents.TWO && RELAYCHAINS.some(function (relay) {
|
|
3877
|
+
return deepEqual(getJunctionValue(location, 'GlobalConsensus'), _defineProperty({}, relay.toLowerCase(), null));
|
|
3878
|
+
})) {
|
|
3879
|
+
return _objectSpread2(_objectSpread2({}, location), {}, {
|
|
3880
|
+
parents: Parents.ONE
|
|
3881
|
+
});
|
|
3882
|
+
}
|
|
3883
|
+
if (origin && ecosystemDiffers && isOriginRelayHere && !hasGlobalConsensus && originRelay !== undefined) {
|
|
3884
|
+
return {
|
|
3885
|
+
parents: Parents.TWO,
|
|
3886
|
+
interior: {
|
|
3887
|
+
X2: [{
|
|
3888
|
+
GlobalConsensus: _defineProperty({}, originRelay, null)
|
|
3889
|
+
}, {
|
|
3890
|
+
Parachain: resolveParaId(origin)
|
|
3891
|
+
}]
|
|
3892
|
+
}
|
|
3893
|
+
};
|
|
3894
|
+
}
|
|
3895
|
+
if (origin && ecosystemDiffers && newInterior !== 'Here' && !hasGlobalConsensus && originRelay !== undefined) {
|
|
3896
|
+
var _junctions = flattenJunctions(newInterior);
|
|
3897
|
+
var updatedJunctions = [{
|
|
3898
|
+
GlobalConsensus: _defineProperty({}, originRelay, null)
|
|
3899
|
+
}].concat(_toConsumableArray(_junctions));
|
|
3900
|
+
return {
|
|
3901
|
+
parents: Parents.TWO,
|
|
3902
|
+
interior: _defineProperty({}, "X".concat(updatedJunctions.length), updatedJunctions)
|
|
3903
|
+
};
|
|
3904
|
+
}
|
|
3905
|
+
var shouldSetParentsToZero = parachainRemoved || newInterior === 'Here' && isRelayChain(chain) || isLocationOnTargetExternal;
|
|
3906
|
+
return {
|
|
3907
|
+
parents: shouldSetParentsToZero ? Parents.ZERO : location.parents,
|
|
3908
|
+
interior: newInterior
|
|
3909
|
+
};
|
|
3910
|
+
};
|
|
3911
|
+
var localizeLocation = function localizeLocation(chain, location, origin) {
|
|
3912
|
+
return localizeLocationInner(chain, location, origin, function (c) {
|
|
3913
|
+
return getRelayChainOf(c);
|
|
3914
|
+
}, function (c) {
|
|
3915
|
+
return getParaId(c);
|
|
3916
|
+
});
|
|
3917
|
+
};
|
|
3918
|
+
var localizeLocationImpl = function localizeLocationImpl(api, chain, location, origin) {
|
|
3919
|
+
return localizeLocationInner(chain, location, origin, function (c) {
|
|
3920
|
+
return getRelayChainOfImpl(api, c);
|
|
3921
|
+
}, function (c) {
|
|
3922
|
+
return getParaIdImpl(c, api._customCtx);
|
|
3923
|
+
});
|
|
3924
|
+
};
|
|
3925
|
+
|
|
3926
|
+
var reverseTransformLocation = function reverseTransformLocation(location) {
|
|
3927
|
+
var parachainJunction = {
|
|
3928
|
+
Parachain: 1000
|
|
3929
|
+
};
|
|
3930
|
+
var alreadyHasP1000 = location.interior !== 'Here' && Object.values(location.interior).flat().some(function (j) {
|
|
3931
|
+
return _typeof(j) === 'object' && j !== null && 'Parachain' in j && j.Parachain === 1000;
|
|
3932
|
+
});
|
|
3933
|
+
if (alreadyHasP1000) {
|
|
3934
|
+
return _objectSpread2(_objectSpread2({}, location), {}, {
|
|
3935
|
+
parents: Parents.ONE
|
|
3936
|
+
});
|
|
3937
|
+
}
|
|
3938
|
+
var existingJunctions = location.interior === 'Here' ? [] // no other junctions
|
|
3939
|
+
: Object.values(location.interior).flat();
|
|
3940
|
+
var allJunctions = [parachainJunction].concat(_toConsumableArray(existingJunctions));
|
|
3941
|
+
return _objectSpread2(_objectSpread2({}, location), {}, {
|
|
3942
|
+
parents: Parents.ONE,
|
|
3943
|
+
interior: _defineProperty({}, "X".concat(allJunctions.length), allJunctions)
|
|
3944
|
+
});
|
|
3945
|
+
};
|
|
3946
|
+
|
|
3947
|
+
var EMPTY_TOPIC = "0x".concat('00'.repeat(32));
|
|
3948
|
+
var getBridgeDestFee = /*#__PURE__*/function () {
|
|
3949
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, destApi, origin, destination, assetInfo, feeAssetInfo, hasSystemFeeAsset, recipient, version) {
|
|
3950
|
+
var systemAsset, transferredAsset, assets, destIsReserve, feeAssetLocation, buyExecution, depositAsset, feesSplitFromAssets, prologue, xcm;
|
|
3951
|
+
return _regenerator().w(function (_context) {
|
|
3952
|
+
while (1) switch (_context.n) {
|
|
3953
|
+
case 0:
|
|
3954
|
+
systemAsset = createAsset(version, MIN_AMOUNT, RELAY_LOCATION);
|
|
3955
|
+
transferredAsset = createAsset(version, assetInfo.amount, normalizeLocation(api.localizeLocation(origin, assetInfo.location), version));
|
|
3956
|
+
assets = hasSystemFeeAsset ? sortAssets([systemAsset, transferredAsset]) : [transferredAsset];
|
|
3957
|
+
destIsReserve = hasSystemFeeAsset ? destination === 'AssetHubPolkadot' : deepEqual(getJunctionValue(assetInfo.location, 'GlobalConsensus'), _defineProperty({}, getRelayChainOf(destination).toLowerCase(), null));
|
|
3958
|
+
feeAssetLocation = hasSystemFeeAsset ? RELAY_LOCATION : assetInfo.location;
|
|
3959
|
+
buyExecution = {
|
|
3960
|
+
BuyExecution: {
|
|
3961
|
+
fees: createAsset(version, MIN_AMOUNT, api.localizeLocation(destination, feeAssetLocation, origin)),
|
|
3962
|
+
weight_limit: 'Unlimited'
|
|
3963
|
+
}
|
|
3964
|
+
};
|
|
3965
|
+
depositAsset = {
|
|
3966
|
+
DepositAsset: {
|
|
3967
|
+
assets: {
|
|
3968
|
+
Wild: hasSystemFeeAsset ? {
|
|
3969
|
+
AllOf: {
|
|
3970
|
+
id: api.localizeLocation(destination, assetInfo.location, origin),
|
|
3971
|
+
fun: 'Fungible'
|
|
3972
|
+
}
|
|
3973
|
+
} : {
|
|
3974
|
+
AllCounted: 1
|
|
3975
|
+
}
|
|
3976
|
+
},
|
|
3977
|
+
beneficiary: createBeneficiaryLocation({
|
|
3978
|
+
api: destApi,
|
|
3979
|
+
address: recipient,
|
|
3980
|
+
version: version
|
|
3981
|
+
})
|
|
3982
|
+
}
|
|
3983
|
+
};
|
|
3984
|
+
feesSplitFromAssets = destIsReserve && hasSystemFeeAsset;
|
|
3985
|
+
prologue = feesSplitFromAssets ? [{
|
|
3986
|
+
ReserveAssetDeposited: [systemAsset]
|
|
3987
|
+
}, buyExecution, {
|
|
3988
|
+
WithdrawAsset: [transferredAsset]
|
|
3989
|
+
}, {
|
|
3990
|
+
ClearOrigin: null
|
|
3991
|
+
}] : [destIsReserve ? {
|
|
3992
|
+
WithdrawAsset: assets
|
|
3993
|
+
} : {
|
|
3994
|
+
ReserveAssetDeposited: assets
|
|
3995
|
+
}, {
|
|
3996
|
+
ClearOrigin: null
|
|
3997
|
+
}, buyExecution];
|
|
3998
|
+
xcm = [].concat(prologue, [buyExecution, depositAsset, {
|
|
3999
|
+
SetTopic: EMPTY_TOPIC
|
|
4000
|
+
}]);
|
|
4001
|
+
return _context.a(2, destApi.getXcmPaymentApiFee(destination, addXcmVersionHeader(xcm, version), [], feeAssetInfo, version, true));
|
|
4002
|
+
}
|
|
4003
|
+
}, _callee);
|
|
4004
|
+
}));
|
|
4005
|
+
return function getBridgeDestFee(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8, _x9) {
|
|
4006
|
+
return _ref.apply(this, arguments);
|
|
4007
|
+
};
|
|
4008
|
+
}();
|
|
4009
|
+
|
|
3690
4010
|
var evmExtension;
|
|
3691
4011
|
var registerEvmExtension = function registerEvmExtension(extension) {
|
|
3692
4012
|
evmExtension = extension;
|
|
@@ -5808,17 +6128,18 @@ var addEthereumBridgeFees = /*#__PURE__*/function () {
|
|
|
5808
6128
|
}();
|
|
5809
6129
|
|
|
5810
6130
|
var dryRunInternal = /*#__PURE__*/function () {
|
|
5811
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
5812
|
-
var
|
|
5813
|
-
|
|
5814
|
-
|
|
6131
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
|
|
6132
|
+
var _traversalResult$dest;
|
|
6133
|
+
var api, origin, destination, currency, tx, sender, feeAsset, swapConfig, version, bypassOptions, keepAlive, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, _resolveCurrency, assets, asset, amount, resolvedVersion, originDryRun, isMythosToEthereum, originDryModified, initialForwardedXcms, initialDestParaId, processHop, traversalResult, relayChain, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, bridgeHubHopIndex, resolveBridgeDestination, result, dryRunError, _t4, _t5, _t6, _t7, _t8, _t9, _t0, _t1, _t10, _t11, _t12, _t13, _t14;
|
|
6134
|
+
return _regenerator().w(function (_context3) {
|
|
6135
|
+
while (1) switch (_context3.n) {
|
|
5815
6136
|
case 0:
|
|
5816
6137
|
api = options.api, origin = options.origin, destination = options.destination, currency = options.currency, tx = options.tx, sender = options.sender, feeAsset = options.feeAsset, swapConfig = options.swapConfig, version = options.version, bypassOptions = options.bypassOptions, keepAlive = options.keepAlive, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi;
|
|
5817
6138
|
resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
|
|
5818
6139
|
_resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination), assets = _resolveCurrency.assets, asset = _resolveCurrency.asset;
|
|
5819
6140
|
amount = asset.amount;
|
|
5820
6141
|
resolvedVersion = pickCompatibleXcmVersion(api, origin, destination, version);
|
|
5821
|
-
|
|
6142
|
+
_context3.n = 1;
|
|
5822
6143
|
return api.getDryRunCall({
|
|
5823
6144
|
tx: tx,
|
|
5824
6145
|
chain: origin,
|
|
@@ -5835,12 +6156,12 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5835
6156
|
useRootOrigin: useRootOrigin || !!bypassOptions
|
|
5836
6157
|
});
|
|
5837
6158
|
case 1:
|
|
5838
|
-
originDryRun =
|
|
6159
|
+
originDryRun = _context3.v;
|
|
5839
6160
|
if (originDryRun.success) {
|
|
5840
|
-
|
|
6161
|
+
_context3.n = 2;
|
|
5841
6162
|
break;
|
|
5842
6163
|
}
|
|
5843
|
-
return
|
|
6164
|
+
return _context3.a(2, {
|
|
5844
6165
|
success: false,
|
|
5845
6166
|
dryRunError: _objectSpread2({
|
|
5846
6167
|
chainKind: 'origin',
|
|
@@ -5852,27 +6173,27 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5852
6173
|
case 2:
|
|
5853
6174
|
isMythosToEthereum = origin === 'Mythos' && destination === 'Ethereum';
|
|
5854
6175
|
if (!isMythosToEthereum) {
|
|
5855
|
-
|
|
6176
|
+
_context3.n = 4;
|
|
5856
6177
|
break;
|
|
5857
6178
|
}
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
6179
|
+
_t5 = _objectSpread2;
|
|
6180
|
+
_t6 = _objectSpread2({}, originDryRun);
|
|
6181
|
+
_t7 = {};
|
|
6182
|
+
_t8 = originDryRun.fee;
|
|
6183
|
+
_context3.n = 3;
|
|
5863
6184
|
return getMythosOriginFee(api);
|
|
5864
6185
|
case 3:
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
fee:
|
|
6186
|
+
_t9 = _context3.v;
|
|
6187
|
+
_t0 = _t8 + _t9;
|
|
6188
|
+
_t4 = _t5(_t6, _t7, {
|
|
6189
|
+
fee: _t0
|
|
5869
6190
|
});
|
|
5870
|
-
|
|
6191
|
+
_context3.n = 5;
|
|
5871
6192
|
break;
|
|
5872
6193
|
case 4:
|
|
5873
|
-
|
|
6194
|
+
_t4 = originDryRun;
|
|
5874
6195
|
case 5:
|
|
5875
|
-
originDryModified =
|
|
6196
|
+
originDryModified = _t4;
|
|
5876
6197
|
initialForwardedXcms = originDryModified.forwardedXcms, initialDestParaId = originDryModified.destParaId;
|
|
5877
6198
|
processHop = /*#__PURE__*/function () {
|
|
5878
6199
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
|
|
@@ -5930,7 +6251,7 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5930
6251
|
return _ref2.apply(this, arguments);
|
|
5931
6252
|
};
|
|
5932
6253
|
}();
|
|
5933
|
-
|
|
6254
|
+
_context3.n = 6;
|
|
5934
6255
|
return traverseXcmHops({
|
|
5935
6256
|
api: api,
|
|
5936
6257
|
origin: origin,
|
|
@@ -5951,7 +6272,7 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5951
6272
|
}
|
|
5952
6273
|
});
|
|
5953
6274
|
case 6:
|
|
5954
|
-
traversalResult =
|
|
6275
|
+
traversalResult = _context3.v;
|
|
5955
6276
|
// Process Ethereum bridge fees
|
|
5956
6277
|
relayChain = api.getRelayChainOf(origin);
|
|
5957
6278
|
bridgeHubChain = relayChain === 'Paseo' ? undefined : "BridgeHub".concat(relayChain);
|
|
@@ -5960,29 +6281,29 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5960
6281
|
return hop.chain === bridgeHubChain;
|
|
5961
6282
|
}); // For Mythos → Ethereum, we skip additional Ethereum bridge fees (aligns with getXcmFeeInternal)
|
|
5962
6283
|
if (!isMythosToEthereum) {
|
|
5963
|
-
|
|
6284
|
+
_context3.n = 7;
|
|
5964
6285
|
break;
|
|
5965
6286
|
}
|
|
5966
|
-
|
|
5967
|
-
|
|
6287
|
+
_t1 = bridgeHubHop === null || bridgeHubHop === void 0 ? void 0 : bridgeHubHop.result;
|
|
6288
|
+
_context3.n = 11;
|
|
5968
6289
|
break;
|
|
5969
6290
|
case 7:
|
|
5970
6291
|
if (!(bridgeHubHop !== null && bridgeHubHop !== void 0 && bridgeHubHop.result.success)) {
|
|
5971
|
-
|
|
6292
|
+
_context3.n = 9;
|
|
5972
6293
|
break;
|
|
5973
6294
|
}
|
|
5974
|
-
|
|
6295
|
+
_context3.n = 8;
|
|
5975
6296
|
return addEthereumBridgeFees(api, bridgeHubHop === null || bridgeHubHop === void 0 ? void 0 : bridgeHubHop.result, destination, assetHubChain);
|
|
5976
6297
|
case 8:
|
|
5977
|
-
|
|
5978
|
-
|
|
6298
|
+
_t10 = _context3.v;
|
|
6299
|
+
_context3.n = 10;
|
|
5979
6300
|
break;
|
|
5980
6301
|
case 9:
|
|
5981
|
-
|
|
6302
|
+
_t10 = bridgeHubHop === null || bridgeHubHop === void 0 ? void 0 : bridgeHubHop.result;
|
|
5982
6303
|
case 10:
|
|
5983
|
-
|
|
6304
|
+
_t1 = _t10;
|
|
5984
6305
|
case 11:
|
|
5985
|
-
processedBridgeHub =
|
|
6306
|
+
processedBridgeHub = _t1;
|
|
5986
6307
|
// Update bridge hub in hops if needed
|
|
5987
6308
|
if (processedBridgeHub && processedBridgeHub.success && bridgeHubHop && bridgeHubHop.result.success && processedBridgeHub.fee !== bridgeHubHop.result.fee) {
|
|
5988
6309
|
bridgeHubHopIndex = traversalResult.hops.findIndex(function (hop) {
|
|
@@ -5994,10 +6315,67 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5994
6315
|
});
|
|
5995
6316
|
}
|
|
5996
6317
|
}
|
|
6318
|
+
resolveBridgeDestination = /*#__PURE__*/function () {
|
|
6319
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
6320
|
+
var _api$findAssetInfoOnD;
|
|
6321
|
+
var destApi, systemAsset, hasSystemFeeAsset, destAsset, _t, _t2, _t3;
|
|
6322
|
+
return _regenerator().w(function (_context2) {
|
|
6323
|
+
while (1) switch (_context2.n) {
|
|
6324
|
+
case 0:
|
|
6325
|
+
if (!(isExternalChain(destination) || !isSubstrateBridge(origin, destination))) {
|
|
6326
|
+
_context2.n = 1;
|
|
6327
|
+
break;
|
|
6328
|
+
}
|
|
6329
|
+
return _context2.a(2, undefined);
|
|
6330
|
+
case 1:
|
|
6331
|
+
destApi = api.clone();
|
|
6332
|
+
_context2.n = 2;
|
|
6333
|
+
return destApi.init(destination);
|
|
6334
|
+
case 2:
|
|
6335
|
+
systemAsset = api.findNativeAssetInfoOrThrow(api.getRelayChainOf(origin));
|
|
6336
|
+
hasSystemFeeAsset = deepEqual(getJunctionValue(asset.location, 'GlobalConsensus'), getEthereumJunction(api, origin, false).GlobalConsensus);
|
|
6337
|
+
destAsset = hasSystemFeeAsset ? api.findAssetInfoOrThrow(destination, {
|
|
6338
|
+
symbol: systemAsset.symbol
|
|
6339
|
+
}) : (_api$findAssetInfoOnD = api.findAssetInfoOnDest(origin, destination, currency, asset)) !== null && _api$findAssetInfoOnD !== void 0 ? _api$findAssetInfoOnD : asset;
|
|
6340
|
+
_context2.n = 3;
|
|
6341
|
+
return getBridgeDestFee(api, destApi, origin, destination, asset, destAsset, hasSystemFeeAsset, sender, resolvedVersion);
|
|
6342
|
+
case 3:
|
|
6343
|
+
_t = _context2.v;
|
|
6344
|
+
_t2 = destAsset;
|
|
6345
|
+
_t3 = [];
|
|
6346
|
+
return _context2.a(2, {
|
|
6347
|
+
success: true,
|
|
6348
|
+
fee: _t,
|
|
6349
|
+
asset: _t2,
|
|
6350
|
+
forwardedXcms: _t3
|
|
6351
|
+
});
|
|
6352
|
+
}
|
|
6353
|
+
}, _callee2);
|
|
6354
|
+
}));
|
|
6355
|
+
return function resolveBridgeDestination() {
|
|
6356
|
+
return _ref3.apply(this, arguments);
|
|
6357
|
+
};
|
|
6358
|
+
}();
|
|
6359
|
+
_t11 = originDryModified;
|
|
6360
|
+
if (!((_traversalResult$dest = traversalResult.destination) !== null && _traversalResult$dest !== void 0)) {
|
|
6361
|
+
_context3.n = 12;
|
|
6362
|
+
break;
|
|
6363
|
+
}
|
|
6364
|
+
_t12 = _traversalResult$dest;
|
|
6365
|
+
_context3.n = 14;
|
|
6366
|
+
break;
|
|
6367
|
+
case 12:
|
|
6368
|
+
_context3.n = 13;
|
|
6369
|
+
return resolveBridgeDestination();
|
|
6370
|
+
case 13:
|
|
6371
|
+
_t12 = _context3.v;
|
|
6372
|
+
case 14:
|
|
6373
|
+
_t13 = _t12;
|
|
6374
|
+
_t14 = traversalResult.hops;
|
|
5997
6375
|
result = {
|
|
5998
|
-
origin:
|
|
5999
|
-
destination:
|
|
6000
|
-
hops:
|
|
6376
|
+
origin: _t11,
|
|
6377
|
+
destination: _t13,
|
|
6378
|
+
hops: _t14
|
|
6001
6379
|
};
|
|
6002
6380
|
dryRunError = getDryRunError({
|
|
6003
6381
|
origin: {
|
|
@@ -6010,12 +6388,12 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
6010
6388
|
} : undefined,
|
|
6011
6389
|
hops: result.hops
|
|
6012
6390
|
});
|
|
6013
|
-
return
|
|
6391
|
+
return _context3.a(2, _objectSpread2({
|
|
6014
6392
|
success: !dryRunError,
|
|
6015
6393
|
dryRunError: dryRunError
|
|
6016
6394
|
}, result));
|
|
6017
6395
|
}
|
|
6018
|
-
},
|
|
6396
|
+
}, _callee3);
|
|
6019
6397
|
}));
|
|
6020
6398
|
return function dryRunInternal(_x) {
|
|
6021
6399
|
return _ref.apply(this, arguments);
|
|
@@ -6645,7 +7023,7 @@ var getOriginXcmFee = /*#__PURE__*/function () {
|
|
|
6645
7023
|
|
|
6646
7024
|
var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
6647
7025
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
|
|
6648
|
-
var api, tx, origin, destination, sender, recipient, currency, feeAsset, version, disableFallback, swapConfig, useRootOrigin, skipReverseFeeCalculation, resolvedFeeAsset, _resolveCurrency, asset, resolvedVersion, _yield$getOriginXcmFe, originFeeRaw, originAsset, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, isMythosToEthereum, originFee, destApi, destFeeRes, _result, _dryRunError, processHop, traversalResult, destFee, destAsset, destFeeType, destDryRunError, destSufficient, destResult, _destApi, destFallback, relayChain, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, bridgeHubHopIndex, convertToFeeDetail, result, dryRunError, _t, _t2, _t3, _t4;
|
|
7026
|
+
var api, tx, origin, destination, sender, recipient, currency, feeAsset, version, disableFallback, swapConfig, useRootOrigin, skipReverseFeeCalculation, resolvedFeeAsset, _resolveCurrency, asset, resolvedVersion, _yield$getOriginXcmFe, originFeeRaw, originAsset, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, isMythosToEthereum, originFee, destApi, destFeeRes, _result, _dryRunError, processHop, traversalResult, destFee, destAsset, destFeeType, destDryRunError, destSufficient, destResult, _destApi, destFallback, _api$findAssetInfoOnD, _destApi2, systemAsset, hasSystemFeeAsset, relayChain, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, bridgeHubHopIndex, convertToFeeDetail, result, dryRunError, _t, _t2, _t3, _t4;
|
|
6649
7027
|
return _regenerator().w(function (_context2) {
|
|
6650
7028
|
while (1) switch (_context2.p = _context2.n) {
|
|
6651
7029
|
case 0:
|
|
@@ -6857,7 +7235,7 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
|
6857
7235
|
destDryRunError = destResult.dryRunError;
|
|
6858
7236
|
destSufficient = destResult.sufficient;
|
|
6859
7237
|
destAsset = destResult.asset;
|
|
6860
|
-
_context2.n =
|
|
7238
|
+
_context2.n = 19;
|
|
6861
7239
|
break;
|
|
6862
7240
|
case 12:
|
|
6863
7241
|
if (!(traversalResult.hops.length > 0 && traversalResult.hops[traversalResult.hops.length - 1].result.dryRunError)) {
|
|
@@ -6896,14 +7274,36 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
|
6896
7274
|
destFeeType = destFallback.feeType;
|
|
6897
7275
|
destSufficient = destFallback.sufficient;
|
|
6898
7276
|
destAsset = api.findNativeAssetInfoOrThrow(destination);
|
|
6899
|
-
_context2.n =
|
|
7277
|
+
_context2.n = 19;
|
|
6900
7278
|
break;
|
|
6901
7279
|
case 15:
|
|
7280
|
+
if (!(!isExternalChain(destination) && isSubstrateBridge(origin, destination))) {
|
|
7281
|
+
_context2.n = 18;
|
|
7282
|
+
break;
|
|
7283
|
+
}
|
|
7284
|
+
_destApi2 = api.clone();
|
|
7285
|
+
_context2.n = 16;
|
|
7286
|
+
return _destApi2.init(destination, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
7287
|
+
case 16:
|
|
7288
|
+
systemAsset = api.findNativeAssetInfoOrThrow(api.getRelayChainOf(origin));
|
|
7289
|
+
hasSystemFeeAsset = deepEqual(getJunctionValue(asset.location, 'GlobalConsensus'), getEthereumJunction(api, origin, false).GlobalConsensus);
|
|
7290
|
+
destAsset = hasSystemFeeAsset ? api.findAssetInfoOrThrow(destination, {
|
|
7291
|
+
symbol: systemAsset.symbol
|
|
7292
|
+
}) : (_api$findAssetInfoOnD = api.findAssetInfoOnDest(origin, destination, currency, asset)) !== null && _api$findAssetInfoOnD !== void 0 ? _api$findAssetInfoOnD : asset;
|
|
7293
|
+
_context2.n = 17;
|
|
7294
|
+
return getBridgeDestFee(api, _destApi2, origin, destination, asset, destAsset, hasSystemFeeAsset, recipient, resolvedVersion);
|
|
7295
|
+
case 17:
|
|
7296
|
+
destFee = _context2.v;
|
|
7297
|
+
destFeeType = 'dryRun';
|
|
7298
|
+
destSufficient = true;
|
|
7299
|
+
_context2.n = 19;
|
|
7300
|
+
break;
|
|
7301
|
+
case 18:
|
|
6902
7302
|
destFee = 0n;
|
|
6903
7303
|
destFeeType = 'noFeeRequired';
|
|
6904
7304
|
destSufficient = true;
|
|
6905
7305
|
destAsset = api.findNativeAssetInfoOrThrow(destination);
|
|
6906
|
-
case
|
|
7306
|
+
case 19:
|
|
6907
7307
|
// Process Ethereum bridge fees
|
|
6908
7308
|
relayChain = api.getRelayChainOf(origin);
|
|
6909
7309
|
bridgeHubChain = relayChain === 'Paseo' ? undefined : "BridgeHub".concat(relayChain);
|
|
@@ -6912,18 +7312,18 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
|
|
|
6912
7312
|
return hop.chain === bridgeHubChain;
|
|
6913
7313
|
});
|
|
6914
7314
|
if (!isMythosToEthereum) {
|
|
6915
|
-
_context2.n =
|
|
7315
|
+
_context2.n = 20;
|
|
6916
7316
|
break;
|
|
6917
7317
|
}
|
|
6918
7318
|
_t4 = bridgeHubHop === null || bridgeHubHop === void 0 ? void 0 : bridgeHubHop.result;
|
|
6919
|
-
_context2.n =
|
|
7319
|
+
_context2.n = 22;
|
|
6920
7320
|
break;
|
|
6921
|
-
case
|
|
6922
|
-
_context2.n =
|
|
7321
|
+
case 20:
|
|
7322
|
+
_context2.n = 21;
|
|
6923
7323
|
return addEthereumBridgeFees(api, bridgeHubHop === null || bridgeHubHop === void 0 ? void 0 : bridgeHubHop.result, destination, assetHubChain);
|
|
6924
|
-
case
|
|
7324
|
+
case 21:
|
|
6925
7325
|
_t4 = _context2.v;
|
|
6926
|
-
case
|
|
7326
|
+
case 22:
|
|
6927
7327
|
processedBridgeHub = _t4;
|
|
6928
7328
|
// Update bridge hub fee in hops if needed
|
|
6929
7329
|
if (processedBridgeHub && bridgeHubHop && processedBridgeHub.fee !== bridgeHubHop.result.fee) {
|
|
@@ -7957,264 +8357,6 @@ var getTransferableAmount = /*#__PURE__*/function () {
|
|
|
7957
8357
|
};
|
|
7958
8358
|
}();
|
|
7959
8359
|
|
|
7960
|
-
var createX1Payload = function createX1Payload(version, junction) {
|
|
7961
|
-
return version === Version.V3 ? {
|
|
7962
|
-
X1: junction
|
|
7963
|
-
} : {
|
|
7964
|
-
X1: [junction]
|
|
7965
|
-
};
|
|
7966
|
-
};
|
|
7967
|
-
|
|
7968
|
-
var createAccountPayload = function createAccountPayload(api, address) {
|
|
7969
|
-
return isAddress(address) ? {
|
|
7970
|
-
AccountKey20: {
|
|
7971
|
-
key: address
|
|
7972
|
-
}
|
|
7973
|
-
} : {
|
|
7974
|
-
AccountId32: {
|
|
7975
|
-
id: api.accountToHex(address)
|
|
7976
|
-
}
|
|
7977
|
-
};
|
|
7978
|
-
};
|
|
7979
|
-
var createBeneficiaryLocXTokens = function createBeneficiaryLocXTokens(_ref) {
|
|
7980
|
-
var api = _ref.api,
|
|
7981
|
-
recipient = _ref.recipient,
|
|
7982
|
-
origin = _ref.origin,
|
|
7983
|
-
destination = _ref.destination,
|
|
7984
|
-
version = _ref.version,
|
|
7985
|
-
paraId = _ref.paraId;
|
|
7986
|
-
if (isTLocation(recipient)) {
|
|
7987
|
-
return recipient;
|
|
7988
|
-
}
|
|
7989
|
-
var scenario = resolveScenario(origin, destination);
|
|
7990
|
-
var accountPayload = createAccountPayload(api, recipient);
|
|
7991
|
-
if (scenario === 'ParaToRelay') {
|
|
7992
|
-
return {
|
|
7993
|
-
parents: Parents.ONE,
|
|
7994
|
-
interior: createX1Payload(version, {
|
|
7995
|
-
AccountId32: {
|
|
7996
|
-
id: api.accountToHex(recipient)
|
|
7997
|
-
}
|
|
7998
|
-
})
|
|
7999
|
-
};
|
|
8000
|
-
} else if (scenario === 'ParaToPara') {
|
|
8001
|
-
return {
|
|
8002
|
-
parents: Parents.ONE,
|
|
8003
|
-
interior: {
|
|
8004
|
-
X2: [{
|
|
8005
|
-
Parachain: paraId
|
|
8006
|
-
}, accountPayload]
|
|
8007
|
-
}
|
|
8008
|
-
};
|
|
8009
|
-
}
|
|
8010
|
-
return {
|
|
8011
|
-
parents: Parents.ZERO,
|
|
8012
|
-
interior: createX1Payload(version, accountPayload)
|
|
8013
|
-
};
|
|
8014
|
-
};
|
|
8015
|
-
var createBeneficiaryLocation = function createBeneficiaryLocation(_ref2) {
|
|
8016
|
-
var api = _ref2.api,
|
|
8017
|
-
address = _ref2.address,
|
|
8018
|
-
version = _ref2.version;
|
|
8019
|
-
if (isTLocation(address)) return address;
|
|
8020
|
-
var accountPayload = createAccountPayload(api, address);
|
|
8021
|
-
return {
|
|
8022
|
-
parents: Parents.ZERO,
|
|
8023
|
-
interior: createX1Payload(version, accountPayload)
|
|
8024
|
-
};
|
|
8025
|
-
};
|
|
8026
|
-
|
|
8027
|
-
var createDestination = function createDestination(api, version, origin, destination, chainId, junction, parents) {
|
|
8028
|
-
var isLocDestination = isTLocation(destination);
|
|
8029
|
-
var isSubBridge = !isLocDestination && !isExternalChain(destination) && isSubstrateBridge(origin, destination);
|
|
8030
|
-
if (isSubBridge) {
|
|
8031
|
-
return {
|
|
8032
|
-
parents: Parents.TWO,
|
|
8033
|
-
interior: {
|
|
8034
|
-
X2: [{
|
|
8035
|
-
GlobalConsensus: api.getRelayChainOf(destination)
|
|
8036
|
-
}, {
|
|
8037
|
-
Parachain: chainId
|
|
8038
|
-
}]
|
|
8039
|
-
}
|
|
8040
|
-
};
|
|
8041
|
-
}
|
|
8042
|
-
var isExternalDestination = !isLocDestination && isExternalChain(destination);
|
|
8043
|
-
if (isExternalDestination) {
|
|
8044
|
-
return {
|
|
8045
|
-
parents: Parents.TWO,
|
|
8046
|
-
interior: {
|
|
8047
|
-
X1: [getEthereumJunction(api, origin)]
|
|
8048
|
-
}
|
|
8049
|
-
};
|
|
8050
|
-
}
|
|
8051
|
-
var scenario = resolveScenario(origin, destination);
|
|
8052
|
-
var parentsResolved = parents !== null && parents !== void 0 ? parents : scenario === 'RelayToPara' ? Parents.ZERO : Parents.ONE;
|
|
8053
|
-
var interior = scenario === 'ParaToRelay' ? 'Here' : createX1Payload(version, junction !== null && junction !== void 0 ? junction : {
|
|
8054
|
-
Parachain: chainId
|
|
8055
|
-
});
|
|
8056
|
-
return isLocDestination ? destination : {
|
|
8057
|
-
parents: parentsResolved,
|
|
8058
|
-
interior: interior
|
|
8059
|
-
};
|
|
8060
|
-
};
|
|
8061
|
-
var createVersionedDestination = function createVersionedDestination(api, version, origin, destination, chainId, junction, parents) {
|
|
8062
|
-
var plainDestination = createDestination(api, version, origin, destination, chainId, junction, parents);
|
|
8063
|
-
return addXcmVersionHeader(plainDestination, version);
|
|
8064
|
-
};
|
|
8065
|
-
|
|
8066
|
-
var getChainLocation = function getChainLocation(chain, destChain, customCtx) {
|
|
8067
|
-
var fromRelay = isRelayChain(chain);
|
|
8068
|
-
var toRelay = isRelayChain(destChain);
|
|
8069
|
-
var parents = fromRelay ? Parents.ZERO : Parents.ONE;
|
|
8070
|
-
var interior = toRelay ? 'Here' : {
|
|
8071
|
-
X1: [{
|
|
8072
|
-
Parachain: getParaIdImpl(destChain, customCtx)
|
|
8073
|
-
}]
|
|
8074
|
-
};
|
|
8075
|
-
return {
|
|
8076
|
-
parents: parents,
|
|
8077
|
-
interior: interior
|
|
8078
|
-
};
|
|
8079
|
-
};
|
|
8080
|
-
|
|
8081
|
-
/**
|
|
8082
|
-
* This function localizes a location by removing the `Parachain` junction
|
|
8083
|
-
* if it exists. The `parents` field is set to `0` either if a `Parachain` was removed
|
|
8084
|
-
* or if the resulting interior is `'Here'` and the chain is a relay chain.
|
|
8085
|
-
*
|
|
8086
|
-
* @param chain - The current chain
|
|
8087
|
-
* @param location - The location to localize
|
|
8088
|
-
* @returns The localized location
|
|
8089
|
-
*/
|
|
8090
|
-
var localizeLocationInner = function localizeLocationInner(chain, location, origin, resolveRelay, resolveParaId) {
|
|
8091
|
-
var _Object$keys$;
|
|
8092
|
-
var targetRelay = isExternalChain(chain) ? undefined : resolveRelay(chain).toLowerCase();
|
|
8093
|
-
var originRelay = origin && !isExternalChain(origin) ? resolveRelay(origin).toLowerCase() : undefined;
|
|
8094
|
-
var locationConsensus = getJunctionValue(location, 'GlobalConsensus');
|
|
8095
|
-
var locationRelay = locationConsensus ? (_Object$keys$ = Object.keys(locationConsensus)[0]) === null || _Object$keys$ === void 0 ? void 0 : _Object$keys$.toLowerCase() : undefined;
|
|
8096
|
-
var ecosystemDiffers = targetRelay && originRelay && originRelay !== targetRelay;
|
|
8097
|
-
var junctions = location.interior === 'Here' ? [] : Object.values(location.interior).flat().filter(function (junction) {
|
|
8098
|
-
return _typeof(junction) === 'object' && junction !== null;
|
|
8099
|
-
});
|
|
8100
|
-
var junctionCount = junctions.length;
|
|
8101
|
-
var isLocationOnTargetRelay = targetRelay !== undefined && locationRelay === targetRelay;
|
|
8102
|
-
// Check if target is an external chain and location's GlobalConsensus matches it
|
|
8103
|
-
var isLocationOnTargetExternal = isExternalChain(chain) && locationRelay === chain.toLowerCase();
|
|
8104
|
-
if (!origin && locationRelay && targetRelay && locationRelay !== targetRelay) {
|
|
8105
|
-
return location;
|
|
8106
|
-
}
|
|
8107
|
-
if (origin && ecosystemDiffers && location.parents === Parents.TWO && originRelay !== undefined && targetRelay !== undefined && deepEqual(getJunctionValue(location, 'GlobalConsensus'), _defineProperty({}, targetRelay, null)) && junctionCount === 1) {
|
|
8108
|
-
return RELAY_LOCATION;
|
|
8109
|
-
}
|
|
8110
|
-
var newInterior = location.interior;
|
|
8111
|
-
var parachainRemoved = false;
|
|
8112
|
-
if (location.interior !== 'Here') {
|
|
8113
|
-
var paraId = resolveParaId(chain);
|
|
8114
|
-
var filteredJunctions = junctions.filter(function (junction) {
|
|
8115
|
-
if ('GlobalConsensus' in junction && (isLocationOnTargetRelay || isLocationOnTargetExternal)) {
|
|
8116
|
-
return false;
|
|
8117
|
-
}
|
|
8118
|
-
if ('Parachain' in junction && (!ecosystemDiffers || isLocationOnTargetRelay)) {
|
|
8119
|
-
var paraJunctionId = getJunctionValue(location, 'Parachain');
|
|
8120
|
-
if (paraJunctionId === paraId) {
|
|
8121
|
-
parachainRemoved = true;
|
|
8122
|
-
return false;
|
|
8123
|
-
}
|
|
8124
|
-
}
|
|
8125
|
-
return true;
|
|
8126
|
-
});
|
|
8127
|
-
if (filteredJunctions.length === 0) {
|
|
8128
|
-
newInterior = 'Here';
|
|
8129
|
-
} else {
|
|
8130
|
-
newInterior = _defineProperty({}, "X".concat(filteredJunctions.length), filteredJunctions);
|
|
8131
|
-
}
|
|
8132
|
-
}
|
|
8133
|
-
var isOriginRelayHere = deepEqual(location, RELAY_LOCATION);
|
|
8134
|
-
var hasGlobalConsensus = hasJunction(location, 'GlobalConsensus');
|
|
8135
|
-
if (origin && isExternalChain(chain) && originRelay !== undefined && isOriginRelayHere && !hasGlobalConsensus) {
|
|
8136
|
-
return {
|
|
8137
|
-
parents: Parents.ONE,
|
|
8138
|
-
interior: {
|
|
8139
|
-
X1: [{
|
|
8140
|
-
GlobalConsensus: _defineProperty({}, originRelay, null)
|
|
8141
|
-
}]
|
|
8142
|
-
}
|
|
8143
|
-
};
|
|
8144
|
-
}
|
|
8145
|
-
if (isExternalChain(chain) && location.parents === Parents.TWO && RELAYCHAINS.some(function (relay) {
|
|
8146
|
-
return deepEqual(getJunctionValue(location, 'GlobalConsensus'), _defineProperty({}, relay.toLowerCase(), null));
|
|
8147
|
-
})) {
|
|
8148
|
-
return _objectSpread2(_objectSpread2({}, location), {}, {
|
|
8149
|
-
parents: Parents.ONE
|
|
8150
|
-
});
|
|
8151
|
-
}
|
|
8152
|
-
if (origin && ecosystemDiffers && isOriginRelayHere && !hasGlobalConsensus && originRelay !== undefined) {
|
|
8153
|
-
return {
|
|
8154
|
-
parents: Parents.TWO,
|
|
8155
|
-
interior: {
|
|
8156
|
-
X2: [{
|
|
8157
|
-
GlobalConsensus: _defineProperty({}, originRelay, null)
|
|
8158
|
-
}, {
|
|
8159
|
-
Parachain: resolveParaId(origin)
|
|
8160
|
-
}]
|
|
8161
|
-
}
|
|
8162
|
-
};
|
|
8163
|
-
}
|
|
8164
|
-
if (origin && ecosystemDiffers && newInterior !== 'Here' && !hasGlobalConsensus && originRelay !== undefined) {
|
|
8165
|
-
var _junctions = Object.values(newInterior).flat().filter(function (junction) {
|
|
8166
|
-
return _typeof(junction) === 'object' && junction !== null;
|
|
8167
|
-
});
|
|
8168
|
-
var updatedJunctions = [{
|
|
8169
|
-
GlobalConsensus: _defineProperty({}, originRelay, null)
|
|
8170
|
-
}].concat(_toConsumableArray(_junctions));
|
|
8171
|
-
return {
|
|
8172
|
-
parents: Parents.TWO,
|
|
8173
|
-
interior: _defineProperty({}, "X".concat(updatedJunctions.length), updatedJunctions)
|
|
8174
|
-
};
|
|
8175
|
-
}
|
|
8176
|
-
var shouldSetParentsToZero = parachainRemoved || newInterior === 'Here' && isRelayChain(chain) || isLocationOnTargetExternal;
|
|
8177
|
-
return {
|
|
8178
|
-
parents: shouldSetParentsToZero ? Parents.ZERO : location.parents,
|
|
8179
|
-
interior: newInterior
|
|
8180
|
-
};
|
|
8181
|
-
};
|
|
8182
|
-
var localizeLocation = function localizeLocation(chain, location, origin) {
|
|
8183
|
-
return localizeLocationInner(chain, location, origin, function (c) {
|
|
8184
|
-
return getRelayChainOf(c);
|
|
8185
|
-
}, function (c) {
|
|
8186
|
-
return getParaId(c);
|
|
8187
|
-
});
|
|
8188
|
-
};
|
|
8189
|
-
var localizeLocationImpl = function localizeLocationImpl(api, chain, location, origin) {
|
|
8190
|
-
return localizeLocationInner(chain, location, origin, function (c) {
|
|
8191
|
-
return getRelayChainOfImpl(api, c);
|
|
8192
|
-
}, function (c) {
|
|
8193
|
-
return getParaIdImpl(c, api._customCtx);
|
|
8194
|
-
});
|
|
8195
|
-
};
|
|
8196
|
-
|
|
8197
|
-
var reverseTransformLocation = function reverseTransformLocation(location) {
|
|
8198
|
-
var parachainJunction = {
|
|
8199
|
-
Parachain: 1000
|
|
8200
|
-
};
|
|
8201
|
-
var alreadyHasP1000 = location.interior !== 'Here' && Object.values(location.interior).flat().some(function (j) {
|
|
8202
|
-
return _typeof(j) === 'object' && j !== null && 'Parachain' in j && j.Parachain === 1000;
|
|
8203
|
-
});
|
|
8204
|
-
if (alreadyHasP1000) {
|
|
8205
|
-
return _objectSpread2(_objectSpread2({}, location), {}, {
|
|
8206
|
-
parents: Parents.ONE
|
|
8207
|
-
});
|
|
8208
|
-
}
|
|
8209
|
-
var existingJunctions = location.interior === 'Here' ? [] // no other junctions
|
|
8210
|
-
: Object.values(location.interior).flat();
|
|
8211
|
-
var allJunctions = [parachainJunction].concat(_toConsumableArray(existingJunctions));
|
|
8212
|
-
return _objectSpread2(_objectSpread2({}, location), {}, {
|
|
8213
|
-
parents: Parents.ONE,
|
|
8214
|
-
interior: _defineProperty({}, "X".concat(allJunctions.length), allJunctions)
|
|
8215
|
-
});
|
|
8216
|
-
};
|
|
8217
|
-
|
|
8218
8360
|
var resolveTransferType = function resolveTransferType(_ref) {
|
|
8219
8361
|
var origin = _ref.origin,
|
|
8220
8362
|
reserve = _ref.reserve,
|
|
@@ -8236,6 +8378,7 @@ var buildTypeAndThenCall = function buildTypeAndThenCall(context, isDotAsset, cu
|
|
|
8236
8378
|
dest = context.dest,
|
|
8237
8379
|
assetInfo = context.assetInfo,
|
|
8238
8380
|
bridgeHopChain = context.bridgeHopChain,
|
|
8381
|
+
isSubBridge = context.isSubBridge,
|
|
8239
8382
|
_context$options = context.options,
|
|
8240
8383
|
version = _context$options.version,
|
|
8241
8384
|
pallet = _context$options.pallet,
|
|
@@ -8245,6 +8388,7 @@ var buildTypeAndThenCall = function buildTypeAndThenCall(context, isDotAsset, cu
|
|
|
8245
8388
|
var finalDest = bridgeHopChain !== null && bridgeHopChain !== void 0 ? bridgeHopChain : origin.chain === reserve.chain ? dest.chain : reserve.chain;
|
|
8246
8389
|
var destLocation = createDestination(origin.api, version, origin.chain, finalDest, origin.api.getParaId(finalDest));
|
|
8247
8390
|
var transferType = bridgeHopChain ? 'DestinationReserve' : resolveTransferType(context);
|
|
8391
|
+
var feesTransferType = isSubBridge && !isDotAsset ? 'LocalReserve' : transferType;
|
|
8248
8392
|
var feeAsset = Array.isArray(overriddenAsset) ? overriddenAsset.find(function (a) {
|
|
8249
8393
|
return a.isFeeAsset;
|
|
8250
8394
|
}) : null;
|
|
@@ -8259,7 +8403,7 @@ var buildTypeAndThenCall = function buildTypeAndThenCall(context, isDotAsset, cu
|
|
|
8259
8403
|
assets: addXcmVersionHeader(assets, version),
|
|
8260
8404
|
assets_transfer_type: transferType,
|
|
8261
8405
|
remote_fees_id: addXcmVersionHeader(feeMultiAsset.id, version),
|
|
8262
|
-
fees_transfer_type:
|
|
8406
|
+
fees_transfer_type: feesTransferType,
|
|
8263
8407
|
custom_xcm_on_dest: addXcmVersionHeader(customXcm, version),
|
|
8264
8408
|
weight_limit: 'Unlimited'
|
|
8265
8409
|
}
|
|
@@ -8287,9 +8431,13 @@ var requiresSystemAssetByLocation = function requiresSystemAssetByLocation(api,
|
|
|
8287
8431
|
});
|
|
8288
8432
|
};
|
|
8289
8433
|
var getBridgeReserve = function getBridgeReserve(api, chain, destination, location) {
|
|
8290
|
-
var
|
|
8291
|
-
var
|
|
8292
|
-
|
|
8434
|
+
var assetConsensus = getJunctionValue(location, 'GlobalConsensus');
|
|
8435
|
+
var ethereumConsensus = getEthereumJunction(api, chain, false).GlobalConsensus;
|
|
8436
|
+
if (!isExternalChain(destination) && deepEqual(assetConsensus, ethereumConsensus)) {
|
|
8437
|
+
return 'AssetHubPolkadot';
|
|
8438
|
+
}
|
|
8439
|
+
var expectedConsensus = isExternalChain(destination) ? ethereumConsensus : _defineProperty({}, getRelayChainOf(destination).toLowerCase(), null);
|
|
8440
|
+
return deepEqual(assetConsensus, expectedConsensus) ? destination : chain;
|
|
8293
8441
|
};
|
|
8294
8442
|
var resolveReserveChain = function resolveReserveChain(api, chain, destination, assetLocation, isSubBridge, overrideReserve) {
|
|
8295
8443
|
if (isSubBridge) {
|
|
@@ -10573,8 +10721,9 @@ var AssetHubKusama = /*#__PURE__*/function (_SubstrateChain) {
|
|
|
10573
10721
|
key: "transferPolkadotXCM",
|
|
10574
10722
|
value: function transferPolkadotXCM(input) {
|
|
10575
10723
|
var asset = input.assetInfo,
|
|
10576
|
-
scenario = input.scenario
|
|
10577
|
-
|
|
10724
|
+
scenario = input.scenario,
|
|
10725
|
+
destination = input.destination;
|
|
10726
|
+
if (scenario === 'ParaToPara' && asset.symbol === 'DOT' && asset.assetId === undefined && destination !== 'Curio') {
|
|
10578
10727
|
throw new ScenarioNotSupportedError('Bridged DOT cannot currently be transfered from AssetHubKusama, if you are sending different DOT asset, please specify {id: <DOTID>}.');
|
|
10579
10728
|
}
|
|
10580
10729
|
return transferPolkadotXcm(input);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-core",
|
|
3
|
-
"version": "14.3.
|
|
3
|
+
"version": "14.3.3",
|
|
4
4
|
"description": "SDK core for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@noble/hashes": "^2.3.0",
|
|
26
|
-
"@paraspell/assets": "14.3.
|
|
27
|
-
"@paraspell/pallets": "14.3.
|
|
28
|
-
"@paraspell/sdk-common": "14.3.
|
|
26
|
+
"@paraspell/assets": "14.3.3",
|
|
27
|
+
"@paraspell/pallets": "14.3.3",
|
|
28
|
+
"@paraspell/sdk-common": "14.3.3",
|
|
29
29
|
"@scure/base": "^2.3.0",
|
|
30
30
|
"viem": "^2.55.19"
|
|
31
31
|
},
|