@paraspell/sdk-core 14.3.0 → 14.3.4

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 CHANGED
@@ -3,11 +3,13 @@ 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';
10
10
  import { mainnet, sepolia } from 'viem/chains';
11
+ import { keccak_256 } from '@noble/hashes/sha3.js';
12
+ import { bytesToHex, hexToBytes } from '@noble/hashes/utils.js';
11
13
 
12
14
  function _arrayLikeToArray(r, a) {
13
15
  (null == a || a > r.length) && (a = r.length);
@@ -2427,9 +2429,30 @@ var CurrenciesPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
2427
2429
  }
2428
2430
  }, {
2429
2431
  key: "getBalance",
2430
- value: function getBalance() {
2431
- throw new UnsupportedOperationError('No balance support.');
2432
- }
2432
+ value: function () {
2433
+ var _getBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, address, asset) {
2434
+ var account;
2435
+ return _regenerator().w(function (_context) {
2436
+ while (1) switch (_context.n) {
2437
+ case 0:
2438
+ assertHasId(asset);
2439
+ _context.n = 1;
2440
+ return api.queryRuntimeApi({
2441
+ module: 'CurrenciesApi',
2442
+ method: 'account',
2443
+ params: [Number(asset.assetId), address]
2444
+ });
2445
+ case 1:
2446
+ account = _context.v;
2447
+ return _context.a(2, (account === null || account === void 0 ? void 0 : account.free) !== undefined ? BigInt(account.free) : 0n);
2448
+ }
2449
+ }, _callee);
2450
+ }));
2451
+ function getBalance(_x, _x2, _x3) {
2452
+ return _getBalance.apply(this, arguments);
2453
+ }
2454
+ return getBalance;
2455
+ }()
2433
2456
  }]);
2434
2457
  }(BaseAssetsPallet);
2435
2458
 
@@ -3687,132 +3710,452 @@ var getMythosOriginFee = /*#__PURE__*/function () {
3687
3710
  };
3688
3711
  }();
3689
3712
 
