@paraspell/sdk-core 11.2.3 → 11.2.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.cjs CHANGED
@@ -5604,21 +5604,17 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
5604
5604
  initialDestParaId = _yield$getOriginXcmFe.destParaId;
5605
5605
  originWeight = _yield$getOriginXcmFe.weight;
5606
5606
  sufficientOriginFee = _yield$getOriginXcmFe.sufficient;
5607
- api.setDisconnectAllowed(true);
5608
- _context2.n = 2;
5609
- return api.disconnect();
5610
- case 2:
5611
5607
  if (!(originDryRunError || originFeeType === 'paymentInfo')) {
5612
- _context2.n = 8;
5608
+ _context2.n = 7;
5613
5609
  break;
5614
5610
  }
5615
5611
  destApi = api.clone();
5616
- _context2.p = 3;
5617
- _context2.n = 4;
5612
+ _context2.p = 2;
5613
+ _context2.n = 3;
5618
5614
  return destApi.init(destination, DRY_RUN_CLIENT_TIMEOUT_MS);
5619
- case 4:
5615
+ case 3:
5620
5616
  destApi.setDisconnectAllowed(false);
5621
- _context2.n = 5;
5617
+ _context2.n = 4;
5622
5618
  return getDestXcmFee({
5623
5619
  api: destApi,
5624
5620
  forwardedXcms: undefined,
@@ -5635,7 +5631,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
5635
5631
  senderAddress: senderAddress,
5636
5632
  disableFallback: disableFallback
5637
5633
  });
5638
- case 5:
5634
+ case 4:
5639
5635
  destFeeRes = _context2.v;
5640
5636
  _result = {
5641
5637
  origin: _objectSpread2(_objectSpread2(_objectSpread2({}, originFee && {
@@ -5669,14 +5665,14 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
5669
5665
  failureChain: _failureChain,
5670
5666
  failureReason: _failureReason
5671
5667
  }));
5672
- case 6:
5673
- _context2.p = 6;
5668
+ case 5:
5669
+ _context2.p = 5;
5674
5670
  destApi.setDisconnectAllowed(true);
5675
- _context2.n = 7;
5671
+ _context2.n = 6;
5676
5672
  return destApi.disconnect();
5673
+ case 6:
5674
+ return _context2.f(5);
5677
5675
  case 7:
5678
- return _context2.f(6);
5679
- case 8:
5680
5676
  processHop = /*#__PURE__*/function () {
5681
5677
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
5682
5678
  var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopResult, hopCurrency;
@@ -5724,7 +5720,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
5724
5720
  return _ref3.apply(this, arguments);
5725
5721
  };
5726
5722
  }();
5727
- _context2.n = 9;
5723
+ _context2.n = 8;
5728
5724
  return traverseXcmHops({
5729
5725
  api: api,
5730
5726
  origin: origin,
@@ -5744,14 +5740,14 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
5744
5740
  };
5745
5741
  }
5746
5742
  });
5747
- case 9:
5743
+ case 8:
5748
5744
  traversalResult = _context2.v;
5749
5745
  // Handle case where we failed before reaching destination
5750
5746
  destFee = 0n;
5751
5747
  destFeeType = destination === 'Ethereum' ? 'noFeeRequired' : 'paymentInfo';
5752
5748
  destSufficient = undefined;
5753
5749
  if (!traversalResult.destination) {
5754
- _context2.n = 10;
5750
+ _context2.n = 9;
5755
5751
  break;
5756
5752
  }
5757
5753
  destResult = traversalResult.destination;
@@ -5760,23 +5756,23 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
5760
5756
  destDryRunError = destResult.dryRunError;
5761
5757
  destSufficient = destResult.sufficient;
5762
5758
  destCurrency = destResult.currency;
5763
- _context2.n = 14;
5759
+ _context2.n = 13;
5764
5760
  break;
5765
- case 10:
5761
+ case 9:
5766
5762
  if (!(traversalResult.hops.length > 0 && traversalResult.hops[traversalResult.hops.length - 1].result.dryRunError)) {
5767
- _context2.n = 13;
5763
+ _context2.n = 12;
5768
5764
  break;
5769
5765
  }
5770
5766
  // We failed before reaching destination, use fallback
5771
5767
  _destApi = api.clone();
5772
5768
  if (!(destination !== 'Ethereum')) {
5773
- _context2.n = 11;
5769
+ _context2.n = 10;
5774
5770
  break;
5775
5771
  }
5776
- _context2.n = 11;
5772
+ _context2.n = 10;
5777
5773
  return _destApi.init(destination, DRY_RUN_CLIENT_TIMEOUT_MS);
5778
- case 11:
5779
- _context2.n = 12;
5774
+ case 10:
5775
+ _context2.n = 11;
5780
5776
  return getDestXcmFee({
5781
5777
  api: _destApi,
5782
5778
  forwardedXcms: undefined,
@@ -5792,25 +5788,25 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
5792
5788
  senderAddress: senderAddress,
5793
5789
  disableFallback: disableFallback
5794
5790
  });
5795
- case 12:
5791
+ case 11:
5796
5792
  destFallback = _context2.v;
5797
5793
  destFee = destFallback.fee;
5798
5794
  destFeeType = destFallback.feeType;
5799
5795
  destSufficient = destFallback.sufficient;
5800
5796
  destCurrency = assets.getNativeAssetSymbol(destination);
5801
- _context2.n = 14;
5797
+ _context2.n = 13;
5802
5798
  break;
5803
- case 13:
5799
+ case 12:
5804
5800
  destFee = 0n;
5805
5801
  destFeeType = 'noFeeRequired';
5806
5802
  destSufficient = true;
