@paraspell/sdk-core 13.0.1 → 13.1.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.d.ts CHANGED
@@ -2264,6 +2264,7 @@ declare const getMinTransferableAmount: <TApi, TRes, TSigner>(options: TGetMinTr
2264
2264
  declare const getTransferableAmountInternal: <TApi, TRes, TSigner>({ api, sender, origin: chain, destination, currency, buildTx, feeAsset, version }: TGetTransferableAmountOptions<TApi, TRes, TSigner>) => Promise<bigint>;
2265
2265
  declare const getTransferableAmount: <TApi, TRes, TSigner>(options: TGetTransferableAmountOptions<TApi, TRes, TSigner>) => Promise<bigint>;
2266
2266
 
2267
+ declare const resolveAssetCount: <TApi, TRes, TSigner>(overriddenAsset: TPolkadotXCMTransferOptions<TApi, TRes, TSigner>["overriddenAsset"], isRelayAsset: boolean) => number;
2267
2268
  declare const constructTypeAndThenCall: <TApi, TRes, TSigner>(context: TTypeAndThenCallContext<TApi, TRes, TSigner>, fees?: TTypeAndThenFees | null) => Promise<TSerializedExtrinsics>;
2268
2269
  /**
2269
2270
  * Creates a type and then call for transferring assets using XCM. Works only for DOT and snowbridge assets so far.
@@ -2452,5 +2453,5 @@ declare const selectXcmVersion: (forcedVersion: Version | undefined, originVersi
2452
2453
  declare const pickCompatibleXcmVersion: (origin: TSubstrateChain$1, destination: TDestination, override?: Version) => Version;
2453
2454
  declare const pickRouterCompatibleXcmVersion: (origin: TSubstrateChain$1 | undefined, exchangeChain: TSubstrateChain$1, destination: TChain$1 | undefined) => Version;
2454
2455
 
2455
- export { API_TYPES, AmountTooLowError, ApiNotInitializedError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, DEFAULT_TTL_MS, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETH_MAINNET_CHAIN_ID, ETH_TESTNET_CHAIN_ID, EXCHANGE_CHAINS, EXTENSION_MS, ExtensionNotInstalledError, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MAX_CLIENTS, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotApi, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiUnavailableError, ScenarioNotSupportedError, SubmitTransactionError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertHasId, assertSender, assertSenderSource, assertSwapSupport, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, compareAddresses, computeOverridenAmount, constructTypeAndThenCall, convertBuilderConfig, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createClientCache, createClientPoolHelpers, createDestination, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createId, createRouterBuilder, createTransfer, createTransferOrSwap, createTransferOrSwapAll, createTxOverrideAmount, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, executeWithRouter, formatAssetIdToERC20, formatUnits, getAssetBalanceInternal, getAssetReserveChain, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getEthErc20Balance, getEvmPrivateKeyHex, getFailureInfo, getLocalTransferAmount, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginXcmFee, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getSwapExtensionOrThrow, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, isSenderSigner, keyFromWs, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, normalizeExchange, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickRouterCompatibleXcmVersion, registerSwapExtension, resolveChainApi, resolveDestChain, resolveModuleError, resolveParaId, resolveTransferParams, reverseTransformLocation, selectXcmVersion, sortAssets, throwUnsupportedCurrency, transferMoonbeamEvm, transferMoonbeamToEth, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateTransact, verifyEdOnDestination, wrapTxBypass };
2456
+ export { API_TYPES, AmountTooLowError, ApiNotInitializedError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, DEFAULT_TTL_MS, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETH_MAINNET_CHAIN_ID, ETH_TESTNET_CHAIN_ID, EXCHANGE_CHAINS, EXTENSION_MS, ExtensionNotInstalledError, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MAX_CLIENTS, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotApi, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiUnavailableError, ScenarioNotSupportedError, SubmitTransactionError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertHasId, assertSender, assertSenderSource, assertSwapSupport, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, compareAddresses, computeOverridenAmount, constructTypeAndThenCall, convertBuilderConfig, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createClientCache, createClientPoolHelpers, createDestination, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createId, createRouterBuilder, createTransfer, createTransferOrSwap, createTransferOrSwapAll, createTxOverrideAmount, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, executeWithRouter, formatAssetIdToERC20, formatUnits, getAssetBalanceInternal, getAssetReserveChain, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getEthErc20Balance, getEvmPrivateKeyHex, getFailureInfo, getLocalTransferAmount, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginXcmFee, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getSwapExtensionOrThrow, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, isSenderSigner, keyFromWs, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, normalizeExchange, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickRouterCompatibleXcmVersion, registerSwapExtension, resolveAssetCount, resolveChainApi, resolveDestChain, resolveModuleError, resolveParaId, resolveTransferParams, reverseTransformLocation, selectXcmVersion, sortAssets, throwUnsupportedCurrency, transferMoonbeamEvm, transferMoonbeamToEth, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateTransact, verifyEdOnDestination, wrapTxBypass };
2456
2457
  export type { BuildHopInfoOptions, ClientCache, HopProcessParams, HopTraversalConfig, HopTraversalResult, IPolkadotXCMTransfer, IXTokensTransfer, OneKey, TAddress, TApiOrUrl, TApiType, TAssetClaimInternalOptions, TAssetClaimOptions, TAssetClaimOptionsBase, TBatchOptions, TBatchedTransferOptions, TBifrostToken, TBridgeStatus, TBuildAllInternalRes, TBuildDestInfoOptions, TBuildInternalRes, TBuildInternalResBase, TBuilderConfig, TBuilderInternalOptions, TBuilderOptions, TBypassOptions, TCacheItem, TChainConfig, TChainConfigMap, TChainEndpoint, TChainWithApi, TClientEntry, TClientKey, TConditionalXcmFeeDetail, TConditionalXcmFeeHopInfo, TCreateBaseSwapXcmOptions, TCreateBaseTransferXcmOptions, TCreateBeneficiaryOptions, TCreateBeneficiaryXTokensOptions, TCreateEthBridgeInstructionsOptions, TCreateSwapXcmInternalOptions, TCreateSwapXcmOptions, TCreateTransferXcmOptions, TCreateTxsOptions, TDestWeight, TDestXcmFeeDetail, TDestination, TDryRunBaseOptions, TDryRunBypassOptions, TDryRunCallBaseOptions, TDryRunCallOptions, TDryRunChainFailure, TDryRunChainResult, TDryRunChainSuccess, TDryRunError, TDryRunOptions, TDryRunPreviewOptions, TDryRunResBase, TDryRunResult, TDryRunXcmBaseOptions, TDryRunXcmOptions, TEvmBuilderOptions, TEvmBuilderOptionsBase, TEvmChainFrom, TExchangeChain, TExchangeInput, TFeeType, TForeignAssetId, TForeignOrNativeAsset, TForeignOrTokenAsset, TGetAssetBalanceOptions, TGetAssetBalanceOptionsBase, TGetBalanceCommonOptions, TGetBalanceOptions, TGetBalanceOptionsBase, TGetFeeForDestChainBaseOptions, TGetFeeForDestChainOptions, TGetMinTransferableAmountOptions, TGetOriginXcmFeeBaseOptions, TGetOriginXcmFeeInternalOptions, TGetOriginXcmFeeOptions, TGetReverseTxFeeOptions, TGetTransferInfoOptions, TGetTransferInfoOptionsBase, TGetTransferableAmountOptions, TGetTransferableAmountOptionsBase, TGetXcmFeeBaseOptions, TGetXcmFeeBuilderOptions, TGetXcmFeeInternalOptions, TGetXcmFeeOptions, TGetXcmFeeResult, THopInfo, THopTransferInfo, TMantaAsset, TModuleError, TNativeTokenAsset, TOriginFeeDetails, TOtherReserveAsset, TPaymentInfo, TPolkadotXCMTransferOptions, TPolkadotXcmMethod, TProviderEntry, TReserveAsset, TResolveHopParams, TScenario, TSelfReserveAsset, TSender, TSerializeEthTransferOptions, TSerializedEthTransfer, TSerializedExtrinsics, TSerializedRuntimeApiQuery, TSerializedStateQuery, TSetBalanceRes, TStatusChangeCallback, TSwapConfig, TSwapEvent, TSwapEventType, TSwapExtension, TSwapFeeEstimates, TSwapOptions, TTransactOptions, TTransactOrigin, TTransactionContext, TTransactionType, TTransferBaseOptions, TTransferBaseOptionsWithSender, TTransferBaseOptionsWithSwap, TTransferFeeEstimates, TTransferInfo, TTransferInternalOptions, TTransferLocalOptions, TTransferOptions, TTransferOptionsWithSwap, TTxFactory, TTypeAndThenCallContext, TTypeAndThenFees, TTypeAndThenOverrides, TUrl, TVerifyEdOnDestinationOptions, TVerifyEdOnDestinationOptionsBase, TWeight, TXTokensCurrencySelection, TXTokensMethod, TXTokensTransferOptions, TXcmAsset, TXcmFeeBase, TXcmFeeDetail, TXcmFeeDetailError, TXcmFeeDetailSuccess, TXcmFeeDetailWithFallback, TXcmFeeHopInfo, TXcmFeeHopResult, TXcmFeeSwapConfig, TXcmForeignAsset, TXcmPalletMethod, TXcmVersioned, TZeitgeistAsset, WithApi, WithRequiredSender, WithRequiredSwapOptions };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { blake2b } from '@noble/hashes/blake2.js';
2
- import { isChainEvm, getAssetsObject, InvalidCurrencyError, extractAssetLocation, isTAsset, findAssetInfoOrThrow, findAssetInfo, findNativeAssetInfoOrThrow, findAssetOnDestOrThrow, findAssetInfoOnDest, isAssetEqual, isStableCoinAsset, isBridgedSystemAsset, isOverrideLocationSpecifier, getRelayChainSymbol, isSymbolSpecifier, normalizeLocation, getNativeAssetSymbol, getExistentialDepositOrThrow, isSymbolMatch, getEdFromAssetOrThrow, hasDryRunSupport, findNativeAssetInfo, isAssetXcEqual, normalizeSymbol, Native, hasXcmPaymentApiSupport, getOtherAssets } from '@paraspell/assets';
2
+ import { isChainEvm, getAssetsObject, InvalidCurrencyError, extractAssetLocation, isTAsset, findAssetInfoOrThrow, findNativeAssetInfoOrThrow, findAssetInfo, findAssetOnDestOrThrow, findAssetInfoOnDest, isAssetEqual, isStableCoinAsset, isBridgedSystemAsset, isOverrideLocationSpecifier, getRelayChainSymbol, isSymbolSpecifier, normalizeLocation, getNativeAssetSymbol, getExistentialDepositOrThrow, isSymbolMatch, getEdFromAssetOrThrow, hasDryRunSupport, findNativeAssetInfo, isAssetXcEqual, normalizeSymbol, Native, hasXcmPaymentApiSupport, getOtherAssets } from '@paraspell/assets';
3
3
  export * from '@paraspell/assets';
4
4
  import { base58 } from '@scure/base';
5
5
  import { isAddress, isHex, pad, toHex, getAddress, concat, keccak256, createPublicClient, http, getContract, parseUnits as parseUnits$1, formatUnits as formatUnits$1 } from 'viem';
@@ -1388,439 +1388,6 @@ var claimAssets = /*#__PURE__*/function () {
1388
1388
  };
1389
1389
  }();