3690
- var evmExtension;
3691
- var registerEvmExtension = function registerEvmExtension(extension) {
3692
- evmExtension = extension;
3693
- };
3694
- var getEvmExtensionOrThrow = function getEvmExtensionOrThrow() {
3695
- assertExtensionInstalled(evmExtension, 'EVM', '@paraspell/evm', 'using an EVM origin');
3696
- return evmExtension;
3713
+ var createX1Payload = function createX1Payload(version, junction) {
3714
+ return version === Version.V3 ? {
3715
+ X1: junction
3716
+ } : {
3717
+ X1: [junction]
3718
+ };
3697
3719
  };
3698
3720
 
3699
- var evmSnowbridgeExtension;
3700
- var registerEvmSnowbridgeExtension = function registerEvmSnowbridgeExtension(extension) {
3701
- evmSnowbridgeExtension = extension;
3721
+ var createAccountPayload = function createAccountPayload(api, address) {
3722
+ return isAddress(address) ? {
3723
+ AccountKey20: {
3724
+ key: address
3725
+ }
3726
+ } : {
3727
+ AccountId32: {
3728
+ id: api.accountToHex(address)
3729
+ }
3730
+ };
3702
3731
  };
3703
- var getEvmSnowbridgeExtensionOrThrow = function getEvmSnowbridgeExtensionOrThrow() {
3704
- assertExtensionInstalled(evmSnowbridgeExtension, 'EVM Snowbridge', '@paraspell/evm-snowbridge', 'using Ethereum as an origin');
3705
- return evmSnowbridgeExtension;
3732
+ var createBeneficiaryLocXTokens = function createBeneficiaryLocXTokens(_ref) {
3733
+ var api = _ref.api,
3734
+ recipient = _ref.recipient,
3735
+ origin = _ref.origin,
3736
+ destination = _ref.destination,
3737
+ version = _ref.version,
3738
+ paraId = _ref.paraId;
3739
+ if (isTLocation(recipient)) {
3740
+ return recipient;
3741
+ }
3742
+ var scenario = resolveScenario(origin, destination);
3743
+ var accountPayload = createAccountPayload(api, recipient);
3744
+ if (scenario === 'ParaToRelay') {
3745
+ return {
3746
+ parents: Parents.ONE,
3747
+ interior: createX1Payload(version, {
3748
+ AccountId32: {
3749
+ id: api.accountToHex(recipient)
3750
+ }
3751
+ })
3752
+ };
3753
+ } else if (scenario === 'ParaToPara') {
3754
+ return {
3755
+ parents: Parents.ONE,
3756
+ interior: {
3757
+ X2: [{
3758
+ Parachain: paraId
3759
+ }, accountPayload]
3760
+ }
3761
+ };
3762
+ }
3763
+ return {
3764
+ parents: Parents.ZERO,
3765
+ interior: createX1Payload(version, accountPayload)
3766
+ };
3767
+ };
3768
+ var createBeneficiaryLocation = function createBeneficiaryLocation(_ref2) {
3769
+ var api = _ref2.api,
3770
+ address = _ref2.address,
3771
+ version = _ref2.version;
3772
+ if (isTLocation(address)) return address;
3773
+ var accountPayload = createAccountPayload(api, address);
3774
+ return {
3775
+ parents: Parents.ZERO,
3776
+ interior: createX1Payload(version, accountPayload)
3777
+ };
3706
3778
  };
3707
3779
 
3708
- var swapExtension;
3709
- var registerSwapExtension = function registerSwapExtension(extension) {
3710
- swapExtension = extension;
3780
+ var createDestination = function createDestination(api, version, origin, destination, chainId, junction, parents) {
3781
+ var isLocDestination = isTLocation(destination);
3782
+ var isSubBridge = !isLocDestination && !isExternalChain(destination) && isSubstrateBridge(origin, destination);
3783
+ if (isSubBridge) {
3784
+ return {
3785
+ parents: Parents.TWO,
3786
+ interior: {
3787
+ X2: [{
3788
+ GlobalConsensus: api.getRelayChainOf(destination)
3789
+ }, {
3790
+ Parachain: chainId
3791
+ }]
3792
+ }
3793
+ };
3794
+ }
3795
+ var isExternalDestination = !isLocDestination && isExternalChain(destination);
3796
+ if (isExternalDestination) {
3797
+ return {
3798
+ parents: Parents.TWO,
3799
+ interior: {
3800
+ X1: [getEthereumJunction(api, origin)]
3801
+ }
3802
+ };
3803
+ }
3804
+ var scenario = resolveScenario(origin, destination);
3805
+ var parentsResolved = parents !== null && parents !== void 0 ? parents : scenario === 'RelayToPara' ? Parents.ZERO : Parents.ONE;
3806
+ var interior = scenario === 'ParaToRelay' ? 'Here' : createX1Payload(version, junction !== null && junction !== void 0 ? junction : {
3807
+ Parachain: chainId
3808
+ });
3809
+ return isLocDestination ? destination : {
3810
+ parents: parentsResolved,
3811
+ interior: interior
3812
+ };
3711
3813
  };
3712
- var getSwapExtensionOrThrow = function getSwapExtensionOrThrow() {
3713
- assertExtensionInstalled(swapExtension, 'swap', '@paraspell/swap', 'using swap features');
3714
- return swapExtension;
3814
+ var createVersionedDestination = function createVersionedDestination(api, version, origin, destination, chainId, junction, parents) {
3815
+ var plainDestination = createDestination(api, version, origin, destination, chainId, junction, parents);
3816
+ return addXcmVersionHeader(plainDestination, version);
3715
3817
  };
3716
3818
 
3717
- var API_TYPES = ['PAPI', 'PJS', 'DEDOT'];
3819
+ var getChainLocation = function getChainLocation(chain, destChain, customCtx) {
3820
+ var fromRelay = isRelayChain(chain);
3821
+ var toRelay = isRelayChain(destChain);
3822
+ var parents = fromRelay ? Parents.ZERO : Parents.ONE;
3823
+ var interior = toRelay ? 'Here' : {
3824
+ X1: [{
3825
+ Parachain: getParaIdImpl(destChain, customCtx)
3826
+ }]
3827
+ };
3828
+ return {
3829
+ parents: parents,
3830
+ interior: interior
3831
+ };
3832
+ };
3718
3833
 
3719
3834
  /**
3720
- * The options for the batch builder.
3835
+ * This function localizes a location by removing the `Parachain` junction
3836
+ * if it exists. The `parents` field is set to `0` either if a `Parachain` was removed
3837
+ * or if the resulting interior is `'Here'` and the chain is a relay chain.
3838
+ *
3839
+ * @param chain - The current chain
3840
+ * @param location - The location to localize
3841
+ * @returns The localized location
3721
3842
  */
3722
- var BatchMode;
3723
- (function (BatchMode) {
3724
- /**
3725
- * Does not commit if one of the calls in the batch fails.
3726
- */
3727
- BatchMode["BATCH_ALL"] = "BATCH_ALL";
3728
- /**
3729
- * Commits each successful call regardless if a call fails.
3730
- */
3731
- BatchMode["BATCH"] = "BATCH";
3732
- })(BatchMode || (BatchMode = {}));
3733
-
3734
- var XTokensError;
3735
- (function (XTokensError) {
3736
- XTokensError["AssetHasNoReserve"] = "AssetHasNoReserve";
3737
- XTokensError["NotCrossChainTransfer"] = "NotCrossChainTransfer";
3738
- XTokensError["InvalidDest"] = "InvalidDest";
3739
- XTokensError["NotCrossChainTransferableCurrency"] = "NotCrossChainTransferableCurrency";
3740
- XTokensError["UnweighableMessage"] = "UnweighableMessage";
3741
- XTokensError["XcmExecutionFailed"] = "XcmExecutionFailed";
3742
- XTokensError["CannotReanchor"] = "CannotReanchor";
3743
- XTokensError["InvalidAncestry"] = "InvalidAncestry";
3744
- XTokensError["InvalidAsset"] = "InvalidAsset";
3745
- XTokensError["DestinationNotInvertible"] = "DestinationNotInvertible";
3746
- XTokensError["BadVersion"] = "BadVersion";
3747
- XTokensError["DistinctReserveForAssetAndFee"] = "DistinctReserveForAssetAndFee";
3748
- XTokensError["ZeroFee"] = "ZeroFee";
3749
- XTokensError["ZeroAmount"] = "ZeroAmount";
3750
- XTokensError["TooManyAssetsBeingSent"] = "TooManyAssetsBeingSent";
3751
- XTokensError["AssetIndexNonExistent"] = "AssetIndexNonExistent";
3752
- XTokensError["FeeNotEnough"] = "FeeNotEnough";
3753
- XTokensError["NotSupportedLocation"] = "NotSupportedLocation";
3754
- XTokensError["MinXcmFeeNotDefined"] = "MinXcmFeeNotDefined";
3755
- XTokensError["RateLimited"] = "RateLimited";
3756
- })(XTokensError || (XTokensError = {}));
3757
- // Mirrors https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/xcm/pallet-xcm/src/errors.rs
3758
- var PolkadotXcmError;
3759
- (function (PolkadotXcmError) {
3760
- PolkadotXcmError["Unreachable"] = "Unreachable";
3761
- PolkadotXcmError["SendFailure"] = "SendFailure";
3762
- PolkadotXcmError["Filtered"] = "Filtered";
3763
- PolkadotXcmError["UnweighableMessage"] = "UnweighableMessage";
3764
- PolkadotXcmError["DestinationNotInvertible"] = "DestinationNotInvertible";
3765
- PolkadotXcmError["Empty"] = "Empty";
3766
- PolkadotXcmError["CannotReanchor"] = "CannotReanchor";
3767
- PolkadotXcmError["TooManyAssets"] = "TooManyAssets";
3768
- PolkadotXcmError["InvalidOrigin"] = "InvalidOrigin";
3769
- PolkadotXcmError["BadVersion"] = "BadVersion";
3770
- PolkadotXcmError["BadLocation"] = "BadLocation";
3771
- PolkadotXcmError["NoSubscription"] = "NoSubscription";
3772
- PolkadotXcmError["AlreadySubscribed"] = "AlreadySubscribed";
3773
- PolkadotXcmError["CannotCheckOutTeleport"] = "CannotCheckOutTeleport";
3774
- PolkadotXcmError["LowBalance"] = "LowBalance";
3775
- PolkadotXcmError["TooManyLocks"] = "TooManyLocks";
3776
- PolkadotXcmError["AccountNotSovereign"] = "AccountNotSovereign";
3777
- PolkadotXcmError["FeesNotMet"] = "FeesNotMet";
3778
- PolkadotXcmError["LockNotFound"] = "LockNotFound";
3779
- PolkadotXcmError["InUse"] = "InUse";
3780
- PolkadotXcmError["REMOVED"] = "REMOVED";
3781
- PolkadotXcmError["InvalidAssetUnknownReserve"] = "InvalidAssetUnknownReserve";
3782
- PolkadotXcmError["InvalidAssetUnsupportedReserve"] = "InvalidAssetUnsupportedReserve";
3783
- PolkadotXcmError["TooManyReserves"] = "TooManyReserves";
3784
- PolkadotXcmError["LocalExecutionIncomplete"] = "LocalExecutionIncomplete";
3785
- PolkadotXcmError["TooManyAuthorizedAliases"] = "TooManyAuthorizedAliases";
3786
- PolkadotXcmError["ExpiresInPast"] = "ExpiresInPast";
3787
- PolkadotXcmError["AliasNotFound"] = "AliasNotFound";
3788
- PolkadotXcmError["LocalExecutionIncompleteWithError"] = "LocalExecutionIncompleteWithError";
3789
- })(PolkadotXcmError || (PolkadotXcmError = {}));
3790
- var PolkadotXcmExecutionError;
3791
- (function (PolkadotXcmExecutionError) {
3792
- PolkadotXcmExecutionError["Overflow"] = "Overflow";
3793
- PolkadotXcmExecutionError["Unimplemented"] = "Unimplemented";
3794
- PolkadotXcmExecutionError["UntrustedReserveLocation"] = "UntrustedReserveLocation";
3795
- PolkadotXcmExecutionError["UntrustedTeleportLocation"] = "UntrustedTeleportLocation";
3796
- PolkadotXcmExecutionError["LocationFull"] = "LocationFull";
3797
- PolkadotXcmExecutionError["LocationNotInvertible"] = "LocationNotInvertible";
3798
- PolkadotXcmExecutionError["BadOrigin"] = "BadOrigin";
3799
- PolkadotXcmExecutionError["InvalidLocation"] = "InvalidLocation";
3800
- PolkadotXcmExecutionError["AssetNotFound"] = "AssetNotFound";
3801
- PolkadotXcmExecutionError["FailedToTransactAsset"] = "FailedToTransactAsset";
3802
- PolkadotXcmExecutionError["NotWithdrawable"] = "NotWithdrawable";
3803
- PolkadotXcmExecutionError["LocationCannotHold"] = "LocationCannotHold";
3804
- PolkadotXcmExecutionError["ExceedsMaxMessageSize"] = "ExceedsMaxMessageSize";
3805
- PolkadotXcmExecutionError["DestinationUnsupported"] = "DestinationUnsupported";
3806
- PolkadotXcmExecutionError["Transport"] = "Transport";
3807
- PolkadotXcmExecutionError["Unroutable"] = "Unroutable";
3808
- PolkadotXcmExecutionError["UnknownClaim"] = "UnknownClaim";
3809
- PolkadotXcmExecutionError["FailedToDecode"] = "FailedToDecode";
3810
- PolkadotXcmExecutionError["MaxWeightInvalid"] = "MaxWeightInvalid";
3811
- PolkadotXcmExecutionError["NotHoldingFees"] = "NotHoldingFees";
3812
- PolkadotXcmExecutionError["TooExpensive"] = "TooExpensive";
3813
- PolkadotXcmExecutionError["Trap"] = "Trap";
3814
- PolkadotXcmExecutionError["ExpectationFalse"] = "ExpectationFalse";
3815
- PolkadotXcmExecutionError["PalletNotFound"] = "PalletNotFound";
3843
+ var localizeLocationInner = function localizeLocationInner(chain, location, origin, resolveRelay, resolveParaId) {
3844
+ var _Object$keys$;
3845
+ var targetRelay = isExternalChain(chain) ? undefined : resolveRelay(chain).toLowerCase();
3846
+ var originRelay = origin && !isExternalChain(origin) ? resolveRelay(origin).toLowerCase() : undefined;
3847
+ var locationConsensus = getJunctionValue(location, 'GlobalConsensus');
3848
+ var locationRelay = locationConsensus ? (_Object$keys$ = Object.keys(locationConsensus)[0]) === null || _Object$keys$ === void 0 ? void 0 : _Object$keys$.toLowerCase() : undefined;
3849
+ var ecosystemDiffers = targetRelay && originRelay && originRelay !== targetRelay;
3850
+ var junctions = location.interior === 'Here' ? [] : flattenJunctions(location.interior);
3851
+ var junctionCount = junctions.length;
3852
+ var isLocationOnTargetRelay = targetRelay !== undefined && locationRelay === targetRelay;
3853
+ // Check if target is an external chain and location's GlobalConsensus matches it
3854
+ var isLocationOnTargetExternal = isExternalChain(chain) && locationRelay === chain.toLowerCase();
3855
+ var isConsensusAnchored = junctions.findIndex(function (junction) {
3856
+ return 'GlobalConsensus' in junction;
3857
+ }) === 0;
3858
+ if (locationRelay && targetRelay && locationRelay !== targetRelay && (!origin || !ecosystemDiffers && isConsensusAnchored)) {
3859
+ return location;
3860
+ }
3861
+ if (origin && ecosystemDiffers && location.parents === Parents.TWO && originRelay !== undefined && targetRelay !== undefined && deepEqual(getJunctionValue(location, 'GlobalConsensus'), _defineProperty({}, targetRelay, null)) && junctionCount === 1) {
3862
+ return RELAY_LOCATION;
3863
+ }
3864
+ var newInterior = location.interior;
3865
+ var parachainRemoved = false;
3866
+ if (location.interior !== 'Here') {
3867
+ var paraId = resolveParaId(chain);
3868
+ var filteredJunctions = junctions.filter(function (junction) {
3869
+ if ('GlobalConsensus' in junction && (isLocationOnTargetRelay || isLocationOnTargetExternal)) {
3870
+ return false;
3871
+ }
3872
+ if ('Parachain' in junction && (!ecosystemDiffers || isLocationOnTargetRelay)) {
3873
+ var paraJunctionId = getJunctionValue(location, 'Parachain');
3874
+ if (paraJunctionId === paraId) {
3875
+ parachainRemoved = true;
3876
+ return false;
3877
+ }
3878
+ }
3879
+ return true;
3880
+ });
3881
+ if (filteredJunctions.length === 0) {
3882
+ newInterior = 'Here';
3883
+ } else {
3884
+ newInterior = _defineProperty({}, "X".concat(filteredJunctions.length), filteredJunctions);
3885
+ }
3886
+ }
3887
+ var isOriginRelayHere = deepEqual(location, RELAY_LOCATION);
3888
+ var hasGlobalConsensus = hasJunction(location, 'GlobalConsensus');
3889
+ if (origin && isExternalChain(chain) && originRelay !== undefined && isOriginRelayHere && !hasGlobalConsensus) {
3890
+ return {
3891
+ parents: Parents.ONE,
3892
+ interior: {
3893
+ X1: [{
3894
+ GlobalConsensus: _defineProperty({}, originRelay, null)
3895
+ }]
3896
+ }
3897
+ };
3898
+ }
3899
+ if (isExternalChain(chain) && location.parents === Parents.TWO && RELAYCHAINS.some(function (relay) {
3900
+ return deepEqual(getJunctionValue(location, 'GlobalConsensus'), _defineProperty({}, relay.toLowerCase(), null));
3901
+ })) {
3902
+ return _objectSpread2(_objectSpread2({}, location), {}, {
3903
+ parents: Parents.ONE
3904
+ });
3905
+ }
3906
+ if (origin && ecosystemDiffers && isOriginRelayHere && !hasGlobalConsensus && originRelay !== undefined) {
3907
+ return {
3908
+ parents: Parents.TWO,
3909
+ interior: {
3910
+ X2: [{
3911
+ GlobalConsensus: _defineProperty({}, originRelay, null)
3912
+ }, {
3913
+ Parachain: resolveParaId(origin)
3914
+ }]
3915
+ }
3916
+ };
3917
+ }
3918
+ if (origin && ecosystemDiffers && newInterior !== 'Here' && !hasGlobalConsensus && originRelay !== undefined) {
3919
+ var _junctions = flattenJunctions(newInterior);
3920
+ var updatedJunctions = [{
3921
+ GlobalConsensus: _defineProperty({}, originRelay, null)
3922
+ }].concat(_toConsumableArray(_junctions));
3923
+ return {
3924
+ parents: Parents.TWO,
3925
+ interior: _defineProperty({}, "X".concat(updatedJunctions.length), updatedJunctions)
3926
+ };
3927
+ }
3928
+ var shouldSetParentsToZero = parachainRemoved || newInterior === 'Here' && isRelayChain(chain) || isLocationOnTargetExternal;
3929
+ return {
3930
+ parents: shouldSetParentsToZero ? Parents.ZERO : location.parents,
3931
+ interior: newInterior
3932
+ };
3933
+ };
3934
+ var localizeLocation = function localizeLocation(chain, location, origin) {
3935
+ return localizeLocationInner(chain, location, origin, function (c) {
3936
+ return getRelayChainOf(c);
3937
+ }, function (c) {
3938
+ return getParaId(c);
3939
+ });
3940
+ };
3941
+ var localizeLocationImpl = function localizeLocationImpl(api, chain, location, origin) {
3942
+ return localizeLocationInner(chain, location, origin, function (c) {
3943
+ return getRelayChainOfImpl(api, c);
3944
+ }, function (c) {
3945
+ return getParaIdImpl(c, api._customCtx);
3946
+ });
3947
+ };
3948
+
3949
+ var reverseTransformLocation = function reverseTransformLocation(location) {
3950
+ var parachainJunction = {
3951
+ Parachain: 1000
3952
+ };
3953
+ var alreadyHasP1000 = location.interior !== 'Here' && Object.values(location.interior).flat().some(function (j) {
3954
+ return _typeof(j) === 'object' && j !== null && 'Parachain' in j && j.Parachain === 1000;
3955
+ });
3956
+ if (alreadyHasP1000) {
3957
+ return _objectSpread2(_objectSpread2({}, location), {}, {
3958
+ parents: Parents.ONE
3959
+ });
3960
+ }
3961
+ var existingJunctions = location.interior === 'Here' ? [] // no other junctions
3962
+ : Object.values(location.interior).flat();
3963
+ var allJunctions = [parachainJunction].concat(_toConsumableArray(existingJunctions));
3964
+ return _objectSpread2(_objectSpread2({}, location), {}, {
3965
+ parents: Parents.ONE,
3966
+ interior: _defineProperty({}, "X".concat(allJunctions.length), allJunctions)
3967
+ });
3968
+ };
3969
+
3970
+ var EMPTY_TOPIC = "0x".concat('00'.repeat(32));
3971
+ var getBridgeDestFee = /*#__PURE__*/function () {
3972
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, destApi, origin, destination, assetInfo, feeAssetInfo, hasSystemFeeAsset, recipient, version) {
3973
+ var systemAsset, transferredAsset, assets, destIsReserve, feeAssetLocation, buyExecution, depositAsset, feesSplitFromAssets, prologue, xcm;
3974
+ return _regenerator().w(function (_context) {
3975
+ while (1) switch (_context.n) {
3976
+ case 0:
3977
+ systemAsset = createAsset(version, MIN_AMOUNT, RELAY_LOCATION);
3978
+ transferredAsset = createAsset(version, assetInfo.amount, normalizeLocation(api.localizeLocation(origin, assetInfo.location), version));
3979
+ assets = hasSystemFeeAsset ? sortAssets([systemAsset, transferredAsset]) : [transferredAsset];
3980
+ destIsReserve = hasSystemFeeAsset ? destination === 'AssetHubPolkadot' : deepEqual(getJunctionValue(assetInfo.location, 'GlobalConsensus'), _defineProperty({}, getRelayChainOf(destination).toLowerCase(), null));
3981
+ feeAssetLocation = hasSystemFeeAsset ? RELAY_LOCATION : assetInfo.location;
3982
+ buyExecution = {
3983
+ BuyExecution: {
3984
+ fees: createAsset(version, MIN_AMOUNT, api.localizeLocation(destination, feeAssetLocation, origin)),
3985
+ weight_limit: 'Unlimited'
3986
+ }
3987
+ };
3988
+ depositAsset = {
3989
+ DepositAsset: {
3990
+ assets: {
3991
+ Wild: hasSystemFeeAsset ? {
3992
+ AllOf: {
3993
+ id: api.localizeLocation(destination, assetInfo.location, origin),
3994
+ fun: 'Fungible'
3995
+ }
3996
+ } : {
3997
+ AllCounted: 1
3998
+ }
3999
+ },
4000
+ beneficiary: createBeneficiaryLocation({
4001
+ api: destApi,
4002
+ address: recipient,
4003
+ version: version
4004
+ })
4005
+ }
4006
+ };
4007
+ feesSplitFromAssets = destIsReserve && hasSystemFeeAsset;
4008
+ prologue = feesSplitFromAssets ? [{
4009
+ ReserveAssetDeposited: [systemAsset]
4010
+ }, buyExecution, {
4011
+ WithdrawAsset: [transferredAsset]
4012
+ }, {
4013
+ ClearOrigin: null
4014
+ }] : [destIsReserve ? {
4015
+ WithdrawAsset: assets
4016
+ } : {
4017
+ ReserveAssetDeposited: assets
4018
+ }, {
4019
+ ClearOrigin: null
4020
+ }, buyExecution];
4021
+ xcm = [].concat(prologue, [buyExecution, depositAsset, {
4022
+ SetTopic: EMPTY_TOPIC
4023
+ }]);
4024
+ return _context.a(2, destApi.getXcmPaymentApiFee(destination, addXcmVersionHeader(xcm, version), [], feeAssetInfo, version, true));
4025
+ }
4026
+ }, _callee);
4027
+ }));
4028
+ return function getBridgeDestFee(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8, _x9) {
4029
+ return _ref.apply(this, arguments);
4030
+ };
4031
+ }();
4032
+
4033
+ var evmExtension;
4034
+ var registerEvmExtension = function registerEvmExtension(extension) {
4035
+ evmExtension = extension;
4036
+ };
4037
+ var getEvmExtensionOrThrow = function getEvmExtensionOrThrow() {
4038
+ assertExtensionInstalled(evmExtension, 'EVM', '@paraspell/evm', 'using an EVM origin');
4039
+ return evmExtension;
4040
+ };
4041
+
4042
+ var evmSnowbridgeExtension;
4043
+ var registerEvmSnowbridgeExtension = function registerEvmSnowbridgeExtension(extension) {
4044
+ evmSnowbridgeExtension = extension;
4045
+ };
4046
+ var getEvmSnowbridgeExtensionOrThrow = function getEvmSnowbridgeExtensionOrThrow() {
4047
+ assertExtensionInstalled(evmSnowbridgeExtension, 'EVM Snowbridge', '@paraspell/evm-snowbridge', 'using Ethereum as an origin');
4048
+ return evmSnowbridgeExtension;
4049
+ };
4050
+
4051
+ var swapExtension;
4052
+ var registerSwapExtension = function registerSwapExtension(extension) {
4053
+ swapExtension = extension;
4054
+ };
4055
+ var getSwapExtensionOrThrow = function getSwapExtensionOrThrow() {
4056
+ assertExtensionInstalled(swapExtension, 'swap', '@paraspell/swap', 'using swap features');
4057
+ return swapExtension;
4058
+ };
4059
+
4060
+ var API_TYPES = ['PAPI', 'PJS', 'DEDOT'];
4061
+
4062
+ /**
4063
+ * The options for the batch builder.
4064
+ */
4065
+ var BatchMode;
4066
+ (function (BatchMode) {
4067
+ /**
4068
+ * Does not commit if one of the calls in the batch fails.
4069
+ */
4070
+ BatchMode["BATCH_ALL"] = "BATCH_ALL";
4071
+ /**
4072
+ * Commits each successful call regardless if a call fails.
4073
+ */
4074
+ BatchMode["BATCH"] = "BATCH";
4075
+ })(BatchMode || (BatchMode = {}));
4076
+
4077
+ var XTokensError;
4078
+ (function (XTokensError) {
4079
+ XTokensError["AssetHasNoReserve"] = "AssetHasNoReserve";
4080
+ XTokensError["NotCrossChainTransfer"] = "NotCrossChainTransfer";
4081
+ XTokensError["InvalidDest"] = "InvalidDest";
4082
+ XTokensError["NotCrossChainTransferableCurrency"] = "NotCrossChainTransferableCurrency";
4083
+ XTokensError["UnweighableMessage"] = "UnweighableMessage";
4084
+ XTokensError["XcmExecutionFailed"] = "XcmExecutionFailed";
4085
+ XTokensError["CannotReanchor"] = "CannotReanchor";
4086
+ XTokensError["InvalidAncestry"] = "InvalidAncestry";
4087
+ XTokensError["InvalidAsset"] = "InvalidAsset";
4088
+ XTokensError["DestinationNotInvertible"] = "DestinationNotInvertible";
4089
+ XTokensError["BadVersion"] = "BadVersion";
4090
+ XTokensError["DistinctReserveForAssetAndFee"] = "DistinctReserveForAssetAndFee";
4091
+ XTokensError["ZeroFee"] = "ZeroFee";
4092
+ XTokensError["ZeroAmount"] = "ZeroAmount";
4093
+ XTokensError["TooManyAssetsBeingSent"] = "TooManyAssetsBeingSent";
4094
+ XTokensError["AssetIndexNonExistent"] = "AssetIndexNonExistent";
4095
+ XTokensError["FeeNotEnough"] = "FeeNotEnough";
4096
+ XTokensError["NotSupportedLocation"] = "NotSupportedLocation";
4097
+ XTokensError["MinXcmFeeNotDefined"] = "MinXcmFeeNotDefined";
4098
+ XTokensError["RateLimited"] = "RateLimited";
4099
+ })(XTokensError || (XTokensError = {}));
4100
+ // Mirrors https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/xcm/pallet-xcm/src/errors.rs
4101
+ var PolkadotXcmError;
4102
+ (function (PolkadotXcmError) {
4103
+ PolkadotXcmError["Unreachable"] = "Unreachable";
4104
+ PolkadotXcmError["SendFailure"] = "SendFailure";
4105
+ PolkadotXcmError["Filtered"] = "Filtered";
4106
+ PolkadotXcmError["UnweighableMessage"] = "UnweighableMessage";
4107
+ PolkadotXcmError["DestinationNotInvertible"] = "DestinationNotInvertible";
4108
+ PolkadotXcmError["Empty"] = "Empty";
4109
+ PolkadotXcmError["CannotReanchor"] = "CannotReanchor";
4110
+ PolkadotXcmError["TooManyAssets"] = "TooManyAssets";
4111
+ PolkadotXcmError["InvalidOrigin"] = "InvalidOrigin";
4112
+ PolkadotXcmError["BadVersion"] = "BadVersion";
4113
+ PolkadotXcmError["BadLocation"] = "BadLocation";
4114
+ PolkadotXcmError["NoSubscription"] = "NoSubscription";
4115
+ PolkadotXcmError["AlreadySubscribed"] = "AlreadySubscribed";
4116
+ PolkadotXcmError["CannotCheckOutTeleport"] = "CannotCheckOutTeleport";
4117
+ PolkadotXcmError["LowBalance"] = "LowBalance";
4118
+ PolkadotXcmError["TooManyLocks"] = "TooManyLocks";
4119
+ PolkadotXcmError["AccountNotSovereign"] = "AccountNotSovereign";
4120
+ PolkadotXcmError["FeesNotMet"] = "FeesNotMet";
4121
+ PolkadotXcmError["LockNotFound"] = "LockNotFound";
4122
+ PolkadotXcmError["InUse"] = "InUse";
4123
+ PolkadotXcmError["REMOVED"] = "REMOVED";
4124
+ PolkadotXcmError["InvalidAssetUnknownReserve"] = "InvalidAssetUnknownReserve";
4125
+ PolkadotXcmError["InvalidAssetUnsupportedReserve"] = "InvalidAssetUnsupportedReserve";
4126
+ PolkadotXcmError["TooManyReserves"] = "TooManyReserves";
4127
+ PolkadotXcmError["LocalExecutionIncomplete"] = "LocalExecutionIncomplete";
4128
+ PolkadotXcmError["TooManyAuthorizedAliases"] = "TooManyAuthorizedAliases";
4129
+ PolkadotXcmError["ExpiresInPast"] = "ExpiresInPast";
4130
+ PolkadotXcmError["AliasNotFound"] = "AliasNotFound";
4131
+ PolkadotXcmError["LocalExecutionIncompleteWithError"] = "LocalExecutionIncompleteWithError";
4132
+ })(PolkadotXcmError || (PolkadotXcmError = {}));
4133
+ var PolkadotXcmExecutionError;
4134
+ (function (PolkadotXcmExecutionError) {
4135
+ PolkadotXcmExecutionError["Overflow"] = "Overflow";
4136
+ PolkadotXcmExecutionError["Unimplemented"] = "Unimplemented";
4137
+ PolkadotXcmExecutionError["UntrustedReserveLocation"] = "UntrustedReserveLocation";
4138
+ PolkadotXcmExecutionError["UntrustedTeleportLocation"] = "UntrustedTeleportLocation";
4139
+ PolkadotXcmExecutionError["LocationFull"] = "LocationFull";
4140
+ PolkadotXcmExecutionError["LocationNotInvertible"] = "LocationNotInvertible";
4141
+ PolkadotXcmExecutionError["BadOrigin"] = "BadOrigin";
4142
+ PolkadotXcmExecutionError["InvalidLocation"] = "InvalidLocation";
4143
+ PolkadotXcmExecutionError["AssetNotFound"] = "AssetNotFound";
4144
+ PolkadotXcmExecutionError["FailedToTransactAsset"] = "FailedToTransactAsset";
4145
+ PolkadotXcmExecutionError["NotWithdrawable"] = "NotWithdrawable";
4146
+ PolkadotXcmExecutionError["LocationCannotHold"] = "LocationCannotHold";
4147
+ PolkadotXcmExecutionError["ExceedsMaxMessageSize"] = "ExceedsMaxMessageSize";
4148
+ PolkadotXcmExecutionError["DestinationUnsupported"] = "DestinationUnsupported";
4149
+ PolkadotXcmExecutionError["Transport"] = "Transport";
4150
+ PolkadotXcmExecutionError["Unroutable"] = "Unroutable";
4151
+ PolkadotXcmExecutionError["UnknownClaim"] = "UnknownClaim";
4152
+ PolkadotXcmExecutionError["FailedToDecode"] = "FailedToDecode";
4153
+ PolkadotXcmExecutionError["MaxWeightInvalid"] = "MaxWeightInvalid";
4154
+ PolkadotXcmExecutionError["NotHoldingFees"] = "NotHoldingFees";
4155
+ PolkadotXcmExecutionError["TooExpensive"] = "TooExpensive";
4156
+ PolkadotXcmExecutionError["Trap"] = "Trap";
4157
+ PolkadotXcmExecutionError["ExpectationFalse"] = "ExpectationFalse";
4158
+ PolkadotXcmExecutionError["PalletNotFound"] = "PalletNotFound";
3816
4159
  PolkadotXcmExecutionError["NameMismatch"] = "NameMismatch";
3817
4160
  PolkadotXcmExecutionError["VersionIncompatible"] = "VersionIncompatible";
3818
4161
  PolkadotXcmExecutionError["HoldingWouldOverflow"] = "HoldingWouldOverflow";
@@ -5808,17 +6151,18 @@ var addEthereumBridgeFees = /*#__PURE__*/function () {
5808
6151
  }();
5809
6152
 
5810
6153
  var dryRunInternal = /*#__PURE__*/function () {
5811
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
5812
- 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, result, dryRunError, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9;
5813
- return _regenerator().w(function (_context2) {
5814
- while (1) switch (_context2.n) {
6154
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
6155
+ var _traversalResult$dest;
6156
+ 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;
6157
+ return _regenerator().w(function (_context3) {
6158
+ while (1) switch (_context3.n) {
5815
6159
  case 0:
5816
6160
  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
6161
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
5818
6162
  _resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination), assets = _resolveCurrency.assets, asset = _resolveCurrency.asset;
5819
6163
  amount = asset.amount;
5820
6164
  resolvedVersion = pickCompatibleXcmVersion(api, origin, destination, version);
5821
- _context2.n = 1;
6165
+ _context3.n = 1;
5822
6166
  return api.getDryRunCall({
5823
6167
  tx: tx,
5824
6168
  chain: origin,
@@ -5835,12 +6179,12 @@ var dryRunInternal = /*#__PURE__*/function () {
5835
6179
  useRootOrigin: useRootOrigin || !!bypassOptions
5836
6180
  });
5837
6181
  case 1:
5838
- originDryRun = _context2.v;
6182
+ originDryRun = _context3.v;
5839
6183
  if (originDryRun.success) {
5840
- _context2.n = 2;
6184
+ _context3.n = 2;
5841
6185
  break;
5842
6186
  }
5843
- return _context2.a(2, {
6187
+ return _context3.a(2, {
5844
6188
  success: false,
5845
6189
  dryRunError: _objectSpread2({
5846
6190
  chainKind: 'origin',
@@ -5852,27 +6196,27 @@ var dryRunInternal = /*#__PURE__*/function () {
5852
6196
  case 2:
5853
6197
  isMythosToEthereum = origin === 'Mythos' && destination === 'Ethereum';
5854
6198
  if (!isMythosToEthereum) {
5855
- _context2.n = 4;
6199
+ _context3.n = 4;
5856
6200
  break;
5857
6201
  }
5858
- _t2 = _objectSpread2;
5859
- _t3 = _objectSpread2({}, originDryRun);
5860
- _t4 = {};
5861
- _t5 = originDryRun.fee;
5862
- _context2.n = 3;
6202
+ _t5 = _objectSpread2;
6203
+ _t6 = _objectSpread2({}, originDryRun);
6204
+ _t7 = {};
6205
+ _t8 = originDryRun.fee;
6206
+ _context3.n = 3;
5863
6207
  return getMythosOriginFee(api);
5864
6208
  case 3:
5865
- _t6 = _context2.v;
5866
- _t7 = _t5 + _t6;
5867
- _t = _t2(_t3, _t4, {
5868
- fee: _t7
6209
+ _t9 = _context3.v;
6210
+ _t0 = _t8 + _t9;
6211
+ _t4 = _t5(_t6, _t7, {
6212
+ fee: _t0
5869
6213
  });
5870
- _context2.n = 5;
6214
+ _context3.n = 5;
5871
6215
  break;
5872
6216
  case 4:
5873
- _t = originDryRun;
6217
+ _t4 = originDryRun;
5874
6218
  case 5:
5875
- originDryModified = _t;
6219
+ originDryModified = _t4;
5876
6220
  initialForwardedXcms = originDryModified.forwardedXcms, initialDestParaId = originDryModified.destParaId;
5877
6221
  processHop = /*#__PURE__*/function () {
5878
6222
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
@@ -5930,7 +6274,7 @@ var dryRunInternal = /*#__PURE__*/function () {
5930
6274
  return _ref2.apply(this, arguments);
5931
6275
  };
5932
6276
  }();
5933
- _context2.n = 6;
6277
+ _context3.n = 6;
5934
6278
  return traverseXcmHops({
5935
6279
  api: api,
5936
6280
  origin: origin,
@@ -5951,7 +6295,7 @@ var dryRunInternal = /*#__PURE__*/function () {
5951
6295
  }
5952
6296
  });
5953
6297
  case 6:
5954
- traversalResult = _context2.v;
6298
+ traversalResult = _context3.v;
5955
6299
  // Process Ethereum bridge fees
5956
6300
  relayChain = api.getRelayChainOf(origin);
5957
6301
  bridgeHubChain = relayChain === 'Paseo' ? undefined : "BridgeHub".concat(relayChain);
@@ -5960,29 +6304,29 @@ var dryRunInternal = /*#__PURE__*/function () {
5960
6304
  return hop.chain === bridgeHubChain;
5961
6305
  }); // For Mythos → Ethereum, we skip additional Ethereum bridge fees (aligns with getXcmFeeInternal)
5962
6306
  if (!isMythosToEthereum) {
5963
- _context2.n = 7;
6307
+ _context3.n = 7;
5964
6308
  break;
5965
6309
  }
5966
- _t8 = bridgeHubHop === null || bridgeHubHop === void 0 ? void 0 : bridgeHubHop.result;
5967
- _context2.n = 11;
6310
+ _t1 = bridgeHubHop === null || bridgeHubHop === void 0 ? void 0 : bridgeHubHop.result;
6311
+ _context3.n = 11;
5968
6312
  break;
5969
6313
  case 7:
5970
6314
  if (!(bridgeHubHop !== null && bridgeHubHop !== void 0 && bridgeHubHop.result.success)) {
5971
- _context2.n = 9;
6315
+ _context3.n = 9;
5972
6316
  break;
5973
6317
  }
5974
- _context2.n = 8;
6318
+ _context3.n = 8;
5975
6319
  return addEthereumBridgeFees(api, bridgeHubHop === null || bridgeHubHop === void 0 ? void 0 : bridgeHubHop.result, destination, assetHubChain);
5976
6320
  case 8:
5977
- _t9 = _context2.v;
5978
- _context2.n = 10;
6321
+ _t10 = _context3.v;
6322
+ _context3.n = 10;
5979
6323
  break;
5980
6324
  case 9:
5981
- _t9 = bridgeHubHop === null || bridgeHubHop === void 0 ? void 0 : bridgeHubHop.result;
6325
+ _t10 = bridgeHubHop === null || bridgeHubHop === void 0 ? void 0 : bridgeHubHop.result;
5982
6326
  case 10:
5983
- _t8 = _t9;
6327
+ _t1 = _t10;
5984
6328
  case 11:
5985
- processedBridgeHub = _t8;
6329
+ processedBridgeHub = _t1;
5986
6330
  // Update bridge hub in hops if needed
5987
6331
  if (processedBridgeHub && processedBridgeHub.success && bridgeHubHop && bridgeHubHop.result.success && processedBridgeHub.fee !== bridgeHubHop.result.fee) {
5988
6332
  bridgeHubHopIndex = traversalResult.hops.findIndex(function (hop) {
@@ -5994,10 +6338,67 @@ var dryRunInternal = /*#__PURE__*/function () {
5994
6338
  });
5995
6339
  }
5996
6340
  }
6341
+ resolveBridgeDestination = /*#__PURE__*/function () {
6342
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
6343
+ var _api$findAssetInfoOnD;
6344
+ var destApi, systemAsset, hasSystemFeeAsset, destAsset, _t, _t2, _t3;
6345
+ return _regenerator().w(function (_context2) {
6346
+ while (1) switch (_context2.n) {
6347
+ case 0:
6348
+ if (!(isExternalChain(destination) || !isSubstrateBridge(origin, destination))) {
6349
+ _context2.n = 1;
6350
+ break;
6351
+ }
6352
+ return _context2.a(2, undefined);
6353
+ case 1:
6354
+ destApi = api.clone();
6355
+ _context2.n = 2;
6356
+ return destApi.init(destination);
6357
+ case 2:
6358
+ systemAsset = api.findNativeAssetInfoOrThrow(api.getRelayChainOf(origin));
6359
+ hasSystemFeeAsset = deepEqual(getJunctionValue(asset.location, 'GlobalConsensus'), getEthereumJunction(api, origin, false).GlobalConsensus);
6360
+ destAsset = hasSystemFeeAsset ? api.findAssetInfoOrThrow(destination, {
6361
+ symbol: systemAsset.symbol
6362
+ }) : (_api$findAssetInfoOnD = api.findAssetInfoOnDest(origin, destination, currency, asset)) !== null && _api$findAssetInfoOnD !== void 0 ? _api$findAssetInfoOnD : asset;
6363
+ _context2.n = 3;
6364
+ return getBridgeDestFee(api, destApi, origin, destination, asset, destAsset, hasSystemFeeAsset, sender, resolvedVersion);
6365
+ case 3:
6366
+ _t = _context2.v;
6367
+ _t2 = destAsset;
6368
+ _t3 = [];
6369
+ return _context2.a(2, {
6370
+ success: true,
6371
+ fee: _t,
6372
+ asset: _t2,
6373
+ forwardedXcms: _t3
6374
+ });
6375
+ }
6376
+ }, _callee2);
6377
+ }));
6378
+ return function resolveBridgeDestination() {
6379
+ return _ref3.apply(this, arguments);
6380
+ };
6381
+ }();
6382
+ _t11 = originDryModified;
6383
+ if (!((_traversalResult$dest = traversalResult.destination) !== null && _traversalResult$dest !== void 0)) {
6384
+ _context3.n = 12;
6385
+ break;
6386
+ }
6387
+ _t12 = _traversalResult$dest;
6388
+ _context3.n = 14;
6389
+ break;
6390
+ case 12:
6391
+ _context3.n = 13;
6392
+ return resolveBridgeDestination();
6393
+ case 13:
6394
+ _t12 = _context3.v;
6395
+ case 14:
6396
+ _t13 = _t12;
6397
+ _t14 = traversalResult.hops;
5997
6398
  result = {
5998
- origin: originDryModified,
5999
- destination: traversalResult.destination,
6000
- hops: traversalResult.hops
6399
+ origin: _t11,
6400
+ destination: _t13,
6401
+ hops: _t14
6001
6402
  };
6002
6403
  dryRunError = getDryRunError({
6003
6404
  origin: {
@@ -6010,12 +6411,12 @@ var dryRunInternal = /*#__PURE__*/function () {
6010
6411
  } : undefined,
6011
6412
  hops: result.hops
6012
6413
  });
6013
- return _context2.a(2, _objectSpread2({
6414
+ return _context3.a(2, _objectSpread2({
6014
6415
  success: !dryRunError,
6015
6416
  dryRunError: dryRunError
6016
6417
  }, result));
6017
6418
  }
6018
- }, _callee2);
6419
+ }, _callee3);
6019
6420
  }));
6020
6421
  return function dryRunInternal(_x) {
6021
6422
  return _ref.apply(this, arguments);
@@ -6645,7 +7046,7 @@ var getOriginXcmFee = /*#__PURE__*/function () {
6645
7046
 
6646
7047
  var getXcmFeeOnce = /*#__PURE__*/function () {
6647
7048
  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;
7049
+ 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
7050
  return _regenerator().w(function (_context2) {
6650
7051
  while (1) switch (_context2.p = _context2.n) {
6651
7052
  case 0:
@@ -6857,7 +7258,7 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
6857
7258
  destDryRunError = destResult.dryRunError;
6858
7259
  destSufficient = destResult.sufficient;
6859
7260
  destAsset = destResult.asset;
6860
- _context2.n = 16;
7261
+ _context2.n = 19;
6861
7262
  break;
6862
7263
  case 12:
6863
7264
  if (!(traversalResult.hops.length > 0 && traversalResult.hops[traversalResult.hops.length - 1].result.dryRunError)) {
@@ -6896,14 +7297,36 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
6896
7297
  destFeeType = destFallback.feeType;
6897
7298
  destSufficient = destFallback.sufficient;
6898
7299
  destAsset = api.findNativeAssetInfoOrThrow(destination);
6899
- _context2.n = 16;
7300
+ _context2.n = 19;
6900
7301
  break;
6901
7302
  case 15:
7303
+ if (!(!isExternalChain(destination) && isSubstrateBridge(origin, destination))) {
7304
+ _context2.n = 18;
7305
+ break;
7306
+ }
7307
+ _destApi2 = api.clone();
7308
+ _context2.n = 16;
7309
+ return _destApi2.init(destination, DRY_RUN_CLIENT_TIMEOUT_MS);
7310
+ case 16:
7311
+ systemAsset = api.findNativeAssetInfoOrThrow(api.getRelayChainOf(origin));
7312
+ hasSystemFeeAsset = deepEqual(getJunctionValue(asset.location, 'GlobalConsensus'), getEthereumJunction(api, origin, false).GlobalConsensus);
7313
+ destAsset = hasSystemFeeAsset ? api.findAssetInfoOrThrow(destination, {
7314
+ symbol: systemAsset.symbol
7315
+ }) : (_api$findAssetInfoOnD = api.findAssetInfoOnDest(origin, destination, currency, asset)) !== null && _api$findAssetInfoOnD !== void 0 ? _api$findAssetInfoOnD : asset;
7316
+ _context2.n = 17;
7317
+ return getBridgeDestFee(api, _destApi2, origin, destination, asset, destAsset, hasSystemFeeAsset, recipient, resolvedVersion);
7318
+ case 17:
7319
+ destFee = _context2.v;
7320
+ destFeeType = 'dryRun';
7321
+ destSufficient = true;
7322
+ _context2.n = 19;
7323
+ break;
7324
+ case 18:
6902
7325
  destFee = 0n;
6903
7326
  destFeeType = 'noFeeRequired';
6904
7327
  destSufficient = true;
6905
7328
  destAsset = api.findNativeAssetInfoOrThrow(destination);
6906
- case 16:
7329
+ case 19:
6907
7330
  // Process Ethereum bridge fees
6908
7331
  relayChain = api.getRelayChainOf(origin);
6909
7332
  bridgeHubChain = relayChain === 'Paseo' ? undefined : "BridgeHub".concat(relayChain);
@@ -6912,18 +7335,18 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
6912
7335
  return hop.chain === bridgeHubChain;
6913
7336
  });
6914
7337
  if (!isMythosToEthereum) {
6915
- _context2.n = 17;
7338
+ _context2.n = 20;
6916
7339
  break;
6917
7340
  }
6918
7341
  _t4 = bridgeHubHop === null || bridgeHubHop === void 0 ? void 0 : bridgeHubHop.result;
6919
- _context2.n = 19;
7342
+ _context2.n = 22;
6920
7343
  break;
6921
- case 17:
6922
- _context2.n = 18;
7344
+ case 20:
7345
+ _context2.n = 21;
6923
7346
  return addEthereumBridgeFees(api, bridgeHubHop === null || bridgeHubHop === void 0 ? void 0 : bridgeHubHop.result, destination, assetHubChain);
6924
- case 18:
7347
+ case 21:
6925
7348
  _t4 = _context2.v;
6926
- case 19:
7349
+ case 22:
6927
7350
  processedBridgeHub = _t4;
6928
7351
  // Update bridge hub fee in hops if needed
6929
7352
  if (processedBridgeHub && bridgeHubHop && processedBridgeHub.fee !== bridgeHubHop.result.fee) {
@@ -7731,489 +8154,231 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
7731
8154
  case 10:
7732
8155
  _context3.n = 11;
7733
8156
  return dryRunInternal({
7734
- api: api,
7735
- tx: tx,
7736
- origin: origin,
7737
- destination: destination,
7738
- sender: sender,
7739
- version: version,
7740
- currency: buildMinCurrency(amounts),
7741
- feeAsset: feeAsset
7742
- });
7743
- case 11:
7744
- dryRunResult = _context3.v;
7745
- if (dryRunResult.success) {
7746
- _context3.n = 12;
7747
- break;
7748
- }
7749
- return _context3.a(2, toResult(amounts.map(function () {
7750
- return 0n;
7751
- })));
7752
- case 12:
7753
- return _context3.a(2, toResult(amounts));
7754
- }
7755
- }, _callee3, null, [[7, 9], [4, 6]]);
7756
- }));
7757
- return function getMinTransferableAmountInternal(_x) {
7758
- return _ref2.apply(this, arguments);
7759
- };
7760
- }();
7761
- var getMinTransferableAmount = /*#__PURE__*/function () {
7762
- var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(options) {
7763
- var api;
7764
- return _regenerator().w(function (_context4) {
7765
- while (1) switch (_context4.p = _context4.n) {
7766
- case 0:
7767
- api = options.api;
7768
- api.disconnectAllowed = false;
7769
- _context4.p = 1;
7770
- _context4.n = 2;
7771
- return getMinTransferableAmountInternal(options);
7772
- case 2:
7773
- return _context4.a(2, _context4.v);
7774
- case 3:
7775
- _context4.p = 3;
7776
- api.disconnectAllowed = true;
7777
- _context4.n = 4;
7778
- return api.disconnect();
7779
- case 4:
7780
- return _context4.f(3);
7781
- case 5:
7782
- return _context4.a(2);
7783
- }
7784
- }, _callee4, null, [[1,, 3, 5]]);
7785
- }));
7786
- return function getMinTransferableAmount(_x5) {
7787
- return _ref5.apply(this, arguments);
7788
- };
7789
- }();
7790
-
7791
- var getOriginFeeOrThrow = /*#__PURE__*/function () {
7792
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, feeCurrency) {
7793
- var api, buildTx, chain, sender, feeAsset, version, currency, _yield$getOriginXcmFe, fee;
7794
- return _regenerator().w(function (_context) {
7795
- while (1) switch (_context.n) {
7796
- case 0:
7797
- api = _ref.api, buildTx = _ref.buildTx, chain = _ref.origin, sender = _ref.sender, feeAsset = _ref.feeAsset, version = _ref.version, currency = _ref.currency;
7798
- _context.n = 1;
7799
- return getOriginXcmFee({
7800
- api: api,
7801
- buildTx: buildTx,
7802
- origin: chain,
7803
- destination: chain,
7804
- sender: sender,
7805
- feeAsset: feeAsset,
7806
- version: version,
7807
- currency: feeCurrency,
7808
- disableFallback: false
7809
- });
7810
- case 1:
7811
- _yield$getOriginXcmFe = _context.v;
7812
- fee = _yield$getOriginXcmFe.fee;
7813
- if (!(fee === undefined)) {
7814
- _context.n = 2;
7815
- break;
7816
- }
7817
- throw new UnableToComputeError("Cannot get origin xcm fee for currency ".concat(JSON.stringify(currency, replaceBigInt), " on chain ").concat(chain, "."));
7818
- case 2:
7819
- return _context.a(2, fee);
7820
- }
7821
- }, _callee);
7822
- }));
7823
- return function getOriginFeeOrThrow(_x, _x2) {
7824
- return _ref2.apply(this, arguments);
7825
- };
7826
- }();
7827
- var computeTransferableAmount = /*#__PURE__*/function () {
7828
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, sender, chain, asset, fee) {
7829
- var balance, transferable;
7830
- return _regenerator().w(function (_context2) {
7831
- while (1) switch (_context2.n) {
7832
- case 0:
7833
- _context2.n = 1;
7834
- return getAssetBalanceInternal({
7835
- api: api,
7836
- address: sender,
7837
- chain: chain,
7838
- asset: asset
7839
- });
7840
- case 1:
7841
- balance = _context2.v;
7842
- transferable = balance - getEdFromAssetOrThrow(asset) - fee;
7843
- return _context2.a(2, transferable > 0n ? transferable : 0n);
7844
- }
7845
- }, _callee2);
7846
- }));
7847
- return function computeTransferableAmount(_x3, _x4, _x5, _x6, _x7) {
7848
- return _ref3.apply(this, arguments);
7849
- };
7850
- }();
7851
- var getTransferableAmountForAsset = /*#__PURE__*/function () {
7852
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options, resolvedFeeAsset) {
7853
- var api, sender, chain, currency, asset, amount, nativeAssetInfo, isNativeAsset, paysOriginInSendingAsset, fee, _t;
7854
- return _regenerator().w(function (_context3) {
7855
- while (1) switch (_context3.n) {
7856
- case 0:
7857
- api = options.api, sender = options.sender, chain = options.origin, currency = options.currency;
7858
- asset = api.findAssetInfoOrThrow(chain, currency);
7859
- amount = abstractDecimals(currency.amount, asset.decimals, api);
7860
- nativeAssetInfo = api.findNativeAssetInfoOrThrow(chain);
7861
- isNativeAsset = isAssetEqual(nativeAssetInfo, asset);
7862
- paysOriginInSendingAsset = !resolvedFeeAsset && isNativeAsset || resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, asset);
7863
- if (!paysOriginInSendingAsset) {
7864
- _context3.n = 2;
7865
- break;
7866
- }
7867
- _context3.n = 1;
7868
- return getOriginFeeOrThrow(options, _objectSpread2(_objectSpread2({}, currency), {}, {
7869
- amount: amount
7870
- }));
7871
- case 1:
7872
- _t = _context3.v;
7873
- _context3.n = 3;
7874
- break;
7875
- case 2:
7876
- _t = 0n;
7877
- case 3:
7878
- fee = _t;
7879
- return _context3.a(2, computeTransferableAmount(api, sender, chain, asset, fee));
7880
- }
7881
- }, _callee3);
7882
- }));
7883
- return function getTransferableAmountForAsset(_x8, _x9) {
7884
- return _ref4.apply(this, arguments);
7885
- };
7886
- }();
7887
- var getTransferableAmountForAssets = /*#__PURE__*/function () {
7888
- var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(options, resolvedFeeAsset) {
7889
- var api, sender, chain, destination, currency, _resolveCurrency, assets, fee;
7890
- return _regenerator().w(function (_context4) {
7891
- while (1) switch (_context4.n) {
7892
- case 0:
7893
- api = options.api, sender = options.sender, chain = options.origin, destination = options.destination, currency = options.currency;
7894
- _resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, chain, destination), assets = _resolveCurrency.assets;
7895
- _context4.n = 1;
7896
- return getOriginFeeOrThrow(options, currency);
7897
- case 1:
7898
- fee = _context4.v;
7899
- return _context4.a(2, Promise.all(assets.map(function (asset) {
7900
- return computeTransferableAmount(api, sender, chain, asset, asset.isFeeAsset ? fee : 0n);
8157
+ api: api,
8158
+ tx: tx,
8159
+ origin: origin,
8160
+ destination: destination,
8161
+ sender: sender,
8162
+ version: version,
8163
+ currency: buildMinCurrency(amounts),
8164
+ feeAsset: feeAsset
8165
+ });
8166
+ case 11:
8167
+ dryRunResult = _context3.v;
8168
+ if (dryRunResult.success) {
8169
+ _context3.n = 12;
8170
+ break;
8171
+ }
8172
+ return _context3.a(2, toResult(amounts.map(function () {
8173
+ return 0n;
7901
8174
  })));
8175
+ case 12:
8176
+ return _context3.a(2, toResult(amounts));
7902
8177
  }
7903
- }, _callee4);
7904
- }));
7905
- return function getTransferableAmountForAssets(_x0, _x1) {
7906
- return _ref5.apply(this, arguments);
7907
- };
7908
- }();
7909
- var getTransferableAmountInternal = /*#__PURE__*/function () {
7910
- var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(options) {
7911
- var api, sender, chain, destination, currency, feeAsset, resolvedFeeAsset;
7912
- return _regenerator().w(function (_context5) {
7913
- while (1) switch (_context5.n) {
7914
- case 0:
7915
- api = options.api, sender = options.sender, chain = options.origin, destination = options.destination, currency = options.currency, feeAsset = options.feeAsset;
7916
- validateAddress(api, sender, chain, false);
7917
- resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, chain, destination, currency) : undefined;
7918
- return _context5.a(2, Array.isArray(currency) ? getTransferableAmountForAssets(_objectSpread2(_objectSpread2({}, options), {}, {
7919
- currency: currency
7920
- }), resolvedFeeAsset) : getTransferableAmountForAsset(_objectSpread2(_objectSpread2({}, options), {}, {
7921
- currency: currency
7922
- }), resolvedFeeAsset));
7923
- }
7924
- }, _callee5);
8178
+ }, _callee3, null, [[7, 9], [4, 6]]);
7925
8179
  }));
