@paraspell/sdk-core 10.6.0 → 10.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2113,6 +2113,42 @@ var createBeneficiaryMultiLocation = function createBeneficiaryMultiLocation(_re
2113
2113
  }
2114
2114
  };
2115
2115
 
2116
+ /**
2117
+ * This function localizes a multiLocation by removing the `Parachain` junction
2118
+ * if it exists. The `parents` field is set to `0` either if a `Parachain` was removed
2119
+ * or if the resulting interior is `'Here'` and the node is a relay chain.
2120
+ *
2121
+ * @param node - The current node
2122
+ * @param multiLocation - The multiLocation to localize
2123
+ * @returns The localized multiLocation
2124
+ */
2125
+ var localizeLocation = function localizeLocation(node, multiLocation) {
2126
+ var newInterior = multiLocation.interior;
2127
+ var parachainRemoved = false;
2128
+ if (multiLocation.interior !== 'Here') {
2129
+ var junctions = Object.values(multiLocation.interior).flat().filter(function (junction) {
2130
+ return _typeof(junction) === 'object' && junction !== null;
2131
+ });
2132
+ var filteredJunctions = junctions.filter(function (junction) {
2133
+ if ('Parachain' in junction) {
2134
+ parachainRemoved = true;
2135
+ return false;
2136
+ }
2137
+ return true;
2138
+ });
2139
+ if (filteredJunctions.length === 0) {
2140
+ newInterior = 'Here';
2141
+ } else {
2142
+ newInterior = _defineProperty({}, "X".concat(filteredJunctions.length), filteredJunctions);
2143
+ }
2144
+ }
2145
+ var shouldSetParentsToZero = parachainRemoved || newInterior === 'Here' && sdkCommon.isRelayChain(node);
2146
+ return {
2147
+ parents: shouldSetParentsToZero ? sdkCommon.Parents.ZERO : multiLocation.parents,
2148
+ interior: newInterior
2149
+ };
2150
+ };
2151
+
2116
2152
  var reverseTransformMultiLocation = function reverseTransformMultiLocation(multiLocation) {
2117
2153
  var parachainJunction = {
2118
2154
  Parachain: 1000
@@ -2135,36 +2171,6 @@ var reverseTransformMultiLocation = function reverseTransformMultiLocation(multi
2135
2171
  });
2136
2172
  };
2137
2173
 
2138
- /**
2139
- * This function transforms a multiLocation by removing the `Parachain` junction
2140
- * if it exists and setting the `parents` to `0`.
2141
- *
2142
- * @param multiLocation - The multiLocation to transform
2143
- * @returns The transformed multiLocation
2144
- */
2145
- var transformMultiLocation = function transformMultiLocation(multiLocation) {
2146
- var newInterior;
2147
- if (multiLocation.interior === 'Here') {
2148
- newInterior = 'Here';
2149
- } else {
2150
- var junctions = Object.values(multiLocation.interior).flat().filter(function (junction) {
2151
- return _typeof(junction) === 'object' && junction !== null;
2152
- });
2153
- var filteredJunctions = junctions.filter(function (junction) {
2154
- return !('Parachain' in junction);
2155
- });
2156
- if (filteredJunctions.length === 0) {
2157
- newInterior = 'Here';
2158
- } else {
2159
- newInterior = _defineProperty({}, "X".concat(filteredJunctions.length), filteredJunctions);
2160
- }
2161
- }
2162
- return _objectSpread2(_objectSpread2({}, multiLocation), {}, {
2163
- parents: sdkCommon.Parents.ZERO,
2164
- interior: newInterior
2165
- });
2166
- };
2167
-
2168
2174
  var createBeneficiary = function createBeneficiary(options) {
2169
2175
  return createBeneficiaryMultiLocation(options);
2170
2176
  };
@@ -2401,15 +2407,6 @@ var resolveModuleError = function resolveModuleError(node, error) {
2401
2407
  return failureReason;
2402
2408
  };
2403
2409
 
2404
- var getFees = function getFees(scenario) {
2405
- if (scenario === 'ParaToRelay') {
2406
- return 4600000000;
2407
- } else if (scenario === 'ParaToPara') {
2408
- return 399600000000;
2409
- }
2410
- throw new InvalidParameterError("Fees for scenario ".concat(scenario, " are not defined."));
2411
- };
2412
-
2413
2410
  /**
2414
2411
  * Retrieves the node instance for a given node.
2415
2412
  *
@@ -2422,7 +2419,7 @@ var getNode = function getNode(node) {
2422
2419
  };
2423
2420
 
2424
2421
  var resolveParaId = function resolveParaId(paraId, destination) {
2425
- if (sdkCommon.isTMultiLocation(destination) || sdkCommon.isRelayChain(destination) || destination === 'Ethereum') {
2422
+ if (sdkCommon.isTMultiLocation(destination)) {
2426
2423
  return undefined;
2427
2424
  }
2428
2425
  return paraId !== null && paraId !== void 0 ? paraId : getParaId(destination);
@@ -2560,14 +2557,14 @@ var getModifiedCurrencySelection = function getModifiedCurrencySelection(input)
2560
2557
  return createDefaultCurrencySelection(input);
2561
2558
  };
2562
2559
 
2563
- var getXTokensParameters = function getXTokensParameters(isMultiAssetTransfer, currencySelection, destLocation, amount, fees, version, overriddenAsset) {
2560
+ var getXTokensParameters = function getXTokensParameters(isMultiAssetTransfer, currencySelection, destLocation, amount, weightLimit, version, overriddenAsset) {
2564
2561
  var versionedDestLocation = addXcmVersionHeader(destLocation, version);
2565
2562
  if (!isMultiAssetTransfer) {
2566
2563
  return {
2567
2564
  currency_id: currencySelection,
2568
2565
  amount: BigInt(amount),
2569
2566
  dest: versionedDestLocation,
2570
- dest_weight_limit: fees
2567
+ dest_weight_limit: weightLimit
2571
2568
  };
2572
2569
  }
2573
2570
  var isOverriddenMultiAssets = overriddenAsset && !sdkCommon.isTMultiLocation(overriddenAsset);
@@ -2580,7 +2577,7 @@ var getXTokensParameters = function getXTokensParameters(isMultiAssetTransfer, c
2580
2577
  fee_item: feeIndexWithFallback
2581
2578
  }), {}, {
2582
2579
  dest: versionedDestLocation,
2583
- dest_weight_limit: fees
2580
+ dest_weight_limit: weightLimit
2584
2581
  });
2585
2582
  };
2586
2583
 
@@ -4835,7 +4832,8 @@ var getDestXcmFee = /*#__PURE__*/function () {
4835
4832
  };
4836
4833
  }();
4837
4834
 