1390
1390
 
1391
- var resolveAsset = function resolveAsset(currency, origin, destination, assetCheckEnabled) {
1392
- return assetCheckEnabled ? findAssetInfo(origin, currency, !isTLocation(destination) ? destination : null) : null;
1393
- };
1394
-
1395
- var resolveFeeAsset = function resolveFeeAsset(feeAsset, origin, destination, currency) {
1396
- if (!origin.startsWith('Hydration') && origin !== 'AssetHubPolkadot') {
1397
- throw new ScenarioNotSupportedError("Fee asset is not supported on ".concat(origin));
1398
- }
1399
- var asset = findAssetInfo(origin, feeAsset, !isTLocation(destination) ? destination : null);
1400
- var usesRawOverriddenMultiAssets = Array.isArray(currency) && currency.every(isTAsset);
1401
- if (!asset && !usesRawOverriddenMultiAssets) {
1402
- throwUnsupportedCurrency(feeAsset, origin);
1403
- }
1404
- return asset !== null && asset !== void 0 ? asset : undefined;
1405
- };
1406
-
1407
- var resolveHopAsset = function resolveHopAsset(_ref) {
1408
- var _findAssetInfoOnDest;
1409
- var api = _ref.api,
1410
- tx = _ref.tx,
1411
- originChain = _ref.originChain,
1412
- currentChain = _ref.currentChain,
1413
- destination = _ref.destination,
1414
- swapConfig = _ref.swapConfig,
1415
- asset = _ref.asset,
1416
- hasPassedExchange = _ref.hasPassedExchange,
1417
- currency = _ref.currency;
1418
- var isRelayAssetIncluded = api.getTypeThenAssetCount(tx) === 2;
1419
- var useRelayAssetAsFee = typeof destination === 'string' && isExternalChain(destination) || isRelayAssetIncluded;
1420
- if (useRelayAssetAsFee) {
1421
- return findNativeAssetInfoOrThrow(getRelayChainOf(currentChain));
1422
- }
1423
- if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
1424
- return findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
1425
- }
1426
- return (_findAssetInfoOnDest = findAssetInfoOnDest(originChain, currentChain, currency)) !== null && _findAssetInfoOnDest !== void 0 ? _findAssetInfoOnDest : asset;
1427
- };
1428
-
1429
- var getEthereumJunction = function getEthereumJunction(chain) {
1430
- var useBigInt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1431
- var relayChain = getRelayChainOf(chain);
1432
- var isTestnet = relayChain === 'Westend' || relayChain === 'Paseo';
1433
- var chainId = isTestnet ? ETH_TESTNET_PARA_ID : ETH_MAINNET_PARA_ID;
1434
- return {
1435
- GlobalConsensus: {
1436
- Ethereum: {
1437
- chainId: useBigInt ? BigInt(chainId) : chainId
1438
- }
1439
- }
1440
- };
1441
- };
1442
-
1443
- var validateBridgeAsset = function validateBridgeAsset(origin, destination, asset, currency, isBridge) {
1444
- if (!asset || isTLocation(destination) || isExternalChain(destination) || !isBridge) {
1445
- return;
1446
- }
1447
- var nativeAsset = findNativeAssetInfoOrThrow(origin);
1448
- var isNativeAsset = isAssetEqual(asset, nativeAsset);
1449
- var isBridgedStablecoin = isStableCoinAsset(asset);
1450
- if (!(isNativeAsset || isBridgedSystemAsset(asset, [getRelayChainOf(destination)]) || isBridgedStablecoin)) {
1451
- throw new InvalidCurrencyError("Substrate bridge does not support currency ".concat(JSON.stringify(currency, replaceBigInt), "."));
1452
- }
1453
- };
1454
- var validateEcosystems = function validateEcosystems(origin, destination) {
1455
- if (isTLocation(destination)) return;
1456
- var relayChain = getRelayChainOf(origin);
1457
- var destinationToRelayChains = {
1458
- Ethereum: ['Polkadot'],
1459
- EthereumTestnet: ['Westend', 'Paseo']
1460
- };
1461
- var allowedRelayChains = destinationToRelayChains[destination];
1462
- if (!allowedRelayChains) return;
1463
- if (!allowedRelayChains.includes(relayChain)) {
1464
- throw new InvalidCurrencyError("Destination ".concat(destination, " is only supported from following ecosystems: ").concat(allowedRelayChains.join(', '), "."));
1465
- }
1466
- };
1467
- var validateEthereumAsset = function validateEthereumAsset(origin, destination, asset) {
1468
- if (!asset || !isTLocation(destination) && !isSnowbridge(origin, destination) || origin === 'Mythos') {
1469
- return;
1470
- }
1471
- validateEcosystems(origin, destination);
1472
- var ADDITIONAL_ALLOWED_LOCATIONS = [RELAY_LOCATION, {
1473
- parents: 2,
1474
- interior: {
1475
- X1: [{
1476
- GlobalConsensus: {
1477
- Kusama: null
1478
- }
1479
- }]
1480
- }
1481
- }];
1482
- var isEthCompatibleAsset = asset.location.parents === Parents.TWO && deepEqual(getJunctionValue(asset.location, 'GlobalConsensus'), getEthereumJunction(origin, false).GlobalConsensus) || ADDITIONAL_ALLOWED_LOCATIONS.some(function (loc) {
1483
- return deepEqual(asset.location, loc);
1484
- });
1485
- if (!isEthCompatibleAsset) {
1486
- throw new InvalidCurrencyError("Currency ".concat(JSON.stringify(asset, replaceBigInt), " is not transferable to Ethereum."));
1487
- }
1488
- };
1489
- var validateAssetSupport = function validateAssetSupport(_ref, assetCheckEnabled, isBridge, asset) {
1490
- var origin = _ref.from,
1491
- destination = _ref.to,
1492
- currency = _ref.currency;
1493
- var isLocationDestination = _typeof(destination) === 'object';
1494
- if (asset === null && assetCheckEnabled) {
1495
- throwUnsupportedCurrency(currency, origin);
1496
- }
1497
- if (!isLocationDestination && assetCheckEnabled && !findAssetInfoOnDest(origin, destination, currency, asset)) {
1498
- throw new InvalidCurrencyError("Destination chain ".concat(destination, " does not support currency ").concat(JSON.stringify(currency, replaceBigInt), "."));
1499
- }
1500
- validateBridgeAsset(origin, destination, asset, currency, isBridge);
1501
- validateEthereumAsset(origin, destination, asset);
1502
- };
1503
-
1504
- var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge, assetCheckEnabled, resolvedFeeAsset) {
1505
- var api = options.api,
1506
- currency = options.currency,
1507
- feeAsset = options.feeAsset,
1508
- origin = options.from,
1509
- destination = options.to;
1510
- if ('location' in currency && isOverrideLocationSpecifier(currency.location)) {
1511
- return currency.location.value;
1512
- }
1513
- if (Array.isArray(currency)) {
1514
- if (!feeAsset) {
1515
- throw new InvalidCurrencyError('Overridden multi assets cannot be used without specifying fee asset');
1516
- }
1517
- if ('location' in feeAsset && isOverrideLocationSpecifier(feeAsset.location)) {
1518
- throw new InvalidCurrencyError('Fee asset cannot be an overridden location specifier');
1519
- }
1520
- if (currency.every(function (asset) {
1521
- return isTAsset(asset);
1522
- })) {
1523
- if (!feeAsset) {
1524
- throw new InvalidCurrencyError('Fee asset not provided');
1525
- }
1526
- if (!('location' in feeAsset)) {
1527
- throw new InvalidCurrencyError('Fee asset must be specified by location when using raw overridden multi assets');
1528
- }
1529
- return currency.map(function (asset) {
1530
- var ml = extractAssetLocation(asset);
1531
- return _objectSpread2(_objectSpread2({}, asset), {}, {
1532
- fun: {
1533
- Fungible: BigInt(asset.fun.Fungible)
1534
- },
1535
- isFeeAsset: deepEqual(ml, feeAsset.location)
1536
- });
1537
- });
1538
- }
1539
- // MultiAsset is an array of TCurrencyCore, search for assets
1540
- var assets = currency.map(function (currency) {
1541
- if (currency.amount === AMOUNT_ALL) {
1542
- throw new InvalidCurrencyError('Multi assets cannot use amount all. Please specify amount.');
1543
- }
1544
- var asset = findAssetInfo(origin, currency, !isTLocation(destination) ? destination : null);
1545
- if (!asset) {
1546
- throw new InvalidCurrencyError("Origin chain ".concat(origin, " does not support currency ").concat(JSON.stringify(currency)));
1547
- }
1548
- if (!resolvedFeeAsset) {
1549
- throw new InvalidCurrencyError('Fee asset not found');
1550
- }
1551
- validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
1552
- var version = getChainVersion(origin);
1553
- var abstractedAmount = abstractDecimals(currency.amount, asset.decimals, api);
1554
- return _objectSpread2({
1555
- isFeeAsset: isAssetEqual(resolvedFeeAsset, asset)
1556
- }, createAsset(version, abstractedAmount, asset.location));
1557
- });
1558
- if (assets.filter(function (asset) {
1559
- return asset.isFeeAsset;
1560
- }).length > 1) {
1561
- throw new InvalidCurrencyError("Fee asset matches multiple assets in multiassets");
1562
- }
1563
- if (assets.filter(function (asset) {
1564
- return asset.isFeeAsset;
1565
- }).length === 0) {
1566
- throw new InvalidCurrencyError("Fee asset not found in multiassets");
1567
- }
1568
- return assets;
1569
- }
1570
- return undefined;
1571
- };
1572
-
1573
- var shouldPerformAssetCheck = function shouldPerformAssetCheck(origin, currency) {
1574
- if (isRelayChain(origin)) return true;
1575
- var isMultipleAssets = Array.isArray(currency);
1576
- var hasOverriddenLocation = 'location' in currency && isOverrideLocationSpecifier(currency.location);
1577
- return !(isMultipleAssets || hasOverriddenLocation);
1578
- };
1579
-
1580
- var validateCurrency = function validateCurrency(currency, feeAsset) {
1581
- if (Array.isArray(currency)) {
1582
- if (currency.length === 0) {
1583
- throw new InvalidCurrencyError('Overridden assets cannot be empty');
1584
- }
1585
- if (currency.length === 1) {
1586
- throw new InvalidCurrencyError('Please provide more than one asset');
1587
- }
1588
- if (currency.length > 1 && !currency.every(function (asset) {
1589
- return isTAsset(asset);
1590
- }) && !feeAsset) {
1591
- throw new InvalidCurrencyError('Overridden assets cannot be used without specifying fee asset');
1592
- }
1593
- }
1594
- };
1595
- var validateDestination = function validateDestination(origin, destination) {
1596
- if (isRelayChain(origin) && !isTLocation(destination) && isRelayChain(destination) && origin !== destination) {
1597
- throw new ScenarioNotSupportedError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
1598
- }
1599
- var allowedChainsToEthereum = ['AssetHubPolkadot', 'AssetHubPaseo', 'AssetHubWestend', 'Hydration', 'BifrostPolkadot', 'Moonbeam', 'Mythos'];
1600
- if (typeof destination === 'string' && isExternalChain(destination) && !allowedChainsToEthereum.includes(origin)) {
1601
- throw new ScenarioNotSupportedError("Transfers to Ethereum are only supported from: ".concat(allowedChainsToEthereum.join(', ')));
1602
- }
1603
- var isLocationDestination = _typeof(destination) === 'object';
1604
- var isBridgeTransfer = !isTLocation(destination) && isBridge(origin, destination);
1605
- var isRelayDestination = !isTLocation(destination) && isRelayChain(destination);
1606
- if (!isRelayDestination && !isLocationDestination) {
1607
- var originRelayChainSymbol = getRelayChainSymbol(origin);
1608
- var destinationRelayChainSymbol = getRelayChainSymbol(destination);
1609
- if (!isBridgeTransfer && originRelayChainSymbol !== destinationRelayChainSymbol) {
1610
- throw new ScenarioNotSupportedError('Origin and destination must share the same relay chain unless using a bridge.');
1611
- }
1612
- }
1613
- if (isRelayChain(origin) && typeof destination === 'string' && !isExternalChain(destination)) {
1614
- var chain = getChain(destination);
1615
- if (!chain.isRelayToParaEnabled()) {
1616
- throw new ScenarioNotSupportedError({
1617
- chain: destination,
1618
- scenario: 'RelayToPara'
1619
- });
1620
- }
1621
- }
1622
- };
1623
- var validateAssetSpecifiers = function validateAssetSpecifiers(assetCheckEnabled, currency) {
1624
- if (!assetCheckEnabled && 'symbol' in currency && isSymbolSpecifier(currency.symbol)) {
1625
- throw new InvalidCurrencyError('Symbol specifier is not supported when asset check is disabled. Please use normal symbol instead.');
1626
- }
1627
- if (!assetCheckEnabled && 'id' in currency) {
1628
- throw new InvalidCurrencyError('Asset ID is not supported when asset check is disabled. Please use normal symbol instead');
1629
- }
1630
- };
1631
- var validateTransact = function validateTransact(_ref) {
1632
- var api = _ref.api,
1633
- from = _ref.from,
1634
- to = _ref.to,
1635
- sender = _ref.sender,
1636
- address = _ref.recipient,
1637
- transactOptions = _ref.transactOptions;
1638
- var call = transactOptions === null || transactOptions === void 0 ? void 0 : transactOptions.call;
1639
- if (!call) return;
1640
- if (from === to) {
1641
- throw new UnsupportedOperationError('Cannot use transact options with local transfers.');
1642
- }
1643
- if (typeof call === 'string' && !isHex(call)) {
1644
- throw new ValidationError('Transact call hex must be a valid hex string.');
1645
- }
1646
- if (isChainEvm(from) || typeof to === 'string' && isChainEvm(to)) {
1647
- throw new UnsupportedOperationError('Transact option is only supported for Substrate to Substrate scenarios.');
1648
- }
1649
- if (typeof address === 'string' && sender && !compareAddresses(api, address, sender)) {
1650
- return new ValidationError('Sender address must match the destination address for transact to work.');
1651
- }
1652
- };
1653
-
1654
- var resolveTransferParams = function resolveTransferParams(options) {
1655
- var api = options.api,
1656
- origin = options.from,
1657
- currency = options.currency,
1658
- feeAsset = options.feeAsset,
1659
- address = options.recipient,
1660
- destination = options.to,
1661
- version = options.version,
1662
- sender = options.sender;
1663
- validateCurrency(currency, feeAsset);
1664
- validateDestination(origin, destination);
1665
- validateTransact(options);
1666
- validateDestinationAddress(address, destination, api);
1667
- if (sender) validateAddress(api, sender, origin, false);
1668
- var isBridge = !isTLocation(destination) && isSubstrateBridge(origin, destination);
1669
- var assetCheckEnabled = shouldPerformAssetCheck(origin, currency);
1670
- validateAssetSpecifiers(assetCheckEnabled, currency);
1671
- var asset = resolveAsset(currency, origin, destination, assetCheckEnabled);
1672
- var resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
1673
- validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
1674
- var amount = Array.isArray(currency) ? 0n : abstractDecimals(currency.amount, asset === null || asset === void 0 ? void 0 : asset.decimals, api);
1675
- // Ensure amount is at least 2 to avoid Rust panic (only for non-array currencies)
1676
- var finalAmount = !Array.isArray(currency) && amount < MIN_AMOUNT ? MIN_AMOUNT : amount;
1677
- var resolvedVersion = pickCompatibleXcmVersion(origin, destination, version);
1678
- var overriddenAsset = resolveOverriddenAsset(options, isBridge, assetCheckEnabled, resolvedFeeAsset);
1679
- // In case asset check is disabled, we create asset object from currency symbol
1680
- var resolvedAsset = asset !== null && asset !== void 0 ? asset : {
1681
- symbol: 'symbol' in currency ? currency.symbol : undefined
1682
- };
1683
- var finalAsset = Array.isArray(currency) ? // TODO: Refactor this
1684
- // We use a dummy values when overriding with multi-assets
1685
- // since these values won't be used but need to pass checks
1686
- _objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
1687
- amount: 0n,
1688
- assetId: '1',
1689
- location: {
1690
- parents: Parents.ZERO,
1691
- interior: {
1692
- Here: null
1693
- }
1694
- }
1695
- }) : _objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
1696
- amount: finalAmount
1697
- });
1698
- var normalizedAsset = finalAsset.location ? _objectSpread2(_objectSpread2({}, finalAsset), {}, {
1699
- location: normalizeLocation(finalAsset.location, resolvedVersion)
1700
- }) : finalAsset;
1701
- return {
1702
- resolvedFeeAsset: resolvedFeeAsset,
1703
- resolvedVersion: resolvedVersion,
1704
- overriddenAsset: overriddenAsset,
1705
- normalizedAsset: normalizedAsset
1706
- };
1707
- };
1708
- var createTransfer = /*#__PURE__*/function () {
1709
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
1710
- var api, origin, currency, feeAsset, recipient, destination, paraIdTo, sender, ahAddress, pallet, method, transactOptions, isAmountAll, keepAlive, _resolveTransferParam, resolvedFeeAsset, resolvedVersion, overriddenAsset, normalizedAsset;
1711
- return _regenerator().w(function (_context) {
1712
- while (1) switch (_context.n) {
1713
- case 0:
1714
- api = options.api, origin = options.from, currency = options.currency, feeAsset = options.feeAsset, recipient = options.recipient, destination = options.to, paraIdTo = options.paraIdTo, sender = options.sender, ahAddress = options.ahAddress, pallet = options.pallet, method = options.method, transactOptions = options.transactOptions, isAmountAll = options.isAmountAll, keepAlive = options.keepAlive;
1715
- _resolveTransferParam = resolveTransferParams(options), resolvedFeeAsset = _resolveTransferParam.resolvedFeeAsset, resolvedVersion = _resolveTransferParam.resolvedVersion, overriddenAsset = _resolveTransferParam.overriddenAsset, normalizedAsset = _resolveTransferParam.normalizedAsset;
1716
- _context.n = 1;
1717
- return api.init(origin, TX_CLIENT_TIMEOUT_MS);
1718
- case 1:
1719
- return _context.a(2, getChain(origin).transfer({
1720
- api: api,
1721
- assetInfo: normalizedAsset,
1722
- currency: currency,
1723
- feeAsset: resolvedFeeAsset,
1724
- feeCurrency: feeAsset,
1725
- recipient: recipient,
1726
- to: destination,
1727
- paraIdTo: paraIdTo,
1728
- overriddenAsset: overriddenAsset,
1729
- version: resolvedVersion,
1730
- sender: sender,
1731
- ahAddress: ahAddress,
1732
- pallet: pallet,
1733
- method: method,
1734
- transactOptions: transactOptions,
1735
- isAmountAll: isAmountAll,
1736
- keepAlive: keepAlive
1737
- }));
1738
- }
1739
- }, _callee);
1740
- }));
1741
- return function createTransfer(_x) {
1742
- return _ref.apply(this, arguments);
1743
- };
1744
- }();
1745
-
1746
- var isAssetHub = function isAssetHub(chain) {
1747
- return chain === 'AssetHubPolkadot' || chain === 'AssetHubKusama';
1748
- };
1749
- var isBridgeHub = function isBridgeHub(chain) {
1750
- return chain === 'BridgeHubPolkadot' || chain === 'BridgeHubKusama';
1751
- };
1752
- var isPeople = function isPeople(chain) {
1753
- return chain === 'PeoplePolkadot' || chain === 'PeopleKusama';
1754
- };
1755
- var isSystemPara = function isSystemPara(chain) {
1756
- return isAssetHub(chain) || isBridgeHub(chain) || isPeople(chain);
1757
- };
1758
- var mul = function mul(v, num) {
1759
- var den = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1n;
1760
- return v * num / den;
1761
- };
1762
- var padFee = function padFee(raw, origin, dest, side) {
1763
- var relayOrigin = isRelayChain(origin);
1764
- var relayDest = isRelayChain(dest);
1765
- var sysParaOrigin = isSystemPara(origin);
1766
- var sysParaDest = isSystemPara(dest);
1767
- var relayToPara = relayOrigin && !relayDest;
1768
- var sysParaToPara = sysParaOrigin && !sysParaDest;
1769
- var paraToPara = !relayOrigin && !sysParaOrigin;
1770
- if (sysParaToPara) return raw * 40n;
1771
- if (relayToPara) return side === 'origin' ? mul(raw, 320n, 100n) : mul(raw, 3000n, 100n);
1772
- if (paraToPara && side == 'origin' && origin === 'Mythos' && dest !== 'Ethereum') {
1773
- return 150000000000000000n;
1774
- }
1775
- if (paraToPara) return mul(raw, 130n, 100n);
1776
- // apply default 30% padding
1777
- return mul(raw, 130n, 100n);
1778
- };
1779
- var padValueBy = function padValueBy(amount, percent) {
1780
- var scaled = BigInt(Math.round(percent * 100)); // 2 decimal precision
1781
- return amount * (BigInt(10000) + scaled) / BigInt(10000);
1782
- };
1783
-
1784
- var getMythosOriginFee = /*#__PURE__*/function () {
1785
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api) {
1786
- var ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, ahExecutionFee, nativeAsset, feeConverted;
1787
- return _regenerator().w(function (_context) {
1788
- while (1) switch (_context.n) {
1789
- case 0:
1790
- ahApi = api.clone();
1791
- _context.n = 1;
1792
- return ahApi.init('AssetHubPolkadot');
1793
- case 1:
1794
- _context.n = 2;
1795
- return getParaEthTransferFees(ahApi, false);
1796
- case 2:
1797
- _yield$getParaEthTran = _context.v;
1798
- _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
1799
- bridgeFee = _yield$getParaEthTran2[0];
1800
- ahExecutionFee = _yield$getParaEthTran2[1];
1801
- nativeAsset = findNativeAssetInfoOrThrow('Mythos');
1802
- _context.n = 3;
1803
- return ahApi.quoteAhPrice(DOT_LOCATION, nativeAsset.location, bridgeFee + ahExecutionFee);
1804
- case 3:
1805
- feeConverted = _context.v;
1806
- _context.n = 4;
1807
- return ahApi.disconnect();
1808
- case 4:
1809
- if (feeConverted) {
1810
- _context.n = 5;
1811
- break;
1812
- }
1813
- throw new UnableToComputeError("Pool DOT -> ".concat(nativeAsset.symbol, " not found."));
1814
- case 5:
1815
- return _context.a(2, padValueBy(feeConverted, 10));
1816
- }
1817
- }, _callee);
1818
- }));
1819
- return function getMythosOriginFee(_x) {
1820
- return _ref.apply(this, arguments);
1821
- };
1822
- }();
1823
-
1824
1391
  var AssetHubPolkadot$1 = {
1825
1392
  name: "Asset Hub",
1826
1393
  info: "PolkadotAssetHub",
@@ -3223,42 +2790,485 @@ var configs = {
3223
2790
  Westend: Westend$1,
3224
2791
  Paseo: Paseo$1
3225
2792
  };
3226
-
3227
- var configsMap = configs;
3228
- var getChainConfig = function getChainConfig(chain) {
3229
- return configsMap[chain];
2793
+
2794
+ var configsMap = configs;
2795
+ var getChainConfig = function getChainConfig(chain) {
2796
+ return configsMap[chain];
2797
+ };
2798
+
2799
+ var getChainProviders = function getChainProviders(chain) {
2800
+ var _getChainConfig = getChainConfig(chain),
2801
+ providers = _getChainConfig.providers;
2802
+ if (providers.length === 0) {
2803
+ throw new ProviderUnavailableError("No providers found for chain ".concat(chain));
2804
+ }
2805
+ // Prefer Dwellir provider
2806
+ providers.sort(function (a, b) {
2807
+ return (a.name === 'Dwellir' ? 0 : 1) - (b.name === 'Dwellir' ? 0 : 1);
2808
+ });
2809
+ return providers.map(function (p) {
2810
+ return p.endpoint;
2811
+ });
2812
+ };
2813
+
2814
+ /**
2815
+ * Retrieves the parachain ID for a specified chain.
2816
+ *
2817
+ * @param chain - The chain for which to get the paraId.
2818
+ * @returns The parachain ID of the chain.
2819
+ */
2820
+ var getParaId = function getParaId(chain) {
2821
+ if (chain === 'Ethereum') {
2822
+ return ETH_MAINNET_PARA_ID;
2823
+ } else if (chain === 'EthereumTestnet') {
2824
+ return ETH_TESTNET_PARA_ID;
2825
+ }
2826
+ return getChainConfig(chain).paraId;
2827
+ };
2828
+
2829
+ var isMoonbeamWhAsset = function isMoonbeamWhAsset(location) {
2830
+ return !!location && hasJunction(location, 'Parachain', getParaId('Moonbeam')) && hasJunction(location, 'PalletInstance', 110);
2831
+ };
2832
+ var inferFeeAsset = function inferFeeAsset(origin, destination, asset) {
2833
+ if (origin === 'Hydration' && destination === 'Moonbeam' && isMoonbeamWhAsset(asset.location)) {
2834
+ return findNativeAssetInfoOrThrow(destination);
2835
+ }
2836
+ return undefined;
2837
+ };
2838
+
2839
+ var resolveAsset = function resolveAsset(currency, origin, destination, assetCheckEnabled) {
2840
+ return assetCheckEnabled ? findAssetInfo(origin, currency, !isTLocation(destination) ? destination : null) : null;
2841
+ };
2842
+
2843
+ var resolveFeeAsset = function resolveFeeAsset(feeAsset, origin, destination, currency) {
2844
+ if (!origin.startsWith('Hydration') && origin !== 'AssetHubPolkadot') {
2845
+ throw new ScenarioNotSupportedError("Fee asset is not supported on ".concat(origin));
2846
+ }
2847
+ var asset = findAssetInfo(origin, feeAsset, !isTLocation(destination) ? destination : null);
2848
+ var usesRawOverriddenMultiAssets = Array.isArray(currency) && currency.every(isTAsset);
2849
+ if (!asset && !usesRawOverriddenMultiAssets) {
2850
+ throwUnsupportedCurrency(feeAsset, origin);
2851
+ }
2852
+ return asset !== null && asset !== void 0 ? asset : undefined;
2853
+ };
2854
+
2855
+ var resolveHopAsset = function resolveHopAsset(_ref) {
2856
+ var _findAssetInfoOnDest;
2857
+ var api = _ref.api,
2858
+ tx = _ref.tx,
2859
+ originChain = _ref.originChain,
2860
+ currentChain = _ref.currentChain,
2861
+ destination = _ref.destination,
2862
+ swapConfig = _ref.swapConfig,
2863
+ asset = _ref.asset,
2864
+ hasPassedExchange = _ref.hasPassedExchange,
2865
+ currency = _ref.currency;
2866
+ var isRelayAssetIncluded = api.getTypeThenAssetCount(tx) === 2;
2867
+ var useRelayAssetAsFee = typeof destination === 'string' && isExternalChain(destination) || isRelayAssetIncluded;
2868
+ if (useRelayAssetAsFee) {
2869
+ return findNativeAssetInfoOrThrow(getRelayChainOf(currentChain));
2870
+ }
2871
+ if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
2872
+ return findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
2873
+ }
2874
+ return (_findAssetInfoOnDest = findAssetInfoOnDest(originChain, currentChain, currency)) !== null && _findAssetInfoOnDest !== void 0 ? _findAssetInfoOnDest : asset;
2875
+ };
2876
+
2877
+ var getEthereumJunction = function getEthereumJunction(chain) {
2878
+ var useBigInt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
2879
+ var relayChain = getRelayChainOf(chain);
2880
+ var isTestnet = relayChain === 'Westend' || relayChain === 'Paseo';
2881
+ var chainId = isTestnet ? ETH_TESTNET_PARA_ID : ETH_MAINNET_PARA_ID;
2882
+ return {
2883
+ GlobalConsensus: {
2884
+ Ethereum: {
2885
+ chainId: useBigInt ? BigInt(chainId) : chainId
2886
+ }
2887
+ }
2888
+ };
2889
+ };
2890
+
2891
+ var validateBridgeAsset = function validateBridgeAsset(origin, destination, asset, currency, isBridge) {
2892
+ if (!asset || isTLocation(destination) || isExternalChain(destination) || !isBridge) {
2893
+ return;
2894
+ }
2895
+ var nativeAsset = findNativeAssetInfoOrThrow(origin);
2896
+ var isNativeAsset = isAssetEqual(asset, nativeAsset);
2897
+ var isBridgedStablecoin = isStableCoinAsset(asset);
2898
+ if (!(isNativeAsset || isBridgedSystemAsset(asset, [getRelayChainOf(destination)]) || isBridgedStablecoin)) {
2899
+ throw new InvalidCurrencyError("Substrate bridge does not support currency ".concat(JSON.stringify(currency, replaceBigInt), "."));
2900
+ }
2901
+ };
2902
+ var validateEcosystems = function validateEcosystems(origin, destination) {
2903
+ if (isTLocation(destination)) return;
2904
+ var relayChain = getRelayChainOf(origin);
2905
+ var destinationToRelayChains = {
2906
+ Ethereum: ['Polkadot'],
2907
+ EthereumTestnet: ['Westend', 'Paseo']
2908
+ };
2909
+ var allowedRelayChains = destinationToRelayChains[destination];
2910
+ if (!allowedRelayChains) return;
2911
+ if (!allowedRelayChains.includes(relayChain)) {
2912
+ throw new InvalidCurrencyError("Destination ".concat(destination, " is only supported from following ecosystems: ").concat(allowedRelayChains.join(', '), "."));
2913
+ }
2914
+ };
2915
+ var validateEthereumAsset = function validateEthereumAsset(origin, destination, asset) {
2916
+ if (!asset || !isTLocation(destination) && !isSnowbridge(origin, destination) || origin === 'Mythos') {
2917
+ return;
2918
+ }
2919
+ validateEcosystems(origin, destination);
2920
+ var ADDITIONAL_ALLOWED_LOCATIONS = [RELAY_LOCATION, {
2921
+ parents: 2,
2922
+ interior: {
2923
+ X1: [{
2924
+ GlobalConsensus: {
2925
+ Kusama: null
2926
+ }
2927
+ }]
2928
+ }
2929
+ }];
2930
+ var isEthCompatibleAsset = asset.location.parents === Parents.TWO && deepEqual(getJunctionValue(asset.location, 'GlobalConsensus'), getEthereumJunction(origin, false).GlobalConsensus) || ADDITIONAL_ALLOWED_LOCATIONS.some(function (loc) {
2931
+ return deepEqual(asset.location, loc);
2932
+ });
2933
+ if (!isEthCompatibleAsset) {
2934
+ throw new InvalidCurrencyError("Currency ".concat(JSON.stringify(asset, replaceBigInt), " is not transferable to Ethereum."));
2935
+ }
2936
+ };
2937
+ var validateAssetSupport = function validateAssetSupport(_ref, assetCheckEnabled, isBridge, asset) {
2938
+ var origin = _ref.from,
2939
+ destination = _ref.to,
2940
+ currency = _ref.currency;
2941
+ var isLocationDestination = _typeof(destination) === 'object';
2942
+ if (asset === null && assetCheckEnabled) {
2943
+ throwUnsupportedCurrency(currency, origin);
2944
+ }
2945
+ if (!isLocationDestination && assetCheckEnabled && !findAssetInfoOnDest(origin, destination, currency, asset)) {
2946
+ throw new InvalidCurrencyError("Destination chain ".concat(destination, " does not support currency ").concat(JSON.stringify(currency, replaceBigInt), "."));
2947
+ }
2948
+ validateBridgeAsset(origin, destination, asset, currency, isBridge);
2949
+ validateEthereumAsset(origin, destination, asset);
2950
+ };
2951
+
2952
+ var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge, assetCheckEnabled, resolvedFeeAsset) {
2953
+ var api = options.api,
2954
+ currency = options.currency,
2955
+ feeAsset = options.feeAsset,
2956
+ origin = options.from,
2957
+ destination = options.to;
2958
+ if ('location' in currency && isOverrideLocationSpecifier(currency.location)) {
2959
+ return currency.location.value;
2960
+ }
2961
+ if (Array.isArray(currency)) {
2962
+ if (!feeAsset) {
2963
+ throw new InvalidCurrencyError('Overridden multi assets cannot be used without specifying fee asset');
2964
+ }
2965
+ if ('location' in feeAsset && isOverrideLocationSpecifier(feeAsset.location)) {
2966
+ throw new InvalidCurrencyError('Fee asset cannot be an overridden location specifier');
2967
+ }
2968
+ if (currency.every(function (asset) {
2969
+ return isTAsset(asset);
2970
+ })) {
2971
+ if (!feeAsset) {
2972
+ throw new InvalidCurrencyError('Fee asset not provided');
2973
+ }
2974
+ if (!('location' in feeAsset)) {
2975
+ throw new InvalidCurrencyError('Fee asset must be specified by location when using raw overridden multi assets');
2976
+ }
2977
+ return currency.map(function (asset) {
2978
+ var ml = extractAssetLocation(asset);
2979
+ return _objectSpread2(_objectSpread2({}, asset), {}, {
2980
+ fun: {
2981
+ Fungible: BigInt(asset.fun.Fungible)
2982
+ },
2983
+ isFeeAsset: deepEqual(ml, feeAsset.location)
2984
+ });
2985
+ });
2986
+ }
2987
+ // MultiAsset is an array of TCurrencyCore, search for assets
2988
+ var assets = currency.map(function (currency) {
2989
+ if (currency.amount === AMOUNT_ALL) {
2990
+ throw new InvalidCurrencyError('Multi assets cannot use amount all. Please specify amount.');
2991
+ }
2992
+ var asset = findAssetInfo(origin, currency, !isTLocation(destination) ? destination : null);
2993
+ if (!asset) {
2994
+ throw new InvalidCurrencyError("Origin chain ".concat(origin, " does not support currency ").concat(JSON.stringify(currency)));
2995
+ }
2996
+ if (!resolvedFeeAsset) {
2997
+ throw new InvalidCurrencyError('Fee asset not found');
2998
+ }
2999
+ validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
3000
+ var version = getChainVersion(origin);
3001
+ var abstractedAmount = abstractDecimals(currency.amount, asset.decimals, api);
3002
+ return _objectSpread2({
3003
+ isFeeAsset: isAssetEqual(resolvedFeeAsset, asset)
3004
+ }, createAsset(version, abstractedAmount, asset.location));
3005
+ });
3006
+ if (assets.filter(function (asset) {
3007
+ return asset.isFeeAsset;
3008
+ }).length > 1) {
3009
+ throw new InvalidCurrencyError("Fee asset matches multiple assets in multiassets");
3010
+ }
3011
+ if (assets.filter(function (asset) {
3012
+ return asset.isFeeAsset;
3013
+ }).length === 0) {
3014
+ throw new InvalidCurrencyError("Fee asset not found in multiassets");
3015
+ }
3016
+ return assets;
3017
+ }
3018
+ return undefined;
3019
+ };
3020
+
3021
+ var shouldPerformAssetCheck = function shouldPerformAssetCheck(origin, currency) {
3022
+ if (isRelayChain(origin)) return true;
3023
+ var isMultipleAssets = Array.isArray(currency);
3024
+ var hasOverriddenLocation = 'location' in currency && isOverrideLocationSpecifier(currency.location);
3025
+ return !(isMultipleAssets || hasOverriddenLocation);
3026
+ };
3027
+
3028
+ var validateCurrency = function validateCurrency(currency, feeAsset) {
3029
+ if (Array.isArray(currency)) {
3030
+ if (currency.length === 0) {
3031
+ throw new InvalidCurrencyError('Overridden assets cannot be empty');
3032
+ }
3033
+ if (currency.length === 1) {
3034
+ throw new InvalidCurrencyError('Please provide more than one asset');
3035
+ }
3036
+ if (currency.length > 1 && !currency.every(function (asset) {
3037
+ return isTAsset(asset);
3038
+ }) && !feeAsset) {
3039
+ throw new InvalidCurrencyError('Overridden assets cannot be used without specifying fee asset');
3040
+ }
3041
+ }
3042
+ };
3043
+ var validateDestination = function validateDestination(origin, destination) {
3044
+ if (isRelayChain(origin) && !isTLocation(destination) && isRelayChain(destination) && origin !== destination) {
3045
+ throw new ScenarioNotSupportedError('Direct relay chain to relay chain transfers are not supported. Please use Polkadot <-> Kusama bridge through AssetHub.');
3046
+ }
3047
+ var allowedChainsToEthereum = ['AssetHubPolkadot', 'AssetHubPaseo', 'AssetHubWestend', 'Hydration', 'BifrostPolkadot', 'Moonbeam', 'Mythos'];
3048
+ if (typeof destination === 'string' && isExternalChain(destination) && !allowedChainsToEthereum.includes(origin)) {
3049
+ throw new ScenarioNotSupportedError("Transfers to Ethereum are only supported from: ".concat(allowedChainsToEthereum.join(', ')));
3050
+ }
3051
+ var isLocationDestination = _typeof(destination) === 'object';
3052
+ var isBridgeTransfer = !isTLocation(destination) && isBridge(origin, destination);
3053
+ var isRelayDestination = !isTLocation(destination) && isRelayChain(destination);
3054
+ if (!isRelayDestination && !isLocationDestination) {
3055
+ var originRelayChainSymbol = getRelayChainSymbol(origin);
3056
+ var destinationRelayChainSymbol = getRelayChainSymbol(destination);
3057
+ if (!isBridgeTransfer && originRelayChainSymbol !== destinationRelayChainSymbol) {
3058
+ throw new ScenarioNotSupportedError('Origin and destination must share the same relay chain unless using a bridge.');
3059
+ }
3060
+ }
3061
+ if (isRelayChain(origin) && typeof destination === 'string' && !isExternalChain(destination)) {
3062
+ var chain = getChain(destination);
3063
+ if (!chain.isRelayToParaEnabled()) {
3064
+ throw new ScenarioNotSupportedError({
3065
+ chain: destination,
3066
+ scenario: 'RelayToPara'
3067
+ });
3068
+ }
3069
+ }
3070
+ };
3071
+ var validateAssetSpecifiers = function validateAssetSpecifiers(assetCheckEnabled, currency) {
3072
+ if (!assetCheckEnabled && 'symbol' in currency && isSymbolSpecifier(currency.symbol)) {
3073
+ throw new InvalidCurrencyError('Symbol specifier is not supported when asset check is disabled. Please use normal symbol instead.');
3074
+ }
3075
+ if (!assetCheckEnabled && 'id' in currency) {
3076
+ throw new InvalidCurrencyError('Asset ID is not supported when asset check is disabled. Please use normal symbol instead');
3077
+ }
3230
3078
  };