7926
- return function getTransferableAmountInternal(_x10) {
7927
- return _ref6.apply(this, arguments);
8180
+ return function getMinTransferableAmountInternal(_x) {
8181
+ return _ref2.apply(this, arguments);
7928
8182
  };
7929
8183
  }();
7930
- var getTransferableAmount = /*#__PURE__*/function () {
7931
- var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(options) {
8184
+ var getMinTransferableAmount = /*#__PURE__*/function () {
8185
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(options) {
7932
8186
  var api;
7933
- return _regenerator().w(function (_context6) {
7934
- while (1) switch (_context6.p = _context6.n) {
8187
+ return _regenerator().w(function (_context4) {
8188
+ while (1) switch (_context4.p = _context4.n) {
7935
8189
  case 0:
7936
8190
  api = options.api;
7937
8191
  api.disconnectAllowed = false;
7938
- _context6.p = 1;
7939
- _context6.n = 2;
7940
- return getTransferableAmountInternal(options);
8192
+ _context4.p = 1;
8193
+ _context4.n = 2;
8194
+ return getMinTransferableAmountInternal(options);
7941
8195
  case 2:
7942
- return _context6.a(2, _context6.v);
8196
+ return _context4.a(2, _context4.v);
7943
8197
  case 3:
7944
- _context6.p = 3;
8198
+ _context4.p = 3;
7945
8199
  api.disconnectAllowed = true;
7946
- _context6.n = 4;
8200
+ _context4.n = 4;
7947
8201
  return api.disconnect();
7948
8202
  case 4:
7949
- return _context6.f(3);
8203
+ return _context4.f(3);
7950
8204
  case 5:
7951
- return _context6.a(2);
8205
+ return _context4.a(2);
7952
8206
  }
7953
- }, _callee6, null, [[1,, 3, 5]]);
8207
+ }, _callee4, null, [[1,, 3, 5]]);
7954
8208
  }));
7955
- return function getTransferableAmount(_x11) {
7956
- return _ref7.apply(this, arguments);
8209
+ return function getMinTransferableAmount(_x5) {
8210
+ return _ref5.apply(this, arguments);
7957
8211
  };
7958
8212
  }();
7959
8213
 
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;
8214
+ var getOriginFeeOrThrow = /*#__PURE__*/function () {
8215
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref, feeCurrency) {
8216
+ var api, buildTx, chain, sender, feeAsset, version, currency, _yield$getOriginXcmFe, fee;
8217
+ return _regenerator().w(function (_context) {
8218
+ while (1) switch (_context.n) {
8219
+ case 0:
8220
+ api = _ref.api, buildTx = _ref.buildTx, chain = _ref.origin, sender = _ref.sender, feeAsset = _ref.feeAsset, version = _ref.version, currency = _ref.currency;
8221
+ _context.n = 1;
8222
+ return getOriginXcmFee({
8223
+ api: api,
8224
+ buildTx: buildTx,
8225
+ origin: chain,
8226
+ destination: chain,
8227
+ sender: sender,
8228
+ feeAsset: feeAsset,
8229
+ version: version,
8230
+ currency: feeCurrency,
8231
+ disableFallback: false
8232
+ });
8233
+ case 1:
8234
+ _yield$getOriginXcmFe = _context.v;
8235
+ fee = _yield$getOriginXcmFe.fee;
8236
+ if (!(fee === undefined)) {
8237
+ _context.n = 2;
8238
+ break;
8239
+ }
8240
+ throw new UnableToComputeError("Cannot get origin xcm fee for currency ".concat(JSON.stringify(currency, replaceBigInt), " on chain ").concat(chain, "."));
8241
+ case 2:
8242
+ return _context.a(2, fee);
8117
8243
  }
8118
- if ('Parachain' in junction && (!ecosystemDiffers || isLocationOnTargetRelay)) {
8119
- var paraJunctionId = getJunctionValue(location, 'Parachain');
8120
- if (paraJunctionId === paraId) {
8121
- parachainRemoved = true;
8122
- return false;
8123
- }
8244
+ }, _callee);
8245
+ }));
8246
+ return function getOriginFeeOrThrow(_x, _x2) {
8247
+ return _ref2.apply(this, arguments);
8248
+ };
8249
+ }();
8250
+ var computeTransferableAmount = /*#__PURE__*/function () {
8251
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, sender, chain, asset, fee) {
8252
+ var balance, transferable;
8253
+ return _regenerator().w(function (_context2) {
8254
+ while (1) switch (_context2.n) {
8255
+ case 0:
8256
+ _context2.n = 1;
8257
+ return getAssetBalanceInternal({
8258
+ api: api,
8259
+ address: sender,
8260
+ chain: chain,
8261
+ asset: asset
8262
+ });
8263
+ case 1:
8264
+ balance = _context2.v;
8265
+ transferable = balance - getEdFromAssetOrThrow(asset) - fee;
8266
+ return _context2.a(2, transferable > 0n ? transferable : 0n);
8124
8267
  }
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
- }]
8268
+ }, _callee2);
8269
+ }));
8270
+ return function computeTransferableAmount(_x3, _x4, _x5, _x6, _x7) {
8271
+ return _ref3.apply(this, arguments);
8272
+ };
8273
+ }();
8274
+ var getTransferableAmountForAsset = /*#__PURE__*/function () {
8275
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options, resolvedFeeAsset) {
8276
+ var api, sender, chain, currency, asset, amount, nativeAssetInfo, isNativeAsset, paysOriginInSendingAsset, fee, _t;
8277
+ return _regenerator().w(function (_context3) {
8278
+ while (1) switch (_context3.n) {
8279
+ case 0:
8280
+ api = options.api, sender = options.sender, chain = options.origin, currency = options.currency;
8281
+ asset = api.findAssetInfoOrThrow(chain, currency);
8282
+ amount = abstractDecimals(currency.amount, asset.decimals, api);
8283
+ nativeAssetInfo = api.findNativeAssetInfoOrThrow(chain);
8284
+ isNativeAsset = isAssetEqual(nativeAssetInfo, asset);
8285
+ paysOriginInSendingAsset = !resolvedFeeAsset && isNativeAsset || resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, asset);
8286
+ if (!paysOriginInSendingAsset) {
8287
+ _context3.n = 2;
8288
+ break;
8289
+ }
8290
+ _context3.n = 1;
8291
+ return getOriginFeeOrThrow(options, _objectSpread2(_objectSpread2({}, currency), {}, {
8292
+ amount: amount
8293
+ }));
8294
+ case 1:
8295
+ _t = _context3.v;
8296
+ _context3.n = 3;
8297
+ break;
8298
+ case 2:
8299
+ _t = 0n;
8300
+ case 3:
8301
+ fee = _t;
8302
+ return _context3.a(2, computeTransferableAmount(api, sender, chain, asset, fee));
8142
8303
  }
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
- }]
8304
+ }, _callee3);
8305
+ }));
8306
+ return function getTransferableAmountForAsset(_x8, _x9) {
8307
+ return _ref4.apply(this, arguments);
8308
+ };
8309
+ }();
8310
+ var getTransferableAmountForAssets = /*#__PURE__*/function () {
8311
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(options, resolvedFeeAsset) {
8312
+ var api, sender, chain, destination, currency, _resolveCurrency, assets, fee;
8313
+ return _regenerator().w(function (_context4) {
8314
+ while (1) switch (_context4.n) {
8315
+ case 0:
8316
+ api = options.api, sender = options.sender, chain = options.origin, destination = options.destination, currency = options.currency;
8317
+ _resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, chain, destination), assets = _resolveCurrency.assets;
8318
+ _context4.n = 1;
8319
+ return getOriginFeeOrThrow(options, currency);
8320
+ case 1:
8321
+ fee = _context4.v;
8322
+ return _context4.a(2, Promise.all(assets.map(function (asset) {
8323
+ return computeTransferableAmount(api, sender, chain, asset, asset.isFeeAsset ? fee : 0n);
8324
+ })));
8161
8325
  }
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
8326
+ }, _callee4);
8327
+ }));
8328
+ return function getTransferableAmountForAssets(_x0, _x1) {
8329
+ return _ref5.apply(this, arguments);
8180
8330
  };
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
8331
+ }();
8332
+ var getTransferableAmountInternal = /*#__PURE__*/function () {
8333
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(options) {
8334
+ var api, sender, chain, destination, currency, feeAsset, resolvedFeeAsset;
8335
+ return _regenerator().w(function (_context5) {
8336
+ while (1) switch (_context5.n) {
8337
+ case 0:
8338
+ api = options.api, sender = options.sender, chain = options.origin, destination = options.destination, currency = options.currency, feeAsset = options.feeAsset;
8339
+ validateAddress(api, sender, chain, false);
8340
+ resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, chain, destination, currency) : undefined;
8341
+ return _context5.a(2, Array.isArray(currency) ? getTransferableAmountForAssets(_objectSpread2(_objectSpread2({}, options), {}, {
8342
+ currency: currency
8343
+ }), resolvedFeeAsset) : getTransferableAmountForAsset(_objectSpread2(_objectSpread2({}, options), {}, {
8344
+ currency: currency
8345
+ }), resolvedFeeAsset));
8346
+ }
8347
+ }, _callee5);
8348
+ }));
8349
+ return function getTransferableAmountInternal(_x10) {
8350
+ return _ref6.apply(this, arguments);
8200
8351
  };
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
- };
8352
+ }();
8353
+ var getTransferableAmount = /*#__PURE__*/function () {
8354
+ var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(options) {
8355
+ var api;
8356
+ return _regenerator().w(function (_context6) {
8357
+ while (1) switch (_context6.p = _context6.n) {
8358
+ case 0:
8359
+ api = options.api;
8360
+ api.disconnectAllowed = false;
8361
+ _context6.p = 1;
8362
+ _context6.n = 2;
8363
+ return getTransferableAmountInternal(options);
8364
+ case 2:
8365
+ return _context6.a(2, _context6.v);
8366
+ case 3:
8367
+ _context6.p = 3;
8368
+ api.disconnectAllowed = true;
8369
+ _context6.n = 4;
8370
+ return api.disconnect();
8371
+ case 4:
8372
+ return _context6.f(3);
8373
+ case 5:
8374
+ return _context6.a(2);
8375
+ }
8376
+ }, _callee6, null, [[1,, 3, 5]]);
8377
+ }));
8378
+ return function getTransferableAmount(_x11) {
8379
+ return _ref7.apply(this, arguments);
8380
+ };
8381
+ }();
8217
8382
 