5807
5803
  destCurrency = assets.getNativeAssetSymbol(destination);
5808
- case 14:
5804
+ case 13:
5809
5805
  // Process Ethereum bridge fees
5810
5806
  assetHubChain = "AssetHub".concat(getRelayChainOf(origin));
5811
- _context2.n = 15;
5807
+ _context2.n = 14;
5812
5808
  return addEthereumBridgeFees(api, traversalResult.bridgeHub, destination, assetHubChain);
5813
- case 15:
5809
+ case 14:
5814
5810
  processedBridgeHub = _context2.v;
5815
5811
  // Update bridge hub fee in hops if needed
5816
5812
  if (processedBridgeHub && traversalResult.bridgeHub && processedBridgeHub.fee !== traversalResult.bridgeHub.fee) {
@@ -5884,7 +5880,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
5884
5880
  failureReason: failureReason
5885
5881
  }));
5886
5882
  }
5887
- }, _callee2, null, [[3,, 6, 8]]);
5883
+ }, _callee2, null, [[2,, 5, 7]]);
5888
5884
  }));
5889
5885
  return function getXcmFeeInternal(_x, _x2) {
5890
5886
  return _ref2.apply(this, arguments);
@@ -5894,7 +5890,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
5894
5890
  var getXcmFee = /*#__PURE__*/function () {
5895
5891
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
5896
5892
  var _real$assetHub, _real$bridgeHub;
5897
- var forced, real;
5893
+ var forced, real, api;
5898
5894
  return _regenerator().w(function (_context) {
5899
5895
  while (1) switch (_context.n) {
5900
5896
  case 0:
@@ -5906,6 +5902,10 @@ var getXcmFee = /*#__PURE__*/function () {
5906
5902
  return getXcmFeeInternal(options, false);
5907
5903
  case 2:
5908
5904
  real = _context.v;
5905
+ api = options.api;
5906
+ _context.n = 3;
5907
+ return api.disconnect();
5908
+ case 3:
5909
5909
  return _context.a(2, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, forced), {}, {
5910
5910
  origin: _objectSpread2(_objectSpread2({}, forced.origin), {}, {
5911
5911
  sufficient: real.origin.sufficient
@@ -8308,20 +8308,21 @@ var Parachain = /*#__PURE__*/function () {
8308
8308
  key: "canUseXTokens",
8309
8309
  value: function canUseXTokens(options) {
8310
8310
  var asset = options.assetInfo;
8311
- var isEthAsset = asset.location && assets.findAssetInfoByLoc(assets.getOtherAssets('Ethereum'), asset.location);
8312
- return !isEthAsset && !this.shouldUseNativeAssetTeleport(options);
8311
+ var isExternalAsset = asset.location && asset.location.parents === sdkCommon.Parents.TWO;
8312
+ return !isExternalAsset && !this.shouldUseNativeAssetTeleport(options);
8313
8313
  }
8314
8314
  }, {
8315
8315
  key: "transfer",
8316
8316
  value: function () {
8317
8317
  var _transfer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(sendOptions) {
8318
- var api, asset, currency, feeAsset, feeCurrency, address, destination, paraIdTo, overriddenAsset, version, senderAddress, ahAddress, pallet, method, scenario, paraId, isLocalTransfer, isBifrostOrigin, isJamtonOrigin, isAssetHubDest, useMultiAssets, input, options, shouldUseTeleport, isAHPOrigin, isAHPDest, isEthAsset, isEthDest, isEthAssetViaAh, isEthAssetToAh, call;
8318
+ var api, asset, currency, feeAsset, feeCurrency, address, destination, paraIdTo, overriddenAsset, version, senderAddress, ahAddress, pallet, method, scenario, paraId, destChain, isLocalTransfer, isBifrostOrigin, isJamtonOrigin, isAssetHubDest, useMultiAssets, input, options, shouldUseTeleport, isAhToOtherPara, isOtherParaToAh, isAHPOrigin, isAHPDest, isExternalAsset, isEthDest, isExternalAssetViaAh, isExternalAssetToAh, call;
8319
8319
  return _regenerator().w(function (_context) {
8320
8320
  while (1) switch (_context.n) {
8321
8321
  case 0:
8322
8322
  api = sendOptions.api, asset = sendOptions.assetInfo, currency = sendOptions.currency, feeAsset = sendOptions.feeAsset, feeCurrency = sendOptions.feeCurrency, address = sendOptions.address, destination = sendOptions.to, paraIdTo = sendOptions.paraIdTo, overriddenAsset = sendOptions.overriddenAsset, version = sendOptions.version, senderAddress = sendOptions.senderAddress, ahAddress = sendOptions.ahAddress, pallet = sendOptions.pallet, method = sendOptions.method;
8323
8323
  scenario = resolveScenario(this.chain, destination);
8324
8324
  paraId = resolveParaId(paraIdTo, destination);
8325
+ destChain = paraId ? getTChain(paraId, getRelayChainOf(this.chain)) : undefined;
8325
8326
  if (!(destination === 'Polimec' && this.chain !== 'AssetHubPolkadot' && this.chain !== 'Hydration' && this.chain !== destination)) {
8326
8327
  _context.n = 1;
8327
8328
  break;
@@ -8401,6 +8402,7 @@ var Parachain = /*#__PURE__*/function () {
8401
8402
  feeCurrency: feeCurrency,
8402
8403
  scenario: scenario,
8403
8404
  destination: destination,
8405
+ destChain: destChain,
8404
8406
  paraIdTo: paraId,
8405
8407
  version: version,
8406
8408
  senderAddress: senderAddress,
@@ -8409,7 +8411,9 @@ var Parachain = /*#__PURE__*/function () {
8409
8411
  method: method
8410
8412
  };
8411
8413
  shouldUseTeleport = this.shouldUseNativeAssetTeleport(sendOptions);
8412
- if (!((this.chain.includes('AssetHub') && destination !== 'Mythos' && typeof destination === 'string' && !sdkCommon.isSystemChain(destination) || !sdkCommon.isSystemChain(this.chain) && this.chain !== 'Mythos' && typeof destination === 'string' && destination.includes('AssetHub')) && shouldUseTeleport)) {
8414
+ isAhToOtherPara = this.chain.startsWith('AssetHub') && destChain && destChain !== 'Mythos' && !sdkCommon.isSystemChain(destChain);
8415
+ isOtherParaToAh = (destChain === null || destChain === void 0 ? void 0 : destChain.startsWith('AssetHub')) && this.chain !== 'Mythos' && !sdkCommon.isSystemChain(this.chain);
8416
+ if (!((isAhToOtherPara || isOtherParaToAh) && shouldUseTeleport)) {
8413
8417
  _context.n = 6;
8414
8418
  break;
8415
8419
  }
@@ -8417,11 +8421,11 @@ var Parachain = /*#__PURE__*/function () {
8417
8421
  case 6:
8418
8422
  isAHPOrigin = this.chain.includes('AssetHub');
8419
8423
  isAHPDest = !sdkCommon.isTLocation(destination) && destination.includes('AssetHub'); // Handle common cases
8420
- isEthAsset = asset.location && assets.findAssetInfoByLoc(assets.getOtherAssets('Ethereum'), asset.location);
8421
- isEthDest = destination === 'Ethereum'; // Eth asset - Any origin to any dest via AH - DestinationReserve - multiple instructions
8422
- isEthAssetViaAh = isEthAsset && !isAHPOrigin && !isAHPDest && !isEthDest && !feeAsset; // Eth asset - Any origin to AHP - DestinationReserve - one DepositAsset instruction
8423
- isEthAssetToAh = isEthAsset && isAHPDest && !isAHPOrigin && !isEthDest && !feeAsset;
8424
- if (!(isEthAssetViaAh || isEthAssetToAh)) {
8424
+ isExternalAsset = asset.location && asset.location.parents === sdkCommon.Parents.TWO;
8425
+ isEthDest = destination === 'Ethereum'; // External asset - Any origin to any dest via AH - DestinationReserve - multiple instructions
8426
+ isExternalAssetViaAh = isExternalAsset && !isAHPOrigin && !isAHPDest && !isEthDest && !feeAsset; // External asset - Any origin to AHP - DestinationReserve - one DepositAsset instruction
8427
+ isExternalAssetToAh = isExternalAsset && isAHPDest && !isAHPOrigin && !isEthDest && !feeAsset;
8428
+ if (!(isExternalAssetViaAh || isExternalAssetToAh)) {
8425
8429
  _context.n = 8;
8426
8430
  break;
8427
8431
  }
@@ -8486,9 +8490,11 @@ var Parachain = /*#__PURE__*/function () {
8486
8490
  }
8487
8491
  }, {
8488
8492
  key: "createCurrencySpec",
8489
- value: function createCurrencySpec(amount, scenario, version, _asset, _isOverridenAsset) {
8493
+ value: function createCurrencySpec(amount, scenario, version, asset, _isOverridenAsset) {
8494
+ var isRelayAsset = sdkCommon.deepEqual(asset === null || asset === void 0 ? void 0 : asset.location, RELAY_LOCATION);
8495
+ var parents = scenario === 'ParaToRelay' || isRelayAsset && sdkCommon.isSystemChain(this.chain) ? sdkCommon.Parents.ONE : sdkCommon.Parents.ZERO;
8490
8496
  return createAsset(version, amount, {
8491
- parents: scenario === 'ParaToRelay' ? sdkCommon.Parents.ONE : sdkCommon.Parents.ZERO,
8497
+ parents: parents,
8492
8498
  interior: 'Here'
8493
8499
  });
8494
8500
  }
@@ -9181,7 +9187,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
9181
9187
  key: "transferPolkadotXCM",
9182
9188
  value: function () {
9183
9189
  var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
9184
- var api, scenario, assetInfo, destination, feeAssetInfo, overriddenAsset, call, isNativeAsset, isNativeFeeAsset, isEthereumAsset, _call, CHAINS_SUPPORT_DOT_TRANSFER, isTrusted, isDotReserveAh, method, modifiedInput, _t, _t2;
9190
+ var api, scenario, assetInfo, destination, feeAssetInfo, overriddenAsset, call, isNativeAsset, isNativeFeeAsset, isExternalAsset, _call, CHAINS_SUPPORT_DOT_TRANSFER, isTrusted, isDotReserveAh, method, modifiedInput, _t, _t2;
9185
9191
  return _regenerator().w(function (_context3) {
9186
9192
  while (1) switch (_context3.n) {
9187
9193
  case 0:
@@ -9236,8 +9242,8 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
9236
9242
  }
9237
9243
  return _context3.a(2, this.handleMythosTransfer(options));
9238
9244
  case 8:
9239
- isEthereumAsset = assetInfo.location && assets.findAssetInfoByLoc(assets.getOtherAssets('Ethereum'), assetInfo.location);
9240
- if (!isEthereumAsset) {
9245
+ isExternalAsset = assetInfo.location && assetInfo.location.parents === sdkCommon.Parents.TWO;
9246
+ if (!isExternalAsset) {
9241
9247
  _context3.n = 10;
9242
9248
  break;
9243
9249
  }
@@ -9625,19 +9631,11 @@ var BridgeHubPolkadot = /*#__PURE__*/function (_Parachain) {
9625
9631
  key: "transferPolkadotXCM",
9626
9632
  value: function transferPolkadotXCM(input) {
9627
9633
  var scenario = input.scenario,
9628
- destination = input.destination;
9629
- var newOverridenAsset = {
9630
- parents: 1,
9631
- interior: {
9632
- Here: null
9633
- }
9634
- };
9635
- input.overriddenAsset = newOverridenAsset;
9636
- if (scenario === 'ParaToPara' && destination !== 'AssetHubPolkadot' && destination !== 'AssetHubKusama' && destination !== 'AssetHubPaseo' && destination !== 'AssetHubWestend') {
9637
- throw new ScenarioNotSupportedError(this.chain, scenario, 'Unable to use bridge hub for transfers to other Parachains.');
9634
+ destChain = input.destChain;
9635
+ if (scenario === 'ParaToPara' && !(destChain !== null && destChain !== void 0 && destChain.startsWith('AssetHub'))) {
9636
+ throw new ScenarioNotSupportedError(this.chain, scenario, "Unable to use ".concat(this.chain, " for transfers to other Parachains."));
9638
9637
  }
9639
- var method = 'limited_teleport_assets';
9640
- return transferPolkadotXcm(input, method, 'Unlimited');
9638
+ return transferPolkadotXcm(input, 'limited_teleport_assets', 'Unlimited');
9641
9639
  }
9642
9640
  }, {
9643
9641
  key: "getRelayToParaOverrides",
@@ -9726,16 +9724,9 @@ var Collectives = /*#__PURE__*/function (_Parachain) {
9726
9724
  key: "transferPolkadotXCM",
9727
9725
  value: function transferPolkadotXCM(input) {
9728
9726
  var scenario = input.scenario,
9729
- destination = input.destination;
9730
- var newOverridenAsset = {
9731
- parents: 1,
9732
- interior: {
9733
- Here: null
9734
- }
9735
- };
9736
- input.overriddenAsset = newOverridenAsset;
9737
- if (scenario === 'ParaToPara' && destination !== 'AssetHubPolkadot' && destination !== 'AssetHubKusama' && destination !== 'AssetHubPaseo' && destination !== 'AssetHubWestend') {
9738
- throw new ScenarioNotSupportedError(this.chain, scenario);
9727
+ destChain = input.destChain;
9728
+ if (scenario === 'ParaToPara' && !(destChain !== null && destChain !== void 0 && destChain.startsWith('AssetHub'))) {
9729
+ throw new ScenarioNotSupportedError(this.chain, scenario, "Unable to use ".concat(this.chain, " for transfers to other Parachains."));
9739
9730
  }
9740
9731
  return transferPolkadotXcm(input, 'limited_teleport_assets', 'Unlimited');
9741
9732
  }
@@ -9814,13 +9805,6 @@ var CoretimePolkadot = /*#__PURE__*/function (_Parachain) {
9814
9805
  key: "transferPolkadotXCM",
9815
9806
  value: function transferPolkadotXCM(input) {
9816
9807
  var scenario = input.scenario;
9817
- var newOverridenAsset = {
9818
- parents: 1,
9819
- interior: {
9820
- Here: null
9821
- }
9822
- };
9823
- input.overriddenAsset = newOverridenAsset;
9824
9808
  if (scenario === 'ParaToPara') {
9825
9809
  throw new ScenarioNotSupportedError(this.chain, scenario);
9826
9810
  }
@@ -11233,17 +11217,10 @@ var PeoplePolkadot = /*#__PURE__*/function (_Parachain) {
11233
11217
  key: "transferPolkadotXCM",
11234
11218
  value: function transferPolkadotXCM(input) {
11235
11219
  var scenario = input.scenario,
11236
- destination = input.destination;
11237
- if (scenario === 'ParaToPara' && destination !== 'AssetHubPolkadot' && destination !== 'AssetHubKusama' && destination !== 'AssetHubPaseo' && destination !== 'AssetHubWestend') {
11238
- throw new ScenarioNotSupportedError(this.chain, scenario);
11220
+ destChain = input.destChain;
11221
+ if (scenario === 'ParaToPara' && !(destChain !== null && destChain !== void 0 && destChain.startsWith('AssetHub'))) {
11222
+ throw new ScenarioNotSupportedError(this.chain, scenario, "Unable to use ".concat(this.chain, " for transfers to other Parachains."));
11239
11223
  }
11240
- var newOverridenAsset = {
11241
- parents: 1,
11242
- interior: {
11243
- Here: null
11244
- }
11245
- };
11246
- input.overriddenAsset = newOverridenAsset;
11247
11224
  return transferPolkadotXcm(input, 'limited_teleport_assets', 'Unlimited');
11248
11225
  }
11249
11226
  }, {
package/dist/index.d.ts CHANGED
@@ -26,6 +26,7 @@ type TPolkadotXCMTransferOptions<TApi, TRes> = {
26
26
  feeAssetInfo?: TAssetInfo;
27
27
  feeCurrency?: TCurrencyInput;
28
28
  destination: TDestination;
29
+ destChain?: TChain;
29
30
  paraIdTo?: number;
30
31
  version: Version;
31
32
  senderAddress?: string;
@@ -1428,7 +1429,7 @@ declare abstract class Parachain<TApi, TRes> {
1428
1429
  shouldUseNativeAssetTeleport({ assetInfo: asset, to }: TSendInternalOptions<TApi, TRes>): boolean;
1429
1430
  getRelayToParaOverrides(): TRelayToParaOverrides;
1430
1431
  transferRelayToPara(options: TRelayToParaOptions<TApi, TRes>): TSerializedApiCall;
1431
- createCurrencySpec(amount: bigint, scenario: TScenario, version: Version, _asset?: TAssetInfo, _isOverridenAsset?: boolean): TAsset;
1432
+ createCurrencySpec(amount: bigint, scenario: TScenario, version: Version, asset?: TAssetInfo, _isOverridenAsset?: boolean): TAsset;
1432
1433
  getNativeAssetSymbol(): string;
1433
1434
  transferLocal(options: TSendInternalOptions<TApi, TRes>): TRes;
1434
1435
  transferLocalNativeAsset(options: TTransferLocalOptions<TApi, TRes>): TRes;
package/dist/index.mjs CHANGED
@@ -5605,21 +5605,17 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
5605
5605
  initialDestParaId = _yield$getOriginXcmFe.destParaId;
5606
5606
  originWeight = _yield$getOriginXcmFe.weight;
5607
5607
  sufficientOriginFee = _yield$getOriginXcmFe.sufficient;
5608
- api.setDisconnectAllowed(true);
5609
- _context2.n = 2;
5610
- return api.disconnect();
5611
- case 2:
5612
5608
  if (!(originDryRunError || originFeeType === 'paymentInfo')) {
5613
- _context2.n = 8;
5609
+ _context2.n = 7;
5614
5610
  break;
5615
5611
  }
5616
5612
  destApi = api.clone();
5617
- _context2.p = 3;
5618
- _context2.n = 4;
5613
+ _context2.p = 2;
5614
+ _context2.n = 3;
5619
5615
  return destApi.init(destination, DRY_RUN_CLIENT_TIMEOUT_MS);
5620
- case 4:
5616
+ case 3:
5621
5617
  destApi.setDisconnectAllowed(false);
5622
- _context2.n = 5;
5618
+ _context2.n = 4;
5623
5619
  return getDestXcmFee({
5624
5620
  api: destApi,
5625
5621
  forwardedXcms: undefined,
@@ -5636,7 +5632,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
5636
5632
  senderAddress: senderAddress,
5637
5633
  disableFallback: disableFallback
5638
5634
  });
5639
- case 5:
5635
+ case 4:
5640
5636
  destFeeRes = _context2.v;
5641
5637
  _result = {
5642
5638
  origin: _objectSpread2(_objectSpread2(_objectSpread2({}, originFee && {
@@ -5670,14 +5666,14 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
5670
5666
  failureChain: _failureChain,
5671
5667
  failureReason: _failureReason
5672
5668
  }));
5673
- case 6:
5674
- _context2.p = 6;
5669
+ case 5:
5670
+ _context2.p = 5;
5675
5671
  destApi.setDisconnectAllowed(true);
5676
- _context2.n = 7;
5672
+ _context2.n = 6;
5677
5673
  return destApi.disconnect();
5674
+ case 6:
5675
+ return _context2.f(5);
5678
5676
  case 7:
5679
- return _context2.f(6);
5680
- case 8:
5681
5677
  processHop = /*#__PURE__*/function () {
5682
5678
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
5683
5679
  var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopResult, hopCurrency;
@@ -5725,7 +5721,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
5725
5721
  return _ref3.apply(this, arguments);
5726
5722
  };
5727
5723
  }();
5728
- _context2.n = 9;
5724
+ _context2.n = 8;
5729
5725
  return traverseXcmHops({
5730
5726
  api: api,
5731
5727
  origin: origin,
@@ -5745,14 +5741,14 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
5745
5741
  };
5746
5742
  }
5747
5743
  });
5748
- case 9:
5744
+ case 8:
5749
5745
  traversalResult = _context2.v;
5750
5746
  // Handle case where we failed before reaching destination
5751
5747
  destFee = 0n;
5752
5748
  destFeeType = destination === 'Ethereum' ? 'noFeeRequired' : 'paymentInfo';
5753
5749
  destSufficient = undefined;
5754
5750
  if (!traversalResult.destination) {
5755
- _context2.n = 10;
5751
+ _context2.n = 9;
5756
5752
  break;
5757
5753
  }
5758
5754
  destResult = traversalResult.destination;
@@ -5761,23 +5757,23 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
5761
5757
  destDryRunError = destResult.dryRunError;
5762
5758
  destSufficient = destResult.sufficient;
5763
5759
  destCurrency = destResult.currency;
5764
- _context2.n = 14;
5760
+ _context2.n = 13;
5765
5761
  break;
5766
- case 10:
5762
+ case 9:
5767
5763
  if (!(traversalResult.hops.length > 0 && traversalResult.hops[traversalResult.hops.length - 1].result.dryRunError)) {
5768
- _context2.n = 13;
5764
+ _context2.n = 12;
5769
5765
  break;
5770
5766
  }
5771
5767
  // We failed before reaching destination, use fallback
5772
5768
  _destApi = api.clone();
5773
5769
  if (!(destination !== 'Ethereum')) {
5774
- _context2.n = 11;
5770
+ _context2.n = 10;
5775
5771
  break;
5776
5772
  }
5777
- _context2.n = 11;
5773
+ _context2.n = 10;
5778
5774
  return _destApi.init(destination, DRY_RUN_CLIENT_TIMEOUT_MS);
5779
- case 11:
5780
- _context2.n = 12;
5775
+ case 10:
5776
+ _context2.n = 11;
5781
5777
  return getDestXcmFee({
5782
5778
  api: _destApi,
5783
5779
  forwardedXcms: undefined,
@@ -5793,25 +5789,25 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
5793
5789
  senderAddress: senderAddress,
5794
5790
  disableFallback: disableFallback
5795
5791
  });
5796
- case 12:
5792
+ case 11:
5797
5793
  destFallback = _context2.v;
5798
5794
  destFee = destFallback.fee;
5799
5795
  destFeeType = destFallback.feeType;
5800
5796
  destSufficient = destFallback.sufficient;
5801
5797
  destCurrency = getNativeAssetSymbol(destination);
5802
- _context2.n = 14;
5798
+ _context2.n = 13;
5803
5799
  break;
5804
- case 13:
5800
+ case 12:
5805
5801
  destFee = 0n;
5806
5802
  destFeeType = 'noFeeRequired';
5807
5803
  destSufficient = true;
5808
5804
  destCurrency = getNativeAssetSymbol(destination);
5809
- case 14:
5805
+ case 13:
5810
5806
  // Process Ethereum bridge fees
5811
5807
  assetHubChain = "AssetHub".concat(getRelayChainOf(origin));
5812
- _context2.n = 15;
5808
+ _context2.n = 14;
5813
5809
  return addEthereumBridgeFees(api, traversalResult.bridgeHub, destination, assetHubChain);
5814
- case 15:
5810
+ case 14:
5815
5811
  processedBridgeHub = _context2.v;
5816
5812
  // Update bridge hub fee in hops if needed
5817
5813
  if (processedBridgeHub && traversalResult.bridgeHub && processedBridgeHub.fee !== traversalResult.bridgeHub.fee) {
@@ -5885,7 +5881,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
5885
5881
  failureReason: failureReason
5886
5882
  }));
5887
5883
  }
5888
- }, _callee2, null, [[3,, 6, 8]]);
5884
+ }, _callee2, null, [[2,, 5, 7]]);
5889
5885
  }));
5890
5886
  return function getXcmFeeInternal(_x, _x2) {
5891
5887
  return _ref2.apply(this, arguments);
@@ -5895,7 +5891,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
5895
5891
  var getXcmFee = /*#__PURE__*/function () {
5896
5892
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
5897
5893
  var _real$assetHub, _real$bridgeHub;
5898
- var forced, real;
5894
+ var forced, real, api;
5899
5895
  return _regenerator().w(function (_context) {
5900
5896
  while (1) switch (_context.n) {
5901
5897
  case 0:
@@ -5907,6 +5903,10 @@ var getXcmFee = /*#__PURE__*/function () {
5907
5903
  return getXcmFeeInternal(options, false);
5908
5904
  case 2:
5909
5905
  real = _context.v;
5906
+ api = options.api;
5907
+ _context.n = 3;
5908
+ return api.disconnect();
5909
+ case 3:
5910
5910
  return _context.a(2, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, forced), {}, {
5911
5911
  origin: _objectSpread2(_objectSpread2({}, forced.origin), {}, {
5912
5912
  sufficient: real.origin.sufficient
@@ -8309,20 +8309,21 @@ var Parachain = /*#__PURE__*/function () {
8309
8309
  key: "canUseXTokens",
8310
8310
  value: function canUseXTokens(options) {
8311
8311
  var asset = options.assetInfo;
8312
- var isEthAsset = asset.location && findAssetInfoByLoc(getOtherAssets('Ethereum'), asset.location);
8313
- return !isEthAsset && !this.shouldUseNativeAssetTeleport(options);
8312
+ var isExternalAsset = asset.location && asset.location.parents === Parents.TWO;
8313
+ return !isExternalAsset && !this.shouldUseNativeAssetTeleport(options);
8314
8314
  }
8315
8315
  }, {
8316
8316
  key: "transfer",
8317
8317
  value: function () {
8318
8318
  var _transfer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(sendOptions) {
8319
- var api, asset, currency, feeAsset, feeCurrency, address, destination, paraIdTo, overriddenAsset, version, senderAddress, ahAddress, pallet, method, scenario, paraId, isLocalTransfer, isBifrostOrigin, isJamtonOrigin, isAssetHubDest, useMultiAssets, input, options, shouldUseTeleport, isAHPOrigin, isAHPDest, isEthAsset, isEthDest, isEthAssetViaAh, isEthAssetToAh, call;
8319
+ var api, asset, currency, feeAsset, feeCurrency, address, destination, paraIdTo, overriddenAsset, version, senderAddress, ahAddress, pallet, method, scenario, paraId, destChain, isLocalTransfer, isBifrostOrigin, isJamtonOrigin, isAssetHubDest, useMultiAssets, input, options, shouldUseTeleport, isAhToOtherPara, isOtherParaToAh, isAHPOrigin, isAHPDest, isExternalAsset, isEthDest, isExternalAssetViaAh, isExternalAssetToAh, call;
8320
8320
  return _regenerator().w(function (_context) {
8321
8321
  while (1) switch (_context.n) {
8322
8322
  case 0:
8323
8323
  api = sendOptions.api, asset = sendOptions.assetInfo, currency = sendOptions.currency, feeAsset = sendOptions.feeAsset, feeCurrency = sendOptions.feeCurrency, address = sendOptions.address, destination = sendOptions.to, paraIdTo = sendOptions.paraIdTo, overriddenAsset = sendOptions.overriddenAsset, version = sendOptions.version, senderAddress = sendOptions.senderAddress, ahAddress = sendOptions.ahAddress, pallet = sendOptions.pallet, method = sendOptions.method;
8324
8324
  scenario = resolveScenario(this.chain, destination);
8325
8325
  paraId = resolveParaId(paraIdTo, destination);
8326
+ destChain = paraId ? getTChain(paraId, getRelayChainOf(this.chain)) : undefined;
8326
8327
  if (!(destination === 'Polimec' && this.chain !== 'AssetHubPolkadot' && this.chain !== 'Hydration' && this.chain !== destination)) {
8327
8328
  _context.n = 1;
8328
8329
  break;
@@ -8402,6 +8403,7 @@ var Parachain = /*#__PURE__*/function () {
8402
8403
  feeCurrency: feeCurrency,
8403
8404
  scenario: scenario,
8404
8405
  destination: destination,
8406
+ destChain: destChain,
8405
8407
  paraIdTo: paraId,
8406
8408
  version: version,
8407
8409
  senderAddress: senderAddress,
@@ -8410,7 +8412,9 @@ var Parachain = /*#__PURE__*/function () {
8410
8412
  method: method
8411
8413
  };
8412
8414
  shouldUseTeleport = this.shouldUseNativeAssetTeleport(sendOptions);
8413
- if (!((this.chain.includes('AssetHub') && destination !== 'Mythos' && typeof destination === 'string' && !isSystemChain(destination) || !isSystemChain(this.chain) && this.chain !== 'Mythos' && typeof destination === 'string' && destination.includes('AssetHub')) && shouldUseTeleport)) {
8415
+ isAhToOtherPara = this.chain.startsWith('AssetHub') && destChain && destChain !== 'Mythos' && !isSystemChain(destChain);
8416
+ isOtherParaToAh = (destChain === null || destChain === void 0 ? void 0 : destChain.startsWith('AssetHub')) && this.chain !== 'Mythos' && !isSystemChain(this.chain);
8417
+ if (!((isAhToOtherPara || isOtherParaToAh) && shouldUseTeleport)) {
8414
8418
  _context.n = 6;
8415
8419
  break;
8416
8420
  }
@@ -8418,11 +8422,11 @@ var Parachain = /*#__PURE__*/function () {
8418
8422
  case 6:
8419
8423
  isAHPOrigin = this.chain.includes('AssetHub');
8420
8424
  isAHPDest = !isTLocation(destination) && destination.includes('AssetHub'); // Handle common cases
8421
- isEthAsset = asset.location && findAssetInfoByLoc(getOtherAssets('Ethereum'), asset.location);
8422
- isEthDest = destination === 'Ethereum'; // Eth asset - Any origin to any dest via AH - DestinationReserve - multiple instructions
8423
- isEthAssetViaAh = isEthAsset && !isAHPOrigin && !isAHPDest && !isEthDest && !feeAsset; // Eth asset - Any origin to AHP - DestinationReserve - one DepositAsset instruction
8424
- isEthAssetToAh = isEthAsset && isAHPDest && !isAHPOrigin && !isEthDest && !feeAsset;
8425
- if (!(isEthAssetViaAh || isEthAssetToAh)) {
8425
+ isExternalAsset = asset.location && asset.location.parents === Parents.TWO;
8426
+ isEthDest = destination === 'Ethereum'; // External asset - Any origin to any dest via AH - DestinationReserve - multiple instructions
8427
+ isExternalAssetViaAh = isExternalAsset && !isAHPOrigin && !isAHPDest && !isEthDest && !feeAsset; // External asset - Any origin to AHP - DestinationReserve - one DepositAsset instruction
8428
+ isExternalAssetToAh = isExternalAsset && isAHPDest && !isAHPOrigin && !isEthDest && !feeAsset;
8429
+ if (!(isExternalAssetViaAh || isExternalAssetToAh)) {
8426
8430
  _context.n = 8;
8427
8431
  break;
8428
8432
  }
@@ -8487,9 +8491,11 @@ var Parachain = /*#__PURE__*/function () {
8487
8491
  }
8488
8492
  }, {
8489
8493
  key: "createCurrencySpec",
8490
- value: function createCurrencySpec(amount, scenario, version, _asset, _isOverridenAsset) {
8494
+ value: function createCurrencySpec(amount, scenario, version, asset, _isOverridenAsset) {
8495
+ var isRelayAsset = deepEqual(asset === null || asset === void 0 ? void 0 : asset.location, RELAY_LOCATION);
8496
+ var parents = scenario === 'ParaToRelay' || isRelayAsset && isSystemChain(this.chain) ? Parents.ONE : Parents.ZERO;
8491
8497
  return createAsset(version, amount, {
8492
- parents: scenario === 'ParaToRelay' ? Parents.ONE : Parents.ZERO,
8498
+ parents: parents,
8493
8499
  interior: 'Here'
8494
8500
  });
8495
8501
  }
@@ -9182,7 +9188,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
9182
9188
  key: "transferPolkadotXCM",
9183
9189
  value: function () {
9184
9190
  var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
9185
- var api, scenario, assetInfo, destination, feeAssetInfo, overriddenAsset, call, isNativeAsset, isNativeFeeAsset, isEthereumAsset, _call, CHAINS_SUPPORT_DOT_TRANSFER, isTrusted, isDotReserveAh, method, modifiedInput, _t, _t2;
9191
+ var api, scenario, assetInfo, destination, feeAssetInfo, overriddenAsset, call, isNativeAsset, isNativeFeeAsset, isExternalAsset, _call, CHAINS_SUPPORT_DOT_TRANSFER, isTrusted, isDotReserveAh, method, modifiedInput, _t, _t2;
9186
9192
  return _regenerator().w(function (_context3) {
9187
9193
  while (1) switch (_context3.n) {
9188
9194
  case 0:
@@ -9237,8 +9243,8 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
9237
9243
  }
9238
9244
  return _context3.a(2, this.handleMythosTransfer(options));
9239
9245
  case 8:
9240
- isEthereumAsset = assetInfo.location && findAssetInfoByLoc(getOtherAssets('Ethereum'), assetInfo.location);
9241
- if (!isEthereumAsset) {
9246
+ isExternalAsset = assetInfo.location && assetInfo.location.parents === Parents.TWO;
9247
+ if (!isExternalAsset) {
9242
9248
  _context3.n = 10;
9243
9249
  break;
9244
9250
  }
@@ -9626,19 +9632,11 @@ var BridgeHubPolkadot = /*#__PURE__*/function (_Parachain) {
9626
9632
  key: "transferPolkadotXCM",
9627
9633
  value: function transferPolkadotXCM(input) {
9628
9634
  var scenario = input.scenario,
9629
- destination = input.destination;
9630
- var newOverridenAsset = {
9631
- parents: 1,
9632
- interior: {
9633
- Here: null
9634
- }
9635
- };
9636
- input.overriddenAsset = newOverridenAsset;
9637
- if (scenario === 'ParaToPara' && destination !== 'AssetHubPolkadot' && destination !== 'AssetHubKusama' && destination !== 'AssetHubPaseo' && destination !== 'AssetHubWestend') {
9638
- throw new ScenarioNotSupportedError(this.chain, scenario, 'Unable to use bridge hub for transfers to other Parachains.');
9635
+ destChain = input.destChain;
9636
+ if (scenario === 'ParaToPara' && !(destChain !== null && destChain !== void 0 && destChain.startsWith('AssetHub'))) {
9637
+ throw new ScenarioNotSupportedError(this.chain, scenario, "Unable to use ".concat(this.chain, " for transfers to other Parachains."));
9639
9638
  }
9640
- var method = 'limited_teleport_assets';
9641
- return transferPolkadotXcm(input, method, 'Unlimited');
9639
+ return transferPolkadotXcm(input, 'limited_teleport_assets', 'Unlimited');
9642
9640
  }
9643
9641
  }, {
9644
9642
  key: "getRelayToParaOverrides",
@@ -9727,16 +9725,9 @@ var Collectives = /*#__PURE__*/function (_Parachain) {
9727
9725
  key: "transferPolkadotXCM",
9728
9726
  value: function transferPolkadotXCM(input) {
9729
9727
  var scenario = input.scenario,
9730
- destination = input.destination;
9731
- var newOverridenAsset = {
9732
- parents: 1,
9733
- interior: {
9734
- Here: null
9735
- }
9736
- };
9737
- input.overriddenAsset = newOverridenAsset;
9738
- if (scenario === 'ParaToPara' && destination !== 'AssetHubPolkadot' && destination !== 'AssetHubKusama' && destination !== 'AssetHubPaseo' && destination !== 'AssetHubWestend') {
9739
- throw new ScenarioNotSupportedError(this.chain, scenario);
9728
+ destChain = input.destChain;
9729
+ if (scenario === 'ParaToPara' && !(destChain !== null && destChain !== void 0 && destChain.startsWith('AssetHub'))) {
9730
+ throw new ScenarioNotSupportedError(this.chain, scenario, "Unable to use ".concat(this.chain, " for transfers to other Parachains."));
9740
9731
  }
9741
9732
  return transferPolkadotXcm(input, 'limited_teleport_assets', 'Unlimited');
9742
9733
  }
@@ -9815,13 +9806,6 @@ var CoretimePolkadot = /*#__PURE__*/function (_Parachain) {
9815
9806
  key: "transferPolkadotXCM",
9816
9807
  value: function transferPolkadotXCM(input) {
9817
9808
  var scenario = input.scenario;
9818
- var newOverridenAsset = {
9819
- parents: 1,
9820
- interior: {
9821
- Here: null
9822
- }
9823
- };
9824
- input.overriddenAsset = newOverridenAsset;
9825
9809
  if (scenario === 'ParaToPara') {
9826
9810
  throw new ScenarioNotSupportedError(this.chain, scenario);
9827
9811
  }
@@ -11234,17 +11218,10 @@ var PeoplePolkadot = /*#__PURE__*/function (_Parachain) {
11234
11218
  key: "transferPolkadotXCM",
11235
11219
  value: function transferPolkadotXCM(input) {
11236
11220
  var scenario = input.scenario,
11237
- destination = input.destination;
11238
- if (scenario === 'ParaToPara' && destination !== 'AssetHubPolkadot' && destination !== 'AssetHubKusama' && destination !== 'AssetHubPaseo' && destination !== 'AssetHubWestend') {
11239
- throw new ScenarioNotSupportedError(this.chain, scenario);
11221
+ destChain = input.destChain;
11222
+ if (scenario === 'ParaToPara' && !(destChain !== null && destChain !== void 0 && destChain.startsWith('AssetHub'))) {
11223
+ throw new ScenarioNotSupportedError(this.chain, scenario, "Unable to use ".concat(this.chain, " for transfers to other Parachains."));
11240
11224
  }
11241
- var newOverridenAsset = {
11242
- parents: 1,
11243
- interior: {
11244
- Here: null
11245
- }
11246
- };
11247
- input.overriddenAsset = newOverridenAsset;
11248
11225
  return transferPolkadotXcm(input, 'limited_teleport_assets', 'Unlimited');
11249
11226
  }
11250
11227
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-core",
3
- "version": "11.2.3",
3
+ "version": "11.2.4",
4
4
  "description": "SDK core for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,9 +26,9 @@
26
26
  "@noble/hashes": "^1.8.0",
27
27
  "@scure/base": "^2.0.0",
28
28
  "viem": "^2.36.0",
29
- "@paraspell/assets": "11.2.3",
30
- "@paraspell/sdk-common": "11.2.3",
31
- "@paraspell/pallets": "11.2.3"
29
+ "@paraspell/pallets": "11.2.4",
30
+ "@paraspell/assets": "11.2.4",
31
+ "@paraspell/sdk-common": "11.2.4"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@babel/plugin-syntax-import-attributes": "^7.27.1",