3231
-
3232
- var getChainProviders = function getChainProviders(chain) {
3233
- var _getChainConfig = getChainConfig(chain),
3234
- providers = _getChainConfig.providers;
3235
- if (providers.length === 0) {
3236
- throw new ProviderUnavailableError("No providers found for chain ".concat(chain));
3079
+ var validateTransact = function validateTransact(_ref) {
3080
+ var api = _ref.api,
3081
+ from = _ref.from,
3082
+ to = _ref.to,
3083
+ sender = _ref.sender,
3084
+ address = _ref.recipient,
3085
+ transactOptions = _ref.transactOptions;
3086
+ var call = transactOptions === null || transactOptions === void 0 ? void 0 : transactOptions.call;
3087
+ if (!call) return;
3088
+ if (from === to) {
3089
+ throw new UnsupportedOperationError('Cannot use transact options with local transfers.');
3237
3090
  }
3238
- // Prefer Dwellir provider
3239
- providers.sort(function (a, b) {
3240
- return (a.name === 'Dwellir' ? 0 : 1) - (b.name === 'Dwellir' ? 0 : 1);
3241
- });
3242
- return providers.map(function (p) {
3243
- return p.endpoint;
3091
+ if (typeof call === 'string' && !isHex(call)) {
3092
+ throw new ValidationError('Transact call hex must be a valid hex string.');
3093
+ }
3094
+ if (isChainEvm(from) || typeof to === 'string' && isChainEvm(to)) {
3095
+ throw new UnsupportedOperationError('Transact option is only supported for Substrate to Substrate scenarios.');
3096
+ }
3097
+ if (typeof address === 'string' && sender && !compareAddresses(api, address, sender)) {
3098
+ return new ValidationError('Sender address must match the destination address for transact to work.');
3099
+ }
3100
+ };
3101
+
3102
+ var resolveTransferParams = function resolveTransferParams(options) {
3103
+ var api = options.api,
3104
+ origin = options.from,
3105
+ currency = options.currency,
3106
+ feeAsset = options.feeAsset,
3107
+ address = options.recipient,
3108
+ destination = options.to,
3109
+ version = options.version,
3110
+ sender = options.sender;
3111
+ validateCurrency(currency, feeAsset);
3112
+ validateDestination(origin, destination);
3113
+ validateTransact(options);
3114
+ validateDestinationAddress(address, destination, api);
3115
+ if (sender) validateAddress(api, sender, origin, false);
3116
+ var isBridge = !isTLocation(destination) && isSubstrateBridge(origin, destination);
3117
+ var assetCheckEnabled = shouldPerformAssetCheck(origin, currency);
3118
+ validateAssetSpecifiers(assetCheckEnabled, currency);
3119
+ var asset = resolveAsset(currency, origin, destination, assetCheckEnabled);
3120
+ var resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
3121
+ validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
3122
+ var amount = Array.isArray(currency) ? 0n : abstractDecimals(currency.amount, asset === null || asset === void 0 ? void 0 : asset.decimals, api);
3123
+ // Ensure amount is at least 2 to avoid Rust panic (only for non-array currencies)
3124
+ var finalAmount = !Array.isArray(currency) && amount < MIN_AMOUNT ? MIN_AMOUNT : amount;
3125
+ var resolvedVersion = pickCompatibleXcmVersion(origin, destination, version);
3126
+ var overriddenAsset = resolveOverriddenAsset(options, isBridge, assetCheckEnabled, resolvedFeeAsset);
3127
+ // In case asset check is disabled, we create asset object from currency symbol
3128
+ var resolvedAsset = asset !== null && asset !== void 0 ? asset : {
3129
+ symbol: 'symbol' in currency ? currency.symbol : undefined
3130
+ };
3131
+ var finalAsset = Array.isArray(currency) ? // TODO: Refactor this
3132
+ // We use a dummy values when overriding with multi-assets
3133
+ // since these values won't be used but need to pass checks
3134
+ _objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
3135
+ amount: 0n,
3136
+ assetId: '1',
3137
+ location: {
3138
+ parents: Parents.ZERO,
3139
+ interior: {
3140
+ Here: null
3141
+ }
3142
+ }
3143
+ }) : _objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
3144
+ amount: finalAmount
3244
3145
  });
3146
+ var normalizedAsset = finalAsset.location ? _objectSpread2(_objectSpread2({}, finalAsset), {}, {
3147
+ location: normalizeLocation(finalAsset.location, resolvedVersion)
3148
+ }) : finalAsset;
3149
+ return {
3150
+ resolvedFeeAsset: resolvedFeeAsset,
3151
+ resolvedVersion: resolvedVersion,
3152
+ overriddenAsset: overriddenAsset,
3153
+ normalizedAsset: normalizedAsset
3154
+ };
3245
3155
  };