4838
- var getFailureInfo$1 = function getFailureInfo(results) {
4835
+ var getFailureInfo$1 = function getFailureInfo(results, hops) {
4836
+ // Check standard chains first for backwards compatibility
4839
4837
  for (var _i = 0, _arr = ['destination', 'assetHub', 'bridgeHub']; _i < _arr.length; _i++) {
4840
4838
  var chain = _arr[_i];
4841
4839
  var res = results[chain];
@@ -4846,17 +4844,34 @@ var getFailureInfo$1 = function getFailureInfo(results) {
4846
4844
  };
4847
4845
  }
4848
4846
  }
4847
+ var _iterator = _createForOfIteratorHelper(hops),
4848
+ _step;
4849
+ try {
4850
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
4851
+ var hop = _step.value;
4852
+ if (!hop.result.success && hop.result.failureReason) {
4853
+ return {
4854
+ failureReason: hop.result.failureReason,
4855
+ failureChain: hop.node
4856
+ };
4857
+ }
4858
+ }
4859
+ } catch (err) {
4860
+ _iterator.e(err);
4861
+ } finally {
4862
+ _iterator.f();
4863
+ }
4849
4864
  return {};
4850
4865
  };
4851
4866
  var dryRunInternal = /*#__PURE__*/function () {
4852
4867
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
4853
4868
  var _intermediateFees$bri, _intermediateFees$ass, _processedBridgeHubDa, _destinationDryRun;
4854
- var origin, destination, currency, api, tx, senderAddress, feeAsset, resolvedFeeAsset, asset, originDryRun, initialForwardedXcms, initialDestParaId, assetHubNode, bridgeHubNode, currentOrigin, forwardedXcms, nextParaId, intermediateFees, destinationDryRun, nextChain, hopApi, hopDryRun, newXcms, destParaId, processedBridgeHubData, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, _getFailureInfo, failureReason, failureChain;
4869
+ var origin, destination, currency, api, tx, senderAddress, feeAsset, resolvedFeeAsset, asset, originDryRun, initialForwardedXcms, initialDestParaId, assetHubNode, bridgeHubNode, currentOrigin, forwardedXcms, nextParaId, intermediateFees, hops, destinationDryRun, nextChain, hopApi, hopDryRun, hopCurrency, newXcms, destParaId, processedBridgeHubData, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, bridgeHubHopIndex, _getFailureInfo, failureReason, failureChain;
4855
4870
  return _regenerator().w(function (_context) {
4856
4871
  while (1) switch (_context.n) {
4857
4872
  case 0:
4858
4873
  origin = options.origin, destination = options.destination, currency = options.currency, api = options.api, tx = options.tx, senderAddress = options.senderAddress, feeAsset = options.feeAsset;
4859
- resolvedFeeAsset = feeAsset && origin === 'AssetHubPolkadot' ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
4874
+ resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
4860
4875
  asset = assets.findAssetForNodeOrThrow(origin, currency, destination);
4861
4876
  _context.n = 1;
4862
4877
  return api.getDryRunCall({
@@ -4875,7 +4890,8 @@ var dryRunInternal = /*#__PURE__*/function () {
4875
4890
  return _context.a(2, {
4876
4891
  failureReason: originDryRun.failureReason,
4877
4892
  failureChain: 'origin',
4878
- origin: originDryRun
4893
+ origin: originDryRun,
4894
+ hops: []
4879
4895
  });
4880
4896
  case 2:
4881
4897
  initialForwardedXcms = originDryRun.forwardedXcms, initialDestParaId = originDryRun.destParaId;
@@ -4885,6 +4901,7 @@ var dryRunInternal = /*#__PURE__*/function () {
4885
4901
  forwardedXcms = initialForwardedXcms;
4886
4902
  nextParaId = initialDestParaId;
4887
4903
  intermediateFees = {};
4904
+ hops = [];
4888
4905
  case 3:
4889
4906
  if (!(Array.isArray(forwardedXcms) && forwardedXcms.length && forwardedXcms[1].length && ('disconnect' in api.getApi() ? Object.values(forwardedXcms[1][0]).length : forwardedXcms[1][0].value.length) > 0 && nextParaId !== undefined)) {
4890
4907
  _context.n = 13;
@@ -4927,6 +4944,23 @@ var dryRunInternal = /*#__PURE__*/function () {
4927
4944
  });
4928
4945
  case 8:
4929
4946
  hopDryRun = _context.v;
4947
+ // Determine the currency for this hop
4948
+ hopCurrency = void 0;
4949
+ if (nextChain === destination) {
4950
+ hopCurrency = asset === null || asset === void 0 ? void 0 : asset.symbol;
4951
+ } else if (sdkCommon.isRelayChain(nextChain) || nextChain === assetHubNode || nextChain === bridgeHubNode) {
4952
+ hopCurrency = resolvedFeeAsset ? resolvedFeeAsset.symbol : assets.getNativeAssetSymbol(nextChain);
4953
+ }
4954
+ // Add to hops array (only if not the destination)
4955
+ if (nextChain !== destination) {
4956
+ hops.push({
4957
+ node: nextChain,
4958
+ result: hopDryRun.success && hopCurrency ? _objectSpread2(_objectSpread2({}, hopDryRun), {}, {
4959
+ currency: hopCurrency
4960
+ }) : hopDryRun
4961
+ });
4962
+ }
4963
+ // Keep existing logic for backwards compatibility
4930
4964
  if (nextChain === destination || sdkCommon.isRelayChain(nextChain) && !sdkCommon.isRelayChain(destination)) {
4931
4965
  destinationDryRun = hopDryRun;
4932
4966
  } else if (nextChain === assetHubNode) {
@@ -4972,12 +5006,21 @@ var dryRunInternal = /*#__PURE__*/function () {
4972
5006
  processedBridgeHubData = _objectSpread2(_objectSpread2({}, intermediateFees.bridgeHub), {}, {
4973
5007
  fee: intermediateFees.bridgeHub.fee + bridgeFee
4974
5008
  });
5009
+ // Update the hop data if BridgeHub is in the hops array
5010
+ bridgeHubHopIndex = hops.findIndex(function (hop) {
5011
+ return hop.node === bridgeHubNode;
5012
+ });
5013
+ if (bridgeHubHopIndex !== -1 && hops[bridgeHubHopIndex].result.success) {
5014
+ hops[bridgeHubHopIndex].result = _objectSpread2(_objectSpread2({}, hops[bridgeHubHopIndex].result), {}, {
5015
+ fee: intermediateFees.bridgeHub.fee + bridgeFee
5016
+ });
5017
+ }
4975
5018
  case 16:
4976
5019
  _getFailureInfo = getFailureInfo$1({
4977
5020
  destination: destinationDryRun,
4978
5021
  assetHub: intermediateFees.assetHub,
4979
5022
  bridgeHub: intermediateFees.bridgeHub
4980
- }), failureReason = _getFailureInfo.failureReason, failureChain = _getFailureInfo.failureChain;
5023
+ }, hops), failureReason = _getFailureInfo.failureReason, failureChain = _getFailureInfo.failureChain;
4981
5024
  return _context.a(2, {
4982
5025
  failureReason: failureReason,
4983
5026
  failureChain: failureChain,
@@ -4985,14 +5028,15 @@ var dryRunInternal = /*#__PURE__*/function () {
4985
5028
  currency: resolvedFeeAsset ? resolvedFeeAsset.symbol : assets.getNativeAssetSymbol(origin)
4986
5029
  }) : originDryRun,
4987
5030
  assetHub: (_intermediateFees$ass = intermediateFees.assetHub) !== null && _intermediateFees$ass !== void 0 && _intermediateFees$ass.success ? _objectSpread2(_objectSpread2({}, intermediateFees.assetHub), {}, {
4988
- currency: assets.getNativeAssetSymbol(assetHubNode)
5031
+ currency: resolvedFeeAsset ? resolvedFeeAsset.symbol : assets.getNativeAssetSymbol(assetHubNode)
4989
5032
  }) : intermediateFees.assetHub,
4990
5033
  bridgeHub: (_processedBridgeHubDa = processedBridgeHubData) !== null && _processedBridgeHubDa !== void 0 && _processedBridgeHubDa.success ? _objectSpread2(_objectSpread2({}, processedBridgeHubData), {}, {
4991
5034
  currency: assets.getNativeAssetSymbol(bridgeHubNode)
4992
5035
  }) : processedBridgeHubData,
4993
5036
  destination: (_destinationDryRun = destinationDryRun) !== null && _destinationDryRun !== void 0 && _destinationDryRun.success ? _objectSpread2(_objectSpread2({}, destinationDryRun), {}, {
4994
5037
  currency: asset === null || asset === void 0 ? void 0 : asset.symbol
4995
- }) : destinationDryRun
5038
+ }) : destinationDryRun,
5039
+ hops: hops // Add the hops array to the return value
4996
5040
  });
4997
5041
  }
4998
5042
  }, _callee, null, [[5,, 10, 12]]);
@@ -5896,6 +5940,7 @@ var send = /*#__PURE__*/function () {
5896
5940
  asset: normalizedAsset,
5897
5941
  currency: currency,
5898
5942
  feeAsset: resolvedFeeAsset,
5943
+ feeCurrency: feeAsset,
5899
5944
  address: address,
5900
5945
  to: destination,
5901
5946
  paraIdTo: paraIdTo,
@@ -5962,11 +6007,11 @@ var ParachainNode = /*#__PURE__*/function () {
5962
6007
  key: "transfer",
5963
6008
  value: function () {
5964
6009
  var _transfer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
5965
- var api, asset, currency, feeAsset, address, destination, paraIdTo, overriddenAsset, version, senderAddress, ahAddress, pallet, method, isRelayDestination, scenario, paraId, isLocalTransfer, isBifrostOrigin, isAssetHubDest, shouldUseMultiasset, input, _options, isEthAsset, isAHPOrigin, isAHPDest, isEthDest;
6010
+ var api, asset, currency, feeAsset, feeCurrency, address, destination, paraIdTo, overriddenAsset, version, senderAddress, ahAddress, pallet, method, isRelayDestination, scenario, paraId, isLocalTransfer, isBifrostOrigin, isAssetHubDest, shouldUseMultiasset, input, _options, isEthAsset, isAHPOrigin, isAHPDest, isEthDest;
5966
6011
  return _regenerator().w(function (_context) {
5967
6012
  while (1) switch (_context.n) {
5968
6013
  case 0:
5969
- api = options.api, asset = options.asset, currency = options.currency, feeAsset = options.feeAsset, address = options.address, destination = options.to, paraIdTo = options.paraIdTo, overriddenAsset = options.overriddenAsset, version = options.version, senderAddress = options.senderAddress, ahAddress = options.ahAddress, pallet = options.pallet, method = options.method;
6014
+ api = options.api, asset = options.asset, currency = options.currency, feeAsset = options.feeAsset, feeCurrency = options.feeCurrency, address = options.address, destination = options.to, paraIdTo = options.paraIdTo, overriddenAsset = options.overriddenAsset, version = options.version, senderAddress = options.senderAddress, ahAddress = options.ahAddress, pallet = options.pallet, method = options.method;
5970
6015
  isRelayDestination = !sdkCommon.isTMultiLocation(destination) && sdkCommon.isRelayChain(destination);
5971
6016
  scenario = isRelayDestination ? 'ParaToRelay' : 'ParaToPara';
5972
6017
  paraId = resolveParaId(paraIdTo, destination);
@@ -6002,7 +6047,6 @@ var ParachainNode = /*#__PURE__*/function () {
6002
6047
  version: version,
6003
6048
  paraId: paraId
6004
6049
  }),
6005
- fees: getFees(scenario),
6006
6050
  origin: this.node,
6007
6051
  scenario: scenario,
6008
6052
  paraIdTo: paraId,
@@ -6058,6 +6102,7 @@ var ParachainNode = /*#__PURE__*/function () {
6058
6102
  asset: asset,
6059
6103
  currency: currency,
6060
6104
  feeAsset: feeAsset,
6105
+ feeCurrency: feeCurrency,
6061
6106
  scenario: scenario,
6062
6107
  destination: destination,
6063
6108
  paraIdTo: paraId,
@@ -6071,13 +6116,13 @@ var ParachainNode = /*#__PURE__*/function () {
6071
6116
  isAHPOrigin = this.node === 'AssetHubPolkadot' || this.node === 'AssetHubKusama';
6072
6117
  isAHPDest = destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama';
6073
6118
  isEthDest = destination === 'Ethereum'; // Eth asset - Any origin to any dest via AH - DestinationReserve - multiple instructions
6074
- if (!(isEthAsset && !isAHPOrigin && !isAHPDest && !isEthDest)) {
6119
+ if (!(isEthAsset && !isAHPOrigin && !isAHPDest && !isEthDest && !feeAsset)) {
6075
6120
  _context.n = 6;
6076
6121
  break;
6077
6122
  }
6078
6123
  return _context.a(2, this.transferEthAssetViaAH(_options));
6079
6124
  case 6:
6080
- if (!(isEthAsset && isAHPDest && !isAHPOrigin && !isEthDest)) {
6125
+ if (!(isEthAsset && isAHPDest && !isAHPOrigin && !isEthDest && !feeAsset)) {
6081
6126
  _context.n = 7;
6082
6127
  break;
6083
6128
  }
@@ -6752,7 +6797,7 @@ var createExecuteExchangeXcm = function createExecuteExchangeXcm(input, weight,
6752
6797
  paraId: paraIdTo
6753
6798
  });
6754
6799
  assertHasLocation(asset);
6755
- var transformedMultiLocation = transformMultiLocation(asset.multiLocation);
6800
+ var transformedMultiLocation = localizeLocation('AssetHubPolkadot', asset.multiLocation);
6756
6801
  var call = {
6757
6802
  module: 'PolkadotXcm',
6758
6803
  method: 'execute',
@@ -6828,8 +6873,97 @@ var createExecuteExchangeXcm = function createExecuteExchangeXcm(input, weight,
6828
6873
  return api.callTxMethod(call);
6829
6874
  };
6830
6875
 
6831
- var createExecuteXcm = function createExecuteXcm(input, executionFee, version) {
6832
- var _feeAsset$multiLocati;
6876
+ var getReserveParaId = function getReserveParaId(assetLocation) {
6877
+ var hasParaJunction = sdkCommon.hasJunction(assetLocation, 'Parachain');
6878
+ var hasGlobalConsensusJunction = sdkCommon.hasJunction(assetLocation, 'GlobalConsensus');
6879
+ if (hasParaJunction) {
6880
+ return sdkCommon.getJunctionValue(assetLocation, 'Parachain');
6881
+ }
6882
+ if (hasGlobalConsensusJunction) {
6883
+ return getParaId('AssetHubPolkadot');
6884
+ }
6885
+ if (sdkCommon.deepEqual(assetLocation, {
6886
+ parents: sdkCommon.Parents.ONE,
6887
+ interior: {
6888
+ Here: null
6889
+ }
6890
+ })) {
6891
+ return getParaId('Polkadot');
6892
+ }
6893
+ };
6894
+ var isOnReserveChain = function isOnReserveChain(node, reserveParaId) {
6895
+ if (reserveParaId === undefined) return false;
6896
+ var currentParaId = getParaId(node);
6897
+ return currentParaId === reserveParaId;
6898
+ };
6899
+ var getChainLocation = function getChainLocation(paraId) {
6900
+ var interior = paraId === getParaId('Polkadot') ? 'Here' : {
6901
+ X1: [{
6902
+ Parachain: paraId
6903
+ }]
6904
+ };
6905
+ return {
6906
+ parents: sdkCommon.Parents.ONE,
6907
+ interior: interior
6908
+ };
6909
+ };
6910
+ var createAssetsFilter = function createAssetsFilter(asset, feeAsset) {
6911
+ return !feeAsset ?
6912
+ // For same fee asset, deposit only this one asset
6913
+ {
6914
+ Wild: {
6915
+ AllCounted: 1
6916
+ }
6917
+ } :
6918
+ // For different fee asset, specify which one to deposit by location and amount
6919
+ {
6920
+ Definite: [asset]
6921
+ };
6922
+ };
6923
+ var sortMultiAssets = function sortMultiAssets(assets$1) {
6924
+ return assets$1.sort(function (a, b) {
6925
+ var aLoc = assets.extractMultiAssetLoc(a);
6926
+ var bLoc = assets.extractMultiAssetLoc(b);
6927
+ var aIsHere = isHere(aLoc);
6928
+ var bIsHere = isHere(bLoc);
6929
+ var aHasGlobal = sdkCommon.hasJunction(aLoc, 'GlobalConsensus');
6930
+ var bHasGlobal = sdkCommon.hasJunction(bLoc, 'GlobalConsensus');
6931
+ var aGeneralIndex = sdkCommon.getJunctionValue(aLoc, 'GeneralIndex');
6932
+ var bGeneralIndex = sdkCommon.getJunctionValue(bLoc, 'GeneralIndex');
6933
+ var getPriority = function getPriority(isHere, hasGlobal) {
6934
+ if (isHere) return 0;
6935
+ if (hasGlobal) return 2;
6936
+ return 1;
6937
+ };
6938
+ var aPriority = getPriority(aIsHere, aHasGlobal);
6939
+ var bPriority = getPriority(bIsHere, bHasGlobal);
6940
+ if (aPriority !== bPriority) return aPriority - bPriority;
6941
+ if (aGeneralIndex === undefined && bGeneralIndex === undefined) return 0;
6942
+ if (aGeneralIndex === undefined) return 1;
6943
+ if (bGeneralIndex === undefined) return -1;
6944
+ return aGeneralIndex - bGeneralIndex;
6945
+ });
6946
+ };
6947
+ function isHere(loc) {
6948
+ var _loc$interior;
6949
+ return loc.interior === 'Here' || ((_loc$interior = loc.interior) === null || _loc$interior === void 0 ? void 0 : _loc$interior.Here) !== undefined;
6950
+ }
6951
+ var updateAsset = function updateAsset(asset, amount) {
6952
+ return _objectSpread2(_objectSpread2({}, asset), {}, {
6953
+ fun: {
6954
+ Fungible: amount
6955
+ }
6956
+ });
6957
+ };
6958
+ var createWithdrawAssets = function createWithdrawAssets(asset, feeAsset) {
6959
+ var assetsToWithdraw = [asset];
6960
+ if (feeAsset) {
6961
+ assetsToWithdraw.push(feeAsset);
6962
+ }
6963
+ return sortMultiAssets(assetsToWithdraw);
6964
+ };
6965
+ var createExecuteXcm = function createExecuteXcm(node, input, executionFee, hopExecutionFee, version) {
6966
+ var _ref;
6833
6967
  var api = input.api,
6834
6968
  asset = input.asset,
6835
6969
  scenario = input.scenario,
@@ -6837,6 +6971,7 @@ var createExecuteXcm = function createExecuteXcm(input, executionFee, version) {
6837
6971
  paraIdTo = input.paraIdTo,
6838
6972
  address = input.address,
6839
6973
  feeAsset = input.feeAsset;
6974
+ var amount = BigInt(asset.amount);
6840
6975
  var dest = createDestination(scenario, version, destination, paraIdTo);
6841
6976
  var beneficiary = createBeneficiary({
6842
6977
  api: api,
@@ -6846,78 +6981,36 @@ var createExecuteXcm = function createExecuteXcm(input, executionFee, version) {
6846
6981
  version: version,
6847
6982
  paraId: paraIdTo
6848
6983
  });
6849
- if (!assets.isForeignAsset(asset) || !asset.multiLocation || !asset.assetId) {
6850
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is missing multiLocation or assetId"));
6851
- }
6852
- if (feeAsset && (!assets.isForeignAsset(feeAsset) || !feeAsset.multiLocation || !feeAsset.assetId)) {
6853
- throw new assets.InvalidCurrencyError("Fee asset ".concat(JSON.stringify(feeAsset), " is missing multiLocation or assetId"));
6854
- }
6855
- var assetML = transformMultiLocation(asset.multiLocation);
6856
- var feeML = transformMultiLocation((_feeAsset$multiLocati = feeAsset === null || feeAsset === void 0 ? void 0 : feeAsset.multiLocation) !== null && _feeAsset$multiLocati !== void 0 ? _feeAsset$multiLocati : asset.multiLocation);
6857
- var sameFeeAsset = feeAsset && assets.isAssetEqual(asset, feeAsset);
6858
- var amountWithoutFee = BigInt(asset.amount) - executionFee;
6859
- var assetsToWithdraw = [{
6860
- assetId: asset.assetId,
6861
- multiasset: {
6862
- id: assetML,
6863
- fun: {
6864
- Fungible: BigInt(asset.amount)
6865
- }
6866
- }
6867
- }];
6868
- if (!sameFeeAsset && feeAsset !== null && feeAsset !== void 0 && feeAsset.multiLocation) {
6869
- assetsToWithdraw.push({
6870
- assetId: feeAsset.assetId,
6871
- multiasset: {
6872
- id: feeML,
6873
- fun: {
6874
- Fungible: executionFee
6875
- }
6876
- }
6877
- });
6878
- }
6879
- assetsToWithdraw.sort(function (a, b) {
6880
- return a.assetId > b.assetId ? 1 : -1;
6881
- });
6882
- var xcm = [{
6883
- WithdrawAsset: assetsToWithdraw.map(function (_ref) {
6884
- var multiasset = _ref.multiasset;
6885
- return multiasset;
6886
- })
6887
- }, {
6888
- BuyExecution: {
6889
- fees: {
6890
- id: feeML,
6891
- fun: {
6892
- Fungible: executionFee
6893
- }
6894
- },
6895
- weight_limit: {
6896
- Limited: {
6897
- ref_time: 150n,
6898
- proof_size: 0n
6899
- }
6900
- }
6984
+ assertHasLocation(asset);
6985
+ if (feeAsset) {
6986
+ assertHasLocation(feeAsset);
6987
+ }
6988
+ var reserveParaId = getReserveParaId(asset.multiLocation);
6989
+ var reserveChain = reserveParaId !== undefined ? getTNode(reserveParaId, determineRelayChain(node) === 'Polkadot' ? 'polkadot' : 'kusama') : undefined;
6990
+ var isReserveDest = reserveParaId === paraIdTo;
6991
+ var multiAsset = createMultiAsset(version, amount, asset.multiLocation);
6992
+ var multiAssetLocalized = createMultiAsset(version, amount, localizeLocation(node, asset.multiLocation));
6993
+ var multiAssetLocalizedToReserve = createMultiAsset(version, amount, localizeLocation(reserveChain !== null && reserveChain !== void 0 ? reserveChain : node, asset.multiLocation));
6994
+ var feeMultiAsset = feeAsset && !assets.isAssetEqual(asset, feeAsset) ? createMultiAsset(version, executionFee, feeAsset.multiLocation) : undefined;
6995
+ var feeMultiAssetLocalized = feeAsset && !assets.isAssetEqual(asset, feeAsset) ? createMultiAsset(version, executionFee, localizeLocation(node, feeAsset.multiLocation)) : undefined;
6996
+ var feeMultiAssetLocalizedToReserve = feeAsset && !assets.isAssetEqual(asset, feeAsset) ? createMultiAsset(version, executionFee, localizeLocation(reserveChain !== null && reserveChain !== void 0 ? reserveChain : node, feeAsset.multiLocation)) : undefined;
6997
+ var withdrawAssets = createWithdrawAssets(node === 'AssetHubPolkadot' ? multiAssetLocalized : multiAsset, node === 'AssetHubPolkadot' ? feeMultiAssetLocalized : feeMultiAsset);
6998
+ var assetsFilter = createAssetsFilter(multiAsset, feeMultiAsset);
6999
+ if (node !== 'AssetHubPolkadot' && reserveParaId === undefined) {
7000
+ throw new InvalidParameterError('Sending local reserve assets with custom fee asset is not yet supported for this chain.');
7001
+ }
7002
+ var depositInstruction = isReserveDest ? {
7003
+ DepositAsset: {
7004
+ assets: createAssetsFilter(multiAssetLocalizedToReserve, feeMultiAssetLocalizedToReserve),
7005
+ beneficiary: beneficiary
6901
7006
  }
6902
- }, {
7007
+ } : {
6903
7008
  DepositReserveAsset: {
6904
- assets: {
6905
- Definite: [{
6906
- id: assetML,
6907
- fun: {
6908
- Fungible: sameFeeAsset ? amountWithoutFee : BigInt(asset.amount)
6909
- }
6910
- }]
6911
- },
7009
+ assets: createAssetsFilter(multiAssetLocalized, feeMultiAssetLocalized),
6912
7010
  dest: dest,
6913
7011
  xcm: [{
6914
7012
  BuyExecution: {
6915
- fees: {
6916
- id: asset.multiLocation,
6917
- fun: {
6918
- Fungible: sameFeeAsset ? amountWithoutFee - executionFee : BigInt(asset.amount)
6919
- }
6920
- },
7013
+ fees: updateAsset(multiAsset, amount - (feeMultiAsset ? hopExecutionFee : executionFee + hopExecutionFee)),
6921
7014
  weight_limit: 'Unlimited'
6922
7015
  }
6923
7016
  }, {
@@ -6931,10 +7024,149 @@ var createExecuteXcm = function createExecuteXcm(input, executionFee, version) {
6931
7024
  }
6932
7025
  }]
6933
7026
  }
6934
- }];
7027
+ };
7028
+ var needsIntermediaryReserve = reserveParaId !== undefined &&
7029
+ // Has a reserve
7030
+ !isOnReserveChain(node, reserveParaId); // Not on reserve
7031
+ var lastInstruction = needsIntermediaryReserve ? {
7032
+ InitiateReserveWithdraw: {
7033
+ assets: assetsFilter,
7034
+ reserve: getChainLocation(reserveParaId),
7035
+ xcm: [{
7036
+ BuyExecution: {
7037
+ fees:
7038
+ // Decrease amount by 2 units becuase for some reason polkadot withdraws 2 units less
7039
+ // than requested, so we need to account for that
7040
+ updateAsset(multiAssetLocalizedToReserve, amount - 2n),
7041
+ weight_limit: 'Unlimited'
7042
+ }
7043
+ }, depositInstruction]
7044
+ }
7045
+ } : depositInstruction;
7046
+ var xcm = [{
7047
+ WithdrawAsset: withdrawAssets
7048
+ }, {
7049
+ BuyExecution: {
7050
+ fees: (_ref = node === 'AssetHubPolkadot' ? feeMultiAssetLocalized : feeMultiAsset) !== null && _ref !== void 0 ? _ref : node === 'AssetHubPolkadot' ? multiAssetLocalized : multiAsset,
7051
+ weight_limit: {
7052
+ Limited: {
7053
+ ref_time: 450n,
7054
+ proof_size: 0n
7055
+ }
7056
+ }
7057
+ }
7058
+ }, lastInstruction];
6935
7059
  return addXcmVersionHeader(xcm, version);
6936
7060
  };
6937
7061
 
7062
+ var handleExecuteTransfer = /*#__PURE__*/function () {
7063
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(node, input) {
7064
+ var api, senderAddress, paraIdTo, asset, currency, feeCurrency, address, feeAsset, version, feeAssetBalance, checkAmount, MIN_FEE, call, destNode, dryRunResult, paddedFee, hopFee, paddedHopFee, xcm, weight, _t;
7065
+ return _regenerator().w(function (_context) {
7066
+ while (1) switch (_context.n) {
7067
+ case 0:
7068
+ api = input.api, senderAddress = input.senderAddress, paraIdTo = input.paraIdTo, asset = input.asset, currency = input.currency, feeCurrency = input.feeCurrency, address = input.address, feeAsset = input.feeAsset, version = input.version;
7069
+ if (senderAddress) {
7070
+ _context.n = 1;
7071
+ break;
7072
+ }
7073
+ throw new InvalidParameterError('Please provide senderAddress');
7074
+ case 1:
7075
+ assertAddressIsString(address);
7076
+ validateAddress(senderAddress, node, false);
7077
+ if (!(feeCurrency && feeAsset && !assets.isAssetEqual(asset, feeAsset))) {
7078
+ _context.n = 3;
7079
+ break;
7080
+ }
7081
+ _context.n = 2;
7082
+ return getAssetBalanceInternal({
7083
+ api: api,
7084
+ address: senderAddress,
7085
+ node: node,
7086
+ currency: feeCurrency
7087
+ });
7088
+ case 2:
7089
+ _t = _context.v;
7090
+ _context.n = 4;
7091
+ break;
7092
+ case 3:
7093
+ _t = undefined;
7094
+ case 4:
7095
+ feeAssetBalance = _t;
7096
+ checkAmount = function checkAmount(fee) {
7097
+ if (BigInt(asset.amount) <= fee) {
7098
+ throw new InvalidParameterError("Asset amount is too low, please increase the amount or use a different fee asset.");
7099
+ }
7100
+ };
7101
+ MIN_FEE = 1000n;
7102
+ checkAmount(MIN_FEE);
7103
+ call = createExecuteCall(createExecuteXcm(node, input, feeAssetBalance && feeAssetBalance > 1n ? feeAssetBalance : MIN_FEE, MIN_FEE, version), MAX_WEIGHT);
7104
+ destNode = getTNode(paraIdTo, determineRelayChain(node) === 'Polkadot' ? 'polkadot' : 'kusama');
7105
+ _context.n = 5;
7106
+ return dryRunInternal({
7107
+ api: api,
7108
+ tx: api.callTxMethod(call),
7109
+ origin: node,
7110
+ destination: destNode,
7111
+ senderAddress: senderAddress,
7112
+ address: address,
7113
+ currency: currency,
7114
+ feeAsset: feeCurrency
7115
+ });
7116
+ case 5:
7117
+ dryRunResult = _context.v;
7118
+ if (dryRunResult.origin.success) {
7119
+ _context.n = 6;
7120
+ break;
7121
+ }
7122
+ throw new DryRunFailedError(dryRunResult.failureReason);
7123
+ case 6:
7124
+ if (!(dryRunResult.assetHub && !dryRunResult.assetHub.success)) {
7125
+ _context.n = 7;
7126
+ break;
7127
+ }
7128
+ throw new DryRunFailedError(dryRunResult.failureReason);
7129
+ case 7:
7130
+ if (!(!dryRunResult.assetHub && dryRunResult.hops)) {
7131
+ _context.n = 9;
7132
+ break;
7133
+ }
7134
+ if (!(dryRunResult.hops.length > 1)) {
7135
+ _context.n = 8;
7136
+ break;
7137
+ }
7138
+ throw new InvalidParameterError("Multiple intermediate hops detected (".concat(dryRunResult.hops.length, "). Only single hop transfers are supported."));
7139
+ case 8:
7140
+ if (!(dryRunResult.hops.length === 1 && !dryRunResult.hops[0].result.success)) {
7141
+ _context.n = 9;
7142
+ break;
7143
+ }
7144
+ throw new DryRunFailedError(dryRunResult.failureReason);
7145
+ case 9:
7146
+ paddedFee = padFeeBy(dryRunResult.origin.fee, 20);
7147
+ if (dryRunResult.assetHub) {
7148
+ hopFee = dryRunResult.assetHub.fee;
7149
+ } else if (dryRunResult.hops && dryRunResult.hops.length === 1 && dryRunResult.hops[0].result.success) {
7150
+ hopFee = dryRunResult.hops[0].result.fee;
7151
+ } else {
7152
+ hopFee = MIN_FEE;
7153
+ }
7154
+ paddedHopFee = padFeeBy(hopFee, 40);
7155
+ checkAmount(feeAsset && !assets.isAssetEqual(asset, feeAsset) ? paddedHopFee : paddedFee + paddedHopFee);
7156
+ xcm = createExecuteXcm(node, input, paddedFee, paddedHopFee, version);
7157
+ _context.n = 10;
7158
+ return api.getXcmWeight(xcm);
7159
+ case 10:
7160
+ weight = _context.v;
7161
+ return _context.a(2, createExecuteCall(xcm, weight));
7162
+ }
7163
+ }, _callee);
7164
+ }));
7165
+ return function handleExecuteTransfer(_x, _x2) {
7166
+ return _ref.apply(this, arguments);
7167
+ };
7168
+ }();
7169
+
6938
7170
  var handleToAhTeleport = /*#__PURE__*/function () {
6939
7171
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(origin, input, defaultTx) {
6940
7172
  var _dryRunResult$destina, _feeResult$origin$wei;
@@ -7287,154 +7519,94 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7287
7519
  if (destination === 'Polimec' || destination === 'Moonbeam') return 'transfer_assets';
7288
7520
  return scenario === 'ParaToPara' && !isSystemNode ? 'limited_reserve_transfer_assets' : 'limited_teleport_assets';
7289
7521
  }
7290
- }, {
7291
- key: "handleExecuteTransfer",
7292
- value: function () {
7293
- var _handleExecuteTransfer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(input) {
7294
- var api, senderAddress, asset, feeAsset, version, decimals, multiplier, base, scaledMultiplier, MIN_FEE, checkAmount, call, dryRunResult, paddedFee, xcm, weight;
7295
- return _regenerator().w(function (_context3) {
7296
- while (1) switch (_context3.n) {
7297
- case 0:
7298
- api = input.api, senderAddress = input.senderAddress, asset = input.asset, feeAsset = input.feeAsset, version = input.version;
7299
- if (senderAddress) {
7300
- _context3.n = 1;
7301
- break;
7302
- }
7303
- throw new InvalidParameterError('Please provide senderAddress');
7304
- case 1:
7305
- validateAddress(senderAddress, this.node, false);
7306
- decimals = asset.decimals;
7307
- multiplier = decimals > 10 ? 0.4 : 0.15;
7308
- base = BigInt(Math.pow(10, decimals));
7309
- scaledMultiplier = BigInt(Math.floor(multiplier * Math.pow(10, decimals)));
7310
- MIN_FEE = base * scaledMultiplier / BigInt(Math.pow(10, decimals));
7311
- checkAmount = function checkAmount(fee) {
7312
- if (feeAsset && assets.isAssetEqual(asset, feeAsset) && BigInt(asset.amount) <= fee * 2n) {
7313
- throw new InvalidParameterError("Asset amount ".concat(asset.amount, " is too low, please increase the amount or use a different fee asset."));
7314
- }
7315
- };
7316
- checkAmount(MIN_FEE);
7317
- call = createExecuteCall(createExecuteXcm(input, MIN_FEE, version), MAX_WEIGHT);
7318
- _context3.n = 2;
7319
- return api.getDryRunCall({
7320
- node: this.node,
7321
- tx: api.callTxMethod(call),
7322
- address: senderAddress,
7323
- asset: asset,
7324
- feeAsset: feeAsset
7325
- });
7326
- case 2:
7327
- dryRunResult = _context3.v;
7328
- if (dryRunResult.success) {
7329
- _context3.n = 3;
7330
- break;
7331
- }
7332
- throw new DryRunFailedError(dryRunResult.failureReason);
7333
- case 3:
7334
- paddedFee = dryRunResult.fee * 120n / 100n;
7335
- checkAmount(paddedFee);
7336
- xcm = createExecuteXcm(input, paddedFee, version);
7337
- _context3.n = 4;
7338
- return api.getXcmWeight(xcm);
7339
- case 4:
7340
- weight = _context3.v;
7341
- return _context3.a(2, createExecuteCall(createExecuteXcm(input, paddedFee, version), weight));
7342
- }
7343
- }, _callee3, this);
7344
- }));
7345
- function handleExecuteTransfer(_x3) {
7346
- return _handleExecuteTransfer.apply(this, arguments);
7347
- }
7348
- return handleExecuteTransfer;
7349
- }()
7350
7522
  }, {
7351
7523
  key: "transferPolkadotXCM",
7352
7524
  value: function () {
7353
- var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(input) {
7525
+ var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(input) {
7354
7526
  var api, scenario, asset, destination, feeAsset, overriddenAsset, isNativeAsset, isEthereumAsset, isSystemNode, method, modifiedInput, _t, _t2;
7355
- return _regenerator().w(function (_context4) {
7356
- while (1) switch (_context4.n) {
7527
+ return _regenerator().w(function (_context3) {
7528
+ while (1) switch (_context3.n) {
7357
7529
  case 0:
7358
7530
  api = input.api, scenario = input.scenario, asset = input.asset, destination = input.destination, feeAsset = input.feeAsset, overriddenAsset = input.overriddenAsset;
7359
7531
  if (!feeAsset) {
7360
- _context4.n = 4;
7532
+ _context3.n = 4;
7361
7533
  break;
7362
7534
  }
7363
7535
  if (!overriddenAsset) {
7364
- _context4.n = 1;
7536
+ _context3.n = 1;
7365
7537
  break;
7366
7538
  }
7367
7539
  throw new assets.InvalidCurrencyError('Cannot use overridden multi-assets with XCM execute');
7368
7540
  case 1:
7369
- if (!(assets.normalizeSymbol(asset.symbol) === assets.normalizeSymbol('KSM'))) {
7370
- _context4.n = 2;
7541
+ if (!assets.isSymbolMatch(asset.symbol, 'KSM')) {
7542
+ _context3.n = 2;
7371
7543
  break;
7372
7544
  }
7373
- return _context4.a(2, this.handleLocalReserveTransfer(input));
7545
+ return _context3.a(2, this.handleLocalReserveTransfer(input));
7374
7546
  case 2:
7375
- isNativeAsset = asset.symbol === this.getNativeAssetSymbol();
7547
+ isNativeAsset = assets.isSymbolMatch(asset.symbol, this.getNativeAssetSymbol());
7376
7548
  if (isNativeAsset) {
7377
- _context4.n = 4;
7549
+ _context3.n = 4;
7378
7550
  break;
7379
7551
  }
7380
7552
  _t = api;
7381
- _context4.n = 3;
7382
- return this.handleExecuteTransfer(input);
7553
+ _context3.n = 3;
7554
+ return handleExecuteTransfer(this.node, input);
7383
7555
  case 3:
7384
- _t2 = _context4.v;
7385
- return _context4.a(2, _t.callTxMethod.call(_t, _t2));
7556
+ _t2 = _context3.v;
7557
+ return _context3.a(2, _t.callTxMethod.call(_t, _t2));
7386
7558
  case 4:
7387
7559
  if (!(destination === 'AssetHubKusama')) {
7388
- _context4.n = 5;
7560
+ _context3.n = 5;
7389
7561
  break;
7390
7562
  }
7391
- return _context4.a(2, this.handleBridgeTransfer(input, 'Kusama'));
7563
+ return _context3.a(2, this.handleBridgeTransfer(input, 'Kusama'));
7392
7564
  case 5:
7393
7565
  if (!(destination === 'Ethereum')) {
7394
- _context4.n = 6;
7566
+ _context3.n = 6;
7395
7567
  break;
7396
7568
  }
7397
- return _context4.a(2, this.handleEthBridgeTransfer(input));
7569
+ return _context3.a(2, this.handleEthBridgeTransfer(input));
7398
7570
  case 6:
7399
7571
  if (!(destination === 'Mythos')) {
7400
- _context4.n = 7;
7572
+ _context3.n = 7;
7401
7573
  break;
7402
7574
  }
7403
- return _context4.a(2, this.handleMythosTransfer(input));
7575
+ return _context3.a(2, this.handleMythosTransfer(input));
7404
7576
  case 7:
7405
7577
  isEthereumAsset = asset.multiLocation && assets.findAssetByMultiLocation(assets.getOtherAssets('Ethereum'), asset.multiLocation);
7406
7578
  if (!(destination === 'BifrostPolkadot' && isEthereumAsset)) {
7407
- _context4.n = 8;
7579
+ _context3.n = 8;
7408
7580
  break;
7409
7581
  }
7410
- return _context4.a(2, this.handleLocalReserveTransfer(input));
7582
+ return _context3.a(2, this.handleLocalReserveTransfer(input));
7411
7583
  case 8:
7412
7584
  if (!isEthereumAsset) {
7413
- _context4.n = 9;
7585
+ _context3.n = 9;
7414
7586
  break;
7415
7587
  }
7416
- return _context4.a(2, this.handleLocalReserveTransfer(input, true));
7588
+ return _context3.a(2, this.handleLocalReserveTransfer(input, true));
7417
7589
  case 9:
7418
7590
  isSystemNode = !sdkCommon.isTMultiLocation(destination) && SYSTEM_NODES_POLKADOT.includes(destination);
7419
7591
  if (!(scenario === 'ParaToPara' && asset.symbol === 'DOT' && !assets.isForeignAsset(asset) && destination !== 'Hydration' && destination !== 'Polimec' && destination !== 'Moonbeam' && destination !== 'BifrostPolkadot' && destination !== 'PeoplePolkadot' && destination !== 'Ajuna' && !isSystemNode)) {
7420
- _context4.n = 10;
7592
+ _context3.n = 10;
7421
7593
  break;
7422
7594
  }
7423
7595
  throw new ScenarioNotSupportedError(this.node, scenario, 'Some Parachains do not have a reserve for DOT on AssetHub. This can also include multihop transfers that have AssetHub as a hop chain and the call contains DOT. Chains that do not have a DOT reserve on AssetHub are not allowed to transfer DOT to it or through it because this transfer will result in asset loss.');
7424
7596
  case 10:
7425
7597
  if (!(scenario === 'ParaToPara' && asset.symbol === 'KSM' && !assets.isForeignAsset(asset))) {
7426
- _context4.n = 11;
7598
+ _context3.n = 11;
7427
7599
  break;
7428
7600
  }
7429
7601
  throw new ScenarioNotSupportedError(this.node, scenario, 'Bridged KSM cannot currently be transfered from AssetHubPolkadot, if you are sending different KSM asset, please specify {id: <KSMID>}.');
7430
7602
  case 11:
7431
7603
  method = this.getMethod(scenario, destination);
7432
7604
  modifiedInput = this.patchInput(input);
7433
- return _context4.a(2, transferPolkadotXcm(modifiedInput, method, 'Unlimited'));
7605
+ return _context3.a(2, transferPolkadotXcm(modifiedInput, method, 'Unlimited'));
7434
7606
  }
7435
- }, _callee4, this);
7607
+ }, _callee3, this);
7436
7608
  }));
7437
- function transferPolkadotXCM(_x4) {
7609
+ function transferPolkadotXCM(_x3) {
7438
7610
  return _transferPolkadotXCM.apply(this, arguments);
7439
7611
  }
7440
7612
  return transferPolkadotXCM;
@@ -7460,7 +7632,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7460
7632
  if (!multiLocation) {
7461
7633
  throw new assets.InvalidCurrencyError('Asset does not have a multiLocation defined');
7462
7634
  }
7463
- var transformedMultiLocation = sdkCommon.hasJunction(multiLocation, 'Parachain', 1000) ? transformMultiLocation(multiLocation) : multiLocation;
7635
+ var transformedMultiLocation = sdkCommon.hasJunction(multiLocation, 'Parachain', getParaId(this.node)) ? localizeLocation(this.node, multiLocation) : multiLocation;
7464
7636
  return createMultiAsset(version, amount, transformedMultiLocation);
7465
7637
  } else {
7466
7638
  return _superPropGet(AssetHubPolkadot, "createCurrencySpec", this, 3)([amount, scenario, version, asset]);
@@ -8413,23 +8585,46 @@ var Hydration = /*#__PURE__*/function (_ParachainNode) {
8413
8585
  key: "transferPolkadotXCM",
8414
8586
  value: function () {
8415
8587
  var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(input) {
8416
- var destination;
8588
+ var api, destination, feeAsset, asset, overriddenAsset, isNativeAsset, isNativeFeeAsset, _t, _t2;
8417
8589
  return _regenerator().w(function (_context) {
8418
8590
  while (1) switch (_context.n) {
8419
8591
  case 0:
8420
- destination = input.destination;
8592
+ api = input.api, destination = input.destination, feeAsset = input.feeAsset, asset = input.asset, overriddenAsset = input.overriddenAsset;
8421
8593
  if (!(destination === 'Ethereum')) {
8422
8594
  _context.n = 1;
8423
8595
  break;
8424
8596
  }
8425
8597
  return _context.a(2, this.transferToEthereum(input));
8426
8598
  case 1:
8427
- if (!(destination === 'Polimec')) {
8599
+ if (!feeAsset) {
8600
+ _context.n = 4;
8601
+ break;
8602
+ }
8603
+ if (!overriddenAsset) {
8428
8604
  _context.n = 2;
8429
8605
  break;
8430
8606
  }
8431
- return _context.a(2, this.transferToPolimec(input));
8607
+ throw new assets.InvalidCurrencyError('Cannot use overridden multi-assets with XCM execute');
8432
8608
  case 2:
8609
+ isNativeAsset = assets.isSymbolMatch(asset.symbol, this.getNativeAssetSymbol());
8610
+ isNativeFeeAsset = assets.isSymbolMatch(feeAsset.symbol, this.getNativeAssetSymbol());
8611
+ if (!(!isNativeAsset || !isNativeFeeAsset)) {
8612
+ _context.n = 4;
8613
+ break;
8614
+ }
8615
+ _t = api;
8616
+ _context.n = 3;
8617
+ return handleExecuteTransfer(this.node, input);
8618
+ case 3:
8619
+ _t2 = _context.v;
8620
+ return _context.a(2, _t.callTxMethod.call(_t, _t2));
8621
+ case 4:
8622
+ if (!(destination === 'Polimec')) {
8623
+ _context.n = 5;
8624
+ break;
8625
+ }
8626
+ return _context.a(2, this.transferToPolimec(input));
8627
+ case 5:
8433
8628
  return _context.a(2, this.transferToAssetHub(input));
8434
8629
  }
8435
8630
  }, _callee, this);
@@ -8455,9 +8650,10 @@ var Hydration = /*#__PURE__*/function (_ParachainNode) {
8455
8650
  key: "canUseXTokens",
8456
8651
  value: function canUseXTokens(_ref3) {
8457
8652
  var destination = _ref3.to,
8458
- asset = _ref3.asset;
8653
+ asset = _ref3.asset,
8654
+ feeAsset = _ref3.feeAsset;
8459
8655
  var isEthAsset = asset.multiLocation && assets.findAssetByMultiLocation(assets.getOtherAssets('Ethereum'), asset.multiLocation);
8460
- return destination !== 'Ethereum' && destination !== 'Polimec' && !(destination === 'AssetHubPolkadot' && asset.symbol === 'DOT') && !isEthAsset;
8656
+ return destination !== 'Ethereum' && destination !== 'Polimec' && !(destination === 'AssetHubPolkadot' && asset.symbol === 'DOT') && !isEthAsset && !feeAsset;
8461
8657
  }
8462
8658
  }, {
8463
8659
  key: "transferLocalNativeAsset",
@@ -10404,7 +10600,6 @@ exports.getBalanceForeignInternal = getBalanceForeignInternal;
10404
10600
  exports.getBalanceNative = getBalanceNative;
10405
10601
  exports.getBalanceNativeInternal = getBalanceNativeInternal;
10406
10602
  exports.getBridgeStatus = getBridgeStatus;
10407
- exports.getFees = getFees;
10408
10603
  exports.getNode = getNode;
10409
10604
  exports.getNodeConfig = getNodeConfig;
10410
10605
  exports.getNodeProviders = getNodeProviders;
@@ -10420,6 +10615,7 @@ exports.getTransferableAmount = getTransferableAmount;
10420
10615
  exports.getTransferableAmountInternal = getTransferableAmountInternal;
10421
10616
  exports.getXcmFee = getXcmFee;
10422
10617
  exports.getXcmFeeEstimate = getXcmFeeEstimate;
10618
+ exports.localizeLocation = localizeLocation;
10423
10619
  exports.resolveModuleError = resolveModuleError;
10424
10620
  exports.resolveParaId = resolveParaId;
10425
10621
  exports.reverseTransformMultiLocation = reverseTransformMultiLocation;
@@ -10427,7 +10623,6 @@ exports.send = send;
10427
10623
  exports.transferMoonbeamEvm = transferMoonbeamEvm;
10428
10624
  exports.transferMoonbeamToEth = transferMoonbeamToEth;
10429
10625
  exports.transferRelayToPara = transferRelayToPara;
10430
- exports.transformMultiLocation = transformMultiLocation;
10431
10626
  exports.validateAddress = validateAddress;
10432
10627
  exports.verifyEdOnDestination = verifyEdOnDestination;
10433
10628
  Object.keys(assets).forEach(function (k) {