@paraspell/sdk-core 14.5.0 → 14.5.2

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
@@ -93,6 +93,7 @@ declare abstract class PolkadotApi<TApi, TRes, TSigner, TCustomChain extends str
93
93
  localizeLocation(chain: TChain | TCustomChain, location: TLocation, origin?: TChain | TCustomChain): TLocation;
94
94
  getAssetReserveChain(chain: TSubstrateChain | TCustomChain, assetLocation: TLocation, resolveExternalReserve?: boolean): TChain | TCustomChain;
95
95
  isAssetXcEqual(a: TChainAssetInfo<TCustomChain>, b: TChainAssetInfo<TCustomChain>): boolean;
96
+ dispatchAs(call: TRes, origin: TDispatchOrigin): TRes;
96
97
  init(chain: TChain | TCustomChain, clientTtlMs?: number, destination?: TDestination): Promise<void>;
97
98
  setCustomCtx(ctx: TFullCustomCtx): void;
98
99
  protected resetChain(): void;
@@ -107,7 +108,6 @@ declare abstract class PolkadotApi<TApi, TRes, TSigner, TCustomChain extends str
107
108
  abstract queryState<T>(serialized: TSerializedStateQuery): Promise<T>;
108
109
  abstract queryRuntimeApi<T>(serialized: TSerializedRuntimeApiQuery): Promise<T>;
109
110
  abstract callBatchMethod(calls: TRes[], mode: BatchMode): TRes;
110
- abstract callDispatchAsMethod(call: TRes, address: string): TRes;
111
111
  abstract objectToHex(obj: unknown, typeName: string, version: Version): Promise<string>;
112
112
  abstract hexToUint8a(hex: string): Uint8Array;
113
113
  abstract stringToUint8a(str: string): Uint8Array;
@@ -525,6 +525,7 @@ declare class Xode<TApi, TRes, TSigner, TCustomChain extends string = never> ext
525
525
  constructor();
526
526
  transferPolkadotXCM(options: TPolkadotXCMTransferOptions<TApi, TRes, TSigner, TCustomChain>): Promise<TRes>;
527
527
  canReceiveFrom<TCustomChain extends string = never>(origin: TChain | TCustomChain): boolean;
528
+ protected getMintConfig(): TMintConfig;
528
529
  transferLocalNonNativeAsset(options: TTransferLocalOptions<TApi, TRes, TSigner, TCustomChain>): TRes;
529
530
  }
530
531
 
@@ -1769,7 +1770,7 @@ type TBuildOriginInfoOptions<TApi, TRes, TSigner, TCustomChain extends string =
1769
1770
  amount: bigint;
1770
1771
  originFee: bigint;
1771
1772
  originFeeAsset: TAssetInfo;
1772
- isFeeAssetAh: boolean;
1773
+ isOriginFeeAsset: boolean;
1773
1774
  };
1774
1775
  type BuildHopInfoOptions<TApi, TRes, TSigner, TCustomChain extends string = never> = {
1775
1776
  api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>;
@@ -1788,7 +1789,7 @@ type TBuildDestInfoOptions<TApi, TRes, TSigner, TCustomChain extends string = ne
1788
1789
  recipient: string;
1789
1790
  currency: WithAmount<TSingleCurrencyInput>;
1790
1791
  originFee: bigint;
1791
- isFeeAssetAh: boolean;
1792
+ isOriginFeeAsset: boolean;
1792
1793
  paysDestFee: boolean;
1793
1794
  destFeeDetail: TXcmFeeDetail;
1794
1795
  totalHopFee: bigint;
@@ -1914,7 +1915,6 @@ type TTypeAndThenFees = {
1914
1915
  destFee: bigint;
1915
1916
  };
1916
1917
  type TTypeAndThenOverrides = {
1917
- reserveChain?: TSubstrateChain;
1918
1918
  noFeeAsset?: boolean;
1919
1919
  };
1920
1920
 
@@ -2175,9 +2175,16 @@ type TCreateEthBridgeInstructionsOptions<TApi, TRes, TSigner, TCustomChain exten
2175
2175
  version: Version;
2176
2176
  };
2177
2177
 
2178
+ type TDispatchOrigin = {
2179
+ type: 'signed';
2180
+ address: string;
2181
+ } | {
2182
+ type: 'treasuryCouncil';
2183
+ };
2178
2184
  type TSetBalanceRes = {
2179
2185
  assetStatusTx?: TSerializedExtrinsics;
2180
2186
  balanceTx: TSerializedExtrinsics;
2187
+ forceOrigin?: TDispatchOrigin;
2181
2188
  };