3156
+ var createTransfer = /*#__PURE__*/function () {
3157
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
3158
+ var api, origin, currency, feeAsset, recipient, destination, paraIdTo, sender, ahAddress, pallet, method, transactOptions, isAmountAll, keepAlive, _resolveTransferParam, resolvedFeeAsset, resolvedVersion, overriddenAsset, normalizedAsset;
3159
+ return _regenerator().w(function (_context) {
3160
+ while (1) switch (_context.n) {
3161
+ case 0:
3162
+ api = options.api, origin = options.from, currency = options.currency, feeAsset = options.feeAsset, recipient = options.recipient, destination = options.to, paraIdTo = options.paraIdTo, sender = options.sender, ahAddress = options.ahAddress, pallet = options.pallet, method = options.method, transactOptions = options.transactOptions, isAmountAll = options.isAmountAll, keepAlive = options.keepAlive;
3163
+ _resolveTransferParam = resolveTransferParams(options), resolvedFeeAsset = _resolveTransferParam.resolvedFeeAsset, resolvedVersion = _resolveTransferParam.resolvedVersion, overriddenAsset = _resolveTransferParam.overriddenAsset, normalizedAsset = _resolveTransferParam.normalizedAsset;
3164
+ _context.n = 1;
3165
+ return api.init(origin, TX_CLIENT_TIMEOUT_MS);
3166
+ case 1:
3167
+ return _context.a(2, getChain(origin).transfer({
3168
+ api: api,
3169
+ assetInfo: normalizedAsset,
3170
+ currency: currency,
3171
+ feeAsset: resolvedFeeAsset,
3172
+ feeCurrency: feeAsset,
3173
+ recipient: recipient,
3174
+ to: destination,
3175
+ paraIdTo: paraIdTo,
3176
+ overriddenAsset: overriddenAsset,
3177
+ version: resolvedVersion,
3178
+ sender: sender,
3179
+ ahAddress: ahAddress,
3180
+ pallet: pallet,
3181
+ method: method,
3182
+ transactOptions: transactOptions,
3183
+ isAmountAll: isAmountAll,
3184
+ keepAlive: keepAlive
3185
+ }));
3186
+ }
3187
+ }, _callee);
3188
+ }));
3189
+ return function createTransfer(_x) {
3190
+ return _ref.apply(this, arguments);
3191
+ };
3192
+ }();
3246
3193
 