8218
8383
  var resolveTransferType = function resolveTransferType(_ref) {
8219
8384
  var origin = _ref.origin,
@@ -8236,6 +8401,7 @@ var buildTypeAndThenCall = function buildTypeAndThenCall(context, isDotAsset, cu
8236
8401
  dest = context.dest,
8237
8402
  assetInfo = context.assetInfo,
8238
8403
  bridgeHopChain = context.bridgeHopChain,
8404
+ isSubBridge = context.isSubBridge,
8239
8405
  _context$options = context.options,
8240
8406
  version = _context$options.version,
8241
8407
  pallet = _context$options.pallet,
@@ -8245,6 +8411,7 @@ var buildTypeAndThenCall = function buildTypeAndThenCall(context, isDotAsset, cu
8245
8411
  var finalDest = bridgeHopChain !== null && bridgeHopChain !== void 0 ? bridgeHopChain : origin.chain === reserve.chain ? dest.chain : reserve.chain;
8246
8412
  var destLocation = createDestination(origin.api, version, origin.chain, finalDest, origin.api.getParaId(finalDest));
8247
8413
  var transferType = bridgeHopChain ? 'DestinationReserve' : resolveTransferType(context);
8414
+ var feesTransferType = isSubBridge && !isDotAsset ? 'LocalReserve' : transferType;
8248
8415
  var feeAsset = Array.isArray(overriddenAsset) ? overriddenAsset.find(function (a) {
8249
8416
  return a.isFeeAsset;
8250
8417
  }) : null;
@@ -8259,7 +8426,7 @@ var buildTypeAndThenCall = function buildTypeAndThenCall(context, isDotAsset, cu
8259
8426
  assets: addXcmVersionHeader(assets, version),
8260
8427
  assets_transfer_type: transferType,
8261
8428
  remote_fees_id: addXcmVersionHeader(feeMultiAsset.id, version),
8262
- fees_transfer_type: transferType,
8429
+ fees_transfer_type: feesTransferType,
8263
8430
  custom_xcm_on_dest: addXcmVersionHeader(customXcm, version),
8264
8431
  weight_limit: 'Unlimited'
8265
8432
  }
@@ -8287,9 +8454,13 @@ var requiresSystemAssetByLocation = function requiresSystemAssetByLocation(api,
8287
8454
  });
8288
8455
  };
8289
8456
  var getBridgeReserve = function getBridgeReserve(api, chain, destination, location) {
8290
- var expectedConsensus = isExternalChain(destination) ? getEthereumJunction(api, chain, false).GlobalConsensus : _defineProperty({}, getRelayChainOf(destination).toLowerCase(), null);
8291
- var isDestReserve = deepEqual(getJunctionValue(location, 'GlobalConsensus'), expectedConsensus);
8292
- return isDestReserve ? destination : chain;
8457
+ var assetConsensus = getJunctionValue(location, 'GlobalConsensus');
8458
+ var ethereumConsensus = getEthereumJunction(api, chain, false).GlobalConsensus;
8459
+ if (!isExternalChain(destination) && deepEqual(assetConsensus, ethereumConsensus)) {
8460
+ return 'AssetHubPolkadot';
8461
+ }
8462
+ var expectedConsensus = isExternalChain(destination) ? ethereumConsensus : _defineProperty({}, getRelayChainOf(destination).toLowerCase(), null);
8463
+ return deepEqual(assetConsensus, expectedConsensus) ? destination : chain;
8293
8464
  };
8294
8465
  var resolveReserveChain = function resolveReserveChain(api, chain, destination, assetLocation, isSubBridge, overrideReserve) {
8295
8466
  if (isSubBridge) {
@@ -10573,8 +10744,9 @@ var AssetHubKusama = /*#__PURE__*/function (_SubstrateChain) {
10573
10744
  key: "transferPolkadotXCM",
10574
10745
  value: function transferPolkadotXCM(input) {
10575
10746
  var asset = input.assetInfo,
10576
- scenario = input.scenario;
10577
- if (scenario === 'ParaToPara' && asset.symbol === 'DOT' && asset.assetId === undefined) {
10747
+ scenario = input.scenario,
10748
+ destination = input.destination;
10749
+ if (scenario === 'ParaToPara' && asset.symbol === 'DOT' && asset.assetId === undefined && destination !== 'Curio') {
10578
10750
  throw new ScenarioNotSupportedError('Bridged DOT cannot currently be transfered from AssetHubKusama, if you are sending different DOT asset, please specify {id: <DOTID>}.');
10579
10751
  }
10580
10752
  return transferPolkadotXcm(input);
@@ -10825,6 +10997,14 @@ var Hydration = /*#__PURE__*/function (_SubstrateChain) {
10825
10997
  useIdPrefix: false
10826
10998
  };
10827
10999
  }
11000
+ }, {
11001
+ key: "mint",
11002
+ value: function mint(api, address, assetInfo, balance) {
11003
+ if (assetInfo.erc20) {
11004
+ return Promise.resolve(buildErc20StorageMint(api, address, assetInfo, assetInfo.erc20, balance + assetInfo.amount));
11005
+ }
11006
+ return _superPropGet(Hydration, "mint", this, 3)([api, address, assetInfo, balance]);
11007
+ }
10828
11008
  }, {
10829
11009
  key: "shouldUseExecuteTransfer",
10830
11010
  value: function shouldUseExecuteTransfer(input) {
@@ -10892,6 +11072,12 @@ var Hydration = /*#__PURE__*/function (_SubstrateChain) {
10892
11072
  }
10893
11073
  }));
10894
11074
  }
11075
+ }, {
11076
+ key: "getBalanceForeign",
11077
+ value: function getBalanceForeign(api, address, asset) {
11078
+ if (!asset.erc20) return _superPropGet(Hydration, "getBalanceForeign", this, 3)([api, address, asset]);
11079
+ return getPalletInstance('Currencies').getBalance(api, address, asset);
11080
+ }
10895
11081
  }, {
10896
11082
  key: "transferLocalNonNativeAsset",
10897
11083
  value: function transferLocalNonNativeAsset(options) {
@@ -10899,9 +11085,22 @@ var Hydration = /*#__PURE__*/function (_SubstrateChain) {
10899
11085
  asset = options.assetInfo,
10900
11086
  recipient = options.recipient,
10901
11087
  isAmountAll = options.isAmountAll,
10902
- keepAlive = options.keepAlive;
11088
+ keepAlive = options.keepAlive,
11089
+ balance = options.balance;
10903
11090
  assertHasId(asset);
10904
11091
  var currencyId = Number(asset.assetId);
11092
+ if (asset.erc20) {
11093
+ var amount = isAmountAll ? balance - (keepAlive ? getEdFromAssetOrThrow(asset) : 0n) : asset.amount;
11094
+ return api.deserializeExtrinsics({
11095
+ module: 'Currencies',
11096
+ method: 'transfer',
11097
+ params: {
11098
+ dest: recipient,
11099
+ currency_id: currencyId,
11100
+ amount: amount
11101
+ }
11102
+ });
11103
+ }
10905
11104
  if (isAmountAll) {
10906
11105
  return api.deserializeExtrinsics({
10907
11106
  module: 'Tokens',
@@ -11576,7 +11775,9 @@ var EnergyWebX = /*#__PURE__*/function (_SubstrateChain) {
11576
11775
  scenario: scenario
11577
11776
  });
11578
11777
  }
11579
- return transferPolkadotXcm(input, 'limited_reserve_transfer_assets', 'Unlimited');
11778
+ // EnergyWebX has to stay on reserve_transfer_assets for now.
11779
+ // limited_reserve_transfer_assets causes 'Extrinsic is now allowed error'
11780
+ return transferPolkadotXcm(input, 'reserve_transfer_assets');
11580
11781
  }
11581
11782
  }, {
11582
11783
  key: "isRelayToParaEnabled",
@@ -12618,6 +12819,39 @@ var formatAssetIdToERC20 = function formatAssetIdToERC20(id) {
12618
12819
  return "0xffffffff".concat(BigInt(id).toString(16).padStart(32, '0'));
12619
12820
  };
12620
12821
 
12822
+ // twox128("EVM") ++ twox128("AccountStorages") — the pallet_evm::AccountStorages storage prefix.
12823
+ var ACCOUNT_STORAGES_PREFIX = '1da53b775b270400e7e61ed5cbc5a146ab1160471b1418779239ba8e2b847e42';
12824
+ // "ETH\0" — prefix of account ids that Hydration derives from an EVM address
12825
+ var EVM_ACCOUNT_PREFIX = '45544800';
12826
+ var word = function word(hex) {
12827
+ return hex.padStart(64, '0');
12828
+ };
12829
+ var blake2128Concat = function blake2128Concat(hex) {
12830
+ return bytesToHex(blake2b(hexToBytes(hex), {
12831
+ dkLen: 16
12832
+ })) + hex;
12833
+ };
12834
+ // Mirrors pallet_evm_accounts::evm_address
12835
+ var toEvmAddress = function toEvmAddress(accountId) {
12836
+ return accountId.startsWith(EVM_ACCOUNT_PREFIX) && accountId.endsWith('0'.repeat(16)) ? accountId.slice(8, 48) : accountId.slice(0, 40);
12837
+ };
12838
+ var buildErc20StorageMint = function buildErc20StorageMint(api, address, asset, erc20, balance) {
12839
+ var _erc20$contract, _getJunctionValue;
12840
+ var contract = (_erc20$contract = erc20.contract) !== null && _erc20$contract !== void 0 ? _erc20$contract : (_getJunctionValue = getJunctionValue(asset.location, 'AccountKey20')) === null || _getJunctionValue === void 0 ? void 0 : _getJunctionValue.key;
12841
+ if (!contract) throw new InvalidCurrencyError("Missing ERC20 contract for asset ".concat(asset.symbol));
12842
+ var evmAddress = toEvmAddress(bytesToHex(api.accountToUint8a(address)));
12843
+ var slotKey = bytesToHex(keccak_256(hexToBytes(word(evmAddress) + word(erc20.balanceSlot.toString(16)))));
12844
+ return {
12845
+ balanceTx: {
12846
+ module: 'System',
12847
+ method: 'set_storage',
12848
+ params: {
12849
+ items: [['0x' + ACCOUNT_STORAGES_PREFIX + blake2128Concat(contract.slice(2)) + blake2128Concat(slotKey), '0x' + word(balance.toString(16))]]
12850
+ }
12851
+ }
12852
+ };
12853
+ };
12854
+
12621
12855
  var maybeOverrideAssets = function maybeOverrideAssets(version, amount, assets, overriddenCurrency) {
12622
12856
  if (!overriddenCurrency) {
12623
12857
  return assets;
@@ -13792,4 +14026,4 @@ var createClientCache = function createClientCache(maxSize, pingClient, onEvicti
13792
14026
  };
13793
14027
  };
13794
14028
 
13795
- export { API_TYPES, AmountTooLowError, ApiNotInitializedError, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, CustomChainConflictError, CustomChainInvalidError, DEFAULT_TTL_MS, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETH_MAINNET_CHAIN_ID, ETH_TESTNET_CHAIN_ID, EXCHANGE_CHAINS, EXTENSION_MS, ExtensionNotInstalledError, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MAX_CLIENTS, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotApi, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiError, RuntimeApiUnavailableError, ScenarioNotSupportedError, SubmitTransactionError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, aggregateHopFees, applyDecimalAbstraction, assertAddressIsString, assertCurrencyCore, assertEvmAddress, assertExtensionInstalled, assertHasId, assertNotEvmTransfer, assertSender, assertSenderSource, assertSubstrateOrigin, assertSwapSupport, assertToIsString, blake2b256, blake2b512, buildCustomChainAssetsInfo, buildCustomChainConfig, buildDestInfo, buildDryRunError, buildHopInfo, buildOriginInfo, calcPreviewMintAmount, compareAddresses, computeOverridenAmount, constructTypeAndThenCall, convertBuilderConfig, convertSs58, createAsset, createAssetId, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createClientCache, createClientPoolHelpers, createCustomXcmOnDest, createDestination, createDirectExecuteXcm, createEthereumBridgeInstructions, createExecuteCall, createExecuteExchangeXcm, createSwapBuilder, createTransfer, createTransferOrSwap, createTransferOrSwapAll, createTxOverrideAmount, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, executeWithSwap, formatAssetIdToERC20, formatUnits, generateMessageId, getAssetBalanceInternal, getAssetReserveChain, getAssetReserveChainImpl, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainConfigImpl, getChainLocation, getChainProviders, getChainProvidersImpl, getChainVersion, getDryRunError, getErrorInstruction, getEthErc20Balance, getEvmExtensionOrThrow, getEvmPrivateKeyHex, getEvmSnowbridgeExtensionOrThrow, getLocalTransferAmount, getMinTransferableAmount, getMinTransferableAmountInternal, getOriginXcmFee, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getParaIdImpl, getRelayChainOf, getRelayChainOfImpl, getRelayChainSymbolOf, getSwapExtensionOrThrow, getTChain, getTSubstrateChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, isExchange, isNativeAssetTeleport, isSenderSigner, isViemSigner, keyFromWs, localizeLocation, localizeLocationImpl, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, normalizeCustomChains, normalizeExchange, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickOtherMintPallet, pickRouterCompatibleXcmVersion, registerEvmExtension, registerEvmSnowbridgeExtension, registerSwapExtension, resolveAssetCount, resolveDestChain, resolveModuleError, resolveParaId, resolveTransferParams, reverseTransformLocation, selectXcmVersion, sortAssets, throwUnsupportedCurrency, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateTransact, verifyEdOnDestination, wrapTxBypass };
14029
+ export { API_TYPES, AmountTooLowError, ApiNotInitializedError, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, CustomChainConflictError, CustomChainInvalidError, DEFAULT_TTL_MS, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETH_MAINNET_CHAIN_ID, ETH_TESTNET_CHAIN_ID, EXCHANGE_CHAINS, EXTENSION_MS, ExtensionNotInstalledError, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MAX_CLIENTS, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotApi, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiError, RuntimeApiUnavailableError, ScenarioNotSupportedError, SubmitTransactionError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, aggregateHopFees, applyDecimalAbstraction, assertAddressIsString, assertCurrencyCore, assertEvmAddress, assertExtensionInstalled, assertHasId, assertNotEvmTransfer, assertSender, assertSenderSource, assertSubstrateOrigin, assertSwapSupport, assertToIsString, blake2b256, blake2b512, buildCustomChainAssetsInfo, buildCustomChainConfig, buildDestInfo, buildDryRunError, buildErc20StorageMint, buildHopInfo, buildOriginInfo, calcPreviewMintAmount, compareAddresses, computeOverridenAmount, constructTypeAndThenCall, convertBuilderConfig, convertSs58, createAsset, createAssetId, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createClientCache, createClientPoolHelpers, createCustomXcmOnDest, createDestination, createDirectExecuteXcm, createEthereumBridgeInstructions, createExecuteCall, createExecuteExchangeXcm, createSwapBuilder, createTransfer, createTransferOrSwap, createTransferOrSwapAll, createTxOverrideAmount, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, executeWithSwap, formatAssetIdToERC20, formatUnits, generateMessageId, getAssetBalanceInternal, getAssetReserveChain, getAssetReserveChainImpl, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainConfigImpl, getChainLocation, getChainProviders, getChainProvidersImpl, getChainVersion, getDryRunError, getErrorInstruction, getEthErc20Balance, getEvmExtensionOrThrow, getEvmPrivateKeyHex, getEvmSnowbridgeExtensionOrThrow, getLocalTransferAmount, getMinTransferableAmount, getMinTransferableAmountInternal, getOriginXcmFee, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getParaIdImpl, getRelayChainOf, getRelayChainOfImpl, getRelayChainSymbolOf, getSwapExtensionOrThrow, getTChain, getTSubstrateChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, isExchange, isNativeAssetTeleport, isSenderSigner, isViemSigner, keyFromWs, localizeLocation, localizeLocationImpl, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, normalizeCustomChains, normalizeExchange, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickOtherMintPallet, pickRouterCompatibleXcmVersion, registerEvmExtension, registerEvmSnowbridgeExtension, registerSwapExtension, resolveAssetCount, resolveDestChain, resolveModuleError, resolveParaId, resolveTransferParams, reverseTransformLocation, selectXcmVersion, sortAssets, throwUnsupportedCurrency, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateTransact, verifyEdOnDestination, wrapTxBypass };