2182
2189
  type TChainAssetInfo<TCustomChain extends string = never> = {
2183
2190
  chain: TChain | TCustomChain;
@@ -2192,6 +2199,7 @@ type TMintConfig = {
2192
2199
  useLocationId?: boolean;
2193
2200
  useBigIntId?: boolean;
2194
2201
  useCustomCurrencyId?: boolean;
2202
+ forceOrigin?: TDispatchOrigin;
2195
2203
  };
2196
2204
  declare abstract class BaseAssetsPallet {
2197
2205
  protected palletName: TAssetsPallet;
@@ -2383,7 +2391,7 @@ declare const aggregateHopFees: (hops: TXcmFeeHopInfo[], matchAsset: TAssetInfo)
2383
2391
  bridgeFee?: bigint;
2384
2392
  };
2385
2393
 
2386
- declare const buildDestInfo: <TApi, TRes, TSigner, TCustomChain extends string = never>({ api, origin, destination, recipient, currency, originFee, isFeeAssetAh, paysDestFee, destFeeDetail, totalHopFee, bridgeFee }: TBuildDestInfoOptions<TApi, TRes, TSigner, TCustomChain>) => Promise<{
2394
+ declare const buildDestInfo: <TApi, TRes, TSigner, TCustomChain extends string = never>({ api, origin, destination, recipient, currency, originFee, isOriginFeeAsset, paysDestFee, destFeeDetail, totalHopFee, bridgeFee }: TBuildDestInfoOptions<TApi, TRes, TSigner, TCustomChain>) => Promise<{
2387
2395
  receivedCurrency: {
2388
2396
  sufficient: boolean | UnableToComputeError;
2389
2397
  receivedAmount: bigint | UnableToComputeError;
@@ -2407,7 +2415,7 @@ declare const buildHopInfo: <TApi, TRes, TSigner, TCustomChain extends string =
2407
2415
  };
2408
2416
  }>;
2409
2417
 
2410
- declare const buildOriginInfo: <TApi, TRes, TSigner, TCustomChain extends string = never>({ api, origin, sender, assets, amount, originFee, originFeeAsset, isFeeAssetAh }: TBuildOriginInfoOptions<TApi, TRes, TSigner, TCustomChain>) => Promise<{
2418
+ declare const buildOriginInfo: <TApi, TRes, TSigner, TCustomChain extends string = never>({ api, origin, sender, assets, amount, originFee, originFeeAsset, isOriginFeeAsset }: TBuildOriginInfoOptions<TApi, TRes, TSigner, TCustomChain>) => Promise<{
2411
2419
  selectedCurrency: TSelectedCurrencyInfo[];
2412
2420
  xcmFee: TOriginXcmFeeInfo;
2413
2421
  }>;
@@ -2427,13 +2435,6 @@ declare const constructTypeAndThenCall: <TApi, TRes, TSigner, TCustomChain exten
2427
2435
  */
2428
2436
  declare const createTypeAndThenCall: <TApi, TRes, TSigner, TCustomChain extends string = never>(options: TPolkadotXCMTransferOptions<TApi, TRes, TSigner, TCustomChain>, overrides?: TTypeAndThenOverrides) => Promise<TSerializedExtrinsics>;
2429
2437
 
2430
- /**
2431
- * Creates a type-and-then call but auto-selects the asset reserve between AssetHub and the Relay chain
2432
- * by dry-running both variants and preferring the one that succeeds. If both fail, returns the
2433
- * AssetHub variant. Supports only relaychain assets.
2434
- */
2435
- declare const createTypeThenAutoReserve: <TApi, TRes, TSigner>(chain: TSubstrateChain, options: TPolkadotXCMTransferOptions<TApi, TRes, TSigner>) => Promise<TSerializedExtrinsics>;
2436
-
2437
2438
  declare const validateCurrency: (currency: TCurrencyInput, feeAsset?: TCurrencyInput) => void;
2438
2439
  declare const validateFeeAssetSupport: (assetInfo: TAssetInfo, feeAsset: TAssetInfo | undefined, overriddenAsset: TAssetWithFee[] | undefined, method: string) => void;
2439
2440
  declare const validateDestination: <TApi, TRes, TSigner, TCustomChain extends string = never>(origin: TSubstrateChain | TCustomChain, destination: TDestination, api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>) => void;
@@ -2638,5 +2639,5 @@ declare const selectXcmVersion: (forcedVersion: Version | undefined, originVersi
2638
2639
  declare const pickCompatibleXcmVersion: <TApi, TRes, TSigner, TCustomChain extends string = never>(api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, origin: TSubstrateChain | TCustomChain, destination: TDestination, override?: Version) => Version;
2639
2640
  declare const pickRouterCompatibleXcmVersion: <TApi, TRes, TSigner, TCustomChain extends string = never>(api: PolkadotApi<TApi, TRes, TSigner, TCustomChain>, origin: TSubstrateChain | undefined, exchangeChain: TSubstrateChain, destination: TChain | undefined) => Version;
2640
2641
 
2641
- export { API_TYPES, AmountTooLowError, ApiNotInitializedError, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, CustomChainConflictError, CustomChainInvalidError, 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, RuntimeApiError, RuntimeApiUnavailableError, ScenarioNotSupportedError, SubmitTransactionError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, aggregateHopFees, applyDecimalAbstraction, assertAddressIsString, assertCurrencyCore, assertEvmAddress, assertExtensionInstalled, assertHasId, assertNotEvmTransfer, assertSender, assertSenderSource, assertSubstrateOrigin, assertSwapSupport, assertToIsString, blake2128Concat, blake2b256, blake2b512, buildCustomChainAssetsInfo, buildCustomChainConfig, buildDestInfo, buildDryRunError, buildErc20StorageMint, buildHopInfo, buildOriginInfo, calcPreviewMintAmount, calcSentAssetPreviewMint, compareAddresses, compareLocationOrder, computeOverridenAmount, constructTypeAndThenCall, convertBuilderConfig, convertSs58, createAllCountedFilter, createAsset, createAssetId, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createBridgedXcmPrefix, createChainClient, createClientCache, createClientPoolHelpers, createCustomXcmOnDest, createDestination, createDirectExecuteXcm, createEthereumBridgeInstructions, createExecuteCall, createSwapBuilder, createTransfer, createTransferOrSwap, createTransferOrSwapAll, createTxOverrideAmount, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, executeWithSwap, formatAssetIdToERC20, formatUnits, generateMessageId, getAssetBalanceInternal, getAssetReserveChain, getAssetReserveChainImpl, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainConfigImpl, getChainLocation, getChainProviders, getChainProvidersImpl, getChainVersion, getDryRunError, getErrorInstruction, getEthErc20Balance, getEvmExtensionOrThrow, getEvmPrivateKeyHex, getEvmSnowbridgeExtensionOrThrow, getLocalTransferAmount, getMinTransferableAmount, getMinTransferableAmountInternal, getOriginXcmFee, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getParaIdImpl, getRelayChainOf, getRelayChainOfImpl, getRelayChainSymbolOf, getSwapExtensionOrThrow, getTChain, getTSubstrateChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, isAssetXcEqualImpl, isConfig, isExchange, isNativeAssetTeleport, isSenderSigner, isViemSigner, keyFromWs, localizeLocation, localizeLocationImpl, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, normalizeCustomChains, normalizeExchange, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickOtherMintPallet, pickRouterCompatibleXcmVersion, registerEvmExtension, registerEvmSnowbridgeExtension, registerSwapExtension, resolveAssetCount, resolveDestChain, resolveModuleError, resolveParaId, resolveTransferParams, reverseTransformLocation, selectXcmVersion, sortAssets, throwUnsupportedCurrency, toLeHex, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateFeeAssetSupport, validateTransact, verifyEdOnDestination, wrapTxBypass };
2642
- export type { BuildHopInfoOptions, ClientCache, HopProcessParams, HopTraversalConfig, HopTraversalResult, IPolkadotXCMTransfer, IXTokensTransfer, OneKey, TAddress, TApiOrUrl, TApiType, TAssetState, TBatchOptions, TBatchedTransferOptions, TBifrostToken, TBridgeStatus, TBridgedXcmParams, TBuildAllInternalRes, TBuildDestInfoOptions, TBuildEvmTransferOptions, TBuildInternalRes, TBuildInternalResBase, TBuildOriginInfoOptions, TBuilderConfig, TBuilderInternalOptions, TBuilderOptions, TBypassOptions, TCacheItem, TChainAssetInfo, TChainConfig, TChainConfigMap, TChainWithApi, TClientEntry, TClientKey, TConditionalXcmFeeDetail, TConditionalXcmFeeHopInfo, TCreateBaseSwapXcmOptions, TCreateBaseTransferXcmOptions, TCreateBeneficiaryOptions, TCreateBeneficiaryXTokensOptions, TCreateEthBridgeInstructionsOptions, TCreateSwapXcmInternalOptions, TCreateSwapXcmOptions, TCreateTransferXcmOptions, TCreateTxsOptions, TCustomChainEntry, TCustomChainEntryHydrated, TCustomChainFrom, TCustomChainInput, TCustomChainPalletsInput, TCustomChainsCtx, TCustomChainsMap, TDestWeight, TDestination, TDryRunBaseOptions, TDryRunBypassOptions, TDryRunCallBaseOptions, TDryRunCallOptions, TDryRunChainFailure, TDryRunChainKind, TDryRunChainResult, TDryRunChainSuccess, TDryRunError, TDryRunFailure, TDryRunOptions, TDryRunPreviewOptions, TDryRunResBase, TDryRunResult, TDryRunXcmBaseOptions, TDryRunXcmOptions, TEvmExtension, TEvmSnowbridgeExtension, TEvmTransferOptions, TEvmTransferOptionsBase, TExchangeChain, TExchangeInput, TFeeType, TForeignAssetId, TForeignOrNativeAsset, TForeignOrTokenAsset, TFullCustomCtx, TGetAssetBalanceOptions, TGetAssetBalanceOptionsBase, TGetBalanceCommonOptions, TGetBalanceOptions, TGetBalanceOptionsBase, TGetFeeForDestChainBaseOptions, TGetFeeForDestChainOptions, TGetMinTransferableAmountOptions, TGetOriginXcmFeeBaseOptions, TGetOriginXcmFeeInternalOptions, TGetOriginXcmFeeOptions, TGetReverseTxFeeOptions, TGetTransferInfoOptions, TGetTransferInfoOptionsBase, TGetTransferableAmountOptions, TGetTransferableAmountOptionsBase, TGetXcmFeeBaseOptions, TGetXcmFeeBuilderOptions, TGetXcmFeeInternalOptions, TGetXcmFeeOptions, TGetXcmFeeResult, THopInfo, THopTransferInfo, TMintConfig, TModuleError, TNativeTokenAsset, TOriginFeeDetails, TOriginXcmFeeInfo, TOtherReserveAsset, TPalletAssetId, TPaymentInfo, TPerAssetResult, TPolkadotXCMTransferOptions, TPolkadotXcmMethod, TProviderEntry, TQueriedAmount, TReceivedCurrencyInfo, TReserveAsset, TResolveEdDepositOptions, TResolveHopParams, TResolvedCurrency, TRuntimeApi, TScenario, TSelectedCurrencyInfo, TSelfReserveAsset, TSender, TSerializedExtrinsics, TSerializedRuntimeApiQuery, TSerializedStateQuery, TSetBalanceRes, TStatusChangeCallback, TSubstrateTransferBaseOptions, TSubstrateTransferBaseOptionsWithSender, TSubstrateTransferOptions, TSwapBuilder, TSwapBuilderFactory, TSwapConfig, TSwapEvent, TSwapEventType, TSwapExtension, TSwapFeeEstimates, TSwapOptions, TSystemProperties, 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, TXcmFeeDetailWithForwardedXcm, TXcmFeeHopInfo, TXcmFeeHopResult, TXcmFeeSwapConfig, TXcmForeignAsset, TXcmVersioned, WithApi, WithRequiredSender, WithRequiredSwapOptions };
2642
+ export { API_TYPES, AmountTooLowError, ApiNotInitializedError, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, CustomChainConflictError, CustomChainInvalidError, 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, RuntimeApiError, RuntimeApiUnavailableError, ScenarioNotSupportedError, SubmitTransactionError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, aggregateHopFees, applyDecimalAbstraction, assertAddressIsString, assertCurrencyCore, assertEvmAddress, assertExtensionInstalled, assertHasId, assertNotEvmTransfer, assertSender, assertSenderSource, assertSubstrateOrigin, assertSwapSupport, assertToIsString, blake2128Concat, blake2b256, blake2b512, buildCustomChainAssetsInfo, buildCustomChainConfig, buildDestInfo, buildDryRunError, buildErc20StorageMint, buildHopInfo, buildOriginInfo, calcPreviewMintAmount, calcSentAssetPreviewMint, compareAddresses, compareLocationOrder, computeOverridenAmount, constructTypeAndThenCall, convertBuilderConfig, convertSs58, createAllCountedFilter, createAsset, createAssetId, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createBridgedXcmPrefix, createChainClient, createClientCache, createClientPoolHelpers, createCustomXcmOnDest, createDestination, createDirectExecuteXcm, createEthereumBridgeInstructions, createExecuteCall, createSwapBuilder, createTransfer, createTransferOrSwap, createTransferOrSwapAll, createTxOverrideAmount, createTypeAndThenCall, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, executeWithSwap, formatAssetIdToERC20, formatUnits, generateMessageId, getAssetBalanceInternal, getAssetReserveChain, getAssetReserveChainImpl, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainConfigImpl, getChainLocation, getChainProviders, getChainProvidersImpl, getChainVersion, getDryRunError, getErrorInstruction, getEthErc20Balance, getEvmExtensionOrThrow, getEvmPrivateKeyHex, getEvmSnowbridgeExtensionOrThrow, getLocalTransferAmount, getMinTransferableAmount, getMinTransferableAmountInternal, getOriginXcmFee, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getParaIdImpl, getRelayChainOf, getRelayChainOfImpl, getRelayChainSymbolOf, getSwapExtensionOrThrow, getTChain, getTSubstrateChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, isAssetXcEqualImpl, isConfig, isExchange, isNativeAssetTeleport, isSenderSigner, isViemSigner, keyFromWs, localizeLocation, localizeLocationImpl, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, normalizeCustomChains, normalizeExchange, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickOtherMintPallet, pickRouterCompatibleXcmVersion, registerEvmExtension, registerEvmSnowbridgeExtension, registerSwapExtension, resolveAssetCount, resolveDestChain, resolveModuleError, resolveParaId, resolveTransferParams, reverseTransformLocation, selectXcmVersion, sortAssets, throwUnsupportedCurrency, toLeHex, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateFeeAssetSupport, validateTransact, verifyEdOnDestination, wrapTxBypass };
2643
+ export type { BuildHopInfoOptions, ClientCache, HopProcessParams, HopTraversalConfig, HopTraversalResult, IPolkadotXCMTransfer, IXTokensTransfer, OneKey, TAddress, TApiOrUrl, TApiType, TAssetState, TBatchOptions, TBatchedTransferOptions, TBifrostToken, TBridgeStatus, TBridgedXcmParams, TBuildAllInternalRes, TBuildDestInfoOptions, TBuildEvmTransferOptions, TBuildInternalRes, TBuildInternalResBase, TBuildOriginInfoOptions, TBuilderConfig, TBuilderInternalOptions, TBuilderOptions, TBypassOptions, TCacheItem, TChainAssetInfo, TChainConfig, TChainConfigMap, TChainWithApi, TClientEntry, TClientKey, TConditionalXcmFeeDetail, TConditionalXcmFeeHopInfo, TCreateBaseSwapXcmOptions, TCreateBaseTransferXcmOptions, TCreateBeneficiaryOptions, TCreateBeneficiaryXTokensOptions, TCreateEthBridgeInstructionsOptions, TCreateSwapXcmInternalOptions, TCreateSwapXcmOptions, TCreateTransferXcmOptions, TCreateTxsOptions, TCustomChainEntry, TCustomChainEntryHydrated, TCustomChainFrom, TCustomChainInput, TCustomChainPalletsInput, TCustomChainsCtx, TCustomChainsMap, TDestWeight, TDestination, TDispatchOrigin, TDryRunBaseOptions, TDryRunBypassOptions, TDryRunCallBaseOptions, TDryRunCallOptions, TDryRunChainFailure, TDryRunChainKind, TDryRunChainResult, TDryRunChainSuccess, TDryRunError, TDryRunFailure, TDryRunOptions, TDryRunPreviewOptions, TDryRunResBase, TDryRunResult, TDryRunXcmBaseOptions, TDryRunXcmOptions, TEvmExtension, TEvmSnowbridgeExtension, TEvmTransferOptions, TEvmTransferOptionsBase, TExchangeChain, TExchangeInput, TFeeType, TForeignAssetId, TForeignOrNativeAsset, TForeignOrTokenAsset, TFullCustomCtx, TGetAssetBalanceOptions, TGetAssetBalanceOptionsBase, TGetBalanceCommonOptions, TGetBalanceOptions, TGetBalanceOptionsBase, TGetFeeForDestChainBaseOptions, TGetFeeForDestChainOptions, TGetMinTransferableAmountOptions, TGetOriginXcmFeeBaseOptions, TGetOriginXcmFeeInternalOptions, TGetOriginXcmFeeOptions, TGetReverseTxFeeOptions, TGetTransferInfoOptions, TGetTransferInfoOptionsBase, TGetTransferableAmountOptions, TGetTransferableAmountOptionsBase, TGetXcmFeeBaseOptions, TGetXcmFeeBuilderOptions, TGetXcmFeeInternalOptions, TGetXcmFeeOptions, TGetXcmFeeResult, THopInfo, THopTransferInfo, TMintConfig, TModuleError, TNativeTokenAsset, TOriginFeeDetails, TOriginXcmFeeInfo, TOtherReserveAsset, TPalletAssetId, TPaymentInfo, TPerAssetResult, TPolkadotXCMTransferOptions, TPolkadotXcmMethod, TProviderEntry, TQueriedAmount, TReceivedCurrencyInfo, TReserveAsset, TResolveEdDepositOptions, TResolveHopParams, TResolvedCurrency, TRuntimeApi, TScenario, TSelectedCurrencyInfo, TSelfReserveAsset, TSender, TSerializedExtrinsics, TSerializedRuntimeApiQuery, TSerializedStateQuery, TSetBalanceRes, TStatusChangeCallback, TSubstrateTransferBaseOptions, TSubstrateTransferBaseOptionsWithSender, TSubstrateTransferOptions, TSwapBuilder, TSwapBuilderFactory, TSwapConfig, TSwapEvent, TSwapEventType, TSwapExtension, TSwapFeeEstimates, TSwapOptions, TSystemProperties, 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, TXcmFeeDetailWithForwardedXcm, TXcmFeeHopInfo, TXcmFeeHopResult, TXcmFeeSwapConfig, TXcmForeignAsset, TXcmVersioned, 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, isAssetEqual, isSymbolMatch, isStableCoinAsset, isAdditionalSubstrateBridgeAsset, isBridgedSystemAsset, STABLECOIN_IDS, isSymbolSpecifier, normalizeLocation, getNativeAssetSymbol, extractAssetLocation, hasDryRunSupport, normalizeSymbol, Native, getOtherAssets, canonicalizeLocation, getAssetsObjectImpl, getAssetsImpl, getNativeAssetsImpl, getOtherAssetsImpl, findAssetInfoImpl, findAssetInfoOrThrowImpl, findAssetInfoOnDestImpl, findAssetOnDestOrThrowImpl, findNativeAssetInfoImpl, findNativeAssetInfoOrThrowImpl, isChainEvmImpl, getNativeAssetSymbolImpl, getRelayChainSymbolImpl, hasDryRunSupportImpl, hasXcmPaymentApiSupportImpl, getExistentialDepositImpl, normalizeCustomAssets } from '@paraspell/assets';
2
+ import { isChainEvm, getAssetsObject, InvalidCurrencyError, isAssetEqual, isSymbolMatch, isStableCoinAsset, isAdditionalSubstrateBridgeAsset, isBridgedSystemAsset, STABLECOIN_IDS, isSymbolSpecifier, normalizeLocation, getNativeAssetSymbol, extractAssetLocation, normalizeSymbol, Native, getOtherAssets, canonicalizeLocation, getAssetsObjectImpl, getAssetsImpl, getNativeAssetsImpl, getOtherAssetsImpl, findAssetInfoImpl, findAssetInfoOrThrowImpl, findAssetInfoOnDestImpl, findAssetOnDestOrThrowImpl, findNativeAssetInfoImpl, findNativeAssetInfoOrThrowImpl, isChainEvmImpl, getNativeAssetSymbolImpl, getRelayChainSymbolImpl, hasDryRunSupportImpl, hasXcmPaymentApiSupportImpl, getExistentialDepositImpl, normalizeCustomAssets } from '@paraspell/assets';
3
3
  export * from '@paraspell/assets';
4
4
  import { base58 } from '@scure/base';
5
5
  import { isAddress, isHex, createPublicClient, http, formatUnits as formatUnits$1, parseUnits as parseUnits$1, stringToHex, numberToBytes } from 'viem';
@@ -2232,6 +2232,7 @@ var AssetsPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
2232
2232
  is_frozen: false
2233
2233
  }
2234
2234
  },
2235
+ forceOrigin: config.forceOrigin,
2235
2236
  balanceTx: {
2236
2237
  module: this.palletName,
2237
2238
  method: 'mint',
@@ -3400,6 +3401,13 @@ var supportsFeeAssetPayment = function supportsFeeAssetPayment(chain) {
3400
3401
  return chain === 'AssetHubPolkadot' || chain.startsWith('Hydration');
3401
3402
  };
3402
3403
 
3404
+ var usesOriginFeeAsset = function usesOriginFeeAsset(api, origin, currency, assetInfo, feeAssetInfo, originFeeAsset) {
3405
+ return (
3406
+ // Hydration chain origin delivery fee is 0n so we need to handle it only for AssetHubPolkadot
3407
+ origin === 'AssetHubPolkadot' && !Array.isArray(currency) && !!feeAssetInfo && isAssetEqual(feeAssetInfo, assetInfo) && isAssetEqual(originFeeAsset, feeAssetInfo) && !isAssetEqual(feeAssetInfo, api.findNativeAssetInfoOrThrow(origin))
3408
+ );
3409
+ };
3410
+
3403
3411
  var validateCurrency = function validateCurrency(currency, feeAsset) {
3404
3412
  if (Array.isArray(currency)) {
3405
3413
  if (currency.length === 0) {
@@ -6452,10 +6460,18 @@ var createOptionalMintTxs = function createOptionalMintTxs(chain, currency, amou
6452
6460
  amount: amount
6453
6461
  }), balance, address, api);
6454
6462
  };
6463
+ var toTxWithOrigin = function toTxWithOrigin(api, tx, origin) {
6464
+ var call = api.deserializeExtrinsics(tx);
6465
+ return origin ? api.dispatchAs(call, origin) : call;
6466
+ };
6455
6467
  var resultToExtrinsics = function resultToExtrinsics(api, address, _ref) {
6456
6468
  var assetStatusTx = _ref.assetStatusTx,
6457
- balanceTx = _ref.balanceTx;
6458
- return [].concat(_toConsumableArray(assetStatusTx ? [api.deserializeExtrinsics(assetStatusTx)] : []), _toConsumableArray(assetStatusTx ? [api.callDispatchAsMethod(api.deserializeExtrinsics(balanceTx), address)] : [api.deserializeExtrinsics(balanceTx)]));
6469
+ balanceTx = _ref.balanceTx,
6470
+ forceOrigin = _ref.forceOrigin;
6471
+ return [].concat(_toConsumableArray(assetStatusTx ? [toTxWithOrigin(api, assetStatusTx, forceOrigin)] : []), [toTxWithOrigin(api, balanceTx, assetStatusTx ? {
6472
+ type: 'signed',
6473
+ address: address
6474
+ } : undefined)]);
6459
6475
  };
6460
6476
  var mintBonusForSent = function mintBonusForSent(chain, sent, feeAsset, mintFeeAssets, api) {
6461
6477
  if (!mintFeeAssets) return 0n;
@@ -6608,7 +6624,10 @@ var wrapTxBypass = /*#__PURE__*/function () {
6608
6624
  mintAssetResults = _context2.v;
6609
6625
  return _context2.a(2, api.callBatchMethod([].concat(_toConsumableArray([mintNativeAssetRes, mintRelayAssetRes, mintFeeAssetRes].concat(_toConsumableArray(mintAssetResults)).flatMap(function (tx) {
6610
6626
  return tx ? resultToExtrinsics(api, address, tx) : [];
6611
- })), [api.callDispatchAsMethod(tx, address)]), BatchMode.BATCH_ALL));
6627
+ })), [api.dispatchAs(tx, {
6628
+ type: 'signed',
6629
+ address: address
6630
+ })]), BatchMode.BATCH_ALL));
6612
6631
  }