3247
- /**
3248
- * Retrieves the parachain ID for a specified chain.
3249
- *
3250
- * @param chain - The chain for which to get the paraId.
3251
- * @returns The parachain ID of the chain.
3252
- */
3253
- var getParaId = function getParaId(chain) {
3254
- if (chain === 'Ethereum') {
3255
- return ETH_MAINNET_PARA_ID;
3256
- } else if (chain === 'EthereumTestnet') {
3257
- return ETH_TESTNET_PARA_ID;
3194
+ var isAssetHub = function isAssetHub(chain) {
3195
+ return chain === 'AssetHubPolkadot' || chain === 'AssetHubKusama';
3196
+ };
3197
+ var isBridgeHub = function isBridgeHub(chain) {
3198
+ return chain === 'BridgeHubPolkadot' || chain === 'BridgeHubKusama';
3199
+ };
3200
+ var isPeople = function isPeople(chain) {
3201
+ return chain === 'PeoplePolkadot' || chain === 'PeopleKusama';
3202
+ };
3203
+ var isSystemPara = function isSystemPara(chain) {
3204
+ return isAssetHub(chain) || isBridgeHub(chain) || isPeople(chain);
3205
+ };
3206
+ var mul = function mul(v, num) {
3207
+ var den = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1n;
3208
+ return v * num / den;
3209
+ };
3210
+ var padFee = function padFee(raw, origin, dest, side) {
3211
+ var relayOrigin = isRelayChain(origin);
3212
+ var relayDest = isRelayChain(dest);
3213
+ var sysParaOrigin = isSystemPara(origin);
3214
+ var sysParaDest = isSystemPara(dest);
3215
+ var relayToPara = relayOrigin && !relayDest;
3216
+ var sysParaToPara = sysParaOrigin && !sysParaDest;
3217
+ var paraToPara = !relayOrigin && !sysParaOrigin;
3218
+ if (sysParaToPara) return raw * 40n;
3219
+ if (relayToPara) return side === 'origin' ? mul(raw, 320n, 100n) : mul(raw, 3000n, 100n);
3220
+ if (paraToPara && side == 'origin' && origin === 'Mythos' && dest !== 'Ethereum') {
3221
+ return 150000000000000000n;
3258
3222
  }
3259
- return getChainConfig(chain).paraId;
3223
+ if (paraToPara) return mul(raw, 130n, 100n);
3224
+ // apply default 30% padding
3225
+ return mul(raw, 130n, 100n);
3226
+ };
3227
+ var padValueBy = function padValueBy(amount, percent) {
3228
+ var scaled = BigInt(Math.round(percent * 100)); // 2 decimal precision
3229
+ return amount * (BigInt(10000) + scaled) / BigInt(10000);
3260
3230
  };
3261
3231
 
3232
+ var getMythosOriginFee = /*#__PURE__*/function () {
3233
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api) {
3234
+ var ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, ahExecutionFee, nativeAsset, feeConverted;
3235
+ return _regenerator().w(function (_context) {
3236
+ while (1) switch (_context.n) {
3237
+ case 0:
3238
+ ahApi = api.clone();
3239
+ _context.n = 1;
3240
+ return ahApi.init('AssetHubPolkadot');
3241
+ case 1:
3242
+ _context.n = 2;
3243
+ return getParaEthTransferFees(ahApi, false);
3244
+ case 2:
3245
+ _yield$getParaEthTran = _context.v;
3246
+ _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
3247
+ bridgeFee = _yield$getParaEthTran2[0];
3248
+ ahExecutionFee = _yield$getParaEthTran2[1];
3249
+ nativeAsset = findNativeAssetInfoOrThrow('Mythos');
3250
+ _context.n = 3;
3251
+ return ahApi.quoteAhPrice(DOT_LOCATION, nativeAsset.location, bridgeFee + ahExecutionFee);
3252
+ case 3:
3253
+ feeConverted = _context.v;
3254
+ _context.n = 4;
3255
+ return ahApi.disconnect();
3256
+ case 4:
3257
+ if (feeConverted) {
3258
+ _context.n = 5;
3259
+ break;
3260
+ }
3261
+ throw new UnableToComputeError("Pool DOT -> ".concat(nativeAsset.symbol, " not found."));
3262
+ case 5:
3263
+ return _context.a(2, padValueBy(feeConverted, 10));
3264
+ }
3265
+ }, _callee);
3266
+ }));
3267
+ return function getMythosOriginFee(_x) {
3268
+ return _ref.apply(this, arguments);
3269
+ };
3270
+ }();
3271
+
3262
3272
  /**
3263
3273
  * Builder class for constructing asset claim transactions.
3264
3274
  *
@@ -6837,13 +6847,13 @@ var addEthereumBridgeFees = /*#__PURE__*/function () {
6837
6847
 
6838
6848
  var dryRunInternal = /*#__PURE__*/function () {
6839
6849
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
6840
- var api, origin, destination, currency, tx, sender, feeAsset, swapConfig, version, bypassOptions, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, asset, amount, resolvedVersion, originDryRun, isMythosToEthereum, originDryModified, initialForwardedXcms, initialDestParaId, processHop, traversalResult, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, bridgeHubHopIndex, result, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9;
6850
+ var api, origin, destination, currency, tx, sender, feeAsset, swapConfig, version, bypassOptions, _options$useRootOrigi, useRootOrigin, asset, resolvedFeeAsset, amount, resolvedVersion, originDryRun, isMythosToEthereum, originDryModified, initialForwardedXcms, initialDestParaId, processHop, traversalResult, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, bridgeHubHopIndex, result, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9;
6841
6851
  return _regenerator().w(function (_context2) {
6842
6852
  while (1) switch (_context2.n) {
6843
6853
  case 0:
6844
6854
  api = options.api, origin = options.origin, destination = options.destination, currency = options.currency, tx = options.tx, sender = options.sender, feeAsset = options.feeAsset, swapConfig = options.swapConfig, version = options.version, bypassOptions = options.bypassOptions, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi;
6845
- resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
6846
6855
  asset = findAssetInfoOrThrow(origin, currency, destination);
6856
+ resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
6847
6857
  amount = abstractDecimals(currency.amount, asset.decimals, api);
6848
6858
  resolvedVersion = pickCompatibleXcmVersion(origin, destination, version);
6849
6859
  _context2.n = 1;
@@ -6900,12 +6910,13 @@ var dryRunInternal = /*#__PURE__*/function () {
6900
6910
  initialForwardedXcms = originDryModified.forwardedXcms, initialDestParaId = originDryModified.destParaId;
6901
6911
  processHop = /*#__PURE__*/function () {
6902
6912
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
6903
- var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopAsset, hopDryRun;
6913
+ var _inferFeeAsset;
6914
+ var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, isDestination, resolvedHopAsset, hopAsset, hopDryRun;
6904
6915
  return _regenerator().w(function (_context) {
6905
6916
  while (1) switch (_context.n) {
6906
6917
  case 0:
6907
- hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange;
6908
- hopAsset = resolveHopAsset({
6918
+ hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange, isDestination = params.isDestination;
6919
+ resolvedHopAsset = resolveHopAsset({
6909
6920
  api: api,
6910
6921
  tx: tx,
6911
6922
  originChain: origin,
@@ -6916,6 +6927,7 @@ var dryRunInternal = /*#__PURE__*/function () {
6916
6927
  swapConfig: swapConfig,
6917
6928
  hasPassedExchange: hasPassedExchange
6918
6929
  });
6930
+ hopAsset = isDestination ? (_inferFeeAsset = inferFeeAsset(origin, destination, asset)) !== null && _inferFeeAsset !== void 0 ? _inferFeeAsset : resolvedHopAsset : resolvedHopAsset;
6919
6931
  if (hasDryRunSupport(currentChain)) {
6920
6932
  _context.n = 1;
6921
6933
  break;
@@ -7329,7 +7341,7 @@ var getBypassResultWithRetries = /*#__PURE__*/function () {
7329
7341
  return 'failureReason' in res ? res.failureReason : 'dryRunError' in res ? res.dryRunError : undefined;
7330
7342
  };
7331
7343
  isFailedToTransact = function isFailedToTransact(res) {
7332
- return 'failureReason' in res && res.failureReason === FAILED_TO_TRANSACT_ASSET;
7344
+ return 'failureReason' in res && res.failureReason === FAILED_TO_TRANSACT_ASSET || 'failureSubReason' in res && res.failureSubReason === FAILED_TO_TRANSACT_ASSET;
7333
7345
  };
7334
7346
  isAmountTooLow = function isAmountTooLow(e) {
7335
7347
  return e instanceof AmountTooLowError;
@@ -7695,7 +7707,7 @@ var getFailureInfo = function getFailureInfo(chains, hops) {
7695
7707
  };
7696
7708
  var getXcmFeeOnce = /*#__PURE__*/function () {
7697
7709
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
7698
- var api, tx, origin, destination, sender, recipient, currency, feeAsset, version, disableFallback, swapConfig, useRootOrigin, skipReverseFeeCalculation, asset, amount, resolvedVersion, _yield$getOriginXcmFe, originFeeRaw, originAsset, originFeeType, originDryRunError, originDryRunSubError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, isMythosToEthereum, originFee, destApi, destFeeRes, _result, _getFailureInfo, _failureChain, _failureReason, processHop, traversalResult, destFee, destAsset, destFeeType, destDryRunError, destDryRunSubError, destSufficient, destResult, _destApi, destFallback, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, _bridgeHubChain, bridgeHubHopIndex, convertToFeeDetail, result, _getFailureInfo2, failureChain, failureReason, _t, _t2, _t3, _t4;
7710
+ var api, tx, origin, destination, sender, recipient, currency, feeAsset, version, disableFallback, swapConfig, useRootOrigin, skipReverseFeeCalculation, asset, amount, resolvedVersion, _yield$getOriginXcmFe, originFeeRaw, originAsset, originFeeType, originDryRunError, originDryRunSubError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, isMythosToEthereum, originFee, destApi, destFeeRes, _result, _getFailureInfo, _failureChain, _failureReason, _failureSubReason, processHop, traversalResult, destFee, destAsset, destFeeType, destDryRunError, destDryRunSubError, destSufficient, destResult, _inferFeeAsset2, _destApi, destFallback, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, _bridgeHubChain, bridgeHubHopIndex, convertToFeeDetail, result, _getFailureInfo2, failureChain, failureReason, failureSubReason, _t, _t2, _t3, _t4;
7699
7711
  return _regenerator().w(function (_context2) {
7700
7712
  while (1) switch (_context2.p = _context2.n) {
7701
7713
  case 0:
@@ -7806,10 +7818,11 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
7806
7818
  _getFailureInfo = getFailureInfo({
7807
7819
  origin: _result.origin,
7808
7820
  destination: _result.destination
7809
- }, []), _failureChain = _getFailureInfo.failureChain, _failureReason = _getFailureInfo.failureReason;
7821
+ }, []), _failureChain = _getFailureInfo.failureChain, _failureReason = _getFailureInfo.failureReason, _failureSubReason = _getFailureInfo.failureSubReason;
7810
7822
  return _context2.a(2, _objectSpread2(_objectSpread2({}, _result), {}, {
7811
7823
  failureChain: _failureChain,
7812
- failureReason: _failureReason
7824
+ failureReason: _failureReason,
7825
+ failureSubReason: _failureSubReason
7813
7826
  }));
7814
7827
  case 8:
7815
7828
  _context2.p = 8;
@@ -7821,12 +7834,13 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
7821
7834
  case 10:
7822
7835
  processHop = /*#__PURE__*/function () {
7823
7836
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
7824
- var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopAsset, hopResult;
7837
+ var _inferFeeAsset;
7838
+ var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, isDestination, resolvedHopAsset, hopAsset, hopResult;
7825
7839
  return _regenerator().w(function (_context) {
7826
7840
  while (1) switch (_context.n) {
7827
7841
  case 0:
7828
- hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange;
7829
- hopAsset = resolveHopAsset({
7842
+ hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange, isDestination = params.isDestination;
7843
+ resolvedHopAsset = resolveHopAsset({
7830
7844
  api: api,
7831
7845
  tx: tx,
7832
7846
  originChain: origin,
@@ -7837,6 +7851,7 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
7837
7851
  swapConfig: swapConfig,
7838
7852
  hasPassedExchange: hasPassedExchange
7839
7853
  });
7854
+ hopAsset = isDestination ? (_inferFeeAsset = inferFeeAsset(origin, destination, asset)) !== null && _inferFeeAsset !== void 0 ? _inferFeeAsset : resolvedHopAsset : resolvedHopAsset;
7840
7855
  _context.n = 1;
7841
7856
  return getDestXcmFee({
7842
7857
  api: hopApi,
@@ -7926,7 +7941,7 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
7926
7941
  }),
7927
7942
  sender: sender,
7928
7943
  recipient: recipient,
7929
- asset: asset,
7944
+ asset: (_inferFeeAsset2 = inferFeeAsset(origin, destination, asset)) !== null && _inferFeeAsset2 !== void 0 ? _inferFeeAsset2 : asset,
7930
7945
  version: resolvedVersion,
7931
7946
  tx: tx,
7932
7947
  originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
@@ -8022,10 +8037,11 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
8022
8037
  _getFailureInfo2 = getFailureInfo({
8023
8038
  origin: result.origin,
8024
8039
  destination: result.destination
8025
- }, result.hops), failureChain = _getFailureInfo2.failureChain, failureReason = _getFailureInfo2.failureReason;
8040
+ }, result.hops), failureChain = _getFailureInfo2.failureChain, failureReason = _getFailureInfo2.failureReason, failureSubReason = _getFailureInfo2.failureSubReason;
8026
8041
  return _context2.a(2, _objectSpread2(_objectSpread2({}, result), {}, {
8027
8042
  failureChain: failureChain,
8028
- failureReason: failureReason
8043
+ failureReason: failureReason,
8044
+ failureSubReason: failureSubReason
8029
8045
  }));
8030
8046
  }
8031
8047
  }, _callee2, null, [[5,, 8, 10]]);
@@ -9102,6 +9118,12 @@ var buildAssets = function buildAssets(chain, asset, feeAmount, isRelayAsset, _r
9102
9118
  assets.push(createAsset(version, asset.amount, localizeLocation(chain, asset.location)));
9103
9119
  return sortAssets(assets);
9104
9120
  };
9121
+ var resolveAssetCount = function resolveAssetCount(overriddenAsset, isRelayAsset) {
9122
+ if (overriddenAsset) {
9123
+ return Array.isArray(overriddenAsset) ? overriddenAsset.length : 1;
9124
+ }
9125
+ return isRelayAsset ? 1 : 2;
9126
+ };
9105
9127
  var DEFAULT_SYSTEM_ASSET_AMOUNT = '1';
9106
9128
  var resolveSystemAssetAmount = function resolveSystemAssetAmount(_ref2, isForFeeCalc, fees) {
9107
9129
  var systemAsset = _ref2.systemAsset;
@@ -9120,6 +9142,7 @@ var constructTypeAndThenCall = /*#__PURE__*/function () {
9120
9142
  options,
9121
9143
  sender,
9122
9144
  version,
9145
+ overriddenAsset,
9123
9146
  assetCount,
9124
9147
  refundInstruction,
9125
9148
  resolvedFees,
@@ -9133,8 +9156,8 @@ var constructTypeAndThenCall = /*#__PURE__*/function () {
9133
9156
  case 0:
9134
9157
  fees = _args.length > 1 && _args[1] !== undefined ? _args[1] : null;
9135
9158
  origin = context.origin, assetInfo = context.assetInfo, isSubBridge = context.isSubBridge, isRelayAsset = context.isRelayAsset, options = context.options;
9136
- sender = options.sender, version = options.version;
9137
- assetCount = isRelayAsset ? 1 : 2;
9159
+ sender = options.sender, version = options.version, overriddenAsset = options.overriddenAsset;
9160
+ assetCount = resolveAssetCount(overriddenAsset, isRelayAsset);
9138
9161
  refundInstruction = sender && !isSubBridge ? createRefundInstruction(origin.api, sender, version, assetCount) : null;
9139
9162
  resolvedFees = fees !== null && fees !== void 0 ? fees : {
9140
9163
  hopFees: 0n,
@@ -12152,7 +12175,7 @@ var Hydration = /*#__PURE__*/function (_Chain) {
12152
12175
  key: "transferPolkadotXCM",
12153
12176
  value: function () {
12154
12177
  var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(input) {
12155
- var destination, asset, feeAsset, overriddenAsset, api, isNativeAsset, isNativeFeeAsset, isMoonbeamWhAsset, _t;
12178
+ var destination, asset, feeAsset, overriddenAsset, api, isNativeAsset, isNativeFeeAsset, _t;
12156
12179
  return _regenerator().w(function (_context) {
12157
12180
  while (1) switch (_context.n) {
12158
12181
  case 0:
@@ -12185,8 +12208,7 @@ var Hydration = /*#__PURE__*/function (_Chain) {
12185
12208
  case 3:
12186
12209
  return _context.a(2, _t.deserializeExtrinsics.call(_t, _context.v));
12187
12210
  case 4:
12188
- isMoonbeamWhAsset = hasJunction(asset.location, 'Parachain', getParaId('Moonbeam')) && hasJunction(asset.location, 'PalletInstance', 110);
12189
- if (!(isMoonbeamWhAsset && destination === 'Moonbeam')) {
12211
+ if (!(isMoonbeamWhAsset(asset.location) && destination === 'Moonbeam')) {
12190
12212
  _context.n = 5;
12191
12213
  break;
12192
12214
  }
@@ -12208,8 +12230,8 @@ var Hydration = /*#__PURE__*/function (_Chain) {
12208
12230
  version = input.version;
12209
12231
  var glmr = findAssetInfoOrThrow(this.chain, {
12210
12232
  symbol: getNativeAssetSymbol('Moonbeam')
12211
- }, null);
12212
- var FEE_AMOUNT = 80000000000000000n; // 0.08 GLMR
12233
+ });
12234
+ var FEE_AMOUNT = 150000000000000000n; // 0.15 GLMR
12213
12235
  return transferPolkadotXcm(_objectSpread2(_objectSpread2({}, input), {}, {
12214
12236
  overriddenAsset: [_objectSpread2(_objectSpread2({}, createAsset(version, FEE_AMOUNT, glmr.location)), {}, {
12215
12237
  isFeeAsset: true
@@ -14214,4 +14236,4 @@ var createClientCache = function createClientCache(maxSize, pingClient, onEvicti
14214
14236
  };
14215
14237
  };
14216
14238
 
14217
- export { API_TYPES, AmountTooLowError, ApiNotInitializedError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, DEFAULT_TTL_MS, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETH_MAINNET_CHAIN_ID, ETH_TESTNET_CHAIN_ID, EXCHANGE_CHAINS, EXTENSION_MS, ExtensionNotInstalledError, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MAX_CLIENTS, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotApi, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiUnavailableError, ScenarioNotSupportedError, SubmitTransactionError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertHasId, assertSender, assertSenderSource, assertSwapSupport, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, compareAddresses, computeOverridenAmount, constructTypeAndThenCall, convertBuilderConfig, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createClientCache, createClientPoolHelpers, createDestination, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createId, createRouterBuilder, createTransfer, createTransferOrSwap, createTransferOrSwapAll, createTxOverrideAmount, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, executeWithRouter, formatAssetIdToERC20, formatUnits, getAssetBalanceInternal, getAssetReserveChain, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getEthErc20Balance, getEvmPrivateKeyHex, getFailureInfo$1 as getFailureInfo, getLocalTransferAmount, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginXcmFee, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getSwapExtensionOrThrow, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, isSenderSigner, keyFromWs, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, normalizeExchange, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickRouterCompatibleXcmVersion, registerSwapExtension, resolveChainApi, resolveDestChain, resolveModuleError, resolveParaId, resolveTransferParams, reverseTransformLocation, selectXcmVersion, sortAssets, throwUnsupportedCurrency, transferMoonbeamEvm, transferMoonbeamToEth, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateTransact, verifyEdOnDestination, wrapTxBypass };
14239
+ export { API_TYPES, AmountTooLowError, ApiNotInitializedError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, DEFAULT_TTL_MS, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETH_MAINNET_CHAIN_ID, ETH_TESTNET_CHAIN_ID, EXCHANGE_CHAINS, EXTENSION_MS, ExtensionNotInstalledError, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MAX_CLIENTS, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotApi, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiUnavailableError, ScenarioNotSupportedError, SubmitTransactionError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertHasId, assertSender, assertSenderSource, assertSwapSupport, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, compareAddresses, computeOverridenAmount, constructTypeAndThenCall, convertBuilderConfig, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createClientCache, createClientPoolHelpers, createDestination, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createId, createRouterBuilder, createTransfer, createTransferOrSwap, createTransferOrSwapAll, createTxOverrideAmount, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, executeWithRouter, formatAssetIdToERC20, formatUnits, getAssetBalanceInternal, getAssetReserveChain, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getEthErc20Balance, getEvmPrivateKeyHex, getFailureInfo$1 as getFailureInfo, getLocalTransferAmount, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginXcmFee, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getSwapExtensionOrThrow, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, isSenderSigner, keyFromWs, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, normalizeExchange, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickRouterCompatibleXcmVersion, registerSwapExtension, resolveAssetCount, resolveChainApi, resolveDestChain, resolveModuleError, resolveParaId, resolveTransferParams, reverseTransformLocation, selectXcmVersion, sortAssets, throwUnsupportedCurrency, transferMoonbeamEvm, transferMoonbeamToEth, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateTransact, verifyEdOnDestination, wrapTxBypass };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-core",
3
- "version": "13.0.1",
3
+ "version": "13.1.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": "^2.0.1",
27
27
  "@scure/base": "^2.0.0",
28
28
  "viem": "^2.47.6",
29
- "@paraspell/assets": "13.0.1",
30
- "@paraspell/pallets": "13.0.1",
31
- "@paraspell/sdk-common": "13.0.1"
29
+ "@paraspell/pallets": "13.1.0",
30
+ "@paraspell/sdk-common": "13.1.0",
31
+ "@paraspell/assets": "13.1.0"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "@paraspell/swap": "13.0.0"