@paraspell/sdk-core 10.7.2 → 10.8.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
@@ -2126,13 +2126,17 @@ var localizeLocation = function localizeLocation(node, multiLocation) {
2126
2126
  var newInterior = multiLocation.interior;
2127
2127
  var parachainRemoved = false;
2128
2128
  if (multiLocation.interior !== 'Here') {
2129
+ var paraId = getParaId(node);
2129
2130
  var junctions = Object.values(multiLocation.interior).flat().filter(function (junction) {
2130
2131
  return _typeof(junction) === 'object' && junction !== null;
2131
2132
  });
2132
2133
  var filteredJunctions = junctions.filter(function (junction) {
2133
2134
  if ('Parachain' in junction) {
2134
- parachainRemoved = true;
2135
- return false;
2135
+ var paraJunctionId = sdkCommon.getJunctionValue(multiLocation, 'Parachain');
2136
+ if (paraJunctionId === paraId) {
2137
+ parachainRemoved = true;
2138
+ return false;
2139
+ }
2136
2140
  }
2137
2141
  return true;
2138
2142
  });
@@ -4268,30 +4272,30 @@ var buildHopInfo = /*#__PURE__*/function () {
4268
4272
  }();
4269
4273
 
4270
4274
  var getTransferInfo = /*#__PURE__*/function () {
4271
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
4272
- var api, tx, origin, destination, senderAddress, ahAddress, address, currency, feeAsset, resolvedFeeAsset, originAsset, originBalanceFee, originBalance, edOrigin, _yield$getXcmFee, _yield$getXcmFee$orig, originFee, originFeeCurrency, assetHubFeeResult, bridgeHubFeeResult, destFeeDetail, isFeeAssetAh, originBalanceAfter, originBalanceFeeAfter, originBalanceNativeSufficient, originBalanceSufficient, assetHub, bridgeHub, bridgeHubNode, destinationInfo, _t;
4273
- return _regenerator().w(function (_context) {
4274
- while (1) switch (_context.n) {
4275
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
4276
+ var api, tx, origin, destination, senderAddress, ahAddress, address, currency, feeAsset, resolvedFeeAsset, originAsset, originBalanceFee, originBalance, edOrigin, _yield$getXcmFee, _yield$getXcmFee$orig, originFee, originFeeCurrency, assetHubFeeResult, bridgeHubFeeResult, destFeeDetail, hops, isFeeAssetAh, originBalanceAfter, originBalanceFeeAfter, originBalanceNativeSufficient, originBalanceSufficient, assetHub, bridgeHub, bridgeHubNode, builtHops, destinationInfo, _t;
4277
+ return _regenerator().w(function (_context2) {
4278
+ while (1) switch (_context2.n) {
4275
4279
  case 0:
4276
4280
  api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, ahAddress = _ref.ahAddress, address = _ref.address, currency = _ref.currency, feeAsset = _ref.feeAsset;
4277
4281
  if (!(assets.isNodeEvm(origin) && !ahAddress)) {
4278
- _context.n = 1;
4282
+ _context2.n = 1;
4279
4283
  break;
4280
4284
  }
4281
4285
  throw new InvalidParameterError("ahAddress is required for EVM origin ".concat(origin, "."));
4282
4286
  case 1:
4283
4287
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
4284
- _context.n = 2;
4288
+ _context2.n = 2;
4285
4289
  return api.init(origin);
4286
4290
  case 2:
4287
4291
  api.setDisconnectAllowed(false);
4288
- _context.p = 3;
4292
+ _context2.p = 3;
4289
4293
  originAsset = assets.findAssetForNodeOrThrow(origin, currency, destination);
4290
4294
  if (!(feeAsset && resolvedFeeAsset)) {
4291
- _context.n = 5;
4295
+ _context2.n = 5;
4292
4296
  break;
4293
4297
  }
4294
- _context.n = 4;
4298
+ _context2.n = 4;
4295
4299
  return getAssetBalanceInternal({
4296
4300
  api: api,
4297
4301
  address: senderAddress,
@@ -4299,21 +4303,21 @@ var getTransferInfo = /*#__PURE__*/function () {
4299
4303
  currency: feeAsset
4300
4304
  });
4301
4305
  case 4:
4302
- _t = _context.v;
4303
- _context.n = 7;
4306
+ _t = _context2.v;
4307
+ _context2.n = 7;
4304
4308
  break;
4305
4309
  case 5:
4306
- _context.n = 6;
4310
+ _context2.n = 6;
4307
4311
  return getBalanceNativeInternal({
4308
4312
  api: api,
4309
4313
  address: senderAddress,
4310
4314
  node: origin
4311
4315
  });
4312
4316
  case 6:
4313
- _t = _context.v;
4317
+ _t = _context2.v;
4314
4318
  case 7:
4315
4319
  originBalanceFee = _t;
4316
- _context.n = 8;
4320
+ _context2.n = 8;
4317
4321
  return getAssetBalanceInternal({
4318
4322
  api: api,
4319
4323
  address: senderAddress,
@@ -4321,9 +4325,9 @@ var getTransferInfo = /*#__PURE__*/function () {
4321
4325
  currency: currency
4322
4326
  });
4323
4327
  case 8:
4324
- originBalance = _context.v;
4328
+ originBalance = _context2.v;
4325
4329
  edOrigin = assets.getExistentialDepositOrThrow(origin, currency);
4326
- _context.n = 9;
4330
+ _context2.n = 9;
4327
4331
  return getXcmFee({
4328
4332
  api: api,
4329
4333
  tx: tx,
@@ -4336,15 +4340,16 @@ var getTransferInfo = /*#__PURE__*/function () {
4336
4340
  disableFallback: false
4337
4341
  });
4338
4342
  case 9:
4339
- _yield$getXcmFee = _context.v;
4343
+ _yield$getXcmFee = _context2.v;
4340
4344
  _yield$getXcmFee$orig = _yield$getXcmFee.origin;
4341
4345
  originFee = _yield$getXcmFee$orig.fee;
4342
4346
  originFeeCurrency = _yield$getXcmFee$orig.currency;
4343
4347
  assetHubFeeResult = _yield$getXcmFee.assetHub;
4344
4348
  bridgeHubFeeResult = _yield$getXcmFee.bridgeHub;
4345
4349
  destFeeDetail = _yield$getXcmFee.destination;
4350
+ hops = _yield$getXcmFee.hops;
4346
4351
  if (!(originFee === undefined)) {
4347
- _context.n = 10;
4352
+ _context2.n = 10;
4348
4353
  break;
4349
4354
  }
4350
4355
  throw new InvalidParameterError("Cannot get origin xcm fee for currency ".concat(JSON.stringify(currency, sdkCommon.replaceBigInt), " on node ").concat(origin, "."));
@@ -4355,10 +4360,10 @@ var getTransferInfo = /*#__PURE__*/function () {
4355
4360
  originBalanceNativeSufficient = originBalanceFee >= originFee;
4356
4361
  originBalanceSufficient = originBalanceAfter >= edOrigin;
4357
4362
  if (!assetHubFeeResult) {
4358
- _context.n = 12;
4363
+ _context2.n = 12;
4359
4364
  break;
4360
4365
  }
4361
- _context.n = 11;
4366
+ _context2.n = 11;
4362
4367
  return buildHopInfo({
4363
4368
  api: api,
4364
4369
  node: determineRelayChain(origin) === 'Polkadot' ? 'AssetHubPolkadot' : 'AssetHubKusama',
@@ -4369,14 +4374,14 @@ var getTransferInfo = /*#__PURE__*/function () {
4369
4374
  ahAddress: ahAddress
4370
4375
  });
4371
4376
  case 11:
4372
- assetHub = _context.v;
4377
+ assetHub = _context2.v;
4373
4378
  case 12:
4374
4379
  if (!bridgeHubFeeResult) {
4375
- _context.n = 14;
4380
+ _context2.n = 14;
4376
4381
  break;
4377
4382
  }
4378
4383
  bridgeHubNode = determineRelayChain(origin) === 'Polkadot' ? 'BridgeHubPolkadot' : 'BridgeHubKusama';
4379
- _context.n = 13;
4384
+ _context2.n = 13;
4380
4385
  return buildHopInfo({
4381
4386
  api: api,
4382
4387
  node: bridgeHubNode,
@@ -4387,9 +4392,47 @@ var getTransferInfo = /*#__PURE__*/function () {
4387
4392
  ahAddress: ahAddress
4388
4393
  });
4389
4394
  case 13:
4390
- bridgeHub = _context.v;
4395
+ bridgeHub = _context2.v;
4391
4396
  case 14:
4392
- _context.n = 15;
4397
+ builtHops = [];
4398
+ if (!(hops && hops.length > 0)) {
4399
+ _context2.n = 16;
4400
+ break;
4401
+ }
4402
+ _context2.n = 15;
4403
+ return Promise.all(hops.map(/*#__PURE__*/function () {
4404
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(hop) {
4405
+ var result;
4406
+ return _regenerator().w(function (_context) {
4407
+ while (1) switch (_context.n) {
4408
+ case 0:
4409
+ _context.n = 1;
4410
+ return buildHopInfo({
4411
+ api: api,
4412
+ node: hop.chain,
4413
+ feeData: hop.result,
4414
+ originNode: origin,
4415
+ currency: currency,
4416
+ senderAddress: senderAddress,
4417
+ ahAddress: ahAddress
4418
+ });
4419
+ case 1:
4420
+ result = _context.v;
4421
+ return _context.a(2, {
4422
+ chain: hop.chain,
4423
+ result: result
4424
+ });
4425
+ }
4426
+ }, _callee);
4427
+ }));
4428
+ return function (_x2) {
4429
+ return _ref3.apply(this, arguments);
4430
+ };
4431
+ }()));
4432
+ case 15:
4433
+ builtHops = _context2.v;
4434
+ case 16:
4435
+ _context2.n = 17;
4393
4436
  return buildDestInfo({
4394
4437
  api: api,
4395
4438
  origin: origin,
@@ -4402,9 +4445,9 @@ var getTransferInfo = /*#__PURE__*/function () {
4402
4445
  assetHubFee: assetHubFeeResult === null || assetHubFeeResult === void 0 ? void 0 : assetHubFeeResult.fee,
4403
4446
  bridgeFee: bridgeHubFeeResult === null || bridgeHubFeeResult === void 0 ? void 0 : bridgeHubFeeResult.fee
4404
4447
  });
4405
- case 15:
4406
- destinationInfo = _context.v;
4407
- return _context.a(2, {
4448
+ case 17:
4449
+ destinationInfo = _context2.v;
4450
+ return _context2.a(2, {
4408
4451
  chain: {
4409
4452
  origin: origin,
4410
4453
  destination: destination,
@@ -4428,19 +4471,20 @@ var getTransferInfo = /*#__PURE__*/function () {
4428
4471
  },
4429
4472
  assetHub: assetHub,
4430
4473
  bridgeHub: bridgeHub,
4474
+ hops: builtHops,
4431
4475
  destination: destinationInfo
4432
4476
  });
4433
- case 16:
4434
- _context.p = 16;
4477
+ case 18:
4478
+ _context2.p = 18;
4435
4479
  api.setDisconnectAllowed(true);
4436
- _context.n = 17;
4480
+ _context2.n = 19;
4437
4481
  return api.disconnect();
4438
- case 17:
4439
- return _context.f(16);
4440
- case 18:
4441
- return _context.a(2);
4482
+ case 19:
4483
+ return _context2.f(18);
4484
+ case 20:
4485
+ return _context2.a(2);
4442
4486
  }
4443
- }, _callee, null, [[3,, 16, 18]]);
4487
+ }, _callee2, null, [[3,, 18, 20]]);
4444
4488
  }));
4445
4489
  return function getTransferInfo(_x) {
4446
4490
  return _ref2.apply(this, arguments);
@@ -4852,7 +4896,7 @@ var getFailureInfo$1 = function getFailureInfo(results, hops) {
4852
4896
  if (!hop.result.success && hop.result.failureReason) {
4853
4897
  return {
4854
4898
  failureReason: hop.result.failureReason,
4855
- failureChain: hop.node
4899
+ failureChain: hop.chain
4856
4900
  };
4857
4901
  }
4858
4902
  }
@@ -4954,7 +4998,7 @@ var dryRunInternal = /*#__PURE__*/function () {
4954
4998
  // Add to hops array (only if not the destination)
4955
4999
  if (nextChain !== destination) {
4956
5000
  hops.push({
4957
- node: nextChain,
5001
+ chain: nextChain,
4958
5002
  result: hopDryRun.success && hopCurrency ? _objectSpread2(_objectSpread2({}, hopDryRun), {}, {
4959
5003
  currency: hopCurrency
4960
5004
  }) : hopDryRun
@@ -5008,7 +5052,7 @@ var dryRunInternal = /*#__PURE__*/function () {
5008
5052
  });
5009
5053
  // Update the hop data if BridgeHub is in the hops array
5010
5054
  bridgeHubHopIndex = hops.findIndex(function (hop) {
5011
- return hop.node === bridgeHubNode;
5055
+ return hop.chain === bridgeHubNode;
5012
5056
  });
5013
5057
  if (bridgeHubHopIndex !== -1 && hops[bridgeHubHopIndex].result.success) {
5014
5058
  hops[bridgeHubHopIndex].result = _objectSpread2(_objectSpread2({}, hops[bridgeHubHopIndex].result), {}, {
@@ -5396,8 +5440,9 @@ var getOriginXcmFeeEstimate = /*#__PURE__*/function () {
5396
5440
  };
5397
5441
  }();
5398
5442
 
5399
- var getFailureInfo = function getFailureInfo(nodes) {
5443
+ var getFailureInfo = function getFailureInfo(nodes, hops) {
5400
5444
  var _nodes$origin, _nodes$assetHub, _nodes$bridgeHub, _nodes$destination;
5445
+ // Check standard chains first for backwards compatibility
5401
5446
  if ((_nodes$origin = nodes.origin) !== null && _nodes$origin !== void 0 && _nodes$origin.dryRunError) return {
5402
5447
  failureChain: 'origin',
5403
5448
  failureReason: nodes.origin.dryRunError
@@ -5414,11 +5459,29 @@ var getFailureInfo = function getFailureInfo(nodes) {
5414
5459
  failureChain: 'destination',
5415
5460
  failureReason: nodes.destination.dryRunError
5416
5461
  };
5462
+ // Check hops for failures
5463
+ var _iterator = _createForOfIteratorHelper(hops),
5464
+ _step;
5465
+ try {
5466
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
5467
+ var hop = _step.value;
5468
+ if (hop.result.dryRunError) {
5469
+ return {
5470
+ failureChain: hop.chain,
5471
+ failureReason: hop.result.dryRunError
5472
+ };
5473
+ }
5474
+ }
5475
+ } catch (err) {
5476
+ _iterator.e(err);
5477
+ } finally {
5478
+ _iterator.f();
5479
+ }
5417
5480
  return {};
5418
5481
  };
5419
5482
  var getXcmFee = /*#__PURE__*/function () {
5420
5483
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
5421
- var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, asset, _yield$getOriginXcmFe, originFee, originCurrency, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, destApi, destFeeRes, _result, _getFailureInfo, _failureChain, _failureReason, assetHubNode, bridgeHubNode, currentOrigin, forwardedXcms, nextParaId, intermediateFees, destinationFee, destinationFeeType, destinationDryRunError, destinationSufficient, nextChain, hopApi, hopResult, failingRecord, hopIsDestination, _destApi, destFallback, processedBridgeHubData, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, destCurrency, result, _getFailureInfo2, failureChain, failureReason;
5484
+ var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, asset, _yield$getOriginXcmFe, originFee, originCurrency, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, hops, destApi, destFeeRes, _result, _getFailureInfo, _failureChain, _failureReason, assetHubNode, bridgeHubNode, currentOrigin, forwardedXcms, nextParaId, intermediateFees, destinationFee, destinationFeeType, destinationDryRunError, destinationSufficient, nextChain, hopApi, hopResult, hopCurrency, hopDetail, failingRecord, hopIsDestination, _destApi, destFallback, processedBridgeHubData, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, bridgeHubHopIndex, destCurrency, result, _getFailureInfo2, failureChain, failureReason;
5422
5485
  return _regenerator().w(function (_context) {
5423
5486
  while (1) switch (_context.n) {
5424
5487
  case 0:
@@ -5449,6 +5512,8 @@ var getXcmFee = /*#__PURE__*/function () {
5449
5512
  _context.n = 2;
5450
5513
  return api.disconnect();
5451
5514
  case 2:
5515
+ // Initialize hops array
5516
+ hops = [];
5452
5517
  if (!(originDryRunError || originFeeType === 'paymentInfo')) {
5453
5518
  _context.n = 8;
5454
5519
  break;
@@ -5498,12 +5563,13 @@ var getXcmFee = /*#__PURE__*/function () {
5498
5563
  sufficient: destFeeRes.sufficient
5499
5564
  }), {}, {
5500
5565
  currency: assets.getNativeAssetSymbol(destination)
5501
- })
5566
+ }),
5567
+ hops: hops // Include empty hops array
5502
5568
  };
5503
5569
  _getFailureInfo = getFailureInfo({
5504
5570
  origin: _result.origin,
5505
5571
  destination: _result.destination
5506
- }), _failureChain = _getFailureInfo.failureChain, _failureReason = _getFailureInfo.failureReason;
5572
+ }, hops), _failureChain = _getFailureInfo.failureChain, _failureReason = _getFailureInfo.failureReason;
5507
5573
  return _context.a(2, _objectSpread2(_objectSpread2({}, _result), {}, {
5508
5574
  failureChain: _failureChain,
5509
5575
  failureReason: _failureReason
@@ -5559,17 +5625,38 @@ var getXcmFee = /*#__PURE__*/function () {
5559
5625
  });
5560
5626
  case 13:
5561
5627
  hopResult = _context.v;
5562
- if (!hopResult.dryRunError) {
5563
- _context.n = 17;
5564
- break;
5628
+ // Determine the currency for this hop
5629
+ hopCurrency = void 0;
5630
+ if (nextChain === destination) {
5631
+ hopCurrency = destinationFeeType === 'dryRun' ? assets.findAssetOnDestOrThrow(origin, destination, currency).symbol : assets.getNativeAssetSymbol(destination);
5632
+ } else if (sdkCommon.isRelayChain(nextChain) || nextChain === assetHubNode || nextChain === bridgeHubNode) {
5633
+ hopCurrency = assets.getNativeAssetSymbol(nextChain);
5634
+ } else {
5635
+ hopCurrency = assets.getNativeAssetSymbol(nextChain);
5565
5636
  }
5566
- failingRecord = {
5637
+ hopDetail = hopResult.dryRunError ? {
5638
+ fee: hopResult.fee,
5639
+ feeType: hopResult.feeType,
5640
+ currency: hopCurrency,
5641
+ sufficient: hopResult.sufficient,
5642
+ dryRunError: hopResult.dryRunError
5643
+ } : {
5567
5644
  fee: hopResult.fee,
5568
5645
  feeType: hopResult.feeType,
5569
- currency: assets.getNativeAssetSymbol(nextChain),
5570
- dryRunError: hopResult.dryRunError,
5646
+ currency: hopCurrency,
5571
5647
  sufficient: hopResult.sufficient
5572
5648
  };
5649
+ if (nextChain !== destination) {
5650
+ hops.push({
5651
+ chain: nextChain,
5652
+ result: hopDetail
5653
+ });
5654
+ }
5655
+ if (!hopResult.dryRunError) {
5656
+ _context.n = 17;
5657
+ break;
5658
+ }
5659
+ failingRecord = hopDetail;
5573
5660
  hopIsDestination = nextChain === destination || sdkCommon.isRelayChain(nextChain) && !sdkCommon.isRelayChain(destination);
5574
5661
  if (hopIsDestination) {
5575
5662
  destinationFee = hopResult.fee;
@@ -5621,19 +5708,9 @@ var getXcmFee = /*#__PURE__*/function () {
5621
5708
  destinationFeeType = hopResult.feeType;
5622
5709
  destinationSufficient = hopResult.sufficient;
5623
5710
  } else if (nextChain === assetHubNode) {
5624
- intermediateFees.assetHub = {
5625
- fee: hopResult.fee,
5626
- feeType: hopResult.feeType,
5627
- currency: assets.getNativeAssetSymbol(nextChain),
5628
- sufficient: hopResult.sufficient
5629
- };
5711
+ intermediateFees.assetHub = hopDetail;
5630
5712
  } else if (nextChain === bridgeHubNode) {
5631
- intermediateFees.bridgeHub = {
5632
- fee: hopResult.fee,
5633
- feeType: hopResult.feeType,
5634
- currency: assets.getNativeAssetSymbol(nextChain),
5635
- sufficient: hopResult.sufficient
5636
- };
5713
+ intermediateFees.bridgeHub = hopDetail;
5637
5714
  } else ;
5638
5715
  forwardedXcms = hopResult.forwardedXcms;
5639
5716
  nextParaId = hopResult.destParaId;
@@ -5666,6 +5743,14 @@ var getXcmFee = /*#__PURE__*/function () {
5666
5743
  processedBridgeHubData = _objectSpread2(_objectSpread2({}, intermediateFees.bridgeHub), {}, {
5667
5744
  fee: intermediateFees.bridgeHub.fee + bridgeFee
5668
5745
  });
5746
+ bridgeHubHopIndex = hops.findIndex(function (hop) {
5747
+ return hop.chain === bridgeHubNode;
5748
+ });
5749
+ if (bridgeHubHopIndex !== -1) {
5750
+ hops[bridgeHubHopIndex].result = _objectSpread2(_objectSpread2({}, hops[bridgeHubHopIndex].result), {}, {
5751
+ fee: intermediateFees.bridgeHub.fee + bridgeFee
5752
+ });
5753
+ }
5669
5754
  case 24:
5670
5755
  intermediateFees.bridgeHub = processedBridgeHubData;
5671
5756
  destCurrency = destinationFeeType === 'dryRun' ? assets.findAssetOnDestOrThrow(origin, destination, currency).symbol : assets.getNativeAssetSymbol(destination);
@@ -5693,14 +5778,15 @@ var getXcmFee = /*#__PURE__*/function () {
5693
5778
  currency: destCurrency
5694
5779
  }, destinationDryRunError && {
5695
5780
  dryRunError: destinationDryRunError
5696
- })
5781
+ }),
5782
+ hops: hops
5697
5783
  });
5698
5784
  _getFailureInfo2 = getFailureInfo({
5699
5785
  origin: result.origin,
5700
5786
  assetHub: result.assetHub,
5701
5787
  bridgeHub: result.bridgeHub,
5702
5788
  destination: result.destination
5703
- }), failureChain = _getFailureInfo2.failureChain, failureReason = _getFailureInfo2.failureReason;
5789
+ }, hops), failureChain = _getFailureInfo2.failureChain, failureReason = _getFailureInfo2.failureReason;
5704
5790
  return _context.a(2, _objectSpread2(_objectSpread2({}, result), {}, {
5705
5791
  failureChain: failureChain,
5706
5792
  failureReason: failureReason
@@ -6924,6 +7010,11 @@ var sortMultiAssets = function sortMultiAssets(assets$1) {
6924
7010
  return assets$1.sort(function (a, b) {
6925
7011
  var aLoc = assets.extractMultiAssetLoc(a);
6926
7012
  var bLoc = assets.extractMultiAssetLoc(b);
7013
+ // 1. Sort by parents first
7014
+ if (aLoc.parents !== bLoc.parents) {
7015
+ return Number(aLoc.parents) - Number(bLoc.parents);
7016
+ }
7017
+ // 2. If parents are equal, use priority function
6927
7018
  var aIsHere = isHere(aLoc);
6928
7019
  var bIsHere = isHere(bLoc);
6929
7020
  var aHasGlobal = sdkCommon.hasJunction(aLoc, 'GlobalConsensus');
@@ -6944,10 +7035,10 @@ var sortMultiAssets = function sortMultiAssets(assets$1) {
6944
7035
  return aGeneralIndex - bGeneralIndex;
6945
7036
  });
6946
7037
  };
6947
- function isHere(loc) {
7038
+ var isHere = function isHere(loc) {
6948
7039
  var _loc$interior;
6949
7040
  return loc.interior === 'Here' || ((_loc$interior = loc.interior) === null || _loc$interior === void 0 ? void 0 : _loc$interior.Here) !== undefined;
6950
- }
7041
+ };
6951
7042
  var updateAsset = function updateAsset(asset, amount) {
6952
7043
  return _objectSpread2(_objectSpread2({}, asset), {}, {
6953
7044
  fun: {
@@ -6962,7 +7053,7 @@ var createWithdrawAssets = function createWithdrawAssets(asset, feeAsset) {
6962
7053
  }
6963
7054
  return sortMultiAssets(assetsToWithdraw);
6964
7055
  };
6965
- var createExecuteXcm = function createExecuteXcm(node, input, executionFee, hopExecutionFee, version) {
7056
+ var createExecuteXcm = function createExecuteXcm(node, destChain, input, executionFee, hopExecutionFee, version) {
6966
7057
  var _ref;
6967
7058
  var api = input.api,
6968
7059
  asset = input.asset,
@@ -6991,6 +7082,7 @@ var createExecuteXcm = function createExecuteXcm(node, input, executionFee, hopE
6991
7082
  var multiAsset = createMultiAsset(version, amount, asset.multiLocation);
6992
7083
  var multiAssetLocalized = createMultiAsset(version, amount, localizeLocation(node, asset.multiLocation));
6993
7084
  var multiAssetLocalizedToReserve = createMultiAsset(version, amount, localizeLocation(reserveChain !== null && reserveChain !== void 0 ? reserveChain : node, asset.multiLocation));
7085
+ var multiAssetLocalizedToDest = createMultiAsset(version, amount, localizeLocation(destChain, asset.multiLocation));
6994
7086
  var feeMultiAsset = feeAsset && !assets.isAssetEqual(asset, feeAsset) ? createMultiAsset(version, executionFee, feeAsset.multiLocation) : undefined;
6995
7087
  var feeMultiAssetLocalized = feeAsset && !assets.isAssetEqual(asset, feeAsset) ? createMultiAsset(version, executionFee, localizeLocation(node, feeAsset.multiLocation)) : undefined;
6996
7088
  var feeMultiAssetLocalizedToReserve = feeAsset && !assets.isAssetEqual(asset, feeAsset) ? createMultiAsset(version, executionFee, localizeLocation(reserveChain !== null && reserveChain !== void 0 ? reserveChain : node, feeAsset.multiLocation)) : undefined;
@@ -6999,7 +7091,8 @@ var createExecuteXcm = function createExecuteXcm(node, input, executionFee, hopE
6999
7091
  if (node !== 'AssetHubPolkadot' && reserveParaId === undefined) {
7000
7092
  throw new InvalidParameterError('Sending local reserve assets with custom fee asset is not yet supported for this chain.');
7001
7093
  }
7002
- var depositInstruction = isReserveDest ? {
7094
+ var chainsAreTrusted = sdkCommon.isSystemChain(node) && sdkCommon.isSystemChain(destChain);
7095
+ var depositInstruction = isReserveDest || chainsAreTrusted ? {
7003
7096
  DepositAsset: {
7004
7097
  assets: createAssetsFilter(multiAssetLocalizedToReserve, feeMultiAssetLocalizedToReserve),
7005
7098
  beneficiary: beneficiary
@@ -7028,7 +7121,31 @@ var createExecuteXcm = function createExecuteXcm(node, input, executionFee, hopE
7028
7121
  var needsIntermediaryReserve = reserveParaId !== undefined &&
7029
7122
  // Has a reserve
7030
7123
  !isOnReserveChain(node, reserveParaId); // Not on reserve
7031
- var lastInstruction = needsIntermediaryReserve ? {
7124
+ var lastInstruction = chainsAreTrusted ?
7125
+ // Use teleport for trusted chains
7126
+ {
7127
+ InitiateTeleport: {
7128
+ assets: assetsFilter,
7129
+ dest: dest,
7130
+ xcm: [{
7131
+ BuyExecution: {
7132
+ fees: updateAsset(multiAssetLocalizedToDest, feeMultiAsset ? amount : amount - executionFee),
7133
+ weight_limit: 'Unlimited'
7134
+ }
7135
+ }, {
7136
+ DepositAsset: {
7137
+ assets: {
7138
+ Wild: {
7139
+ AllCounted: 1
7140
+ }
7141
+ },
7142
+ beneficiary: beneficiary
7143
+ }
7144
+ }]
7145
+ }
7146
+ } : needsIntermediaryReserve ?
7147
+ // Use reserve for non-trusted chains
7148
+ {
7032
7149
  InitiateReserveWithdraw: {
7033
7150
  assets: assetsFilter,
7034
7151
  reserve: getChainLocation(reserveParaId),
@@ -7061,7 +7178,7 @@ var createExecuteXcm = function createExecuteXcm(node, input, executionFee, hopE
7061
7178
 
7062
7179
  var handleExecuteTransfer = /*#__PURE__*/function () {
7063
7180
  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;
7181
+ var api, senderAddress, paraIdTo, asset, currency, feeCurrency, address, feeAsset, version, feeAssetBalance, checkAmount, MIN_FEE, destChain, call, dryRunResult, paddedFee, hopFee, paddedHopFee, xcm, weight, _t;
7065
7182
  return _regenerator().w(function (_context) {
7066
7183
  while (1) switch (_context.n) {
7067
7184
  case 0:
@@ -7100,14 +7217,14 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
7100
7217
  };
7101
7218
  MIN_FEE = 1000n;
7102
7219
  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');
7220
+ destChain = getTNode(paraIdTo, determineRelayChain(node) === 'Polkadot' ? 'polkadot' : 'kusama');
7221
+ call = createExecuteCall(createExecuteXcm(node, destChain, input, feeAssetBalance && feeAssetBalance > 1n ? feeAssetBalance : MIN_FEE, MIN_FEE, version), MAX_WEIGHT);
7105
7222
  _context.n = 5;
7106
7223
  return dryRunInternal({
7107
7224
  api: api,
7108
7225
  tx: api.callTxMethod(call),
7109
7226
  origin: node,
7110
- destination: destNode,
7227
+ destination: destChain,
7111
7228
  senderAddress: senderAddress,
7112
7229
  address: address,
7113
7230
  currency: currency,
@@ -7153,7 +7270,7 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
7153
7270
  }
7154
7271
  paddedHopFee = padFeeBy(hopFee, 40);
7155
7272
  checkAmount(feeAsset && !assets.isAssetEqual(asset, feeAsset) ? paddedHopFee : paddedFee + paddedHopFee);
7156
- xcm = createExecuteXcm(node, input, paddedFee, paddedHopFee, version);
7273
+ xcm = createExecuteXcm(node, destChain, input, paddedFee, paddedHopFee, version);
7157
7274
  _context.n = 10;
7158
7275
  return api.getXcmWeight(xcm);
7159
7276
  case 10:
@@ -7523,7 +7640,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7523
7640
  key: "transferPolkadotXCM",
7524
7641
  value: function () {
7525
7642
  var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(input) {
7526
- var api, scenario, asset, destination, feeAsset, overriddenAsset, isNativeAsset, isEthereumAsset, isSystemNode, method, modifiedInput, _t, _t2;
7643
+ var api, scenario, asset, destination, feeAsset, overriddenAsset, isNativeAsset, isNativeFeeAsset, isEthereumAsset, isSystemNode, method, modifiedInput, _t, _t2;
7527
7644
  return _regenerator().w(function (_context3) {
7528
7645
  while (1) switch (_context3.n) {
7529
7646
  case 0:
@@ -7545,7 +7662,8 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7545
7662
  return _context3.a(2, this.handleLocalReserveTransfer(input));
7546
7663
  case 2:
7547
7664
  isNativeAsset = assets.isSymbolMatch(asset.symbol, this.getNativeAssetSymbol());
7548
- if (isNativeAsset) {
7665
+ isNativeFeeAsset = assets.isSymbolMatch(feeAsset.symbol, this.getNativeAssetSymbol());
7666
+ if (!(!isNativeAsset || !isNativeFeeAsset)) {
7549
7667
  _context3.n = 4;
7550
7668
  break;
7551
7669
  }
package/dist/index.d.ts CHANGED
@@ -580,7 +580,7 @@ type TDryRunNodeResult = (TDryRunNodeSuccess & {
580
580
  currency: string;
581
581
  }) | TDryRunNodeFailure;
582
582
  type THopInfo = {
583
- node: TNodeWithRelayChains;
583
+ chain: TNodeWithRelayChains;
584
584
  result: TDryRunNodeResultInternal & {
585
585
  currency?: string;
586
586
  };
@@ -766,6 +766,15 @@ declare class UnableToComputeError extends Error {
766
766
  constructor(message: string);
767
767
  }
768
768
 
769
+ type THopTransferInfo = {
770
+ chain: TNodeWithRelayChains;
771
+ result: {
772
+ xcmFee: TXcmFeeBase;
773
+ balance?: bigint;
774
+ existentialDeposit?: bigint;
775
+ currencySymbol: string;
776
+ };
777
+ };
769
778
  type TXcmFeeBase = {
770
779
  fee: bigint;
771
780
  balance: bigint;
@@ -800,6 +809,7 @@ type TTransferInfo = {
800
809
  currencySymbol: string;
801
810
  xcmFee: TXcmFeeBase;
802
811
  };
812
+ hops?: THopTransferInfo[];
803
813
  destination: {
804
814
  receivedCurrency: {
805
815
  sufficient: boolean | UnableToComputeError;
@@ -902,7 +912,11 @@ type TXcmFeeDetail = {
902
912
  sufficient?: boolean;
903
913
  dryRunError: string;
904
914
  };
905
- type TXcmFeeChain = 'origin' | 'destination' | 'assetHub' | 'bridgeHub';
915
+ type TXcmFeeChain = 'origin' | 'destination' | 'assetHub' | 'bridgeHub' | TNodeWithRelayChains;
916
+ type TXcmFeeHopInfo = {
917
+ chain: TNodeWithRelayChains;
918
+ result: TXcmFeeDetail;
919
+ };
906
920
  type TGetXcmFeeResult = {
907
921
  failureReason?: string;
908
922
  failureChain?: TXcmFeeChain;
@@ -910,6 +924,7 @@ type TGetXcmFeeResult = {
910
924
  destination: TXcmFeeDetail;
911
925
  assetHub?: TXcmFeeDetail;
912
926
  bridgeHub?: TXcmFeeDetail;
927
+ hops: TXcmFeeHopInfo[];
913
928
  };
914
929
  type TGetXcmFeeEstimateDetail = {
915
930
  fee: bigint;
@@ -1794,4 +1809,4 @@ declare const validateAddress: (address: TAddress, node: TNodeWithRelayChains, i
1794
1809
  declare const determineRelayChain: (node: TNodeWithRelayChains) => TRelaychain;
1795
1810
 
1796
1811
  export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, addXcmVersionHeader, assertAddressIsString, assertHasLocation, assertToIsString, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createBeneficiary, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, deriveAccountId, determineRelayChain, dryRun, dryRunOrigin, encodeSs58, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, localizeLocation, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, validateAddress, verifyEdOnDestination };
1797
- export type { IPolkadotApi, IPolkadotXCMTransfer, IXTokensTransfer, IXTransferTransfer, OneKey, TAddress, TApiOrUrl, TAssetClaimOptions, TAssetClaimOptionsBase, TBalanceResponse, TBatchOptions, TBifrostToken, TBridgeStatus, TCreateBeneficiaryOptions, TDestWeight, TDestination, TDryRunBaseOptions, TDryRunCallBaseOptions, TDryRunCallOptions, TDryRunChain, TDryRunNodeFailure, TDryRunNodeResult, TDryRunNodeResultInternal, TDryRunNodeSuccess, TDryRunOptions, TDryRunResult, TDryRunXcmBaseOptions, TDryRunXcmOptions, TEdJsonMap, TEvmBuilderOptions, TEvmBuilderOptionsBase, TEvmNodeFrom, TFeeType, TForeignAssetId, TForeignOrNativeAsset, TForeignOrTokenAsset, TGetAssetBalanceOptions, TGetAssetBalanceOptionsBase, TGetBalanceForeignOptions, TGetBalanceForeignOptionsBase, TGetBalanceNativeOptions, TGetBalanceNativeOptionsBase, TGetFeeForDestNodeBaseOptions, TGetFeeForDestNodeOptions, TGetMaxForeignTransferableAmountOptions, TGetMaxForeignTransferableAmountOptionsBase, TGetMaxNativeTransferableAmountOptions, TGetMaxNativeTransferableAmountOptionsBase, TGetOriginFeeDetailsOptions, TGetOriginFeeDetailsOptionsBase, TGetOriginXcmFeeBaseOptions, TGetOriginXcmFeeEstimateOptions, TGetOriginXcmFeeOptions, TGetReverseTxFeeOptions, TGetTransferInfoOptions, TGetTransferInfoOptionsBase, TGetTransferableAmountOptions, TGetTransferableAmountOptionsBase, TGetXcmFeeBaseOptions, TGetXcmFeeBuilderOptions, TGetXcmFeeEstimateDetail, TGetXcmFeeEstimateOptions, TGetXcmFeeEstimateResult, TGetXcmFeeOptions, TGetXcmFeeResult, THopInfo, THubKey, TMantaAsset, TModuleError, TNativeTokenAsset, TNodeConfig, TNodeConfigMap, TNodleAsset, TOriginFeeDetails, TOtherReserveAsset, TPolkadotXCMTransferOptions, TPolkadotXcmMethod, TProviderEntry, TRelayToParaDestination, TRelayToParaOptions, TRelayToParaOverrides, TRelaychain, TReserveAsset, TScenario, TSelfReserveAsset, TSendBaseOptions, TSendBaseOptionsWithSenderAddress, TSendInternalOptions, TSendOptions, TSerializeEthTransferOptions, TSerializedApiCall, TSerializedEthTransfer, TTransferInfo, TTransferLocalOptions, TVerifyEdOnDestinationOptions, TVerifyEdOnDestinationOptionsBase, TWeight, TXTokensCurrencySelection, TXTokensMethod, TXTokensTransferOptions, TXTransferMethod, TXTransferTransferOptions, TXcmAsset, TXcmFeeBase, TXcmFeeChain, TXcmFeeDetail, TXcmForeignAsset, TXcmPalletMethod, TXcmVersioned, TZeitgeistAsset, WithApi, WithRequiredSenderAddress };
1812
+ export type { IPolkadotApi, IPolkadotXCMTransfer, IXTokensTransfer, IXTransferTransfer, OneKey, TAddress, TApiOrUrl, TAssetClaimOptions, TAssetClaimOptionsBase, TBalanceResponse, TBatchOptions, TBifrostToken, TBridgeStatus, TCreateBeneficiaryOptions, TDestWeight, TDestination, TDryRunBaseOptions, TDryRunCallBaseOptions, TDryRunCallOptions, TDryRunChain, TDryRunNodeFailure, TDryRunNodeResult, TDryRunNodeResultInternal, TDryRunNodeSuccess, TDryRunOptions, TDryRunResult, TDryRunXcmBaseOptions, TDryRunXcmOptions, TEdJsonMap, TEvmBuilderOptions, TEvmBuilderOptionsBase, TEvmNodeFrom, TFeeType, TForeignAssetId, TForeignOrNativeAsset, TForeignOrTokenAsset, TGetAssetBalanceOptions, TGetAssetBalanceOptionsBase, TGetBalanceForeignOptions, TGetBalanceForeignOptionsBase, TGetBalanceNativeOptions, TGetBalanceNativeOptionsBase, TGetFeeForDestNodeBaseOptions, TGetFeeForDestNodeOptions, TGetMaxForeignTransferableAmountOptions, TGetMaxForeignTransferableAmountOptionsBase, TGetMaxNativeTransferableAmountOptions, TGetMaxNativeTransferableAmountOptionsBase, TGetOriginFeeDetailsOptions, TGetOriginFeeDetailsOptionsBase, TGetOriginXcmFeeBaseOptions, TGetOriginXcmFeeEstimateOptions, TGetOriginXcmFeeOptions, TGetReverseTxFeeOptions, TGetTransferInfoOptions, TGetTransferInfoOptionsBase, TGetTransferableAmountOptions, TGetTransferableAmountOptionsBase, TGetXcmFeeBaseOptions, TGetXcmFeeBuilderOptions, TGetXcmFeeEstimateDetail, TGetXcmFeeEstimateOptions, TGetXcmFeeEstimateResult, TGetXcmFeeOptions, TGetXcmFeeResult, THopInfo, THopTransferInfo, THubKey, TMantaAsset, TModuleError, TNativeTokenAsset, TNodeConfig, TNodeConfigMap, TNodleAsset, TOriginFeeDetails, TOtherReserveAsset, TPolkadotXCMTransferOptions, TPolkadotXcmMethod, TProviderEntry, TRelayToParaDestination, TRelayToParaOptions, TRelayToParaOverrides, TRelaychain, TReserveAsset, TScenario, TSelfReserveAsset, TSendBaseOptions, TSendBaseOptionsWithSenderAddress, TSendInternalOptions, TSendOptions, TSerializeEthTransferOptions, TSerializedApiCall, TSerializedEthTransfer, TTransferInfo, TTransferLocalOptions, TVerifyEdOnDestinationOptions, TVerifyEdOnDestinationOptionsBase, TWeight, TXTokensCurrencySelection, TXTokensMethod, TXTokensTransferOptions, TXTransferMethod, TXTransferTransferOptions, TXcmAsset, TXcmFeeBase, TXcmFeeChain, TXcmFeeDetail, TXcmFeeHopInfo, TXcmForeignAsset, TXcmPalletMethod, TXcmVersioned, TZeitgeistAsset, WithApi, WithRequiredSenderAddress };
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import { isNodeEvm, getAssetsObject, InvalidCurrencyError, getNativeAssetSymbol,
3
3
  export * from '@paraspell/assets';
4
4
  import { base58 } from '@scure/base';
5
5
  import { isAddress, createPublicClient, http, getContract } from 'viem';
6
- import { Parents, isTMultiLocation, Version, isRelayChain, replaceBigInt, NODE_NAMES_DOT_KSM, hasJunction, deepEqual, isDotKsmBridge, getJunctionValue } from '@paraspell/sdk-common';
6
+ import { Parents, isTMultiLocation, Version, getJunctionValue, isRelayChain, replaceBigInt, NODE_NAMES_DOT_KSM, hasJunction, deepEqual, isDotKsmBridge, isSystemChain } from '@paraspell/sdk-common';
7
7
  export * from '@paraspell/sdk-common';
8
8
  import { getSupportedPalletsDetails, getDefaultPallet } from '@paraspell/pallets';
9
9
  export * from '@paraspell/pallets';
@@ -2127,13 +2127,17 @@ var localizeLocation = function localizeLocation(node, multiLocation) {
2127
2127
  var newInterior = multiLocation.interior;
2128
2128
  var parachainRemoved = false;
2129
2129
  if (multiLocation.interior !== 'Here') {
2130
+ var paraId = getParaId(node);
2130
2131
  var junctions = Object.values(multiLocation.interior).flat().filter(function (junction) {
2131
2132
  return _typeof(junction) === 'object' && junction !== null;
2132
2133
  });
2133
2134
  var filteredJunctions = junctions.filter(function (junction) {
2134
2135
  if ('Parachain' in junction) {
2135
- parachainRemoved = true;
2136
- return false;
2136
+ var paraJunctionId = getJunctionValue(multiLocation, 'Parachain');
2137
+ if (paraJunctionId === paraId) {
2138
+ parachainRemoved = true;
2139
+ return false;
2140
+ }
2137
2141
  }
2138
2142
  return true;
2139
2143
  });
@@ -4269,30 +4273,30 @@ var buildHopInfo = /*#__PURE__*/function () {
4269
4273
  }();
4270
4274
 
4271
4275
  var getTransferInfo = /*#__PURE__*/function () {
4272
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
4273
- var api, tx, origin, destination, senderAddress, ahAddress, address, currency, feeAsset, resolvedFeeAsset, originAsset, originBalanceFee, originBalance, edOrigin, _yield$getXcmFee, _yield$getXcmFee$orig, originFee, originFeeCurrency, assetHubFeeResult, bridgeHubFeeResult, destFeeDetail, isFeeAssetAh, originBalanceAfter, originBalanceFeeAfter, originBalanceNativeSufficient, originBalanceSufficient, assetHub, bridgeHub, bridgeHubNode, destinationInfo, _t;
4274
- return _regenerator().w(function (_context) {
4275
- while (1) switch (_context.n) {
4276
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
4277
+ var api, tx, origin, destination, senderAddress, ahAddress, address, currency, feeAsset, resolvedFeeAsset, originAsset, originBalanceFee, originBalance, edOrigin, _yield$getXcmFee, _yield$getXcmFee$orig, originFee, originFeeCurrency, assetHubFeeResult, bridgeHubFeeResult, destFeeDetail, hops, isFeeAssetAh, originBalanceAfter, originBalanceFeeAfter, originBalanceNativeSufficient, originBalanceSufficient, assetHub, bridgeHub, bridgeHubNode, builtHops, destinationInfo, _t;
4278
+ return _regenerator().w(function (_context2) {
4279
+ while (1) switch (_context2.n) {
4276
4280
  case 0:
4277
4281
  api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, ahAddress = _ref.ahAddress, address = _ref.address, currency = _ref.currency, feeAsset = _ref.feeAsset;
4278
4282
  if (!(isNodeEvm(origin) && !ahAddress)) {
4279
- _context.n = 1;
4283
+ _context2.n = 1;
4280
4284
  break;
4281
4285
  }
4282
4286
  throw new InvalidParameterError("ahAddress is required for EVM origin ".concat(origin, "."));
4283
4287
  case 1:
4284
4288
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
4285
- _context.n = 2;
4289
+ _context2.n = 2;
4286
4290
  return api.init(origin);
4287
4291
  case 2:
4288
4292
  api.setDisconnectAllowed(false);
4289
- _context.p = 3;
4293
+ _context2.p = 3;
4290
4294
  originAsset = findAssetForNodeOrThrow(origin, currency, destination);
4291
4295
  if (!(feeAsset && resolvedFeeAsset)) {
4292
- _context.n = 5;
4296
+ _context2.n = 5;
4293
4297
  break;
4294
4298
  }
4295
- _context.n = 4;
4299
+ _context2.n = 4;
4296
4300
  return getAssetBalanceInternal({
4297
4301
  api: api,
4298
4302
  address: senderAddress,
@@ -4300,21 +4304,21 @@ var getTransferInfo = /*#__PURE__*/function () {
4300
4304
  currency: feeAsset
4301
4305
  });
4302
4306
  case 4:
4303
- _t = _context.v;
4304
- _context.n = 7;
4307
+ _t = _context2.v;
4308
+ _context2.n = 7;
4305
4309
  break;
4306
4310
  case 5:
4307
- _context.n = 6;
4311
+ _context2.n = 6;
4308
4312
  return getBalanceNativeInternal({
4309
4313
  api: api,
4310
4314
  address: senderAddress,
4311
4315
  node: origin
4312
4316
  });
4313
4317
  case 6:
4314
- _t = _context.v;
4318
+ _t = _context2.v;
4315
4319
  case 7:
4316
4320
  originBalanceFee = _t;
4317
- _context.n = 8;
4321
+ _context2.n = 8;
4318
4322
  return getAssetBalanceInternal({
4319
4323
  api: api,
4320
4324
  address: senderAddress,
@@ -4322,9 +4326,9 @@ var getTransferInfo = /*#__PURE__*/function () {
4322
4326
  currency: currency
4323
4327
  });
4324
4328
  case 8:
4325
- originBalance = _context.v;
4329
+ originBalance = _context2.v;
4326
4330
  edOrigin = getExistentialDepositOrThrow(origin, currency);
4327
- _context.n = 9;
4331
+ _context2.n = 9;
4328
4332
  return getXcmFee({
4329
4333
  api: api,
4330
4334
  tx: tx,
@@ -4337,15 +4341,16 @@ var getTransferInfo = /*#__PURE__*/function () {
4337
4341
  disableFallback: false
4338
4342
  });
4339
4343
  case 9:
4340
- _yield$getXcmFee = _context.v;
4344
+ _yield$getXcmFee = _context2.v;
4341
4345
  _yield$getXcmFee$orig = _yield$getXcmFee.origin;
4342
4346
  originFee = _yield$getXcmFee$orig.fee;
4343
4347
  originFeeCurrency = _yield$getXcmFee$orig.currency;
4344
4348
  assetHubFeeResult = _yield$getXcmFee.assetHub;
4345
4349
  bridgeHubFeeResult = _yield$getXcmFee.bridgeHub;
4346
4350
  destFeeDetail = _yield$getXcmFee.destination;
4351
+ hops = _yield$getXcmFee.hops;
4347
4352
  if (!(originFee === undefined)) {
4348
- _context.n = 10;
4353
+ _context2.n = 10;
4349
4354
  break;
4350
4355
  }
4351
4356
  throw new InvalidParameterError("Cannot get origin xcm fee for currency ".concat(JSON.stringify(currency, replaceBigInt), " on node ").concat(origin, "."));
@@ -4356,10 +4361,10 @@ var getTransferInfo = /*#__PURE__*/function () {
4356
4361
  originBalanceNativeSufficient = originBalanceFee >= originFee;
4357
4362
  originBalanceSufficient = originBalanceAfter >= edOrigin;
4358
4363
  if (!assetHubFeeResult) {
4359
- _context.n = 12;
4364
+ _context2.n = 12;
4360
4365
  break;
4361
4366
  }
4362
- _context.n = 11;
4367
+ _context2.n = 11;
4363
4368
  return buildHopInfo({
4364
4369
  api: api,
4365
4370
  node: determineRelayChain(origin) === 'Polkadot' ? 'AssetHubPolkadot' : 'AssetHubKusama',
@@ -4370,14 +4375,14 @@ var getTransferInfo = /*#__PURE__*/function () {
4370
4375
  ahAddress: ahAddress
4371
4376
  });
4372
4377
  case 11:
4373
- assetHub = _context.v;
4378
+ assetHub = _context2.v;
4374
4379
  case 12:
4375
4380
  if (!bridgeHubFeeResult) {
4376
- _context.n = 14;
4381
+ _context2.n = 14;
4377
4382
  break;
4378
4383
  }
4379
4384
  bridgeHubNode = determineRelayChain(origin) === 'Polkadot' ? 'BridgeHubPolkadot' : 'BridgeHubKusama';
4380
- _context.n = 13;
4385
+ _context2.n = 13;
4381
4386
  return buildHopInfo({
4382
4387
  api: api,
4383
4388
  node: bridgeHubNode,
@@ -4388,9 +4393,47 @@ var getTransferInfo = /*#__PURE__*/function () {
4388
4393
  ahAddress: ahAddress
4389
4394
  });
4390
4395
  case 13:
4391
- bridgeHub = _context.v;
4396
+ bridgeHub = _context2.v;
4392
4397
  case 14:
4393
- _context.n = 15;
4398
+ builtHops = [];
4399
+ if (!(hops && hops.length > 0)) {
4400
+ _context2.n = 16;
4401
+ break;
4402
+ }
4403
+ _context2.n = 15;
4404
+ return Promise.all(hops.map(/*#__PURE__*/function () {
4405
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(hop) {
4406
+ var result;
4407
+ return _regenerator().w(function (_context) {
4408
+ while (1) switch (_context.n) {
4409
+ case 0:
4410
+ _context.n = 1;
4411
+ return buildHopInfo({
4412
+ api: api,
4413
+ node: hop.chain,
4414
+ feeData: hop.result,
4415
+ originNode: origin,
4416
+ currency: currency,
4417
+ senderAddress: senderAddress,
4418
+ ahAddress: ahAddress
4419
+ });
4420
+ case 1:
4421
+ result = _context.v;
4422
+ return _context.a(2, {
4423
+ chain: hop.chain,
4424
+ result: result
4425
+ });
4426
+ }
4427
+ }, _callee);
4428
+ }));
4429
+ return function (_x2) {
4430
+ return _ref3.apply(this, arguments);
4431
+ };
4432
+ }()));
4433
+ case 15:
4434
+ builtHops = _context2.v;
4435
+ case 16:
4436
+ _context2.n = 17;
4394
4437
  return buildDestInfo({
4395
4438
  api: api,
4396
4439
  origin: origin,
@@ -4403,9 +4446,9 @@ var getTransferInfo = /*#__PURE__*/function () {
4403
4446
  assetHubFee: assetHubFeeResult === null || assetHubFeeResult === void 0 ? void 0 : assetHubFeeResult.fee,
4404
4447
  bridgeFee: bridgeHubFeeResult === null || bridgeHubFeeResult === void 0 ? void 0 : bridgeHubFeeResult.fee
4405
4448
  });
4406
- case 15:
4407
- destinationInfo = _context.v;
4408
- return _context.a(2, {
4449
+ case 17:
4450
+ destinationInfo = _context2.v;
4451
+ return _context2.a(2, {
4409
4452
  chain: {
4410
4453
  origin: origin,
4411
4454
  destination: destination,
@@ -4429,19 +4472,20 @@ var getTransferInfo = /*#__PURE__*/function () {
4429
4472
  },
4430
4473
  assetHub: assetHub,
4431
4474
  bridgeHub: bridgeHub,
4475
+ hops: builtHops,
4432
4476
  destination: destinationInfo
4433
4477
  });
4434
- case 16:
4435
- _context.p = 16;
4478
+ case 18:
4479
+ _context2.p = 18;
4436
4480
  api.setDisconnectAllowed(true);
4437
- _context.n = 17;
4481
+ _context2.n = 19;
4438
4482
  return api.disconnect();
4439
- case 17:
4440
- return _context.f(16);
4441
- case 18:
4442
- return _context.a(2);
4483
+ case 19:
4484
+ return _context2.f(18);
4485
+ case 20:
4486
+ return _context2.a(2);
4443
4487
  }
4444
- }, _callee, null, [[3,, 16, 18]]);
4488
+ }, _callee2, null, [[3,, 18, 20]]);
4445
4489
  }));
4446
4490
  return function getTransferInfo(_x) {
4447
4491
  return _ref2.apply(this, arguments);
@@ -4853,7 +4897,7 @@ var getFailureInfo$1 = function getFailureInfo(results, hops) {
4853
4897
  if (!hop.result.success && hop.result.failureReason) {
4854
4898
  return {
4855
4899
  failureReason: hop.result.failureReason,
4856
- failureChain: hop.node
4900
+ failureChain: hop.chain
4857
4901
  };
4858
4902
  }
4859
4903
  }
@@ -4955,7 +4999,7 @@ var dryRunInternal = /*#__PURE__*/function () {
4955
4999
  // Add to hops array (only if not the destination)
4956
5000
  if (nextChain !== destination) {
4957
5001
  hops.push({
4958
- node: nextChain,
5002
+ chain: nextChain,
4959
5003
  result: hopDryRun.success && hopCurrency ? _objectSpread2(_objectSpread2({}, hopDryRun), {}, {
4960
5004
  currency: hopCurrency
4961
5005
  }) : hopDryRun
@@ -5009,7 +5053,7 @@ var dryRunInternal = /*#__PURE__*/function () {
5009
5053
  });
5010
5054
  // Update the hop data if BridgeHub is in the hops array
5011
5055
  bridgeHubHopIndex = hops.findIndex(function (hop) {
5012
- return hop.node === bridgeHubNode;
5056
+ return hop.chain === bridgeHubNode;
5013
5057
  });
5014
5058
  if (bridgeHubHopIndex !== -1 && hops[bridgeHubHopIndex].result.success) {
5015
5059
  hops[bridgeHubHopIndex].result = _objectSpread2(_objectSpread2({}, hops[bridgeHubHopIndex].result), {}, {
@@ -5397,8 +5441,9 @@ var getOriginXcmFeeEstimate = /*#__PURE__*/function () {
5397
5441
  };
5398
5442
  }();
5399
5443
 
5400
- var getFailureInfo = function getFailureInfo(nodes) {
5444
+ var getFailureInfo = function getFailureInfo(nodes, hops) {
5401
5445
  var _nodes$origin, _nodes$assetHub, _nodes$bridgeHub, _nodes$destination;
5446
+ // Check standard chains first for backwards compatibility
5402
5447
  if ((_nodes$origin = nodes.origin) !== null && _nodes$origin !== void 0 && _nodes$origin.dryRunError) return {
5403
5448
  failureChain: 'origin',
5404
5449
  failureReason: nodes.origin.dryRunError
@@ -5415,11 +5460,29 @@ var getFailureInfo = function getFailureInfo(nodes) {
5415
5460
  failureChain: 'destination',
5416
5461
  failureReason: nodes.destination.dryRunError
5417
5462
  };
5463
+ // Check hops for failures
5464
+ var _iterator = _createForOfIteratorHelper(hops),
5465
+ _step;
5466
+ try {
5467
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
5468
+ var hop = _step.value;
5469
+ if (hop.result.dryRunError) {
5470
+ return {
5471
+ failureChain: hop.chain,
5472
+ failureReason: hop.result.dryRunError
5473
+ };
5474
+ }
5475
+ }
5476
+ } catch (err) {
5477
+ _iterator.e(err);
5478
+ } finally {
5479
+ _iterator.f();
5480
+ }
5418
5481
  return {};
5419
5482
  };
5420
5483
  var getXcmFee = /*#__PURE__*/function () {
5421
5484
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
5422
- var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, asset, _yield$getOriginXcmFe, originFee, originCurrency, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, destApi, destFeeRes, _result, _getFailureInfo, _failureChain, _failureReason, assetHubNode, bridgeHubNode, currentOrigin, forwardedXcms, nextParaId, intermediateFees, destinationFee, destinationFeeType, destinationDryRunError, destinationSufficient, nextChain, hopApi, hopResult, failingRecord, hopIsDestination, _destApi, destFallback, processedBridgeHubData, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, destCurrency, result, _getFailureInfo2, failureChain, failureReason;
5485
+ var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, asset, _yield$getOriginXcmFe, originFee, originCurrency, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, hops, destApi, destFeeRes, _result, _getFailureInfo, _failureChain, _failureReason, assetHubNode, bridgeHubNode, currentOrigin, forwardedXcms, nextParaId, intermediateFees, destinationFee, destinationFeeType, destinationDryRunError, destinationSufficient, nextChain, hopApi, hopResult, hopCurrency, hopDetail, failingRecord, hopIsDestination, _destApi, destFallback, processedBridgeHubData, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, bridgeHubHopIndex, destCurrency, result, _getFailureInfo2, failureChain, failureReason;
5423
5486
  return _regenerator().w(function (_context) {
5424
5487
  while (1) switch (_context.n) {
5425
5488
  case 0:
@@ -5450,6 +5513,8 @@ var getXcmFee = /*#__PURE__*/function () {
5450
5513
  _context.n = 2;
5451
5514
  return api.disconnect();
5452
5515
  case 2:
5516
+ // Initialize hops array
5517
+ hops = [];
5453
5518
  if (!(originDryRunError || originFeeType === 'paymentInfo')) {
5454
5519
  _context.n = 8;
5455
5520
  break;
@@ -5499,12 +5564,13 @@ var getXcmFee = /*#__PURE__*/function () {
5499
5564
  sufficient: destFeeRes.sufficient
5500
5565
  }), {}, {
5501
5566
  currency: getNativeAssetSymbol(destination)
5502
- })
5567
+ }),
5568
+ hops: hops // Include empty hops array
5503
5569
  };
5504
5570
  _getFailureInfo = getFailureInfo({
5505
5571
  origin: _result.origin,
5506
5572
  destination: _result.destination
5507
- }), _failureChain = _getFailureInfo.failureChain, _failureReason = _getFailureInfo.failureReason;
5573
+ }, hops), _failureChain = _getFailureInfo.failureChain, _failureReason = _getFailureInfo.failureReason;
5508
5574
  return _context.a(2, _objectSpread2(_objectSpread2({}, _result), {}, {
5509
5575
  failureChain: _failureChain,
5510
5576
  failureReason: _failureReason
@@ -5560,17 +5626,38 @@ var getXcmFee = /*#__PURE__*/function () {
5560
5626
  });
5561
5627
  case 13:
5562
5628
  hopResult = _context.v;
5563
- if (!hopResult.dryRunError) {
5564
- _context.n = 17;
5565
- break;
5629
+ // Determine the currency for this hop
5630
+ hopCurrency = void 0;
5631
+ if (nextChain === destination) {
5632
+ hopCurrency = destinationFeeType === 'dryRun' ? findAssetOnDestOrThrow(origin, destination, currency).symbol : getNativeAssetSymbol(destination);
5633
+ } else if (isRelayChain(nextChain) || nextChain === assetHubNode || nextChain === bridgeHubNode) {
5634
+ hopCurrency = getNativeAssetSymbol(nextChain);
5635
+ } else {
5636
+ hopCurrency = getNativeAssetSymbol(nextChain);
5566
5637
  }
5567
- failingRecord = {
5638
+ hopDetail = hopResult.dryRunError ? {
5639
+ fee: hopResult.fee,
5640
+ feeType: hopResult.feeType,
5641
+ currency: hopCurrency,
5642
+ sufficient: hopResult.sufficient,
5643
+ dryRunError: hopResult.dryRunError
5644
+ } : {
5568
5645
  fee: hopResult.fee,
5569
5646
  feeType: hopResult.feeType,
5570
- currency: getNativeAssetSymbol(nextChain),
5571
- dryRunError: hopResult.dryRunError,
5647
+ currency: hopCurrency,
5572
5648
  sufficient: hopResult.sufficient
5573
5649
  };
5650
+ if (nextChain !== destination) {
5651
+ hops.push({
5652
+ chain: nextChain,
5653
+ result: hopDetail
5654
+ });
5655
+ }
5656
+ if (!hopResult.dryRunError) {
5657
+ _context.n = 17;
5658
+ break;
5659
+ }
5660
+ failingRecord = hopDetail;
5574
5661
  hopIsDestination = nextChain === destination || isRelayChain(nextChain) && !isRelayChain(destination);
5575
5662
  if (hopIsDestination) {
5576
5663
  destinationFee = hopResult.fee;
@@ -5622,19 +5709,9 @@ var getXcmFee = /*#__PURE__*/function () {
5622
5709
  destinationFeeType = hopResult.feeType;
5623
5710
  destinationSufficient = hopResult.sufficient;
5624
5711
  } else if (nextChain === assetHubNode) {
5625
- intermediateFees.assetHub = {
5626
- fee: hopResult.fee,
5627
- feeType: hopResult.feeType,
5628
- currency: getNativeAssetSymbol(nextChain),
5629
- sufficient: hopResult.sufficient
5630
- };
5712
+ intermediateFees.assetHub = hopDetail;
5631
5713
  } else if (nextChain === bridgeHubNode) {
5632
- intermediateFees.bridgeHub = {
5633
- fee: hopResult.fee,
5634
- feeType: hopResult.feeType,
5635
- currency: getNativeAssetSymbol(nextChain),
5636
- sufficient: hopResult.sufficient
5637
- };
5714
+ intermediateFees.bridgeHub = hopDetail;
5638
5715
  } else ;
5639
5716
  forwardedXcms = hopResult.forwardedXcms;
5640
5717
  nextParaId = hopResult.destParaId;
@@ -5667,6 +5744,14 @@ var getXcmFee = /*#__PURE__*/function () {
5667
5744
  processedBridgeHubData = _objectSpread2(_objectSpread2({}, intermediateFees.bridgeHub), {}, {
5668
5745
  fee: intermediateFees.bridgeHub.fee + bridgeFee
5669
5746
  });
5747
+ bridgeHubHopIndex = hops.findIndex(function (hop) {
5748
+ return hop.chain === bridgeHubNode;
5749
+ });
5750
+ if (bridgeHubHopIndex !== -1) {
5751
+ hops[bridgeHubHopIndex].result = _objectSpread2(_objectSpread2({}, hops[bridgeHubHopIndex].result), {}, {
5752
+ fee: intermediateFees.bridgeHub.fee + bridgeFee
5753
+ });
5754
+ }
5670
5755
  case 24:
5671
5756
  intermediateFees.bridgeHub = processedBridgeHubData;
5672
5757
  destCurrency = destinationFeeType === 'dryRun' ? findAssetOnDestOrThrow(origin, destination, currency).symbol : getNativeAssetSymbol(destination);
@@ -5694,14 +5779,15 @@ var getXcmFee = /*#__PURE__*/function () {
5694
5779
  currency: destCurrency
5695
5780
  }, destinationDryRunError && {
5696
5781
  dryRunError: destinationDryRunError
5697
- })
5782
+ }),
5783
+ hops: hops
5698
5784
  });
5699
5785
  _getFailureInfo2 = getFailureInfo({
5700
5786
  origin: result.origin,
5701
5787
  assetHub: result.assetHub,
5702
5788
  bridgeHub: result.bridgeHub,
5703
5789
  destination: result.destination
5704
- }), failureChain = _getFailureInfo2.failureChain, failureReason = _getFailureInfo2.failureReason;
5790
+ }, hops), failureChain = _getFailureInfo2.failureChain, failureReason = _getFailureInfo2.failureReason;
5705
5791
  return _context.a(2, _objectSpread2(_objectSpread2({}, result), {}, {
5706
5792
  failureChain: failureChain,
5707
5793
  failureReason: failureReason
@@ -6925,6 +7011,11 @@ var sortMultiAssets = function sortMultiAssets(assets) {
6925
7011
  return assets.sort(function (a, b) {
6926
7012
  var aLoc = extractMultiAssetLoc(a);
6927
7013
  var bLoc = extractMultiAssetLoc(b);
7014
+ // 1. Sort by parents first
7015
+ if (aLoc.parents !== bLoc.parents) {
7016
+ return Number(aLoc.parents) - Number(bLoc.parents);
7017
+ }
7018
+ // 2. If parents are equal, use priority function
6928
7019
  var aIsHere = isHere(aLoc);
6929
7020
  var bIsHere = isHere(bLoc);
6930
7021
  var aHasGlobal = hasJunction(aLoc, 'GlobalConsensus');
@@ -6945,10 +7036,10 @@ var sortMultiAssets = function sortMultiAssets(assets) {
6945
7036
  return aGeneralIndex - bGeneralIndex;
6946
7037
  });
6947
7038
  };
6948
- function isHere(loc) {
7039
+ var isHere = function isHere(loc) {
6949
7040
  var _loc$interior;
6950
7041
  return loc.interior === 'Here' || ((_loc$interior = loc.interior) === null || _loc$interior === void 0 ? void 0 : _loc$interior.Here) !== undefined;
6951
- }
7042
+ };
6952
7043
  var updateAsset = function updateAsset(asset, amount) {
6953
7044
  return _objectSpread2(_objectSpread2({}, asset), {}, {
6954
7045
  fun: {
@@ -6963,7 +7054,7 @@ var createWithdrawAssets = function createWithdrawAssets(asset, feeAsset) {
6963
7054
  }
6964
7055
  return sortMultiAssets(assetsToWithdraw);
6965
7056
  };
6966
- var createExecuteXcm = function createExecuteXcm(node, input, executionFee, hopExecutionFee, version) {
7057
+ var createExecuteXcm = function createExecuteXcm(node, destChain, input, executionFee, hopExecutionFee, version) {
6967
7058
  var _ref;
6968
7059
  var api = input.api,
6969
7060
  asset = input.asset,
@@ -6992,6 +7083,7 @@ var createExecuteXcm = function createExecuteXcm(node, input, executionFee, hopE
6992
7083
  var multiAsset = createMultiAsset(version, amount, asset.multiLocation);
6993
7084
  var multiAssetLocalized = createMultiAsset(version, amount, localizeLocation(node, asset.multiLocation));
6994
7085
  var multiAssetLocalizedToReserve = createMultiAsset(version, amount, localizeLocation(reserveChain !== null && reserveChain !== void 0 ? reserveChain : node, asset.multiLocation));
7086
+ var multiAssetLocalizedToDest = createMultiAsset(version, amount, localizeLocation(destChain, asset.multiLocation));
6995
7087
  var feeMultiAsset = feeAsset && !isAssetEqual(asset, feeAsset) ? createMultiAsset(version, executionFee, feeAsset.multiLocation) : undefined;
6996
7088
  var feeMultiAssetLocalized = feeAsset && !isAssetEqual(asset, feeAsset) ? createMultiAsset(version, executionFee, localizeLocation(node, feeAsset.multiLocation)) : undefined;
6997
7089
  var feeMultiAssetLocalizedToReserve = feeAsset && !isAssetEqual(asset, feeAsset) ? createMultiAsset(version, executionFee, localizeLocation(reserveChain !== null && reserveChain !== void 0 ? reserveChain : node, feeAsset.multiLocation)) : undefined;
@@ -7000,7 +7092,8 @@ var createExecuteXcm = function createExecuteXcm(node, input, executionFee, hopE
7000
7092
  if (node !== 'AssetHubPolkadot' && reserveParaId === undefined) {
7001
7093
  throw new InvalidParameterError('Sending local reserve assets with custom fee asset is not yet supported for this chain.');
7002
7094
  }
7003
- var depositInstruction = isReserveDest ? {
7095
+ var chainsAreTrusted = isSystemChain(node) && isSystemChain(destChain);
7096
+ var depositInstruction = isReserveDest || chainsAreTrusted ? {
7004
7097
  DepositAsset: {
7005
7098
  assets: createAssetsFilter(multiAssetLocalizedToReserve, feeMultiAssetLocalizedToReserve),
7006
7099
  beneficiary: beneficiary
@@ -7029,7 +7122,31 @@ var createExecuteXcm = function createExecuteXcm(node, input, executionFee, hopE
7029
7122
  var needsIntermediaryReserve = reserveParaId !== undefined &&
7030
7123
  // Has a reserve
7031
7124
  !isOnReserveChain(node, reserveParaId); // Not on reserve
7032
- var lastInstruction = needsIntermediaryReserve ? {
7125
+ var lastInstruction = chainsAreTrusted ?
7126
+ // Use teleport for trusted chains
7127
+ {
7128
+ InitiateTeleport: {
7129
+ assets: assetsFilter,
7130
+ dest: dest,
7131
+ xcm: [{
7132
+ BuyExecution: {
7133
+ fees: updateAsset(multiAssetLocalizedToDest, feeMultiAsset ? amount : amount - executionFee),
7134
+ weight_limit: 'Unlimited'
7135
+ }
7136
+ }, {
7137
+ DepositAsset: {
7138
+ assets: {
7139
+ Wild: {
7140
+ AllCounted: 1
7141
+ }
7142
+ },
7143
+ beneficiary: beneficiary
7144
+ }
7145
+ }]
7146
+ }
7147
+ } : needsIntermediaryReserve ?
7148
+ // Use reserve for non-trusted chains
7149
+ {
7033
7150
  InitiateReserveWithdraw: {
7034
7151
  assets: assetsFilter,
7035
7152
  reserve: getChainLocation(reserveParaId),
@@ -7062,7 +7179,7 @@ var createExecuteXcm = function createExecuteXcm(node, input, executionFee, hopE
7062
7179
 
7063
7180
  var handleExecuteTransfer = /*#__PURE__*/function () {
7064
7181
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(node, input) {
7065
- var api, senderAddress, paraIdTo, asset, currency, feeCurrency, address, feeAsset, version, feeAssetBalance, checkAmount, MIN_FEE, call, destNode, dryRunResult, paddedFee, hopFee, paddedHopFee, xcm, weight, _t;
7182
+ var api, senderAddress, paraIdTo, asset, currency, feeCurrency, address, feeAsset, version, feeAssetBalance, checkAmount, MIN_FEE, destChain, call, dryRunResult, paddedFee, hopFee, paddedHopFee, xcm, weight, _t;
7066
7183
  return _regenerator().w(function (_context) {
7067
7184
  while (1) switch (_context.n) {
7068
7185
  case 0:
@@ -7101,14 +7218,14 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
7101
7218
  };
7102
7219
  MIN_FEE = 1000n;
7103
7220
  checkAmount(MIN_FEE);
7104
- call = createExecuteCall(createExecuteXcm(node, input, feeAssetBalance && feeAssetBalance > 1n ? feeAssetBalance : MIN_FEE, MIN_FEE, version), MAX_WEIGHT);
7105
- destNode = getTNode(paraIdTo, determineRelayChain(node) === 'Polkadot' ? 'polkadot' : 'kusama');
7221
+ destChain = getTNode(paraIdTo, determineRelayChain(node) === 'Polkadot' ? 'polkadot' : 'kusama');
7222
+ call = createExecuteCall(createExecuteXcm(node, destChain, input, feeAssetBalance && feeAssetBalance > 1n ? feeAssetBalance : MIN_FEE, MIN_FEE, version), MAX_WEIGHT);
7106
7223
  _context.n = 5;
7107
7224
  return dryRunInternal({
7108
7225
  api: api,
7109
7226
  tx: api.callTxMethod(call),
7110
7227
  origin: node,
7111
- destination: destNode,
7228
+ destination: destChain,
7112
7229
  senderAddress: senderAddress,
7113
7230
  address: address,
7114
7231
  currency: currency,
@@ -7154,7 +7271,7 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
7154
7271
  }
7155
7272
  paddedHopFee = padFeeBy(hopFee, 40);
7156
7273
  checkAmount(feeAsset && !isAssetEqual(asset, feeAsset) ? paddedHopFee : paddedFee + paddedHopFee);
7157
- xcm = createExecuteXcm(node, input, paddedFee, paddedHopFee, version);
7274
+ xcm = createExecuteXcm(node, destChain, input, paddedFee, paddedHopFee, version);
7158
7275
  _context.n = 10;
7159
7276
  return api.getXcmWeight(xcm);
7160
7277
  case 10:
@@ -7524,7 +7641,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7524
7641
  key: "transferPolkadotXCM",
7525
7642
  value: function () {
7526
7643
  var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(input) {
7527
- var api, scenario, asset, destination, feeAsset, overriddenAsset, isNativeAsset, isEthereumAsset, isSystemNode, method, modifiedInput, _t, _t2;
7644
+ var api, scenario, asset, destination, feeAsset, overriddenAsset, isNativeAsset, isNativeFeeAsset, isEthereumAsset, isSystemNode, method, modifiedInput, _t, _t2;
7528
7645
  return _regenerator().w(function (_context3) {
7529
7646
  while (1) switch (_context3.n) {
7530
7647
  case 0:
@@ -7546,7 +7663,8 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7546
7663
  return _context3.a(2, this.handleLocalReserveTransfer(input));
7547
7664
  case 2:
7548
7665
  isNativeAsset = isSymbolMatch(asset.symbol, this.getNativeAssetSymbol());
7549
- if (isNativeAsset) {
7666
+ isNativeFeeAsset = isSymbolMatch(feeAsset.symbol, this.getNativeAssetSymbol());
7667
+ if (!(!isNativeAsset || !isNativeFeeAsset)) {
7550
7668
  _context3.n = 4;
7551
7669
  break;
7552
7670
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-core",
3
- "version": "10.7.2",
3
+ "version": "10.8.0",
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": "^1.2.6",
28
28
  "viem": "^2.30.5",
29
- "@paraspell/assets": "10.7.2",
30
- "@paraspell/sdk-common": "10.7.2",
31
- "@paraspell/pallets": "10.7.2"
29
+ "@paraspell/pallets": "10.8.0",
30
+ "@paraspell/sdk-common": "10.8.0",
31
+ "@paraspell/assets": "10.8.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@babel/plugin-syntax-import-attributes": "^7.27.1",