6613
6632
  }, _callee2);
6614
6633
  }));
@@ -6977,15 +6996,192 @@ var getOriginXcmFee = /*#__PURE__*/function () {
6977
6996
  };
6978
6997
  }();
6979
6998
 
6999
+ var FEE_PADDING = 30;
7000
+ var sumHopFees = function sumHopFees(result, _ref) {
7001
+ var assetInfo = _ref.assetInfo,
7002
+ feeAssetInfo = _ref.feeAssetInfo,
7003
+ isRelayAsset = _ref.isRelayAsset,
7004
+ systemAsset = _ref.systemAsset,
7005
+ overriddenAsset = _ref.options.overriddenAsset;
7006
+ var feeAsset = isRelayAsset || overriddenAsset ? assetInfo : feeAssetInfo !== null && feeAssetInfo !== void 0 ? feeAssetInfo : systemAsset;
7007
+ return result.hops.reduce(function (acc, hop) {
7008
+ // only add if asset is equal
7009
+ return isAssetEqual(hop.result.asset, feeAsset) ? acc + hop.result.fee : acc;
7010
+ }, 0n);
7011
+ };
7012
+ var computeAllFees = /*#__PURE__*/function () {
7013
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, buildTx) {
7014
+ var origin, dest, feeAssetInfo, edDeposit, _context$options, sender, recipient, currency, feeCurrency, version, overriddenAsset, result, hopFees, destFee;
7015
+ return _regenerator().w(function (_context) {
7016
+ while (1) switch (_context.n) {
7017
+ case 0:
7018
+ origin = context.origin, dest = context.dest, feeAssetInfo = context.feeAssetInfo, edDeposit = context.edDeposit, _context$options = context.options, sender = _context$options.sender, recipient = _context$options.recipient, currency = _context$options.currency, feeCurrency = _context$options.feeCurrency, version = _context$options.version, overriddenAsset = _context$options.overriddenAsset;
7019
+ assertSender(sender);
7020
+ assertAddressIsString(recipient);
7021
+ if (origin.api.hasDryRunSupport(context.origin.chain)) {
7022
+ _context.n = 2;
7023
+ break;
7024
+ }
7025
+ if (!(feeAssetInfo || overriddenAsset)) {
7026
+ _context.n = 1;
7027
+ break;
7028
+ }
7029
+ throw new ScenarioNotSupportedError("Fee asset cannot be used on ".concat(origin.chain, " because it does not support dry run."));
7030
+ case 1:
7031
+ return _context.a(2, null);
7032
+ case 2:
7033
+ _context.n = 3;
7034
+ return getXcmFeeInternal({
7035
+ api: origin.api,
7036
+ buildTx: buildTx,
7037
+ origin: origin.chain,
7038
+ destination: dest.chain,
7039
+ sender: sender,
7040
+ recipient: recipient,
7041
+ version: version,
7042
+ currency: currency,
7043
+ feeAsset: feeCurrency,
7044
+ disableFallback: false,
7045
+ skipReverseFeeCalculation: true
7046
+ });
7047
+ case 3:
7048
+ result = _context.v;
7049
+ hopFees = sumHopFees(result, context);
7050
+ destFee = result.destination.fee;
7051
+ return _context.a(2, {
7052
+ hopFees: padValueBy(hopFees, FEE_PADDING),
7053
+ destFee: padValueBy(destFee, FEE_PADDING) + (edDeposit !== null && edDeposit !== void 0 ? edDeposit : 0n)
7054
+ });
7055
+ }
7056
+ }, _callee);
7057
+ }));
7058
+ return function computeAllFees(_x, _x2) {
7059
+ return _ref2.apply(this, arguments);
7060
+ };
7061
+ }();
7062
+
7063
+ var isAssetSufficient = /*#__PURE__*/function () {
7064
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, chain, asset) {
7065
+ var pallets, _state$isSufficient, state;
7066
+ return _regenerator().w(function (_context) {
7067
+ while (1) switch (_context.p = _context.n) {
7068
+ case 0:
7069
+ pallets = getOtherAssetsPallets(chain, api._customCtx);
7070
+ if (!(asset.isNative || pallets.length === 0)) {
7071
+ _context.n = 1;
7072
+ break;
7073
+ }
7074
+ return _context.a(2, true);
7075
+ case 1:
7076
+ _context.p = 1;
7077
+ _context.n = 2;
7078
+ return getPalletInstance(pickOtherMintPallet(asset, pallets)).getAssetState(api, asset);
7079
+ case 2:
7080
+ state = _context.v;
7081
+ return _context.a(2, (_state$isSufficient = state === null || state === void 0 ? void 0 : state.isSufficient) !== null && _state$isSufficient !== void 0 ? _state$isSufficient : true);
7082
+ case 3:
7083
+ _context.p = 3;
7084
+ _context.v;
7085
+ return _context.a(2, true);
7086
+ }
7087
+ }, _callee, null, [[1, 3]]);
7088
+ }));
7089
+ return function isAssetSufficient(_x, _x2, _x3) {
7090
+ return _ref.apply(this, arguments);
7091
+ };
7092
+ }();
7093
+
7094
+ var resolveEdDeposit = /*#__PURE__*/function () {
7095
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
7096
+ var _overriddenAsset$map;
7097
+ var origin, _ref$dest, destApi, destChain, assetInfo, overriddenAsset, feeAssetLocation, recipient, nativeAsset, nativeLocation, feeLocation, isFeeNative, _yield$destApi$queryS, providers, destAssets, sufficiency, ed, feeAmount;
7098
+ return _regenerator().w(function (_context) {
7099
+ while (1) switch (_context.n) {
7100
+ case 0:
7101
+ origin = _ref.origin, _ref$dest = _ref.dest, destApi = _ref$dest.api, destChain = _ref$dest.chain, assetInfo = _ref.assetInfo, overriddenAsset = _ref.overriddenAsset, feeAssetLocation = _ref.feeAssetLocation, recipient = _ref.recipient;
7102
+ if (!(isExternalChain(destChain) || typeof recipient !== 'string')) {
7103
+ _context.n = 1;
7104
+ break;
7105
+ }
7106
+ return _context.a(2, undefined);
7107
+ case 1:
7108
+ nativeAsset = destApi.findNativeAssetInfoOrThrow(destChain);
7109
+ nativeLocation = origin.api.localizeLocation(destChain, nativeAsset.location);
7110
+ feeLocation = origin.api.localizeLocation(destChain, feeAssetLocation, origin.chain);
7111
+ isFeeNative = deepEqual(feeLocation, nativeLocation);
7112
+ if (!(!isFeeNative && !destChain.startsWith('AssetHub'))) {
7113
+ _context.n = 2;
7114
+ break;
7115
+ }
7116
+ return _context.a(2, undefined);
7117
+ case 2:
7118
+ _context.n = 3;
7119
+ return destApi.queryState({
7120
+ module: 'System',
7121
+ method: 'Account',
7122
+ params: [recipient]
7123
+ });
7124
+ case 3:
7125
+ _yield$destApi$queryS = _context.v;
7126
+ providers = _yield$destApi$queryS.providers;
7127
+ if (!(providers > 0)) {
7128
+ _context.n = 4;
7129
+ break;
7130
+ }
7131
+ return _context.a(2, undefined);
7132
+ case 4:
7133
+ destAssets = ((_overriddenAsset$map = overriddenAsset === null || overriddenAsset === void 0 ? void 0 : overriddenAsset.map(function (asset) {
7134
+ return extractAssetLocation(asset);
7135
+ })) !== null && _overriddenAsset$map !== void 0 ? _overriddenAsset$map : [assetInfo.location]).map(function (location) {
7136
+ return origin.api.findAssetOnDestOrThrow(origin.chain, destChain, {
7137
+ location: location
7138
+ });
7139
+ });
7140
+ _context.n = 5;
7141
+ return Promise.all(destAssets.map(function (asset) {
7142
+ return isAssetSufficient(destApi, destChain, asset);
7143
+ }));
7144
+ case 5:
7145
+ sufficiency = _context.v;
7146
+ if (!sufficiency.every(Boolean)) {
7147
+ _context.n = 6;
7148
+ break;
7149
+ }
7150
+ return _context.a(2, undefined);
7151
+ case 6:
7152
+ ed = BigInt(nativeAsset.existentialDeposit);
7153
+ if (!isFeeNative) {
7154
+ _context.n = 7;
7155
+ break;
7156
+ }
7157
+ return _context.a(2, ed);
7158
+ case 7:
7159
+ _context.n = 8;
7160
+ return destApi.queryRuntimeApi({
7161
+ module: 'AssetConversionApi',
7162
+ method: 'quote_price_tokens_for_exact_tokens',
7163
+ params: [feeLocation, nativeLocation, ed, true]
7164
+ });
7165
+ case 8:
7166
+ feeAmount = _context.v;
7167
+ return _context.a(2, feeAmount == null ? undefined : padValueBy(BigInt(feeAmount), FEE_PADDING));
7168
+ }
7169
+ }, _callee);
7170
+ }));
7171
+ return function resolveEdDeposit(_x) {
7172
+ return _ref2.apply(this, arguments);
7173
+ };
7174
+ }();
7175
+
6980
7176
  var getXcmFeeOnce = /*#__PURE__*/function () {
6981
7177
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
6982
- var api, tx, origin, destination, sender, recipient, currency, feeAsset, version, disableFallback, swapConfig, useRootOrigin, skipReverseFeeCalculation, resolvedFeeAsset, _resolveCurrency, asset, resolvedVersion, _yield$getOriginXcmFe, originFeeRaw, originAsset, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, isMythosToEthereum, originFee, destApi, destFeeRes, _result, _dryRunError, processHop, traversalResult, destFee, destAsset, destFeeType, destDryRunError, destSufficient, destResult, _destApi, destFallback, relayChain, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, bridgeHubHopIndex, convertToFeeDetail, result, dryRunError, _t, _t2, _t3, _t4;
7178
+ var api, tx, origin, destination, sender, recipient, currency, feeAsset, version, disableFallback, swapConfig, useRootOrigin, skipReverseFeeCalculation, resolvedFeeAsset, _resolveCurrency, asset, assets, resolvedVersion, _yield$getOriginXcmFe, originFeeRaw, originAsset, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, isMythosToEthereum, originFee, destApi, destFeeRes, _result, _dryRunError, processHop, traversalResult, destFee, destAsset, destFeeType, destDryRunError, destSufficient, destResult, _destApi, destFallback, relayChain, bridgeHubChain, assetHubChain, bridgeHubHop, processedBridgeHub, bridgeHubHopIndex, convertToFeeDetail, result, dryRunError, _t, _t2, _t3, _t4;
6983
7179
  return _regenerator().w(function (_context2) {
6984
7180
  while (1) switch (_context2.p = _context2.n) {
6985
7181
  case 0:
6986
7182
  api = _ref.api, tx = _ref.tx, origin = _ref.origin, destination = _ref.destination, sender = _ref.sender, recipient = _ref.recipient, currency = _ref.currency, feeAsset = _ref.feeAsset, version = _ref.version, disableFallback = _ref.disableFallback, swapConfig = _ref.swapConfig, useRootOrigin = _ref.useRootOrigin, skipReverseFeeCalculation = _ref.skipReverseFeeCalculation;
6987
7183
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(api, feeAsset, origin, destination, currency) : undefined;
6988
- _resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination), asset = _resolveCurrency.asset;
7184
+ _resolveCurrency = resolveCurrency(api, currency, resolvedFeeAsset, origin, destination), asset = _resolveCurrency.asset, assets = _resolveCurrency.assets;
6989
7185
  resolvedVersion = pickCompatibleXcmVersion(api, origin, destination, version);
6990
7186
  _context2.n = 1;
6991
7187
  return getOriginXcmFeeInternal({
@@ -7109,11 +7305,11 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
7109
7305
  case 10:
7110
7306
  processHop = /*#__PURE__*/function () {
7111
7307
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
7112
- var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, resolvedHopAsset, hopResult;
7308
+ var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, isDestination, resolvedHopAsset, hopResult, edDeposit;
7113
7309
  return _regenerator().w(function (_context) {
7114
7310
  while (1) switch (_context.n) {
7115
7311
  case 0:
7116
- hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange;
7312
+ hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange, isDestination = params.isDestination;
7117
7313
  resolvedHopAsset = resolveHopAsset({
7118
7314
  api: api,
7119
7315
  tx: tx,
@@ -7152,7 +7348,36 @@ var getXcmFeeOnce = /*#__PURE__*/function () {
7152
7348
  });
7153
7349
  case 1:
7154
7350
  hopResult = _context.v;
7351
+ if (!(!isDestination || hopResult.fee === undefined || hopResult.dryRunError || isAssetEqual(hopResult.asset, hopApi.findNativeAssetInfoOrThrow(currentChain)))) {
7352
+ _context.n = 2;
7353
+ break;
7354
+ }
7155
7355
  return _context.a(2, hopResult);
7356
+ case 2:
7357
+ _context.n = 3;
7358
+ return resolveEdDeposit({
7359
+ origin: {
7360
+ api: api,
7361
+ chain: origin
7362
+ },
7363
+ dest: {
7364
+ api: hopApi,
7365
+ chain: currentChain
7366
+ },
7367
+ assetInfo: asset,
7368
+ overriddenAsset: assets.map(function (_ref4) {
7369
+ var amount = _ref4.amount,
7370
+ location = _ref4.location;
7371
+ return createAsset(resolvedVersion, amount, location);
7372
+ }),
7373
+ feeAssetLocation: hopResult.asset.location,
7374
+ recipient: recipient
7375
+ });
7376
+ case 3:
7377
+ edDeposit = _context.v;
7378
+ return _context.a(2, _objectSpread2(_objectSpread2({}, hopResult), {}, {
7379
+ fee: hopResult.fee + (edDeposit !== null && edDeposit !== void 0 ? edDeposit : 0n)
7380
+ }));
7156
7381
  }
7157
7382
  }, _callee);
7158
7383
  }));
@@ -7478,11 +7703,11 @@ var aggregateHopFees = function aggregateHopFees(hops, matchAsset) {
7478
7703
 
7479
7704
  var buildDestInfo = /*#__PURE__*/function () {
7480
7705
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
7481
- var api, origin, destination, recipient, currency, originFee, isFeeAssetAh, paysDestFee, 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;
7706
+ var api, origin, destination, recipient, currency, originFee, isOriginFeeAsset, paysDestFee, 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;
7482
7707
  return _regenerator().w(function (_context) {
7483
7708
  while (1) switch (_context.n) {
7484
7709
  case 0:
7485
- api = _ref.api, origin = _ref.origin, destination = _ref.destination, recipient = _ref.recipient, currency = _ref.currency, originFee = _ref.originFee, isFeeAssetAh = _ref.isFeeAssetAh, paysDestFee = _ref.paysDestFee, destFeeDetail = _ref.destFeeDetail, totalHopFee = _ref.totalHopFee, bridgeFee = _ref.bridgeFee;
7710
+ api = _ref.api, origin = _ref.origin, destination = _ref.destination, recipient = _ref.recipient, currency = _ref.currency, originFee = _ref.originFee, isOriginFeeAsset = _ref.isOriginFeeAsset, paysDestFee = _ref.paysDestFee, destFeeDetail = _ref.destFeeDetail, totalHopFee = _ref.totalHopFee, bridgeFee = _ref.bridgeFee;
7486
7711
  destApi = api.clone();
7487
7712
  _context.n = 1;
7488
7713
  return destApi.init(destination);
@@ -7498,7 +7723,7 @@ var buildDestInfo = /*#__PURE__*/function () {
7498
7723
  });
7499
7724
  case 2:
7500
7725
  destBalance = _context.v;
7501
- destAmount = isFeeAssetAh ? currency.amount - originFee : currency.amount;
7726
+ destAmount = isOriginFeeAsset ? currency.amount - originFee : currency.amount;
7502
7727
  destFeeAssetEqual = isSymbolMatch(destFeeDetail.asset.symbol, destAsset.symbol);
7503
7728
  effectiveDestFee = paysDestFee && destFeeAssetEqual ? destFeeDetail.fee : 0n;
7504
7729
  effectiveAmountForBalance = destAmount - totalHopFee;
@@ -7552,7 +7777,7 @@ var buildDestInfo = /*#__PURE__*/function () {
7552
7777
  case 4:
7553
7778
  destXcmFeeBalance = destBalance;
7554
7779
  case 5:
7555
- destXcmFeeBalanceAfter = isFeeAssetAh ? destBalanceAfter : destXcmFeeBalance - destFeeDetail.fee + (destFeeAssetEqual ? effectiveAmountForBalance : 0n);
7780
+ destXcmFeeBalanceAfter = isOriginFeeAsset ? destBalanceAfter : destXcmFeeBalance - destFeeDetail.fee + (destFeeAssetEqual ? effectiveAmountForBalance : 0n);
7556
7781
  return _context.a(2, {
7557
7782
  receivedCurrency: {
7558
7783
  sufficient: destBalanceSufficientResult,
@@ -7629,11 +7854,11 @@ var buildHopInfo = /*#__PURE__*/function () {
7629
7854
  var _excluded$1 = ["amount"];
7630
7855
  var buildOriginInfo = /*#__PURE__*/function () {
7631
7856
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
7632
- var api, origin, sender, assets, amount, originFee, originFeeAsset, isFeeAssetAh, buildSelectedCurrency, selectedCurrency, originBalanceFee, originBalanceFeeAfter;
7857
+ var api, origin, sender, assets, amount, originFee, originFeeAsset, isOriginFeeAsset, buildSelectedCurrency, selectedCurrency, originBalanceFee, originBalanceFeeAfter;
7633
7858
  return _regenerator().w(function (_context2) {
7634
7859
  while (1) switch (_context2.n) {
7635
7860
  case 0:
7636
- api = _ref.api, origin = _ref.origin, sender = _ref.sender, assets = _ref.assets, amount = _ref.amount, originFee = _ref.originFee, originFeeAsset = _ref.originFeeAsset, isFeeAssetAh = _ref.isFeeAssetAh;
7861
+ api = _ref.api, origin = _ref.origin, sender = _ref.sender, assets = _ref.assets, amount = _ref.amount, originFee = _ref.originFee, originFeeAsset = _ref.originFeeAsset, isOriginFeeAsset = _ref.isOriginFeeAsset;
7637
7862
  buildSelectedCurrency = /*#__PURE__*/function () {
7638
7863
  var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref3) {
7639
7864
  var assetAmount, asset, balance, balanceAfter;
@@ -7677,7 +7902,7 @@ var buildOriginInfo = /*#__PURE__*/function () {
7677
7902
  });
7678
7903
  case 2:
7679
7904
  originBalanceFee = _context2.v;
7680
- originBalanceFeeAfter = isFeeAssetAh ? originBalanceFee - amount : originBalanceFee - originFee;
7905
+ originBalanceFeeAfter = isOriginFeeAsset ? originBalanceFee - amount : originBalanceFee - originFee;
7681
7906
  return _context2.a(2, {
7682
7907
  selectedCurrency: selectedCurrency,
7683
7908
  xcmFee: {
@@ -7698,7 +7923,7 @@ var buildOriginInfo = /*#__PURE__*/function () {
7698
7923
 
7699
7924
  var getTransferInfo = /*#__PURE__*/function () {
7700
7925
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
7701
- var api, buildTx, origin, destination, sender, ahAddress, recipient, currency, feeAsset, version, resolvedFeeAsset, _resolveCurrency, assets, originAsset, amount, _yield$getXcmFeeInter, _yield$getXcmFeeInter2, originFee, originFeeAsset, destFeeDetail, hops, isFeeAssetAh, feeAssetIndex, feeCurrency, _yield$buildOriginInf, selectedCurrency, originXcmFee, builtHops, _aggregateHopFees, totalHopFee, bridgeFee, buildDestInfoForAsset, destResults, feeResult, result, _t, _t2;
7926
+ var api, buildTx, origin, destination, sender, ahAddress, recipient, currency, feeAsset, version, resolvedFeeAsset, _resolveCurrency, assets, originAsset, amount, _yield$getXcmFeeInter, _yield$getXcmFeeInter2, originFee, originFeeAsset, destFeeDetail, hops, isOriginFeeAsset, feeAssetIndex, feeCurrency, _yield$buildOriginInf, selectedCurrency, originXcmFee, builtHops, _aggregateHopFees, totalHopFee, bridgeFee, buildDestInfoForAsset, destResults, feeResult, result, _t, _t2;
7702
7927
  return _regenerator().w(function (_context2) {
7703
7928
  while (1) switch (_context2.p = _context2.n) {
7704
7929
  case 0:
@@ -7737,7 +7962,7 @@ var getTransferInfo = /*#__PURE__*/function () {
7737
7962
  originFeeAsset = _yield$getXcmFeeInter2.asset;
7738
7963
  destFeeDetail = _yield$getXcmFeeInter.destination;
7739
7964
  hops = _yield$getXcmFeeInter.hops;
7740
- isFeeAssetAh = origin === 'AssetHubPolkadot' && !!resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, originAsset);
7965
+ isOriginFeeAsset = usesOriginFeeAsset(api, origin, currency, originAsset, resolvedFeeAsset, originFeeAsset);
7741
7966
  feeAssetIndex = assets.findIndex(function (asset) {
7742
7967
  return isAssetEqual(asset, originAsset);
7743
7968
  });
@@ -7751,7 +7976,7 @@ var getTransferInfo = /*#__PURE__*/function () {
7751
7976
  amount: amount,
7752
7977
  originFee: originFee,
7753
7978
  originFeeAsset: originFeeAsset,
7754
- isFeeAssetAh: isFeeAssetAh
7979
+ isOriginFeeAsset: isOriginFeeAsset
7755
7980
  });
7756
7981
  case 5:
7757
7982
  _yield$buildOriginInf = _context2.v;
@@ -7805,7 +8030,7 @@ var getTransferInfo = /*#__PURE__*/function () {
7805
8030
  recipient: recipient,
7806
8031
  currency: item,
7807
8032
  originFee: originFee,
7808
- isFeeAssetAh: isFeeAssetAh && isFeeElement,
8033
+ isOriginFeeAsset: isOriginFeeAsset && isFeeElement,
7809
8034
  paysDestFee: isFeeElement,
7810
8035
  destFeeDetail: destFeeDetail,
7811
8036
  totalHopFee: isFeeElement ? totalHopFee : 0n,
@@ -7873,76 +8098,12 @@ var getTransferInfo = /*#__PURE__*/function () {
7873
8098
  };
7874
8099
  }();
7875
8100
 
7876
- var FEE_PADDING = 30;
7877
- var sumHopFees = function sumHopFees(result, _ref) {
7878
- var assetInfo = _ref.assetInfo,
7879
- feeAssetInfo = _ref.feeAssetInfo,
7880
- isRelayAsset = _ref.isRelayAsset,
7881
- systemAsset = _ref.systemAsset,
7882
- overriddenAsset = _ref.options.overriddenAsset;
7883
- var feeAsset = isRelayAsset || overriddenAsset ? assetInfo : feeAssetInfo !== null && feeAssetInfo !== void 0 ? feeAssetInfo : systemAsset;
7884
- return result.hops.reduce(function (acc, hop) {
7885
- // only add if asset is equal
7886
- return isAssetEqual(hop.result.asset, feeAsset) ? acc + hop.result.fee : acc;
7887
- }, 0n);
7888
- };
7889
- var computeAllFees = /*#__PURE__*/function () {
7890
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, buildTx) {
7891
- var origin, dest, feeAssetInfo, edDeposit, _context$options, sender, recipient, currency, feeCurrency, version, overriddenAsset, result, hopFees, destFee;
7892
- return _regenerator().w(function (_context) {
7893
- while (1) switch (_context.n) {
7894
- case 0:
7895
- origin = context.origin, dest = context.dest, feeAssetInfo = context.feeAssetInfo, edDeposit = context.edDeposit, _context$options = context.options, sender = _context$options.sender, recipient = _context$options.recipient, currency = _context$options.currency, feeCurrency = _context$options.feeCurrency, version = _context$options.version, overriddenAsset = _context$options.overriddenAsset;
7896
- assertSender(sender);
7897
- assertAddressIsString(recipient);
7898
- if (origin.api.hasDryRunSupport(context.origin.chain)) {
7899
- _context.n = 2;
7900
- break;
7901
- }
7902
- if (!(feeAssetInfo || overriddenAsset)) {
7903
- _context.n = 1;
7904
- break;
7905
- }
7906
- throw new ScenarioNotSupportedError("Fee asset cannot be used on ".concat(origin.chain, " because it does not support dry run."));
7907
- case 1:
7908
- return _context.a(2, null);
7909
- case 2:
7910
- _context.n = 3;
7911
- return getXcmFeeInternal({
7912
- api: origin.api,
7913
- buildTx: buildTx,
7914
- origin: origin.chain,
7915
- destination: dest.chain,
7916
- sender: sender,
7917
- recipient: recipient,
7918
- version: version,
7919
- currency: currency,
7920
- feeAsset: feeCurrency,
7921
- disableFallback: false,
7922
- skipReverseFeeCalculation: true
7923
- });
7924
- case 3:
7925
- result = _context.v;
7926
- hopFees = sumHopFees(result, context);
7927
- destFee = result.destination.fee;
7928
- return _context.a(2, {
7929
- hopFees: padValueBy(hopFees, FEE_PADDING),
7930
- destFee: padValueBy(destFee, FEE_PADDING) + (edDeposit !== null && edDeposit !== void 0 ? edDeposit : 0n)
7931
- });
7932
- }
7933
- }, _callee);
7934
- }));
7935
- return function computeAllFees(_x, _x2) {
7936
- return _ref2.apply(this, arguments);
7937
- };
7938
- }();
7939
-
7940
8101
  var toSelectors = function toSelectors(currency) {
7941
8102
  return Array.isArray(currency) ? currency : [currency];
7942
8103
  };
7943
8104
  var getMinTransferableAmountInternal = /*#__PURE__*/function () {
7944
8105
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(_ref) {
7945
- var api, origin, sender, recipient, destination, currency, feeAsset, buildTx, builder, version, resolvedFeeAsset, _resolveCurrency, assets, isMulti, selectors, toResult, destApi, nativeAssetInfo, result, minAmounts, buildMinCurrency, createTx, amounts, tx, dryRunResult, _t;
8106
+ var api, origin, sender, recipient, destination, currency, feeAsset, buildTx, builder, version, resolvedFeeAsset, _resolveCurrency, assets, isMulti, selectors, toResult, destApi, result, minAmounts, buildMinCurrency, createTx, amounts, tx, dryRunResult, _t;
7946
8107
  return _regenerator().w(function (_context3) {
7947
8108
  while (1) switch (_context3.p = _context3.n) {
7948
8109
  case 0:
@@ -7959,7 +8120,6 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
7959
8120
  _context3.n = 1;
7960
8121
  return destApi.init(destination);
7961
8122
  case 1:
7962
- nativeAssetInfo = api.findNativeAssetInfoOrThrow(origin);
7963
8123
  _context3.n = 2;
7964
8124
  return getXcmFee({
7965
8125
  api: api,
@@ -7980,7 +8140,7 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
7980
8140
  _context3.n = 3;
7981
8141
  return Promise.all(assets.map(/*#__PURE__*/function () {
7982
8142
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(asset, index) {
7983
- var destAsset, destBalance, destEd, paysOriginInSendingAsset, originFee, originChainAsset, hopFeeTotal, destinationFee, edComponent;
8143
+ var destAsset, destBalance, destEd, isOriginFeeAsset, originFee, originChainAsset, hopFeeTotal, destinationFee, edComponent;
7984
8144
  return _regenerator().w(function (_context) {
7985
8145
  while (1) switch (_context.n) {
7986
8146
  case 0:
@@ -7995,8 +8155,8 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
7995
8155
  case 1:
7996
8156
  destBalance = _context.v;
7997
8157
  destEd = BigInt(destAsset.existentialDeposit);
7998
- paysOriginInSendingAsset = !resolvedFeeAsset && isAssetEqual(nativeAssetInfo, asset) || resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, asset);
7999
- originFee = result.origin && paysOriginInSendingAsset && isAssetEqual(result.origin.asset, asset) ? result.origin.fee : 0n;
8158
+ isOriginFeeAsset = usesOriginFeeAsset(api, origin, currency, asset, resolvedFeeAsset, result.origin.asset);
8159
+ originFee = isOriginFeeAsset ? result.origin.fee : 0n;
8000
8160
  originChainAsset = {
8001
8161
  chain: origin,
8002
8162
  asset: asset
@@ -8314,119 +8474,6 @@ var getTransferableAmount = /*#__PURE__*/function () {
8314
8474
  };
8315
8475
  }();
8316
8476
 
8317
- var isAssetSufficient = /*#__PURE__*/function () {
8318
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, chain, asset) {
8319
- var pallets, _state$isSufficient, state;
8320
- return _regenerator().w(function (_context) {
8321
- while (1) switch (_context.p = _context.n) {
8322
- case 0:
8323
- pallets = getOtherAssetsPallets(chain, api._customCtx);
8324
- if (!(asset.isNative || pallets.length === 0)) {
8325
- _context.n = 1;
8326
- break;
8327
- }
8328
- return _context.a(2, true);
8329
- case 1:
8330
- _context.p = 1;
8331
- _context.n = 2;
8332
- return getPalletInstance(pickOtherMintPallet(asset, pallets)).getAssetState(api, asset);
8333
- case 2:
8334
- state = _context.v;
8335
- return _context.a(2, (_state$isSufficient = state === null || state === void 0 ? void 0 : state.isSufficient) !== null && _state$isSufficient !== void 0 ? _state$isSufficient : true);
8336
- case 3:
8337
- _context.p = 3;
8338
- _context.v;
8339
- return _context.a(2, true);
8340
- }
8341
- }, _callee, null, [[1, 3]]);
8342
- }));
8343
- return function isAssetSufficient(_x, _x2, _x3) {
8344
- return _ref.apply(this, arguments);
8345
- };
8346
- }();
8347
-
8348
- var resolveEdDeposit = /*#__PURE__*/function () {
8349
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
8350
- var _overriddenAsset$map;
8351
- var origin, _ref$dest, destApi, destChain, assetInfo, overriddenAsset, feeAssetLocation, recipient, nativeAsset, nativeLocation, feeLocation, isFeeNative, _yield$destApi$queryS, providers, destAssets, sufficiency, ed, feeAmount;
8352
- return _regenerator().w(function (_context) {
8353
- while (1) switch (_context.n) {
8354
- case 0:
8355
- origin = _ref.origin, _ref$dest = _ref.dest, destApi = _ref$dest.api, destChain = _ref$dest.chain, assetInfo = _ref.assetInfo, overriddenAsset = _ref.overriddenAsset, feeAssetLocation = _ref.feeAssetLocation, recipient = _ref.recipient;
8356
- if (!(isExternalChain(destChain) || typeof recipient !== 'string')) {
8357
- _context.n = 1;
8358
- break;
8359
- }
8360
- return _context.a(2, undefined);
8361
- case 1:
8362
- nativeAsset = destApi.findNativeAssetInfoOrThrow(destChain);
8363
- nativeLocation = origin.api.localizeLocation(destChain, nativeAsset.location);
8364
- feeLocation = origin.api.localizeLocation(destChain, feeAssetLocation, origin.chain);
8365
- isFeeNative = deepEqual(feeLocation, nativeLocation);
8366
- if (!(!isFeeNative && !destChain.startsWith('AssetHub'))) {
8367
- _context.n = 2;
8368
- break;
8369
- }
8370
- return _context.a(2, undefined);
8371
- case 2:
8372
- _context.n = 3;
8373
- return destApi.queryState({
8374
- module: 'System',
8375
- method: 'Account',
8376
- params: [recipient]
8377
- });
8378
- case 3:
8379
- _yield$destApi$queryS = _context.v;
8380
- providers = _yield$destApi$queryS.providers;
8381
- if (!(providers > 0)) {
8382
- _context.n = 4;
8383
- break;
8384
- }
8385
- return _context.a(2, undefined);
8386
- case 4:
8387
- destAssets = ((_overriddenAsset$map = overriddenAsset === null || overriddenAsset === void 0 ? void 0 : overriddenAsset.map(function (asset) {
8388
- return extractAssetLocation(asset);
8389
- })) !== null && _overriddenAsset$map !== void 0 ? _overriddenAsset$map : [assetInfo.location]).map(function (location) {
8390
- return origin.api.findAssetOnDestOrThrow(origin.chain, destChain, {
8391
- location: location
8392
- });
8393
- });
8394
- _context.n = 5;
8395
- return Promise.all(destAssets.map(function (asset) {
8396
- return isAssetSufficient(destApi, destChain, asset);
8397
- }));
8398
- case 5:
8399
- sufficiency = _context.v;
8400
- if (!sufficiency.every(Boolean)) {
8401
- _context.n = 6;
8402
- break;
8403
- }
8404
- return _context.a(2, undefined);
8405
- case 6:
8406
- ed = BigInt(nativeAsset.existentialDeposit);
8407
- if (!isFeeNative) {
8408
- _context.n = 7;
8409
- break;
8410
- }
8411
- return _context.a(2, ed);
8412
- case 7:
8413
- _context.n = 8;
8414
- return destApi.queryRuntimeApi({
8415
- module: 'AssetConversionApi',
8416
- method: 'quote_price_tokens_for_exact_tokens',
8417
- params: [feeLocation, nativeLocation, ed, true]
8418
- });
8419
- case 8:
8420
- feeAmount = _context.v;
8421
- return _context.a(2, feeAmount == null ? undefined : padValueBy(BigInt(feeAmount), FEE_PADDING));
8422
- }
8423
- }, _callee);
8424
- }));
8425
- return function resolveEdDeposit(_x) {
8426
- return _ref2.apply(this, arguments);
8427
- };
8428
- }();
8429
-
8430
8477
  var PINK_LOCATION = {
8431
8478
  parents: 1,
8432
8479
  interior: {
@@ -8464,13 +8511,10 @@ var getBridgeReserve = function getBridgeReserve(api, chain, destination, locati
8464
8511
  var expectedConsensus = isExternalChain(destination) ? ethereumConsensus : _defineProperty({}, getRelayChainOf(destination).toLowerCase(), null);
8465
8512
  return deepEqual(assetConsensus, expectedConsensus) ? destination : chain;
8466
8513
  };
8467
- var resolveReserveChain = function resolveReserveChain(api, chain, destination, assetLocation, isSubBridge, overrideReserve) {
8514
+ var resolveReserveChain = function resolveReserveChain(api, chain, destination, assetLocation, isSubBridge) {
8468
8515
  if (isSubBridge) {
8469
8516
  return getBridgeReserve(api, chain, destination, assetLocation);
8470
8517
  }
8471
- if (overrideReserve !== undefined) {
8472
- return overrideReserve;
8473
- }
8474
8518
  return api.getAssetReserveChain(chain, assetLocation, isExternalChain(destination));
8475
8519
  };
8476
8520
  var createTypeAndThenCallContext = /*#__PURE__*/function () {
@@ -8487,7 +8531,7 @@ var createTypeAndThenCallContext = /*#__PURE__*/function () {
8487
8531
  transferredAsset = overriddenAsset === null || overriddenAsset === void 0 ? void 0 : overriddenAsset.find(function (asset) {
8488
8532
  return !asset.isFeeAsset;
8489
8533
  });
8490
- reserveChain = resolveReserveChain(api, chain, destination, transferredAsset ? extractAssetLocation(transferredAsset) : assetInfo.location, isSubBridge, overrides.reserveChain);
8534
+ reserveChain = resolveReserveChain(api, chain, destination, transferredAsset ? extractAssetLocation(transferredAsset) : assetInfo.location, isSubBridge);
8491
8535
  feeAssetInfo = getFeeAssetInfo(assetInfo, options.feeAssetInfo);
8492
8536
  feeAssetLocation = transferredAsset ? assetInfo.location : feeAssetInfo === null || feeAssetInfo === void 0 ? void 0 : feeAssetInfo.location;
8493
8537
  feeReserveChain = feeAssetLocation && resolveReserveChain(api, chain, destination, feeAssetLocation, isSubBridge);
@@ -9054,7 +9098,6 @@ var createTypeAndThenCall = /*#__PURE__*/function () {
9054
9098
  while (1) switch (_context3.n) {
9055
9099
  case 0:
9056
9100
  overrides = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {
9057
- reserveChain: undefined,
9058
9101
  noFeeAsset: false
9059
9102
  };
9060
9103
  _context3.n = 1;
@@ -9112,102 +9155,6 @@ var createTypeAndThenCall = /*#__PURE__*/function () {
9112
9155
  };
9113
9156
  }();
9114
9157
 
9115
- var createCallForReserve = /*#__PURE__*/function () {
9116
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, reserveChain, options) {
9117
- var api, destination, sender, recipient, currency, feeCurrency, version, serialized, tx, dryRunResult;
9118
- return _regenerator().w(function (_context) {
9119
- while (1) switch (_context.n) {
9120
- case 0:
9121
- api = options.api, destination = options.destination, sender = options.sender, recipient = options.recipient, currency = options.currency, feeCurrency = options.feeCurrency, version = options.version;
9122
- _context.n = 1;
9123
- return createTypeAndThenCall(options, {
9124
- reserveChain: reserveChain
9125
- });
9126
- case 1:
9127
- serialized = _context.v;
9128
- assertSender(sender);
9129
- assertAddressIsString(recipient);
9130
- assertToIsString(destination, 'Location destination is not supported for reserve auto-selection.');
9131
- tx = api.deserializeExtrinsics(serialized);
9132
- _context.n = 2;
9133
- return dryRunInternal({
9134
- api: api,
9135
- tx: tx,
9136
- origin: chain,
9137
- destination: destination,
9138
- sender: sender,
9139
- currency: currency,
9140
- version: version,
9141
- feeAsset: feeCurrency,
9142
- useRootOrigin: true
9143
- });
9144
- case 2:
9145
- dryRunResult = _context.v;
9146
- return _context.a(2, {
9147
- call: serialized,
9148
- success: dryRunResult.success
9149
- });
9150
- }
9151
- }, _callee);
9152
- }));
9153
- return function createCallForReserve(_x, _x2, _x3) {
9154
- return _ref.apply(this, arguments);
9155
- };
9156
- }();
9157
- /**
9158
- * Creates a type-and-then call but auto-selects the asset reserve between AssetHub and the Relay chain
9159
- * by dry-running both variants and preferring the one that succeeds. If both fail, returns the
9160
- * AssetHub variant. Supports only relaychain assets.
9161
- */
9162
- var createTypeThenAutoReserve = /*#__PURE__*/function () {
9163
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(chain, options) {
9164
- var originSupports, destSupports, relay, assetHubReserve, ahResult, relayResult;
9165
- return _regenerator().w(function (_context2) {
9166
- while (1) switch (_context2.n) {
9167
- case 0:
9168
- // Use dry-run path only when BOTH origin and destination support it
9169
- originSupports = hasDryRunSupport(chain);
9170
- destSupports = options.destChain ? hasDryRunSupport(options.destChain) : false;
9171
- if (originSupports && destSupports) {
9172
- _context2.n = 2;
9173
- break;
9174
- }
9175
- _context2.n = 1;
9176
- return createTypeAndThenCall(options);
9177
- case 1:
9178
- return _context2.a(2, _context2.v);
9179
- case 2:
9180
- relay = getRelayChainOf(chain);
9181
- assetHubReserve = "AssetHub".concat(relay);
9182
- _context2.n = 3;
9183
- return createCallForReserve(chain, assetHubReserve, options);
9184
- case 3:
9185
- ahResult = _context2.v;
9186
- if (!ahResult.success) {
9187
- _context2.n = 4;
9188
- break;
9189
- }
9190
- return _context2.a(2, ahResult.call);
9191
- case 4:
9192
- _context2.n = 5;
9193
- return createCallForReserve(chain, relay, options);
9194
- case 5:
9195
- relayResult = _context2.v;
9196
- if (!relayResult.success) {
9197
- _context2.n = 6;
9198
- break;
9199
- }
9200
- return _context2.a(2, relayResult.call);
9201
- case 6:
9202
- return _context2.a(2, ahResult.call);
9203
- }
9204
- }, _callee2);
9205
- }));
9206
- return function createTypeThenAutoReserve(_x4, _x5) {
9207
- return _ref2.apply(this, arguments);
9208
- };
9209
- }();
9210
-
9211
9158
  var calculateTotalXcmFee = function calculateTotalXcmFee(asset, feeResult) {
9212
9159
  var totalHopFee = feeResult.hops.reduce(function (acc, hop) {
9213
9160
  return isAssetEqual(hop.result.asset, asset) ? acc + hop.result.fee : acc;
@@ -9697,7 +9644,7 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
9697
9644
  var hopFeeAssetToReserve = isReserveDest ? feeAssetLocalizedToDest : feeAssetLocalizedToReserve;
9698
9645
  // When fees are paid in a separate asset, originFee is denominated in that asset's
9699
9646
  // currency and must not be subtracted from the transfer amount.
9700
- var originFeeDeduction = feeAsset ? 0n : originFee;
9647
+ var originFeeDeduction = feeAssetInfo && !feeAsset ? originFee : 0n;
9701
9648
  var destLocation = createDestination(api, version, chain, destChain, paraIdTo);
9702
9649
  if (chain !== 'AssetHubPolkadot' && reserveChain === undefined) {
9703
9650
  throw new UnsupportedOperationError('Sending local reserve assets with custom fee asset is not yet supported for this chain.');
@@ -9776,7 +9723,7 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
9776
9723
  reserve: getChainLocation(chain, reserveChain, api._customCtx),
9777
9724
  xcm: [].concat(_toConsumableArray(createBuyExecution(// Decrease amount by 2 units because for some reason polkadot withdraws 2 units less
9778
9725
  // than requested, so we need to account for that
9779
- hopFeeAssetToReserve !== null && hopFeeAssetToReserve !== void 0 ? hopFeeAssetToReserve : updateAsset(assetLocalizedToReserve, amount - 2n))), _toConsumableArray(createReserveToDestXcm()))
9726
+ hopFeeAssetToReserve !== null && hopFeeAssetToReserve !== void 0 ? hopFeeAssetToReserve : updateAsset(assetLocalizedToReserve, amount - originFeeDeduction - 2n))), _toConsumableArray(createReserveToDestXcm()))
9780
9727
  }
9781
9728
  }];
9782
9729
  break;
@@ -9805,6 +9752,7 @@ xcm, maxWeight) {
9805
9752
  var prepareCommonExecuteXcm = function prepareCommonExecuteXcm(options, assetToDeposit) {
9806
9753
  var depositFeeAsset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
9807
9754
  var api = options.api,
9755
+ feeAssetInfo = options.feeAssetInfo,
9808
9756
  useJitWithdraw = options.useJitWithdraw,
9809
9757
  recipient = options.recipient,
9810
9758
  version = options.version,
@@ -9818,8 +9766,8 @@ var prepareCommonExecuteXcm = function prepareCommonExecuteXcm(options, assetToD
9818
9766
  prefix.push({
9819
9767
  WithdrawAsset: withdrawAssets
9820
9768
  });
9821
- if (feeAssetLocalized && !useJitWithdraw) {
9822
- prefix.push.apply(prefix, _toConsumableArray(createBuyExecution(feeAssetLocalized, MIN_WEIGHT)));
9769
+ if (feeAssetInfo && !useJitWithdraw) {
9770
+ prefix.push.apply(prefix, _toConsumableArray(createBuyExecution(feeAssetLocalized !== null && feeAssetLocalized !== void 0 ? feeAssetLocalized : assetLocalized, MIN_WEIGHT)));
9823
9771
  } else {
9824
9772
  prefix.push({
9825
9773
  SetFeesMode: {
@@ -9888,7 +9836,7 @@ var FEE_PADDING_PERCENTAGE$1 = 40;
9888
9836
  var handleExecuteTransfer = /*#__PURE__*/function () {
9889
9837
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
9890
9838
  var _dryRunResult$hops$at;
9891
- var api, chain, sender, paraIdTo, destChain, assetInfo, currency, feeCurrency, recipient, feeAssetInfo, version, transactOptions, checkAmount, resolvedFeeAssetInfo, destApi, edDeposit, internalOptions, FEE_ASSET_AMOUNT, feeAssetAmount, hopFeeAmount, call, dryRunResult, originFee, reserveFee, destFee, xcm, weight, _t, _t2;
9839
+ var api, chain, sender, paraIdTo, destChain, assetInfo, currency, feeCurrency, recipient, feeAssetInfo, version, transactOptions, checkAmount, resolvedFeeAssetInfo, destApi, edDeposit, internalOptions, FEE_ASSET_AMOUNT, feeAssetAmount, call, dryRunResult, originFee, reserveFee, destFee, xcm, weight, _t, _t2;
9892
9840
  return _regenerator().w(function (_context) {
9893
9841
  while (1) switch (_context.n) {
9894
9842
  case 0:
@@ -9951,16 +9899,15 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
9951
9899
  edDeposit: edDeposit
9952
9900
  }; // We mint 1000 units of feeAsset and use 100
9953
9901
  FEE_ASSET_AMOUNT = 100;
9954
- feeAssetAmount = feeAssetInfo ? parseUnits(FEE_ASSET_AMOUNT.toString(), feeAssetInfo.decimals) : MIN_FEE;
9955
- hopFeeAmount = resolvedFeeAssetInfo ? feeAssetAmount : MIN_FEE;
9902
+ feeAssetAmount = resolvedFeeAssetInfo ? parseUnits(FEE_ASSET_AMOUNT.toString(), resolvedFeeAssetInfo.decimals) : MIN_FEE;
9956
9903
  _t = createExecuteCall;
9957
9904
  _t2 = chain;
9958
9905
  _context.n = 6;
9959
9906
  return createDirectExecuteXcm(_objectSpread2(_objectSpread2({}, internalOptions), {}, {
9960
9907
  fees: {
9961
9908
  originFee: feeAssetAmount,
9962
- reserveFee: hopFeeAmount,
9963
- destFee: hopFeeAmount
9909
+ reserveFee: feeAssetAmount,
9910
+ destFee: feeAssetAmount
9964
9911
  }
9965
9912
  }));
9966
9913
  case 6:
@@ -12488,7 +12435,7 @@ var PeoplePolkadot = /*#__PURE__*/function (_SubstrateChain) {
12488
12435
  value: function transferPolkadotXCM(input) {
12489
12436
  var scenario = input.scenario,
12490
12437
  destChain = input.destChain;
12491
- if (scenario === 'ParaToPara' && !(destChain !== null && destChain !== void 0 && destChain.startsWith('AssetHub'))) {
12438
+ if (scenario === 'ParaToPara' && !(destChain !== null && destChain !== void 0 && destChain.startsWith('AssetHub')) && destChain !== 'Hydration') {
12492
12439
  throw new ScenarioNotSupportedError("Unable to use ".concat(this.chain, " for transfers to other Parachains."));
12493
12440
  }
12494
12441
  return transferPolkadotXcm(input);
@@ -12697,6 +12644,15 @@ var Xode = /*#__PURE__*/function (_SubstrateChain) {
12697
12644
  value: function canReceiveFrom(origin) {
12698
12645
  return origin === 'AssetHubPolkadot';
12699
12646
  }
12647
+ }, {
12648
+ key: "getMintConfig",
12649
+ value: function getMintConfig() {
12650
+ return {
12651
+ forceOrigin: {
12652
+ type: 'treasuryCouncil'
12653
+ }
12654
+ };
12655
+ }
12700
12656
  }, {
12701
12657
  key: "transferLocalNonNativeAsset",
12702
12658
  value: function transferLocalNonNativeAsset(options) {
@@ -13867,6 +13823,26 @@ var PolkadotApi = /*#__PURE__*/function () {
13867
13823
  value: function isAssetXcEqual(a, b) {
13868
13824
  return isAssetXcEqualImpl(this, a, b);
13869
13825
  }
13826
+ }, {
13827
+ key: "dispatchAs",
13828
+ value: function dispatchAs(call, origin) {
13829
+ return this.deserializeExtrinsics({
13830
+ module: 'Utility',
13831
+ method: 'dispatch_as',
13832
+ params: {
13833
+ as_origin: origin.type === 'treasuryCouncil' ? {
13834
+ TreasuryCouncil: {
13835
+ Members: [1, 1]
13836
+ }
13837
+ } : {
13838
+ system: {
13839
+ Signed: origin.address
13840
+ }
13841
+ },
13842
+ call: call
13843
+ }
13844
+ });
13845
+ }
13870
13846
  }, {
13871
13847
  key: "init",
13872
13848
  value: function () {
@@ -14244,4 +14220,4 @@ var createClientCache = function createClientCache(maxSize, pingClient, onEvicti
14244
14220
  };
14245
14221
  };
14246
14222
 
14247
- export { API_TYPES, AmountTooLowError, ApiNotInitializedError, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, CustomChainConflictError, CustomChainInvalidError, 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, RuntimeApiError, RuntimeApiUnavailableError, ScenarioNotSupportedError, SubmitTransactionError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, aggregateHopFees, applyDecimalAbstraction, assertAddressIsString, assertCurrencyCore, assertEvmAddress, assertExtensionInstalled, assertHasId, assertNotEvmTransfer, assertSender, assertSenderSource, assertSubstrateOrigin, assertSwapSupport, assertToIsString, blake2128Concat, blake2b256, blake2b512, buildCustomChainAssetsInfo, buildCustomChainConfig, buildDestInfo, buildDryRunError, buildErc20StorageMint, buildHopInfo, buildOriginInfo, calcPreviewMintAmount, calcSentAssetPreviewMint, compareAddresses, compareLocationOrder, computeOverridenAmount, constructTypeAndThenCall, convertBuilderConfig, convertSs58, createAllCountedFilter, createAsset, createAssetId, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createBridgedXcmPrefix, createChainClient, createClientCache, createClientPoolHelpers, createCustomXcmOnDest, createDestination, createDirectExecuteXcm, createEthereumBridgeInstructions, createExecuteCall, createSwapBuilder, createTransfer, createTransferOrSwap, createTransferOrSwapAll, createTxOverrideAmount, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, executeWithSwap, formatAssetIdToERC20, formatUnits, generateMessageId, getAssetBalanceInternal, getAssetReserveChain, getAssetReserveChainImpl, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainConfigImpl, getChainLocation, getChainProviders, getChainProvidersImpl, getChainVersion, getDryRunError, getErrorInstruction, getEthErc20Balance, getEvmExtensionOrThrow, getEvmPrivateKeyHex, getEvmSnowbridgeExtensionOrThrow, getLocalTransferAmount, getMinTransferableAmount, getMinTransferableAmountInternal, getOriginXcmFee, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getParaIdImpl, getRelayChainOf, getRelayChainOfImpl, getRelayChainSymbolOf, getSwapExtensionOrThrow, getTChain, getTSubstrateChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, isAssetXcEqualImpl, isConfig, isExchange, isNativeAssetTeleport, isSenderSigner, isViemSigner, keyFromWs, localizeLocation, localizeLocationImpl, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, normalizeCustomChains, normalizeExchange, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickOtherMintPallet, pickRouterCompatibleXcmVersion, registerEvmExtension, registerEvmSnowbridgeExtension, registerSwapExtension, resolveAssetCount, resolveDestChain, resolveModuleError, resolveParaId, resolveTransferParams, reverseTransformLocation, selectXcmVersion, sortAssets, throwUnsupportedCurrency, toLeHex, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateFeeAssetSupport, validateTransact, verifyEdOnDestination, wrapTxBypass };
14223
+ export { API_TYPES, AmountTooLowError, ApiNotInitializedError, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, CustomChainConflictError, CustomChainInvalidError, 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, RuntimeApiError, RuntimeApiUnavailableError, ScenarioNotSupportedError, SubmitTransactionError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, aggregateHopFees, applyDecimalAbstraction, assertAddressIsString, assertCurrencyCore, assertEvmAddress, assertExtensionInstalled, assertHasId, assertNotEvmTransfer, assertSender, assertSenderSource, assertSubstrateOrigin, assertSwapSupport, assertToIsString, blake2128Concat, blake2b256, blake2b512, buildCustomChainAssetsInfo, buildCustomChainConfig, buildDestInfo, buildDryRunError, buildErc20StorageMint, buildHopInfo, buildOriginInfo, calcPreviewMintAmount, calcSentAssetPreviewMint, compareAddresses, compareLocationOrder, computeOverridenAmount, constructTypeAndThenCall, convertBuilderConfig, convertSs58, createAllCountedFilter, createAsset, createAssetId, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createBridgedXcmPrefix, createChainClient, createClientCache, createClientPoolHelpers, createCustomXcmOnDest, createDestination, createDirectExecuteXcm, createEthereumBridgeInstructions, createExecuteCall, createSwapBuilder, createTransfer, createTransferOrSwap, createTransferOrSwapAll, createTxOverrideAmount, createTypeAndThenCall, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, executeWithSwap, formatAssetIdToERC20, formatUnits, generateMessageId, getAssetBalanceInternal, getAssetReserveChain, getAssetReserveChainImpl, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainConfigImpl, getChainLocation, getChainProviders, getChainProvidersImpl, getChainVersion, getDryRunError, getErrorInstruction, getEthErc20Balance, getEvmExtensionOrThrow, getEvmPrivateKeyHex, getEvmSnowbridgeExtensionOrThrow, getLocalTransferAmount, getMinTransferableAmount, getMinTransferableAmountInternal, getOriginXcmFee, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getParaIdImpl, getRelayChainOf, getRelayChainOfImpl, getRelayChainSymbolOf, getSwapExtensionOrThrow, getTChain, getTSubstrateChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, isAssetXcEqualImpl, isConfig, isExchange, isNativeAssetTeleport, isSenderSigner, isViemSigner, keyFromWs, localizeLocation, localizeLocationImpl, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, normalizeCustomChains, normalizeExchange, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickOtherMintPallet, pickRouterCompatibleXcmVersion, registerEvmExtension, registerEvmSnowbridgeExtension, registerSwapExtension, resolveAssetCount, resolveDestChain, resolveModuleError, resolveParaId, resolveTransferParams, reverseTransformLocation, selectXcmVersion, sortAssets, throwUnsupportedCurrency, toLeHex, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateFeeAssetSupport, validateTransact, verifyEdOnDestination, wrapTxBypass };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-core",
3
- "version": "14.5.0",
3
+ "version": "14.5.2",
4
4
  "description": "SDK core for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,9 +23,9 @@
23
23
  ],
24
24
  "dependencies": {
25
25
  "@noble/hashes": "^2.4.0",
26
- "@paraspell/assets": "14.5.0",
27
- "@paraspell/pallets": "14.5.0",
28
- "@paraspell/sdk-common": "14.5.0",
26
+ "@paraspell/assets": "14.5.2",
27
+ "@paraspell/pallets": "14.5.2",
28
+ "@paraspell/sdk-common": "14.5.2",
29
29
  "@scure/base": "^2.4.0",
30
30
  "viem": "^2.57.13"
31
31
  },