@paraspell/sdk-core 11.14.7 → 11.14.9

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
@@ -751,6 +751,14 @@ var assertIsForeign = function assertIsForeign(asset) {
751
751
  }
752
752
  };
753
753
 
754
+ var createId = function createId(version, location) {
755
+ if (version === sdkCommon.Version.V3) {
756
+ return {
757
+ Concrete: location
758
+ };
759
+ }
760
+ return location;
761
+ };
754
762
  var createAsset = function createAsset(version, amount, location) {
755
763
  if (version === sdkCommon.Version.V3) {
756
764
  return {
@@ -2774,16 +2782,6 @@ var resolveTChainFromLocation = function resolveTChainFromLocation(relaychain, l
2774
2782
  }
2775
2783
  return chain;
2776
2784
  };
2777
- var throwUnsupportedCurrency = function throwUnsupportedCurrency(currency, chain) {
2778
- var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
2779
- isDestination: false
2780
- },
2781
- isDestination = _ref.isDestination;
2782
- if ('location' in currency) {
2783
- throw new assets.InvalidCurrencyError("\n Selected chain doesn't support location you provided. Maybe you meant custom location. If so, you need to use override option. Your selection should look like this: {location: Override(".concat(JSON.stringify(currency.location), ")}."));
2784
- }
2785
- throw new assets.InvalidCurrencyError("".concat(isDestination ? 'Destination' : 'Origin', " chain ").concat(chain, " does not support currency ").concat(JSON.stringify(currency, sdkCommon.replaceBigInt), "."));
2786
- };
2787
2785
 
2788
2786
  var buildClaimAssetsParams = function buildClaimAssetsParams(options) {
2789
2787
  var assets = options.assets,
@@ -4551,14 +4549,13 @@ var validateAssetSupport = function validateAssetSupport(_ref, assetCheckEnabled
4551
4549
  var origin = _ref.from,
4552
4550
  destination = _ref.to,
4553
4551
  currency = _ref.currency;
4554
- var isRelayDestination = !sdkCommon.isTLocation(destination) && sdkCommon.isRelayChain(destination);
4555
4552
  var isLocationDestination = _typeof(destination) === 'object';
4556
- if (!isBridge && !isRelayDestination && !isLocationDestination && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== undefined && assetCheckEnabled && !('id' in currency) && !assets.hasSupportForAsset(destination, asset.symbol)) {
4557
- throw new assets.InvalidCurrencyError("Destination chain ".concat(destination, " does not support currency ").concat(JSON.stringify(currency, sdkCommon.replaceBigInt), "."));
4558
- }
4559
4553
  if (asset === null && assetCheckEnabled) {
4560
4554
  throwUnsupportedCurrency(currency, origin);
4561
4555
  }
4556
+ if (!isLocationDestination && assetCheckEnabled && !assets.findAssetInfoOnDest(origin, destination, currency, asset)) {
4557
+ throw new assets.InvalidCurrencyError("Destination chain ".concat(destination, " does not support currency ").concat(JSON.stringify(currency, sdkCommon.replaceBigInt), "."));
4558
+ }
4562
4559
  validateBridgeAsset(origin, destination, asset, currency, isBridge);
4563
4560
  validateEthereumAsset(origin, destination, asset);
4564
4561
  };
@@ -7470,7 +7467,7 @@ var send = /*#__PURE__*/function () {
7470
7467
 
7471
7468
  var buildDestInfo = /*#__PURE__*/function () {
7472
7469
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
7473
- var api, origin, destination, address, currency, originFee, isFeeAssetAh, destFeeDetail, totalHopFee, bridgeFee, destApi, destAsset, edDest, destBalance, destAmount, effectiveAmountForBalance, destBalanceSufficient, destBalanceSufficientResult, destBalanceAfter, destbalanceAfterResult, receivedAmount, isSubBridge, nativeAssetOfOriginSymbol, isOriginAssetNative, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, destXcmFeeBalanceAfter;
7470
+ var api, origin, destination, address, currency, originFee, isFeeAssetAh, destFeeDetail, totalHopFee, bridgeFee, destApi, destAsset, edDest, destBalance, destAmount, destFeeAssetEqual, effectiveDestFee, effectiveAmountForBalance, destBalanceSufficient, destBalanceAfter, createUnableToComputeError, isUnableToCompute, destbalanceAfterResult, destBalanceSufficientResult, receivedAmount, isSubBridge, nativeAssetOfOriginSymbol, isOriginAssetNative, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, destXcmFeeBalanceAfter;
7474
7471
  return _regenerator().w(function (_context) {
7475
7472
  while (1) switch (_context.n) {
7476
7473
  case 0:
@@ -7491,11 +7488,17 @@ var buildDestInfo = /*#__PURE__*/function () {
7491
7488
  case 2:
7492
7489
  destBalance = _context.v;
7493
7490
  destAmount = isFeeAssetAh ? currency.amount - originFee : currency.amount;
7491
+ destFeeAssetEqual = assets.isSymbolMatch(destFeeDetail.asset.symbol, destAsset.symbol);
7492
+ effectiveDestFee = destFeeAssetEqual ? destFeeDetail.fee : 0n;
7494
7493
  effectiveAmountForBalance = destAmount - totalHopFee;
7495
- destBalanceSufficient = effectiveAmountForBalance - destFeeDetail.fee > (destBalance < edDest ? edDest : 0n);
7496
- destBalanceSufficientResult = destFeeDetail.currency !== destAsset.symbol && destination !== 'Ethereum' ? new UnableToComputeError('Unable to compute if dest balance will be sufficient. Fee currency is not the same') : destBalanceSufficient;
7497
- destBalanceAfter = destBalance - (destFeeDetail.currency === destAsset.symbol ? destFeeDetail.fee : 0n) + effectiveAmountForBalance;
7498
- destbalanceAfterResult = destFeeDetail.currency !== destAsset.symbol && destination !== 'Ethereum' ? new UnableToComputeError('Unable to compute if dest balance will be sufficient. Fee currency is not the same') : destBalanceAfter;
7494
+ destBalanceSufficient = effectiveAmountForBalance - effectiveDestFee > (destBalance < edDest ? edDest : 0n);
7495
+ destBalanceAfter = destBalance - effectiveDestFee + effectiveAmountForBalance;
7496
+ createUnableToComputeError = function createUnableToComputeError() {
7497
+ return new UnableToComputeError('Unable to compute if dest balance will be sufficient. Fee currency is not the same');
7498
+ };
7499
+ isUnableToCompute = destFeeDetail.feeType === 'paymentInfo' && !destFeeAssetEqual;
7500
+ destbalanceAfterResult = isUnableToCompute ? createUnableToComputeError() : destBalanceAfter;
7501
+ destBalanceSufficientResult = isUnableToCompute ? createUnableToComputeError() : destBalanceSufficient;
7499
7502
  isSubBridge = sdkCommon.isSubstrateBridge(origin, destination);
7500
7503
  if (isSubBridge) {
7501
7504
  nativeAssetOfOriginSymbol = assets.getNativeAssetSymbol(origin);
@@ -7538,7 +7541,7 @@ var buildDestInfo = /*#__PURE__*/function () {
7538
7541
  case 4:
7539
7542
  destXcmFeeBalance = destBalance;
7540
7543
  case 5:
7541
- destXcmFeeBalanceAfter = isFeeAssetAh ? destBalanceAfter : destXcmFeeBalance - destFeeDetail.fee + (destFeeDetail.currency === destAsset.symbol ? effectiveAmountForBalance : 0n);
7544
+ destXcmFeeBalanceAfter = isFeeAssetAh ? destBalanceAfter : destXcmFeeBalance - destFeeDetail.fee + (destFeeAssetEqual ? effectiveAmountForBalance : 0n);
7542
7545
  return _context.a(2, {
7543
7546
  receivedCurrency: {
7544
7547
  sufficient: destBalanceSufficientResult,
@@ -7553,7 +7556,7 @@ var buildDestInfo = /*#__PURE__*/function () {
7553
7556
  fee: destFeeDetail.fee,
7554
7557
  balance: destXcmFeeBalance,
7555
7558
  balanceAfter: destXcmFeeBalanceAfter,
7556
- currencySymbol: destFeeDetail.currency,
7559
+ currencySymbol: destFeeDetail.asset.symbol,
7557
7560
  asset: destFeeDetail.asset
7558
7561
  }
7559
7562
  });
@@ -8568,20 +8571,16 @@ var createTypeThenAutoReserve = /*#__PURE__*/function () {
8568
8571
  };
8569
8572
  }();
8570
8573
 
8571
- var calculateTotalXcmFee = function calculateTotalXcmFee(feeResult) {
8572
- var _feeResult$assetHub;
8573
- var totalFee = 0n;
8574
- if (((_feeResult$assetHub = feeResult.assetHub) === null || _feeResult$assetHub === void 0 ? void 0 : _feeResult$assetHub.fee) !== undefined) {
8575
- totalFee += feeResult.assetHub.fee;
8576
- }
8577
- if (feeResult.destination.fee !== undefined) {
8578
- totalFee += feeResult.destination.fee;
8579
- }
8580
- return totalFee;
8574
+ var calculateTotalXcmFee = function calculateTotalXcmFee(asset, feeResult) {
8575
+ var totalHopFee = feeResult.hops.reduce(function (acc, hop) {
8576
+ return assets.isAssetXcEqual(hop.result.asset, asset) ? acc + hop.result.fee : acc;
8577
+ }, 0n);
8578
+ var destFee = assets.isAssetXcEqual(feeResult.destination.asset, asset) ? feeResult.destination.fee : 0n;
8579
+ return totalHopFee + destFee;
8581
8580
  };
8582
8581
  var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
8583
8582
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
8584
- var api, buildTx, origin, destination, currency, address, senderAddress, feeAsset, isSubBridge, destApi, asset, amount, destAsset, ed, balance, xcmFeeResult, dryRunError, assetHubFeeResult, bridgeHubFeeResult, _xcmFeeResult$destina, destFee, destFeeCurrency, destDryRunError, hopDryRunError, tx, totalFee, method, feeToSubtract;
8583
+ var api, buildTx, origin, destination, currency, address, senderAddress, feeAsset, isSubBridge, destApi, asset, amount, destAsset, ed, balance, xcmFeeResult, dryRunError, hops, _xcmFeeResult$destina, destFee, destFeeType, destFeeAsset, destDryRunError, erroredHop, hopError, isUnableToCompute, tx, totalFee, method, feeToSubtract;
8585
8584
  return _regenerator().w(function (_context) {
8586
8585
  while (1) switch (_context.n) {
8587
8586
  case 0:
@@ -8633,19 +8632,22 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
8633
8632
  });
8634
8633
  case 5:
8635
8634
  xcmFeeResult = _context.v;
8636
- dryRunError = xcmFeeResult.origin.dryRunError, assetHubFeeResult = xcmFeeResult.assetHub, bridgeHubFeeResult = xcmFeeResult.bridgeHub, _xcmFeeResult$destina = xcmFeeResult.destination, destFee = _xcmFeeResult$destina.fee, destFeeCurrency = _xcmFeeResult$destina.currency, destDryRunError = _xcmFeeResult$destina.dryRunError;
8635
+ dryRunError = xcmFeeResult.origin.dryRunError, hops = xcmFeeResult.hops, _xcmFeeResult$destina = xcmFeeResult.destination, destFee = _xcmFeeResult$destina.fee, destFeeType = _xcmFeeResult$destina.feeType, destFeeAsset = _xcmFeeResult$destina.asset, destDryRunError = _xcmFeeResult$destina.dryRunError;
8637
8636
  if (!dryRunError) {
8638
8637
  _context.n = 6;
8639
8638
  break;
8640
8639
  }
8641
8640
  throw new DryRunFailedError(dryRunError, 'origin');
8642
8641
  case 6:
8643
- hopDryRunError = (assetHubFeeResult === null || assetHubFeeResult === void 0 ? void 0 : assetHubFeeResult.dryRunError) || (bridgeHubFeeResult === null || bridgeHubFeeResult === void 0 ? void 0 : bridgeHubFeeResult.dryRunError);
8644
- if (!hopDryRunError) {
8642
+ erroredHop = hops.find(function (hop) {
8643
+ return hop.result.dryRunError;
8644
+ });
8645
+ hopError = erroredHop === null || erroredHop === void 0 ? void 0 : erroredHop.result.dryRunError;
8646
+ if (!hopError) {
8645
8647
  _context.n = 7;
8646
8648
  break;
8647
8649
  }
8648
- throw new DryRunFailedError(hopDryRunError, assetHubFeeResult !== null && assetHubFeeResult !== void 0 && assetHubFeeResult.dryRunError ? 'assetHub' : 'bridgeHub');
8650
+ throw new DryRunFailedError(hopError, erroredHop.chain);
8649
8651
  case 7:
8650
8652
  if (!destDryRunError) {
8651
8653
  _context.n = 8;
@@ -8653,7 +8655,8 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
8653
8655
  }
8654
8656
  throw new UnableToComputeError("Unable to compute fee for the destination asset. Destination dry run error: ".concat(destDryRunError));
8655
8657
  case 8:
8656
- if (!(assets.normalizeSymbol(asset.symbol) !== assets.normalizeSymbol(destFeeCurrency))) {
8658
+ isUnableToCompute = !assets.isSymbolMatch(assets.normalizeSymbol(destAsset.symbol), assets.normalizeSymbol(destFeeAsset.symbol)) && destFeeType === 'paymentInfo';
8659
+ if (!isUnableToCompute) {
8657
8660
  _context.n = 9;
8658
8661
  break;
8659
8662
  }
@@ -8663,7 +8666,7 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
8663
8666
  return buildTx();
8664
8667
  case 10:
8665
8668
  tx = _context.v;
8666
- totalFee = calculateTotalXcmFee(xcmFeeResult);
8669
+ totalFee = calculateTotalXcmFee(asset, xcmFeeResult);
8667
8670
  method = api.getMethod(tx);
8668
8671
  if (method === 'transfer_assets_using_type_and_then' || method === 'transferAssetsUsingTypeAndThen') {
8669
8672
  feeToSubtract = totalFee;
@@ -9773,11 +9776,13 @@ var applyDecimalAbstraction = function applyDecimalAbstraction(amount, decimals,
9773
9776
  return parseUnits(amount.toString(), decimals);
9774
9777
  };
9775
9778
 
9776
- var createAssetsFilter = function createAssetsFilter(asset) {
9779
+ var createAssetsFilter = function createAssetsFilter(asset, version) {
9780
+ var location = assets.extractAssetLocation(asset);
9781
+ var id = createId(version, location);
9777
9782
  return {
9778
9783
  Wild: {
9779
9784
  AllOf: {
9780
- id: assets.extractAssetLocation(asset),
9785
+ id: id,
9781
9786
  fun: 'Fungible'
9782
9787
  }
9783
9788
  }
@@ -9860,7 +9865,7 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
9860
9865
  var isReserveDest = reserveChain === destChain;
9861
9866
  var resolvedDepositInstruction = isReserveDest ? suffixXcm : [{
9862
9867
  DepositReserveAsset: {
9863
- assets: createAssetsFilter(assetLocalizedToReserve),
9868
+ assets: createAssetsFilter(assetLocalizedToReserve, version),
9864
9869
  dest: createDestination(version, reserveChain !== null && reserveChain !== void 0 ? reserveChain : chain, destChain, paraIdTo),
9865
9870
  xcm: [{
9866
9871
  BuyExecution: {
@@ -9876,7 +9881,7 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
9876
9881
  // Use teleport for trusted chains
9877
9882
  mainInstructions = [{
9878
9883
  InitiateTeleport: {
9879
- assets: createAssetsFilter(assetLocalized),
9884
+ assets: createAssetsFilter(assetLocalized, version),
9880
9885
  dest: destLocation,
9881
9886
  xcm: [{
9882
9887
  BuyExecution: {
@@ -9891,7 +9896,7 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
9891
9896
  // Teleport to reserve chain first
9892
9897
  mainInstructions = [{
9893
9898
  InitiateTeleport: {
9894
- assets: createAssetsFilter(assetLocalized),
9899
+ assets: createAssetsFilter(assetLocalized, version),
9895
9900
  dest: getChainLocation(chain, reserveChain),
9896
9901
  xcm: [{
9897
9902
  BuyExecution: {
@@ -9906,7 +9911,7 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
9906
9911
  // Use InitiateReserve for non-trusted chains
9907
9912
  mainInstructions = [{
9908
9913
  InitiateReserveWithdraw: {
9909
- assets: createAssetsFilter(assetLocalized),
9914
+ assets: createAssetsFilter(assetLocalized, version),
9910
9915
  reserve: getChainLocation(chain, reserveChain),
9911
9916
  xcm: [{
9912
9917
  BuyExecution: {
@@ -10072,7 +10077,7 @@ var prepareCommonExecuteXcm = function prepareCommonExecuteXcm(options, assetToD
10072
10077
  });
10073
10078
  var depositInstruction = {
10074
10079
  DepositAsset: {
10075
- assets: createAssetsFilter(assetToDeposit !== null && assetToDeposit !== void 0 ? assetToDeposit : assetLocalizedToDest),
10080
+ assets: createAssetsFilter(assetToDeposit !== null && assetToDeposit !== void 0 ? assetToDeposit : assetLocalizedToDest, version),
10076
10081
  beneficiary: beneficiary
10077
10082
  }
10078
10083
  };
@@ -10211,7 +10216,7 @@ var createExchangeInstructions = /*#__PURE__*/function () {
10211
10216
  }
10212
10217
  return _context.a(2, [{
10213
10218
  ExchangeAsset: {
10214
- give: createAssetsFilter(assetFrom),
10219
+ give: createAssetsFilter(assetFrom, version),
10215
10220
  want: [assetTo],
10216
10221
  maximal: false
10217
10222
  }
@@ -10224,13 +10229,13 @@ var createExchangeInstructions = /*#__PURE__*/function () {
10224
10229
  assetNative = createAsset(version, exchangeFee === 0n ? (nativeAmountOut + 1n) / 2n : nativeAmountOut, localizeLocation(exchangeChain, nativeAsset.location));
10225
10230
  return _context.a(2, [{
10226
10231
  ExchangeAsset: {
10227
- give: createAssetsFilter(assetFrom),
10232
+ give: createAssetsFilter(assetFrom, version),
10228
10233
  want: [assetNative],
10229
10234
  maximal: false
10230
10235
  }
10231
10236
  }, {
10232
10237
  ExchangeAsset: {
10233
- give: createAssetsFilter(assetNative),
10238
+ give: createAssetsFilter(assetNative, version),
10234
10239
  want: [assetTo],
10235
10240
  maximal: true
10236
10241
  }
@@ -10633,6 +10638,17 @@ var handleToAhTeleport = /*#__PURE__*/function () {
10633
10638
  };
10634
10639
  }();
10635
10640
 
10641
+ var throwUnsupportedCurrency = function throwUnsupportedCurrency(currency, chain) {
10642
+ var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
10643
+ isDestination: false
10644
+ },
10645
+ isDestination = _ref.isDestination;
10646
+ if ('location' in currency) {
10647
+ throw new assets.InvalidCurrencyError("\n Selected chain doesn't support location you provided. Maybe you meant custom location. If so, you need to use override option. Your selection should look like this: {location: Override(".concat(JSON.stringify(currency.location), ")}."));
10648
+ }
10649
+ throw new assets.InvalidCurrencyError("".concat(isDestination ? 'Destination' : 'Origin', " chain ").concat(chain, " does not support currency ").concat(JSON.stringify(currency, sdkCommon.replaceBigInt), "."));
10650
+ };
10651
+
10636
10652
  var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
10637
10653
  function AssetHubPolkadot() {
10638
10654
  var chain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'AssetHubPolkadot';
@@ -14228,6 +14244,7 @@ exports.createChainClient = createChainClient;
14228
14244
  exports.createDirectExecuteXcm = createDirectExecuteXcm;
14229
14245
  exports.createExecuteCall = createExecuteCall;
14230
14246
  exports.createExecuteExchangeXcm = createExecuteExchangeXcm;
14247
+ exports.createId = createId;
14231
14248
  exports.createTx = createTx;
14232
14249
  exports.createTypeAndThenCall = createTypeAndThenCall;
14233
14250
  exports.createTypeThenAutoReserve = createTypeThenAutoReserve;
@@ -14290,6 +14307,7 @@ exports.resolveParaId = resolveParaId;
14290
14307
  exports.reverseTransformLocation = reverseTransformLocation;
14291
14308
  exports.send = send;
14292
14309
  exports.sortAssets = sortAssets;
14310
+ exports.throwUnsupportedCurrency = throwUnsupportedCurrency;
14293
14311
  exports.transferMoonbeamEvm = transferMoonbeamEvm;
14294
14312
  exports.transferMoonbeamToEth = transferMoonbeamToEth;
14295
14313
  exports.transferRelayToPara = transferRelayToPara;
package/dist/index.d.ts CHANGED
@@ -2281,6 +2281,9 @@ declare const assertHasLocation: (asset: TAssetInfo) => asserts asset is TAssetW
2281
2281
  declare const assertHasId: (asset: TAssetInfo) => asserts asset is TForeignAssetWithId;
2282
2282
  declare const assertIsForeign: (asset: TAssetInfo) => asserts asset is TForeignAssetInfo;
2283
2283
 
2284
+ declare const createId: (version: Version, location: TLocation) => TLocation | {
2285
+ Concrete: TLocation;
2286
+ };
2284
2287
  declare const createAsset: (version: Version, amount: bigint, location: TLocation) => TAsset;
2285
2288
  declare const createVersionedAssets: (version: Version, amount: bigint, location: TLocation) => OneKey<Version, TAsset[]>;
2286
2289
 
@@ -2357,10 +2360,12 @@ declare const resolveParaId: (paraId: number | undefined, destination: TDestinat
2357
2360
  declare const abstractDecimals: <TApi, TRes>(amount: TAmount, decimals: number | undefined, api: IPolkadotApi<TApi, TRes>) => bigint;
2358
2361
  declare const applyDecimalAbstraction: (amount: TAmount, decimals: number | undefined, shouldAbstract: boolean) => bigint;
2359
2362
 
2360
- declare const createAssetsFilter: (asset: TAsset) => {
2363
+ declare const createAssetsFilter: (asset: TAsset, version: Version) => {
2361
2364
  Wild: {
2362
2365
  AllOf: {
2363
- id: _paraspell_sdk_common.TLocation;
2366
+ id: _paraspell_sdk_common.TLocation | {
2367
+ Concrete: _paraspell_sdk_common.TLocation;
2368
+ };
2364
2369
  fun: string;
2365
2370
  };
2366
2371
  };
@@ -2382,10 +2387,14 @@ declare const handleSwapExecuteTransfer: <TApi, TRes>(options: TCreateSwapXcmOpt
2382
2387
 
2383
2388
  declare const handleToAhTeleport: <TApi, TRes>(origin: TParachain, input: TPolkadotXCMTransferOptions<TApi, TRes>, defaultTx: TRes) => Promise<TRes>;
2384
2389
 
2390
+ declare const throwUnsupportedCurrency: (currency: TCurrencyInput, chain: string, { isDestination }?: {
2391
+ isDestination: boolean;
2392
+ }) => never;
2393
+
2385
2394
  declare const parseUnits: typeof parseUnits$1;
2386
2395
  declare const formatUnits: typeof formatUnits$1;
2387
2396
 
2388
2397
  declare const validateAddress: <TApi, TRes>(api: IPolkadotApi<TApi, TRes>, address: TAddress, chain: TChain, isDestination?: boolean) => void;
2389
2398
 
2390
- export { AmountTooLowError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BridgeHaltedError, Builder, ChainNotSupportedError, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleChainsError, InvalidAddressError, InvalidParameterError, MissingChainApiError, NoXCMSupportImplementedError, PolkadotXcmError, PolkadotXcmExecutionError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertHasId, assertHasLocation, assertIsForeign, assertSenderAddress, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, computeOverridenAmount, constructTypeAndThenCall, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createTx, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, formatAssetIdToERC20, formatUnits, getAssetBalanceInternal, getAssetReserveChain, getBalance, getBalanceInternal, getBalanceNative, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getEthErc20Balance, getFailureInfo, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, overrideTxAmount, padFee, padValueBy, parseUnits, resolveDestChain, resolveModuleError, resolveParaId, reverseTransformLocation, send, sortAssets, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, verifyEdOnDestination, wrapTxBypass };
2399
+ export { AmountTooLowError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BridgeHaltedError, Builder, ChainNotSupportedError, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleChainsError, InvalidAddressError, InvalidParameterError, MissingChainApiError, NoXCMSupportImplementedError, PolkadotXcmError, PolkadotXcmExecutionError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertHasId, assertHasLocation, assertIsForeign, assertSenderAddress, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, computeOverridenAmount, constructTypeAndThenCall, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createId, createTx, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, formatAssetIdToERC20, formatUnits, getAssetBalanceInternal, getAssetReserveChain, getBalance, getBalanceInternal, getBalanceNative, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getEthErc20Balance, getFailureInfo, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, overrideTxAmount, padFee, padValueBy, parseUnits, resolveDestChain, resolveModuleError, resolveParaId, reverseTransformLocation, send, sortAssets, throwUnsupportedCurrency, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, verifyEdOnDestination, wrapTxBypass };
2391
2400
  export type { BuildHopInfoOptions, HopProcessParams, HopTraversalConfig, HopTraversalResult, IPolkadotApi, IPolkadotXCMTransfer, IXTokensTransfer, IXTransferTransfer, OneKey, TAddress, TApiOrUrl, TAssetClaimInternalOptions, TAssetClaimOptions, TAssetClaimOptionsBase, TBatchOptions, TBatchedSendOptions, TBifrostToken, TBridgeStatus, TBuildDestInfoOptions, TBuildInternalRes, TBuilderConfig, TBuilderOptions, TBypassOptions, TChainConfig, TChainConfigMap, TChainWithApi, TConditionalXcmFeeDetail, TConditionalXcmFeeHopInfo, TCreateBaseSwapXcmOptions, TCreateBaseTransferXcmOptions, TCreateBeneficiaryOptions, TCreateBeneficiaryXTokensOptions, TCreateSwapXcmInternalOptions, TCreateSwapXcmOptions, TCreateTransferXcmOptions, TCreateTxsOptions, TDestWeight, TDestXcmFeeDetail, TDestination, TDryRunBaseOptions, TDryRunBypassOptions, TDryRunCallBaseOptions, TDryRunCallOptions, TDryRunChain, TDryRunChainFailure, TDryRunChainResult, TDryRunChainSuccess, TDryRunError, TDryRunOptions, TDryRunPreviewOptions, TDryRunResBase, TDryRunResult, TDryRunXcmBaseOptions, TDryRunXcmOptions, TEvmBuilderOptions, TEvmBuilderOptionsBase, TEvmChainFrom, TFeeType, TForeignAssetId, TForeignOrNativeAsset, TForeignOrTokenAsset, TGetAssetBalanceOptions, TGetAssetBalanceOptionsBase, TGetBalanceCommonOptions, TGetBalanceForeignByAssetOptions, TGetBalanceForeignOptions, TGetBalanceForeignOptionsBase, TGetBalanceNativeOptions, TGetBalanceNativeOptionsBase, TGetBalanceOptions, TGetBalanceOptionsBase, TGetFeeForDestChainBaseOptions, TGetFeeForDestChainOptions, TGetMinTransferableAmountOptions, TGetOriginFeeDetailsOptions, TGetOriginFeeDetailsOptionsBase, TGetOriginXcmFeeBaseOptions, TGetOriginXcmFeeEstimateOptions, TGetOriginXcmFeeInternalOptions, TGetOriginXcmFeeOptions, TGetReverseTxFeeOptions, TGetTransferInfoOptions, TGetTransferInfoOptionsBase, TGetTransferableAmountOptions, TGetTransferableAmountOptionsBase, TGetXcmFeeBaseOptions, TGetXcmFeeBuilderOptions, TGetXcmFeeEstimateDetail, TGetXcmFeeEstimateOptions, TGetXcmFeeEstimateResult, TGetXcmFeeInternalOptions, TGetXcmFeeOptions, TGetXcmFeeResult, THopInfo, THopTransferInfo, THubKey, TMantaAsset, TModuleError, TNativeTokenAsset, TNodleAsset, TOriginFeeDetails, TOtherReserveAsset, TPolkadotXCMTransferOptions, TPolkadotXcmMethod, TProviderEntry, TRelayToParaDestination, TRelayToParaOptions, TRelayToParaOverrides, TReserveAsset, TResolveHopParams, TScenario, TSelfReserveAsset, TSendBaseOptions, TSendBaseOptionsWithSenderAddress, TSendInternalOptions, TSendOptions, TSerializeEthTransferOptions, TSerializedEthTransfer, TSerializedExtrinsics, TSerializedRuntimeApiQuery, TSerializedStateQuery, TSetBalanceRes, TSwapConfig, TSwapFeeEstimates, TTransferFeeEstimates, TTransferInfo, TTransferLocalOptions, TTxFactory, TTypeAndThenCallContext, TTypeAndThenFees, TUrl, TVerifyEdOnDestinationOptions, TVerifyEdOnDestinationOptionsBase, TWeight, TXTokensCurrencySelection, TXTokensMethod, TXTokensTransferOptions, TXTransferMethod, TXTransferTransferOptions, TXcmAsset, TXcmFeeBase, TXcmFeeChain, TXcmFeeDetail, TXcmFeeDetailError, TXcmFeeDetailSuccess, TXcmFeeDetailWithFallback, TXcmFeeHopInfo, TXcmFeeHopResult, TXcmFeeSwapConfig, TXcmForeignAsset, TXcmPalletMethod, TXcmVersioned, TZeitgeistAsset, WithApi, WithRequiredSenderAddress };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { blake2b } from '@noble/hashes/blake2';
2
- import { isChainEvm, getAssetsObject, InvalidCurrencyError, isForeignAsset, extractAssetLocation, findAssetInfoOrThrow, getOtherAssets, isTAsset, findNativeAssetInfoOrThrow, findAssetInfo, getExistentialDepositOrThrow, isSymbolMatch, getNativeAssetSymbol, getEdFromAssetOrThrow, hasDryRunSupport, findAssetOnDestOrThrow, findAssetInfoOnDest, hasSupportForAsset, isAssetEqual, isOverrideLocationSpecifier, getRelayChainSymbol, isSymbolSpecifier, findNativeAssetInfo, isAssetXcEqual, getExistentialDeposit, normalizeLocation, normalizeSymbol, Native, hasXcmPaymentApiSupport, findAssetInfoByLoc } from '@paraspell/assets';
2
+ import { isChainEvm, getAssetsObject, InvalidCurrencyError, isForeignAsset, extractAssetLocation, findAssetInfoOrThrow, getOtherAssets, isTAsset, findNativeAssetInfoOrThrow, findAssetInfo, getExistentialDepositOrThrow, isSymbolMatch, getNativeAssetSymbol, getEdFromAssetOrThrow, hasDryRunSupport, findAssetOnDestOrThrow, findAssetInfoOnDest, isAssetEqual, isOverrideLocationSpecifier, getRelayChainSymbol, isSymbolSpecifier, findNativeAssetInfo, isAssetXcEqual, getExistentialDeposit, normalizeLocation, normalizeSymbol, Native, hasXcmPaymentApiSupport, findAssetInfoByLoc } from '@paraspell/assets';
3
3
  export * from '@paraspell/assets';
4
4
  import { base58 } from '@scure/base';
5
5
  import { isAddress, parseUnits as parseUnits$1, formatUnits as formatUnits$1, getContract, createPublicClient, http, pad, toHex, getAddress, concat, keccak256 } from 'viem';
@@ -752,6 +752,14 @@ var assertIsForeign = function assertIsForeign(asset) {
752
752
  }
753
753
  };
754
754
 
755
+ var createId = function createId(version, location) {
756
+ if (version === Version.V3) {
757
+ return {
758
+ Concrete: location
759
+ };
760
+ }
761
+ return location;
762
+ };
755
763
  var createAsset = function createAsset(version, amount, location) {
756
764
  if (version === Version.V3) {
757
765
  return {
@@ -2775,16 +2783,6 @@ var resolveTChainFromLocation = function resolveTChainFromLocation(relaychain, l
2775
2783
  }
2776
2784
  return chain;
2777
2785
  };
2778
- var throwUnsupportedCurrency = function throwUnsupportedCurrency(currency, chain) {
2779
- var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
2780
- isDestination: false
2781
- },
2782
- isDestination = _ref.isDestination;
2783
- if ('location' in currency) {
2784
- throw new InvalidCurrencyError("\n Selected chain doesn't support location you provided. Maybe you meant custom location. If so, you need to use override option. Your selection should look like this: {location: Override(".concat(JSON.stringify(currency.location), ")}."));
2785
- }
2786
- throw new InvalidCurrencyError("".concat(isDestination ? 'Destination' : 'Origin', " chain ").concat(chain, " does not support currency ").concat(JSON.stringify(currency, replaceBigInt), "."));
2787
- };
2788
2786
 
2789
2787
  var buildClaimAssetsParams = function buildClaimAssetsParams(options) {
2790
2788
  var assets = options.assets,
@@ -4552,14 +4550,13 @@ var validateAssetSupport = function validateAssetSupport(_ref, assetCheckEnabled
4552
4550
  var origin = _ref.from,
4553
4551
  destination = _ref.to,
4554
4552
  currency = _ref.currency;
4555
- var isRelayDestination = !isTLocation(destination) && isRelayChain(destination);
4556
4553
  var isLocationDestination = _typeof(destination) === 'object';
4557
- if (!isBridge && !isRelayDestination && !isLocationDestination && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== undefined && assetCheckEnabled && !('id' in currency) && !hasSupportForAsset(destination, asset.symbol)) {
4558
- throw new InvalidCurrencyError("Destination chain ".concat(destination, " does not support currency ").concat(JSON.stringify(currency, replaceBigInt), "."));
4559
- }
4560
4554
  if (asset === null && assetCheckEnabled) {
4561
4555
  throwUnsupportedCurrency(currency, origin);
4562
4556
  }
4557
+ if (!isLocationDestination && assetCheckEnabled && !findAssetInfoOnDest(origin, destination, currency, asset)) {
4558
+ throw new InvalidCurrencyError("Destination chain ".concat(destination, " does not support currency ").concat(JSON.stringify(currency, replaceBigInt), "."));
4559
+ }
4563
4560
  validateBridgeAsset(origin, destination, asset, currency, isBridge);
4564
4561
  validateEthereumAsset(origin, destination, asset);
4565
4562
  };
@@ -7471,7 +7468,7 @@ var send = /*#__PURE__*/function () {
7471
7468
 
7472
7469
  var buildDestInfo = /*#__PURE__*/function () {
7473
7470
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
7474
- var api, origin, destination, address, currency, originFee, isFeeAssetAh, destFeeDetail, totalHopFee, bridgeFee, destApi, destAsset, edDest, destBalance, destAmount, effectiveAmountForBalance, destBalanceSufficient, destBalanceSufficientResult, destBalanceAfter, destbalanceAfterResult, receivedAmount, isSubBridge, nativeAssetOfOriginSymbol, isOriginAssetNative, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, destXcmFeeBalanceAfter;
7471
+ var api, origin, destination, address, currency, originFee, isFeeAssetAh, destFeeDetail, totalHopFee, bridgeFee, destApi, destAsset, edDest, destBalance, destAmount, destFeeAssetEqual, effectiveDestFee, effectiveAmountForBalance, destBalanceSufficient, destBalanceAfter, createUnableToComputeError, isUnableToCompute, destbalanceAfterResult, destBalanceSufficientResult, receivedAmount, isSubBridge, nativeAssetOfOriginSymbol, isOriginAssetNative, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, destXcmFeeBalanceAfter;
7475
7472
  return _regenerator().w(function (_context) {
7476
7473
  while (1) switch (_context.n) {
7477
7474
  case 0:
@@ -7492,11 +7489,17 @@ var buildDestInfo = /*#__PURE__*/function () {
7492
7489
  case 2:
7493
7490
  destBalance = _context.v;
7494
7491
  destAmount = isFeeAssetAh ? currency.amount - originFee : currency.amount;
7492
+ destFeeAssetEqual = isSymbolMatch(destFeeDetail.asset.symbol, destAsset.symbol);
7493
+ effectiveDestFee = destFeeAssetEqual ? destFeeDetail.fee : 0n;
7495
7494
  effectiveAmountForBalance = destAmount - totalHopFee;
7496
- destBalanceSufficient = effectiveAmountForBalance - destFeeDetail.fee > (destBalance < edDest ? edDest : 0n);
7497
- destBalanceSufficientResult = destFeeDetail.currency !== destAsset.symbol && destination !== 'Ethereum' ? new UnableToComputeError('Unable to compute if dest balance will be sufficient. Fee currency is not the same') : destBalanceSufficient;
7498
- destBalanceAfter = destBalance - (destFeeDetail.currency === destAsset.symbol ? destFeeDetail.fee : 0n) + effectiveAmountForBalance;
7499
- destbalanceAfterResult = destFeeDetail.currency !== destAsset.symbol && destination !== 'Ethereum' ? new UnableToComputeError('Unable to compute if dest balance will be sufficient. Fee currency is not the same') : destBalanceAfter;
7495
+ destBalanceSufficient = effectiveAmountForBalance - effectiveDestFee > (destBalance < edDest ? edDest : 0n);
7496
+ destBalanceAfter = destBalance - effectiveDestFee + effectiveAmountForBalance;
7497
+ createUnableToComputeError = function createUnableToComputeError() {
7498
+ return new UnableToComputeError('Unable to compute if dest balance will be sufficient. Fee currency is not the same');
7499
+ };
7500
+ isUnableToCompute = destFeeDetail.feeType === 'paymentInfo' && !destFeeAssetEqual;
7501
+ destbalanceAfterResult = isUnableToCompute ? createUnableToComputeError() : destBalanceAfter;
7502
+ destBalanceSufficientResult = isUnableToCompute ? createUnableToComputeError() : destBalanceSufficient;
7500
7503
  isSubBridge = isSubstrateBridge(origin, destination);
7501
7504
  if (isSubBridge) {
7502
7505
  nativeAssetOfOriginSymbol = getNativeAssetSymbol(origin);
@@ -7539,7 +7542,7 @@ var buildDestInfo = /*#__PURE__*/function () {
7539
7542
  case 4:
7540
7543
  destXcmFeeBalance = destBalance;
7541
7544
  case 5:
7542
- destXcmFeeBalanceAfter = isFeeAssetAh ? destBalanceAfter : destXcmFeeBalance - destFeeDetail.fee + (destFeeDetail.currency === destAsset.symbol ? effectiveAmountForBalance : 0n);
7545
+ destXcmFeeBalanceAfter = isFeeAssetAh ? destBalanceAfter : destXcmFeeBalance - destFeeDetail.fee + (destFeeAssetEqual ? effectiveAmountForBalance : 0n);
7543
7546
  return _context.a(2, {
7544
7547
  receivedCurrency: {
7545
7548
  sufficient: destBalanceSufficientResult,
@@ -7554,7 +7557,7 @@ var buildDestInfo = /*#__PURE__*/function () {
7554
7557
  fee: destFeeDetail.fee,
7555
7558
  balance: destXcmFeeBalance,
7556
7559
  balanceAfter: destXcmFeeBalanceAfter,
7557
- currencySymbol: destFeeDetail.currency,
7560
+ currencySymbol: destFeeDetail.asset.symbol,
7558
7561
  asset: destFeeDetail.asset
7559
7562
  }
7560
7563
  });
@@ -8569,20 +8572,16 @@ var createTypeThenAutoReserve = /*#__PURE__*/function () {
8569
8572
  };
8570
8573
  }();
8571
8574
 
8572
- var calculateTotalXcmFee = function calculateTotalXcmFee(feeResult) {
8573
- var _feeResult$assetHub;
8574
- var totalFee = 0n;
8575
- if (((_feeResult$assetHub = feeResult.assetHub) === null || _feeResult$assetHub === void 0 ? void 0 : _feeResult$assetHub.fee) !== undefined) {
8576
- totalFee += feeResult.assetHub.fee;
8577
- }
8578
- if (feeResult.destination.fee !== undefined) {
8579
- totalFee += feeResult.destination.fee;
8580
- }
8581
- return totalFee;
8575
+ var calculateTotalXcmFee = function calculateTotalXcmFee(asset, feeResult) {
8576
+ var totalHopFee = feeResult.hops.reduce(function (acc, hop) {
8577
+ return isAssetXcEqual(hop.result.asset, asset) ? acc + hop.result.fee : acc;
8578
+ }, 0n);
8579
+ var destFee = isAssetXcEqual(feeResult.destination.asset, asset) ? feeResult.destination.fee : 0n;
8580
+ return totalHopFee + destFee;
8582
8581
  };
8583
8582
  var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
8584
8583
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
8585
- var api, buildTx, origin, destination, currency, address, senderAddress, feeAsset, isSubBridge, destApi, asset, amount, destAsset, ed, balance, xcmFeeResult, dryRunError, assetHubFeeResult, bridgeHubFeeResult, _xcmFeeResult$destina, destFee, destFeeCurrency, destDryRunError, hopDryRunError, tx, totalFee, method, feeToSubtract;
8584
+ var api, buildTx, origin, destination, currency, address, senderAddress, feeAsset, isSubBridge, destApi, asset, amount, destAsset, ed, balance, xcmFeeResult, dryRunError, hops, _xcmFeeResult$destina, destFee, destFeeType, destFeeAsset, destDryRunError, erroredHop, hopError, isUnableToCompute, tx, totalFee, method, feeToSubtract;
8586
8585
  return _regenerator().w(function (_context) {
8587
8586
  while (1) switch (_context.n) {
8588
8587
  case 0:
@@ -8634,19 +8633,22 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
8634
8633
  });
8635
8634
  case 5:
8636
8635
  xcmFeeResult = _context.v;
8637
- dryRunError = xcmFeeResult.origin.dryRunError, assetHubFeeResult = xcmFeeResult.assetHub, bridgeHubFeeResult = xcmFeeResult.bridgeHub, _xcmFeeResult$destina = xcmFeeResult.destination, destFee = _xcmFeeResult$destina.fee, destFeeCurrency = _xcmFeeResult$destina.currency, destDryRunError = _xcmFeeResult$destina.dryRunError;
8636
+ dryRunError = xcmFeeResult.origin.dryRunError, hops = xcmFeeResult.hops, _xcmFeeResult$destina = xcmFeeResult.destination, destFee = _xcmFeeResult$destina.fee, destFeeType = _xcmFeeResult$destina.feeType, destFeeAsset = _xcmFeeResult$destina.asset, destDryRunError = _xcmFeeResult$destina.dryRunError;
8638
8637
  if (!dryRunError) {
8639
8638
  _context.n = 6;
8640
8639
  break;
8641
8640
  }
8642
8641
  throw new DryRunFailedError(dryRunError, 'origin');
8643
8642
  case 6:
8644
- hopDryRunError = (assetHubFeeResult === null || assetHubFeeResult === void 0 ? void 0 : assetHubFeeResult.dryRunError) || (bridgeHubFeeResult === null || bridgeHubFeeResult === void 0 ? void 0 : bridgeHubFeeResult.dryRunError);
8645
- if (!hopDryRunError) {
8643
+ erroredHop = hops.find(function (hop) {
8644
+ return hop.result.dryRunError;
8645
+ });
8646
+ hopError = erroredHop === null || erroredHop === void 0 ? void 0 : erroredHop.result.dryRunError;
8647
+ if (!hopError) {
8646
8648
  _context.n = 7;
8647
8649
  break;
8648
8650
  }
8649
- throw new DryRunFailedError(hopDryRunError, assetHubFeeResult !== null && assetHubFeeResult !== void 0 && assetHubFeeResult.dryRunError ? 'assetHub' : 'bridgeHub');
8651
+ throw new DryRunFailedError(hopError, erroredHop.chain);
8650
8652
  case 7:
8651
8653
  if (!destDryRunError) {
8652
8654
  _context.n = 8;
@@ -8654,7 +8656,8 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
8654
8656
  }
8655
8657
  throw new UnableToComputeError("Unable to compute fee for the destination asset. Destination dry run error: ".concat(destDryRunError));
8656
8658
  case 8:
8657
- if (!(normalizeSymbol(asset.symbol) !== normalizeSymbol(destFeeCurrency))) {
8659
+ isUnableToCompute = !isSymbolMatch(normalizeSymbol(destAsset.symbol), normalizeSymbol(destFeeAsset.symbol)) && destFeeType === 'paymentInfo';
8660
+ if (!isUnableToCompute) {
8658
8661
  _context.n = 9;
8659
8662
  break;
8660
8663
  }
@@ -8664,7 +8667,7 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
8664
8667
  return buildTx();
8665
8668
  case 10:
8666
8669
  tx = _context.v;
8667
- totalFee = calculateTotalXcmFee(xcmFeeResult);
8670
+ totalFee = calculateTotalXcmFee(asset, xcmFeeResult);
8668
8671
  method = api.getMethod(tx);
8669
8672
  if (method === 'transfer_assets_using_type_and_then' || method === 'transferAssetsUsingTypeAndThen') {
8670
8673
  feeToSubtract = totalFee;
@@ -9774,11 +9777,13 @@ var applyDecimalAbstraction = function applyDecimalAbstraction(amount, decimals,
9774
9777
  return parseUnits(amount.toString(), decimals);
9775
9778
  };
9776
9779
 
9777
- var createAssetsFilter = function createAssetsFilter(asset) {
9780
+ var createAssetsFilter = function createAssetsFilter(asset, version) {
9781
+ var location = extractAssetLocation(asset);
9782
+ var id = createId(version, location);
9778
9783
  return {
9779
9784
  Wild: {
9780
9785
  AllOf: {
9781
- id: extractAssetLocation(asset),
9786
+ id: id,
9782
9787
  fun: 'Fungible'
9783
9788
  }
9784
9789
  }
@@ -9861,7 +9866,7 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
9861
9866
  var isReserveDest = reserveChain === destChain;
9862
9867
  var resolvedDepositInstruction = isReserveDest ? suffixXcm : [{
9863
9868
  DepositReserveAsset: {
9864
- assets: createAssetsFilter(assetLocalizedToReserve),
9869
+ assets: createAssetsFilter(assetLocalizedToReserve, version),
9865
9870
  dest: createDestination(version, reserveChain !== null && reserveChain !== void 0 ? reserveChain : chain, destChain, paraIdTo),
9866
9871
  xcm: [{
9867
9872
  BuyExecution: {
@@ -9877,7 +9882,7 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
9877
9882
  // Use teleport for trusted chains
9878
9883
  mainInstructions = [{
9879
9884
  InitiateTeleport: {
9880
- assets: createAssetsFilter(assetLocalized),
9885
+ assets: createAssetsFilter(assetLocalized, version),
9881
9886
  dest: destLocation,
9882
9887
  xcm: [{
9883
9888
  BuyExecution: {
@@ -9892,7 +9897,7 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
9892
9897
  // Teleport to reserve chain first
9893
9898
  mainInstructions = [{
9894
9899
  InitiateTeleport: {
9895
- assets: createAssetsFilter(assetLocalized),
9900
+ assets: createAssetsFilter(assetLocalized, version),
9896
9901
  dest: getChainLocation(chain, reserveChain),
9897
9902
  xcm: [{
9898
9903
  BuyExecution: {
@@ -9907,7 +9912,7 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
9907
9912
  // Use InitiateReserve for non-trusted chains
9908
9913
  mainInstructions = [{
9909
9914
  InitiateReserveWithdraw: {
9910
- assets: createAssetsFilter(assetLocalized),
9915
+ assets: createAssetsFilter(assetLocalized, version),
9911
9916
  reserve: getChainLocation(chain, reserveChain),
9912
9917
  xcm: [{
9913
9918
  BuyExecution: {
@@ -10073,7 +10078,7 @@ var prepareCommonExecuteXcm = function prepareCommonExecuteXcm(options, assetToD
10073
10078
  });
10074
10079
  var depositInstruction = {
10075
10080
  DepositAsset: {
10076
- assets: createAssetsFilter(assetToDeposit !== null && assetToDeposit !== void 0 ? assetToDeposit : assetLocalizedToDest),
10081
+ assets: createAssetsFilter(assetToDeposit !== null && assetToDeposit !== void 0 ? assetToDeposit : assetLocalizedToDest, version),
10077
10082
  beneficiary: beneficiary
10078
10083
  }
10079
10084
  };
@@ -10212,7 +10217,7 @@ var createExchangeInstructions = /*#__PURE__*/function () {
10212
10217
  }
10213
10218
  return _context.a(2, [{
10214
10219
  ExchangeAsset: {
10215
- give: createAssetsFilter(assetFrom),
10220
+ give: createAssetsFilter(assetFrom, version),
10216
10221
  want: [assetTo],
10217
10222
  maximal: false
10218
10223
  }
@@ -10225,13 +10230,13 @@ var createExchangeInstructions = /*#__PURE__*/function () {
10225
10230
  assetNative = createAsset(version, exchangeFee === 0n ? (nativeAmountOut + 1n) / 2n : nativeAmountOut, localizeLocation(exchangeChain, nativeAsset.location));
10226
10231
  return _context.a(2, [{
10227
10232
  ExchangeAsset: {
10228
- give: createAssetsFilter(assetFrom),
10233
+ give: createAssetsFilter(assetFrom, version),
10229
10234
  want: [assetNative],
10230
10235
  maximal: false
10231
10236
  }
10232
10237
  }, {
10233
10238
  ExchangeAsset: {
10234
- give: createAssetsFilter(assetNative),
10239
+ give: createAssetsFilter(assetNative, version),
10235
10240
  want: [assetTo],
10236
10241
  maximal: true
10237
10242
  }
@@ -10634,6 +10639,17 @@ var handleToAhTeleport = /*#__PURE__*/function () {
10634
10639
  };
10635
10640
  }();
10636
10641
 
10642
+ var throwUnsupportedCurrency = function throwUnsupportedCurrency(currency, chain) {
10643
+ var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
10644
+ isDestination: false
10645
+ },
10646
+ isDestination = _ref.isDestination;
10647
+ if ('location' in currency) {
10648
+ throw new InvalidCurrencyError("\n Selected chain doesn't support location you provided. Maybe you meant custom location. If so, you need to use override option. Your selection should look like this: {location: Override(".concat(JSON.stringify(currency.location), ")}."));
10649
+ }
10650
+ throw new InvalidCurrencyError("".concat(isDestination ? 'Destination' : 'Origin', " chain ").concat(chain, " does not support currency ").concat(JSON.stringify(currency, replaceBigInt), "."));
10651
+ };
10652
+
10637
10653
  var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
10638
10654
  function AssetHubPolkadot() {
10639
10655
  var chain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'AssetHubPolkadot';
@@ -14181,4 +14197,4 @@ var getMoonbeamErc20Balance = /*#__PURE__*/function () {
14181
14197
  };
14182
14198
  }();
14183
14199
 
14184
- export { AmountTooLowError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BridgeHaltedError, Builder, ChainNotSupportedError, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleChainsError, InvalidAddressError, InvalidParameterError, MissingChainApiError, NoXCMSupportImplementedError, PolkadotXcmError, PolkadotXcmExecutionError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertHasId, assertHasLocation, assertIsForeign, assertSenderAddress, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, computeOverridenAmount, constructTypeAndThenCall, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createTx, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, formatAssetIdToERC20, formatUnits, getAssetBalanceInternal, getAssetReserveChain, getBalance, getBalanceInternal, getBalanceNative, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getEthErc20Balance, getFailureInfo$1 as getFailureInfo, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, overrideTxAmount, padFee, padValueBy, parseUnits, resolveDestChain, resolveModuleError, resolveParaId, reverseTransformLocation, send, sortAssets, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, verifyEdOnDestination, wrapTxBypass };
14200
+ export { AmountTooLowError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BridgeHaltedError, Builder, ChainNotSupportedError, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleChainsError, InvalidAddressError, InvalidParameterError, MissingChainApiError, NoXCMSupportImplementedError, PolkadotXcmError, PolkadotXcmExecutionError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertHasId, assertHasLocation, assertIsForeign, assertSenderAddress, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, computeOverridenAmount, constructTypeAndThenCall, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createId, createTx, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, formatAssetIdToERC20, formatUnits, getAssetBalanceInternal, getAssetReserveChain, getBalance, getBalanceInternal, getBalanceNative, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getEthErc20Balance, getFailureInfo$1 as getFailureInfo, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, overrideTxAmount, padFee, padValueBy, parseUnits, resolveDestChain, resolveModuleError, resolveParaId, reverseTransformLocation, send, sortAssets, throwUnsupportedCurrency, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, verifyEdOnDestination, wrapTxBypass };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-core",
3
- "version": "11.14.7",
3
+ "version": "11.14.9",
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.40.3",
29
- "@paraspell/sdk-common": "11.14.7",
30
- "@paraspell/assets": "11.14.7",
31
- "@paraspell/pallets": "11.14.7"
29
+ "@paraspell/pallets": "11.14.9",
30
+ "@paraspell/sdk-common": "11.14.9",
31
+ "@paraspell/assets": "11.14.9"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@babel/plugin-syntax-import-attributes": "^7.27.1",