@paraspell/sdk-core 12.1.2 → 12.2.1

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
@@ -1,7 +1,7 @@
1
1
  import * as _paraspell_sdk_common from '@paraspell/sdk-common';
2
- import { TChain, TLocation, TSubstrateChain, Version, TRelaychain, TParachain, TExternalChain, TJunction, TJunctions } from '@paraspell/sdk-common';
2
+ import { TChain, TSubstrateChain, TLocation, Version, TRelaychain, TParachain, TExternalChain, TJunction, TJunctions } from '@paraspell/sdk-common';
3
3
  export * from '@paraspell/sdk-common';
4
- import { TCurrencyInputWithAmount, TCurrencyInput, WithAmount, TAssetInfo, TAsset, TAssetWithFee, WithComplexAmount, TCurrencyCore, TAmount, TAssetWithLocation, TAssetInfoWithId } from '@paraspell/assets';
4
+ import { TAssetInfo, TCurrencyInputWithAmount, TCurrencyInput, WithAmount, TAsset, TAssetWithFee, WithComplexAmount, TCurrencyCore, TAmount, TAssetWithLocation, TAssetInfoWithId } from '@paraspell/assets';
5
5
  export * from '@paraspell/assets';
6
6
  import { TPallet, TAssetsPallet } from '@paraspell/pallets';
7
7
  export * from '@paraspell/pallets';
@@ -12,6 +12,66 @@ type WithApi<TBase, TApi, TRes> = TBase & {
12
12
  };
13
13
  type TUrl = string | string[];
14
14
  type TApiOrUrl<TApi> = TApi | TUrl;
15
+ type TClientKey = string;
16
+ type TClientEntry<T> = {
17
+ client: T;
18
+ refs: number;
19
+ destroyWanted: boolean;
20
+ };
21
+ type TCacheItem<T> = {
22
+ value: TClientEntry<T>;
23
+ ttl: number;
24
+ expireAt: number;
25
+ extended: boolean;
26
+ };
27
+ type ClientCache<T> = {
28
+ set: (k: TClientKey, v: TClientEntry<T>, ttl: number) => void;
29
+ get: (k: TClientKey) => TClientEntry<T> | undefined;
30
+ delete: (k: TClientKey) => boolean;
31
+ has: (k: TClientKey) => boolean;
32
+ clear: () => void;
33
+ peek: (k: TClientKey) => TClientEntry<T> | undefined;
34
+ remainingTtl: (k: TClientKey) => number | undefined;
35
+ revive: (k: TClientKey, ttl: number) => void;
36
+ };
37
+
38
+ interface IPolkadotApi<TApi, TRes> {
39
+ getConfig(): TBuilderOptions<TApiOrUrl<TApi>> | undefined;
40
+ getApi(): TApi;
41
+ init(chain: TChain, clientTtlMs?: number): Promise<void>;
42
+ createApiInstance: (wsUrl: TUrl, chain: TSubstrateChain) => Promise<TApi>;
43
+ accountToHex(address: string, isPrefixed?: boolean): string;
44
+ accountToUint8a(address: string): Uint8Array;
45
+ deserializeExtrinsics(serialized: TSerializedExtrinsics): TRes;
46
+ queryState<T>(serialized: TSerializedStateQuery): Promise<T>;
47
+ queryRuntimeApi<T>(serialized: TSerializedRuntimeApiQuery): Promise<T>;
48
+ callBatchMethod(calls: TRes[], mode: BatchMode): TRes;
49
+ callDispatchAsMethod(call: TRes, address: string): TRes;
50
+ objectToHex(obj: unknown, typeName: string): Promise<string>;
51
+ hexToUint8a(hex: string): Uint8Array;
52
+ stringToUint8a(str: string): Uint8Array;
53
+ getMethod(tx: TRes): string;
54
+ getTypeThenAssetCount(tx: TRes): number | undefined;
55
+ hasMethod(pallet: TPallet, method: string): Promise<boolean>;
56
+ calculateTransactionFee(tx: TRes, address: string): Promise<bigint>;
57
+ quoteAhPrice(fromMl: TLocation, toMl: TLocation, amountIn: bigint, includeFee?: boolean): Promise<bigint | undefined>;
58
+ getXcmWeight(xcm: any): Promise<TWeight>;
59
+ getXcmPaymentApiFee(chain: TSubstrateChain, localXcm: any, forwardedXcm: any, asset: TAssetInfo, transformXcm: boolean): Promise<bigint>;
60
+ getEvmStorage(contract: string, slot: string): Promise<string>;
61
+ getFromRpc(module: string, method: string, key: string): Promise<string>;
62
+ blake2AsHex(data: Uint8Array): string;
63
+ clone(): IPolkadotApi<TApi, TRes>;
64
+ createApiForChain(chain: TSubstrateChain): Promise<IPolkadotApi<TApi, TRes>>;
65
+ getDryRunCall(options: TDryRunCallBaseOptions<TRes>): Promise<TDryRunChainResult>;
66
+ getDryRunXcm(options: TDryRunXcmBaseOptions<TRes>): Promise<TDryRunChainResult>;
67
+ getBridgeStatus(): Promise<TBridgeStatus>;
68
+ setDisconnectAllowed(allowed: boolean): void;
69
+ getDisconnectAllowed(): boolean;
70
+ disconnect(force?: boolean): Promise<void>;
71
+ validateSubstrateAddress(address: string): boolean;
72
+ deriveAddress(path: string): string;
73
+ signAndSubmit(tx: TRes, path: string): Promise<string>;
74
+ }
15
75
 
16
76
  type TPolkadotXCMTransferOptions<TApi, TRes> = {
17
77
  api: IPolkadotApi<TApi, TRes>;
@@ -298,7 +358,7 @@ declare abstract class BaseAssetsPallet {
298
358
  /**
299
359
  * Builder class for constructing asset claim transactions.
300
360
  */
301
- declare class AssetClaimBuilder<TApi, TRes, T extends Partial<TAssetClaimOptionsBase> = object> {
361
+ declare class AssetClaimBuilder<TApi, TRes, T extends Partial<TAssetClaimOptionsBase & TBuilderInternalOptions> = object> {
302
362
  readonly api: IPolkadotApi<TApi, TRes>;
303
363
  readonly _options: T;
304
364
  constructor(api: IPolkadotApi<TApi, TRes>, options?: T);
@@ -311,6 +371,15 @@ declare class AssetClaimBuilder<TApi, TRes, T extends Partial<TAssetClaimOptions
311
371
  currency(currency: TAssetClaimOptionsBase['currency']): AssetClaimBuilder<TApi, TRes, T & {
312
372
  currency: TAssetClaimOptionsBase['currency'];
313
373
  }>;
374
+ /**
375
+ * Sets the sender address.
376
+ *
377
+ * @param address - The sender address.
378
+ * @returns
379
+ */
380
+ senderAddress(addressOrPath: string): AssetClaimBuilder<TApi, TRes, T & {
381
+ senderAddress: string;
382
+ }>;
314
383
  /**
315
384
  * Specifies the account address on which the assets will be claimed.
316
385
  *
@@ -335,6 +404,7 @@ declare class AssetClaimBuilder<TApi, TRes, T extends Partial<TAssetClaimOptions
335
404
  * @returns A Promise that resolves to the asset claim extrinsic.
336
405
  */
337
406
  build(this: AssetClaimBuilder<TApi, TRes, TAssetClaimOptionsBase>): Promise<TRes>;
407
+ signAndSubmit(this: AssetClaimBuilder<TApi, TRes, TAssetClaimOptionsBase & TBuilderInternalOptions>): Promise<string>;
338
408
  /**
339
409
  * Returns the API instance used by the builder.
340
410
  *
@@ -359,7 +429,7 @@ declare class BatchTransactionManager<TApi, TRes> {
359
429
  /**
360
430
  * A builder class for constructing Para-to-Para, Para-to-Relay, Relay-to-Para transactions and asset claims.
361
431
  */
362
- declare class GeneralBuilder<TApi, TRes, T extends Partial<TSendBaseOptions> = object> {
432
+ declare class GeneralBuilder<TApi, TRes, T extends Partial<TSendBaseOptions & TBuilderInternalOptions> = object> {
363
433
  readonly batchManager: BatchTransactionManager<TApi, TRes>;
364
434
  readonly api: IPolkadotApi<TApi, TRes>;
365
435
  readonly _options: T;
@@ -416,7 +486,7 @@ declare class GeneralBuilder<TApi, TRes, T extends Partial<TSendBaseOptions> = o
416
486
  * @param address - The sender address.
417
487
  * @returns
418
488
  */
419
- senderAddress(address: string): GeneralBuilder<TApi, TRes, T & {
489
+ senderAddress(addressOrPath: string): GeneralBuilder<TApi, TRes, T & {
420
490
  senderAddress: string;
421
491
  }>;
422
492
  /**
@@ -556,6 +626,7 @@ declare class GeneralBuilder<TApi, TRes, T extends Partial<TSendBaseOptions> = o
556
626
  * @throws \{UnableToComputeError\} Thrown when the receivable amount cannot be determined.
557
627
  */
558
628
  getReceivableAmount(this: GeneralBuilder<TApi, TRes, TSendBaseOptionsWithSenderAddress>): Promise<bigint>;
629
+ signAndSubmit(this: GeneralBuilder<TApi, TRes, TSendBaseOptionsWithSenderAddress & TBuilderInternalOptions>): Promise<string>;
559
630
  /**
560
631
  * Returns the API instance used by the builder.
561
632
  *
@@ -1127,6 +1198,9 @@ type TBuildInternalRes<TApi, TRes, TOptions extends TSendBaseOptions = TSendBase
1127
1198
  tx: TRes;
1128
1199
  options: TSendOptions<TApi, TRes> & TOptions;
1129
1200
  };
1201
+ type TBuilderInternalOptions = {
1202
+ path?: string;
1203
+ };
1130
1204
 
1131
1205
  type TProviderEntry = {
1132
1206
  name: string;
@@ -1446,41 +1520,13 @@ type TTypeAndThenFees = {
1446
1520
  destFee: bigint;
1447
1521
  };
1448
1522
 
1449
- interface IPolkadotApi<TApi, TRes> {
1450
- getConfig(): TBuilderOptions<TApiOrUrl<TApi>> | undefined;
1451
- getApi(): TApi;
1452
- init(chain: TChain, clientTtlMs?: number): Promise<void>;
1453
- createApiInstance: (wsUrl: string | string[], chain: TSubstrateChain) => Promise<TApi>;
1454
- accountToHex(address: string, isPrefixed?: boolean): string;
1455
- accountToUint8a(address: string): Uint8Array;
1456
- deserializeExtrinsics(serialized: TSerializedExtrinsics): TRes;
1457
- queryState<T>(serialized: TSerializedStateQuery): Promise<T>;
1458
- queryRuntimeApi<T>(serialized: TSerializedRuntimeApiQuery): Promise<T>;
1459
- callBatchMethod(calls: TRes[], mode: BatchMode): TRes;
1460
- callDispatchAsMethod(call: TRes, address: string): TRes;
1461
- objectToHex(obj: unknown, typeName: string): Promise<string>;
1462
- hexToUint8a(hex: string): Uint8Array;
1463
- stringToUint8a(str: string): Uint8Array;
1464
- getMethod(tx: TRes): string;
1465
- getTypeThenAssetCount(tx: TRes): number | undefined;
1466
- hasMethod(pallet: TPallet, method: string): Promise<boolean>;
1467
- calculateTransactionFee(tx: TRes, address: string): Promise<bigint>;
1468
- quoteAhPrice(fromMl: TLocation, toMl: TLocation, amountIn: bigint, includeFee?: boolean): Promise<bigint | undefined>;
1469
- getXcmWeight(xcm: any): Promise<TWeight>;
1470
- getXcmPaymentApiFee(chain: TSubstrateChain, localXcm: any, forwardedXcm: any, asset: TAssetInfo, transformXcm: boolean): Promise<bigint>;
1471
- getEvmStorage(contract: string, slot: string): Promise<string>;
1472
- getFromRpc(module: string, method: string, key: string): Promise<string>;
1473
- blake2AsHex(data: Uint8Array): string;
1474
- clone(): IPolkadotApi<TApi, TRes>;
1475
- createApiForChain(chain: TSubstrateChain): Promise<IPolkadotApi<TApi, TRes>>;
1476
- getDryRunCall(options: TDryRunCallBaseOptions<TRes>): Promise<TDryRunChainResult>;
1477
- getDryRunXcm(options: TDryRunXcmBaseOptions<TRes>): Promise<TDryRunChainResult>;
1478
- getBridgeStatus(): Promise<TBridgeStatus>;
1479
- setDisconnectAllowed(allowed: boolean): void;
1480
- getDisconnectAllowed(): boolean;
1481
- disconnect(force?: boolean): Promise<void>;
1482
- validateSubstrateAddress(address: string): boolean;
1483
- }
1523
+ declare const keyFromWs: (ws: TUrl) => TClientKey;
1524
+ declare const createClientPoolHelpers: <TClient>(clientPool: ClientCache<TClient>, createClient: (ws: TUrl, useLegacy: boolean) => TClient | Promise<TClient>) => {
1525
+ leaseClient: (ws: TUrl, ttlMs: number, useLegacy: boolean) => Promise<TClient>;
1526
+ releaseClient: (ws: TUrl) => void;
1527
+ };
1528
+
1529
+ declare const createClientCache: <T>(maxSize: number, pingClient: (client: T) => Promise<void>, onEviction?: (key: TClientKey, value: TClientEntry<T>) => void, extensionMs?: number) => ClientCache<T>;
1484
1530
 
1485
1531
  declare const blake2b256: (msg: Uint8Array) => Uint8Array<ArrayBufferLike>;
1486
1532
  declare const blake2b512: (msg: Uint8Array) => Uint8Array<ArrayBufferLike>;
@@ -2198,6 +2244,7 @@ declare const assertAddressIsString: (address: TAddress) => asserts address is E
2198
2244
  declare const assertSenderAddress: (address: string | undefined) => asserts address is string;
2199
2245
  declare const assertHasLocation: (asset: TAssetInfo) => asserts asset is TAssetWithLocation;
2200
2246
  declare const assertHasId: (asset: TAssetInfo) => asserts asset is TAssetInfoWithId;
2247
+ declare const assertDerivationPath: (path: string | undefined) => asserts path is string;
2201
2248
 
2202
2249
  declare const createId: (version: Version, location: TLocation) => TLocation | {
2203
2250
  Concrete: TLocation;
@@ -2249,6 +2296,8 @@ declare const padValueBy: (amount: bigint, percent: number) => bigint;
2249
2296
  */
2250
2297
  declare const getChain: <TApi, TRes, T extends keyof ReturnType<typeof chains>>(chain: T) => ReturnType<typeof chains<TApi, TRes>>[T];
2251
2298
 
2299
+ declare const getEvmPrivateKeyHex: (path: string) => "0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133" | "0x8075991ce870b93a8870eca0c0f91913d12f47948ca0fd25b49c6fa7cdbeee8b" | "0x0b6e18cafb6ed99687ec547bd28139cafdd2bffe70e6b688025de6b445aa5c5b" | "0x39539ab1876910bbf3a223d84a29e28f1cb4e2e456503e7e91ed39b2e7223d68" | "0x7dce9bc8babb68fec1409be38c8e1a52650206a7ed90ff956ae8a6d15eeaaef4" | "0xb9d2ea9a615f3165812e8d44de0d24da9bbd164b65c4f0573e1ce2c8dbd9c8df" | undefined;
2300
+
2252
2301
  declare const createBeneficiaryLocXTokens: <TApi, TRes>({ api, address: recipientAddress, origin, destination, version, paraId }: TCreateBeneficiaryXTokensOptions<TApi, TRes>) => TLocation;
2253
2302
  declare const createBeneficiaryLocation: <TApi, TRes>({ api, address, version }: TCreateBeneficiaryOptions<TApi, TRes>) => TLocation;
2254
2303
 
@@ -2314,5 +2363,5 @@ declare const formatUnits: typeof formatUnits$1;
2314
2363
 
2315
2364
  declare const validateAddress: <TApi, TRes>(api: IPolkadotApi<TApi, TRes>, address: TAddress, chain: TChain, isDestination?: boolean) => void;
2316
2365
 
2317
- export { AmountTooLowError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiUnavailableError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, UnsupportedOperationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertHasId, assertHasLocation, assertSenderAddress, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, computeOverridenAmount, constructTypeAndThenCall, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createId, createTx, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, formatAssetIdToERC20, formatUnits, getAssetBalanceInternal, getAssetReserveChain, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getEthErc20Balance, getFailureInfo, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginXcmFee, getOriginXcmFeeEstimate, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, overrideTxAmount, padFee, padValueBy, parseUnits, resolveDestChain, resolveModuleError, resolveParaId, reverseTransformLocation, send, sortAssets, throwUnsupportedCurrency, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, verifyEdOnDestination, wrapTxBypass };
2318
- export type { BuildHopInfoOptions, HopProcessParams, HopTraversalConfig, HopTraversalResult, IPolkadotApi, IPolkadotXCMTransfer, IXTokensTransfer, IXTransferTransfer, OneKey, TAddress, TApiOrUrl, TAssetClaimInternalOptions, TAssetClaimOptions, TAssetClaimOptionsBase, TBatchOptions, TBatchedSendOptions, TBifrostToken, TBridgeStatus, TBuildDestInfoOptions, TBuildInternalRes, TBuilderConfig, TBuilderOptions, TBypassOptions, TChainConfig, TChainConfigMap, TChainEndpoint, TChainWithApi, TConditionalXcmFeeDetail, TConditionalXcmFeeHopInfo, TCreateBaseSwapXcmOptions, TCreateBaseTransferXcmOptions, TCreateBeneficiaryOptions, TCreateBeneficiaryXTokensOptions, TCreateSwapXcmInternalOptions, TCreateSwapXcmOptions, TCreateTransferXcmOptions, TCreateTxsOptions, TDestWeight, TDestXcmFeeDetail, TDestination, TDryRunBaseOptions, TDryRunBypassOptions, TDryRunCallBaseOptions, TDryRunCallOptions, TDryRunChainFailure, TDryRunChainResult, TDryRunChainSuccess, TDryRunError, TDryRunOptions, TDryRunPreviewOptions, TDryRunResBase, TDryRunResult, TDryRunXcmBaseOptions, TDryRunXcmOptions, TEvmBuilderOptions, TEvmBuilderOptionsBase, TEvmChainFrom, TFeeType, TForeignAssetId, TForeignOrNativeAsset, TForeignOrTokenAsset, TGetAssetBalanceOptions, TGetAssetBalanceOptionsBase, TGetBalanceCommonOptions, TGetBalanceOptions, TGetBalanceOptionsBase, TGetFeeForDestChainBaseOptions, TGetFeeForDestChainOptions, TGetMinTransferableAmountOptions, TGetOriginXcmFeeBaseOptions, TGetOriginXcmFeeEstimateOptions, TGetOriginXcmFeeInternalOptions, TGetOriginXcmFeeOptions, TGetReverseTxFeeOptions, TGetTransferInfoOptions, TGetTransferInfoOptionsBase, TGetTransferableAmountOptions, TGetTransferableAmountOptionsBase, TGetXcmFeeBaseOptions, TGetXcmFeeBuilderOptions, TGetXcmFeeEstimateDetail, TGetXcmFeeEstimateOptions, TGetXcmFeeEstimateResult, TGetXcmFeeInternalOptions, TGetXcmFeeOptions, TGetXcmFeeResult, THopInfo, THopTransferInfo, TMantaAsset, TModuleError, TNativeTokenAsset, TNodleAsset, TOriginFeeDetails, TOtherReserveAsset, TPolkadotXCMTransferOptions, TPolkadotXcmMethod, TProviderEntry, TRelayToParaDestination, TRelayToParaOptions, TRelayToParaOverrides, TReserveAsset, TResolveHopParams, TScenario, TSelfReserveAsset, TSendBaseOptions, TSendBaseOptionsWithSenderAddress, TSendInternalOptions, TSendOptions, TSerializeEthTransferOptions, TSerializedEthTransfer, TSerializedExtrinsics, TSerializedRuntimeApiQuery, TSerializedStateQuery, TSetBalanceRes, TSwapConfig, TSwapFeeEstimates, TTransferFeeEstimates, TTransferInfo, TTransferLocalOptions, TTxFactory, TTypeAndThenCallContext, TTypeAndThenFees, TUrl, TVerifyEdOnDestinationOptions, TVerifyEdOnDestinationOptionsBase, TWeight, TXTokensCurrencySelection, TXTokensMethod, TXTokensTransferOptions, TXTransferMethod, TXTransferTransferOptions, TXcmAsset, TXcmFeeBase, TXcmFeeDetail, TXcmFeeDetailError, TXcmFeeDetailSuccess, TXcmFeeDetailWithFallback, TXcmFeeHopInfo, TXcmFeeHopResult, TXcmFeeSwapConfig, TXcmForeignAsset, TXcmPalletMethod, TXcmVersioned, TZeitgeistAsset, WithApi, WithRequiredSenderAddress };
2366
+ export { AmountTooLowError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiUnavailableError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, UnsupportedOperationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertDerivationPath, assertHasId, assertHasLocation, assertSenderAddress, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, computeOverridenAmount, constructTypeAndThenCall, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createClientCache, createClientPoolHelpers, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createId, createTx, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, formatAssetIdToERC20, formatUnits, getAssetBalanceInternal, getAssetReserveChain, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getEthErc20Balance, getEvmPrivateKeyHex, getFailureInfo, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginXcmFee, getOriginXcmFeeEstimate, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, keyFromWs, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, overrideTxAmount, padFee, padValueBy, parseUnits, resolveDestChain, resolveModuleError, resolveParaId, reverseTransformLocation, send, sortAssets, throwUnsupportedCurrency, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, verifyEdOnDestination, wrapTxBypass };
2367
+ export type { BuildHopInfoOptions, ClientCache, HopProcessParams, HopTraversalConfig, HopTraversalResult, IPolkadotApi, IPolkadotXCMTransfer, IXTokensTransfer, IXTransferTransfer, OneKey, TAddress, TApiOrUrl, TAssetClaimInternalOptions, TAssetClaimOptions, TAssetClaimOptionsBase, TBatchOptions, TBatchedSendOptions, TBifrostToken, TBridgeStatus, TBuildDestInfoOptions, TBuildInternalRes, TBuilderConfig, TBuilderInternalOptions, TBuilderOptions, TBypassOptions, TCacheItem, TChainConfig, TChainConfigMap, TChainEndpoint, TChainWithApi, TClientEntry, TClientKey, TConditionalXcmFeeDetail, TConditionalXcmFeeHopInfo, TCreateBaseSwapXcmOptions, TCreateBaseTransferXcmOptions, TCreateBeneficiaryOptions, TCreateBeneficiaryXTokensOptions, TCreateSwapXcmInternalOptions, TCreateSwapXcmOptions, TCreateTransferXcmOptions, TCreateTxsOptions, TDestWeight, TDestXcmFeeDetail, TDestination, TDryRunBaseOptions, TDryRunBypassOptions, TDryRunCallBaseOptions, TDryRunCallOptions, TDryRunChainFailure, TDryRunChainResult, TDryRunChainSuccess, TDryRunError, TDryRunOptions, TDryRunPreviewOptions, TDryRunResBase, TDryRunResult, TDryRunXcmBaseOptions, TDryRunXcmOptions, TEvmBuilderOptions, TEvmBuilderOptionsBase, TEvmChainFrom, TFeeType, TForeignAssetId, TForeignOrNativeAsset, TForeignOrTokenAsset, TGetAssetBalanceOptions, TGetAssetBalanceOptionsBase, TGetBalanceCommonOptions, TGetBalanceOptions, TGetBalanceOptionsBase, TGetFeeForDestChainBaseOptions, TGetFeeForDestChainOptions, TGetMinTransferableAmountOptions, TGetOriginXcmFeeBaseOptions, TGetOriginXcmFeeEstimateOptions, TGetOriginXcmFeeInternalOptions, TGetOriginXcmFeeOptions, TGetReverseTxFeeOptions, TGetTransferInfoOptions, TGetTransferInfoOptionsBase, TGetTransferableAmountOptions, TGetTransferableAmountOptionsBase, TGetXcmFeeBaseOptions, TGetXcmFeeBuilderOptions, TGetXcmFeeEstimateDetail, TGetXcmFeeEstimateOptions, TGetXcmFeeEstimateResult, TGetXcmFeeInternalOptions, TGetXcmFeeOptions, TGetXcmFeeResult, THopInfo, THopTransferInfo, TMantaAsset, TModuleError, TNativeTokenAsset, TNodleAsset, TOriginFeeDetails, TOtherReserveAsset, TPolkadotXCMTransferOptions, TPolkadotXcmMethod, TProviderEntry, TRelayToParaDestination, TRelayToParaOptions, TRelayToParaOverrides, TReserveAsset, TResolveHopParams, TScenario, TSelfReserveAsset, TSendBaseOptions, TSendBaseOptionsWithSenderAddress, TSendInternalOptions, TSendOptions, TSerializeEthTransferOptions, TSerializedEthTransfer, TSerializedExtrinsics, TSerializedRuntimeApiQuery, TSerializedStateQuery, TSetBalanceRes, TSwapConfig, TSwapFeeEstimates, TTransferFeeEstimates, TTransferInfo, TTransferLocalOptions, TTxFactory, TTypeAndThenCallContext, TTypeAndThenFees, TUrl, TVerifyEdOnDestinationOptions, TVerifyEdOnDestinationOptionsBase, TWeight, TXTokensCurrencySelection, TXTokensMethod, TXTokensTransferOptions, TXTransferMethod, TXTransferTransferOptions, TXcmAsset, TXcmFeeBase, TXcmFeeDetail, TXcmFeeDetailError, TXcmFeeDetailSuccess, TXcmFeeDetailWithFallback, TXcmFeeHopInfo, TXcmFeeHopResult, TXcmFeeSwapConfig, TXcmForeignAsset, TXcmPalletMethod, TXcmVersioned, TZeitgeistAsset, WithApi, WithRequiredSenderAddress };
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import { isChainEvm, getAssetsObject, InvalidCurrencyError, extractAssetLocation
3
3
  export * from '@paraspell/assets';
4
4
  import { base58 } from '@scure/base';
5
5
  import { isAddress, parseUnits as parseUnits$1, formatUnits as formatUnits$1, getContract, createPublicClient, http, pad, toHex, getAddress, concat, keccak256 } from 'viem';
6
- import { replaceBigInt, isTLocation, Version, hasJunction, getJunctionValue, isRelayChain, deepEqual, Parents, isExternalChain, isSubstrateBridge, PARACHAINS, RELAYCHAINS, isSystemChain, isTrustedChain } from '@paraspell/sdk-common';
6
+ import { replaceBigInt, isTLocation, Version, hasJunction, getJunctionValue, isRelayChain, deepEqual, Parents, isExternalChain, isSubstrateBridge, PARACHAINS, RELAYCHAINS, isTrustedChain } from '@paraspell/sdk-common';
7
7
  export * from '@paraspell/sdk-common';
8
8
  import { mainnet, moonbeam, moonriver } from 'viem/chains';
9
9
  import { getSupportedPallets, getNativeAssetsPallet, getOtherAssetsPallets, getSupportedPalletsDetails } from '@paraspell/pallets';
@@ -789,6 +789,229 @@ var convertSs58 = function convertSs58(api, address, chain) {
789
789
  return encodeSs58(deriveAccountId(publicKey), ss58Prefix);
790
790
  };
791
791
 
792
+ var keyFromWs = function keyFromWs(ws) {
793
+ return Array.isArray(ws) ? JSON.stringify(ws) : ws;
794
+ };
795
+ var createClientPoolHelpers = function createClientPoolHelpers(clientPool, createClient) {
796
+ var leaseClient = /*#__PURE__*/function () {
797
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(ws, ttlMs, useLegacy) {
798
+ var key, entry, client;
799
+ return _regenerator().w(function (_context) {
800
+ while (1) switch (_context.n) {
801
+ case 0:
802
+ key = keyFromWs(ws);
803
+ entry = clientPool.peek(key);
804
+ if (entry) {
805
+ _context.n = 2;
806
+ break;
807
+ }
808
+ _context.n = 1;
809
+ return createClient(ws, useLegacy);
810
+ case 1:
811
+ client = _context.v;
812
+ entry = {
813
+ client: client,
814
+ refs: 0,
815
+ destroyWanted: false
816
+ };
817
+ clientPool.set(key, entry, ttlMs);
818
+ case 2:
819
+ entry.refs += 1;
820
+ clientPool.revive(key, ttlMs);
821
+ entry.destroyWanted = false;
822
+ return _context.a(2, entry.client);
823
+ }
824
+ }, _callee);
825
+ }));
826
+ return function leaseClient(_x, _x2, _x3) {
827
+ return _ref.apply(this, arguments);
828
+ };
829
+ }();
830
+ var releaseClient = function releaseClient(ws) {
831
+ var key = keyFromWs(ws);
832
+ var entry = clientPool.peek(key);
833
+ if (!entry) {
834
+ return;
835
+ }
836
+ entry.refs -= 1;
837
+ if (entry.refs === 0 && entry.destroyWanted) {
838
+ clientPool["delete"](key);
839
+ }
840
+ };
841
+ return {
842
+ leaseClient: leaseClient,
843
+ releaseClient: releaseClient
844
+ };
845
+ };
846
+
847
+ var createClientCache = function createClientCache(maxSize, pingClient, onEviction) {
848
+ var extensionMs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 5 * 60000;
849
+ var data = new Map();
850
+ var timers = new Map();
851
+ var now = function now() {
852
+ return Date.now();
853
+ };
854
+ var timeLeft = function timeLeft(w) {
855
+ return Math.max(w.expireAt - now(), 0);
856
+ };
857
+ var schedule = function schedule(k, delay) {
858
+ if (timers.has(k)) clearTimeout(timers.get(k));
859
+ timers.set(k, setTimeout(function () {
860
+ return handleTimeout(k);
861
+ }, delay));
862
+ };
863
+ var handleTimeout = function handleTimeout(k) {
864
+ var w = data.get(k);
865
+ if (!w) return;
866
+ if (!w.extended && w.value.refs > 0) {
867
+ // first expiry while still in use - Extend grace period
868
+ // Call rpc.properties to keep the connection alive
869
+ void _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
870
+ return _regenerator().w(function (_context) {
871
+ while (1) switch (_context.p = _context.n) {
872
+ case 0:
873
+ _context.p = 0;
874
+ _context.n = 1;
875
+ return pingClient(w.value.client);
876
+ case 1:
877
+ _context.n = 3;
878
+ break;
879
+ case 2:
880
+ _context.p = 2;
881
+ _context.v;
882
+ case 3:
883
+ return _context.a(2);
884
+ }
885
+ }, _callee, null, [[0, 2]]);
886
+ }))();
887
+ w.value.destroyWanted = true;
888
+ w.extended = true;
889
+ w.expireAt = now() + extensionMs;
890
+ schedule(k, extensionMs);
891
+ return;
892
+ }
893
+ evict(k); // second expiry or unused - real eviction
894
+ };
895
+ var evict = function evict(k) {
896
+ var w = data.get(k);
897
+ if (!w) return;
898
+ clearTimeout(timers.get(k));
899
+ timers["delete"](k);
900
+ data["delete"](k);
901
+ onEviction === null || onEviction === void 0 || onEviction(k, w.value);
902
+ };
903
+ var evictIfNeeded = function evictIfNeeded() {
904
+ if (data.size <= maxSize) return;
905
+ var victimKey;
906
+ var victim;
907
+ var _iterator = _createForOfIteratorHelper(data),
908
+ _step;
909
+ try {
910
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
911
+ var _step$value = _slicedToArray(_step.value, 2),
912
+ k = _step$value[0],
913
+ w = _step$value[1];
914
+ if (!victim) {
915
+ victimKey = k;
916
+ victim = w;
917
+ continue;
918
+ }
919
+ var better = w.extended && !victim.extended ||
920
+ // Prefer extended over normal
921
+ w.extended === victim.extended && w.value.destroyWanted && !victim.value.destroyWanted || w.extended === victim.extended && w.value.destroyWanted === victim.value.destroyWanted && timeLeft(w) < timeLeft(victim) || w.extended === victim.extended && w.value.destroyWanted === victim.value.destroyWanted && timeLeft(w) === timeLeft(victim) && w.value.refs < victim.value.refs; // Prefer with less refs
922
+ if (better) {
923
+ victimKey = k;
924
+ victim = w;
925
+ }
926
+ }
927
+ } catch (err) {
928
+ _iterator.e(err);
929
+ } finally {
930
+ _iterator.f();
931
+ }
932
+ if (victimKey !== undefined) evict(victimKey);
933
+ };
934
+ var set = function set(k, v, ttl) {
935
+ var existing = data.get(k);
936
+ if (existing) {
937
+ existing.value = v;
938
+ existing.ttl = ttl;
939
+ existing.extended = false;
940
+ existing.expireAt = now() + ttl;
941
+ schedule(k, ttl);
942
+ } else {
943
+ data.set(k, {
944
+ value: v,
945
+ ttl: ttl,
946
+ extended: false,
947
+ expireAt: now() + ttl
948
+ });
949
+ schedule(k, ttl);
950
+ }
951
+ evictIfNeeded();
952
+ };
953
+ var get = function get(k) {
954
+ var w = data.get(k);
955
+ if (!w) return undefined;
956
+ if (!w.extended && timeLeft(w) < w.ttl) {
957
+ w.expireAt = now() + w.ttl; // refresh normal life
958
+ schedule(k, w.ttl);
959
+ }
960
+ return w.value;
961
+ };
962
+ var revive = function revive(k, ttl) {
963
+ var w = data.get(k);
964
+ if (!w) return;
965
+ var remaining = timeLeft(w);
966
+ w.extended = false;
967
+ if (ttl < remaining) {
968
+ w.ttl = ttl;
969
+ w.expireAt = now() + ttl;
970
+ schedule(k, ttl);
971
+ }
972
+ // if ttl ≥ remaining - keep current timer
973
+ };
974
+ var del = function del(k) {
975
+ if (!data.has(k)) return false;
976
+ evict(k);
977
+ return true;
978
+ };
979
+ var clear = function clear() {
980
+ var _iterator2 = _createForOfIteratorHelper(timers.values()),
981
+ _step2;
982
+ try {
983
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
984
+ var t = _step2.value;
985
+ clearTimeout(t);
986
+ }
987
+ } catch (err) {
988
+ _iterator2.e(err);
989
+ } finally {
990
+ _iterator2.f();
991
+ }
992
+ timers.clear();
993
+ data.clear();
994
+ };
995
+ return {
996
+ set: set,
997
+ get: get,
998
+ "delete": del,
999
+ has: function has(k) {
1000
+ return data.has(k);
1001
+ },
1002
+ clear: clear,
1003
+ peek: function peek(k) {
1004
+ var _data$get;
1005
+ return (_data$get = data.get(k)) === null || _data$get === void 0 ? void 0 : _data$get.value;
1006
+ },
1007
+ remainingTtl: function remainingTtl(k) {
1008
+ var w = data.get(k);
1009
+ return w ? timeLeft(w) : undefined;
1010
+ },
1011
+ revive: revive
1012
+ };
1013
+ };
1014
+
792
1015
  var BaseAssetsPallet = /*#__PURE__*/_createClass(function BaseAssetsPallet(palletName) {
793
1016
  _classCallCheck(this, BaseAssetsPallet);
794
1017
  this.palletName = palletName;
@@ -823,6 +1046,11 @@ var assertHasId = function assertHasId(asset) {
823
1046
  throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset, replaceBigInt), " has no assetId"));
824
1047
  }
825
1048
  };
1049
+ var assertDerivationPath = function assertDerivationPath(path) {
1050
+ if (!path) {
1051
+ throw new InvalidAddressError('Sender address needs to be a derivation path to sign and submit transaction using this method.');
1052
+ }
1053
+ };
826
1054
 
827
1055
  var createId = function createId(version, location) {
828
1056
  if (version === Version.V3) {
@@ -3018,6 +3246,22 @@ var AssetClaimBuilder = /*#__PURE__*/function () {
3018
3246
  currency: _currency
3019
3247
  }));
3020
3248
  }
3249
+ /**
3250
+ * Sets the sender address.
3251
+ *
3252
+ * @param address - The sender address.
3253
+ * @returns
3254
+ */
3255
+ }, {
3256
+ key: "senderAddress",
3257
+ value: function senderAddress(addressOrPath) {
3258
+ var isPath = addressOrPath.startsWith('//');
3259
+ var address = isPath ? this.api.deriveAddress(addressOrPath) : addressOrPath;
3260
+ return new AssetClaimBuilder(this.api, _objectSpread2(_objectSpread2({}, this._options), {}, {
3261
+ senderAddress: address,
3262
+ path: isPath ? addressOrPath : undefined
3263
+ }));
3264
+ }
3021
3265
  /**
3022
3266
  * Specifies the account address on which the assets will be claimed.
3023
3267
  *
@@ -3027,8 +3271,10 @@ var AssetClaimBuilder = /*#__PURE__*/function () {
3027
3271
  }, {
3028
3272
  key: "address",
3029
3273
  value: function address(_address) {
3274
+ var isPath = typeof _address === 'string' && _address.startsWith('//');
3275
+ var resolvedAddress = isPath ? this.api.deriveAddress(_address) : _address;
3030
3276
  return new AssetClaimBuilder(this.api, _objectSpread2(_objectSpread2({}, this._options), {}, {
3031
- address: _address
3277
+ address: resolvedAddress
3032
3278
  }));
3033
3279
  }
3034
3280
  /**
@@ -3056,6 +3302,31 @@ var AssetClaimBuilder = /*#__PURE__*/function () {
3056
3302
  api: this.api
3057
3303
  }, this._options));
3058
3304
  }
3305
+ }, {
3306
+ key: "signAndSubmit",
3307
+ value: function () {
3308
+ var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
3309
+ var path, tx;
3310
+ return _regenerator().w(function (_context) {
3311
+ while (1) switch (_context.n) {
3312
+ case 0:
3313
+ path = this._options.path;
3314
+ assertDerivationPath(path);
3315
+ _context.n = 1;
3316
+ return claimAssets(_objectSpread2({
3317
+ api: this.api
3318
+ }, this._options));
3319
+ case 1:
3320
+ tx = _context.v;
3321
+ return _context.a(2, this.api.signAndSubmit(tx, path));
3322
+ }
3323
+ }, _callee, this);
3324
+ }));
3325
+ function signAndSubmit() {
3326
+ return _signAndSubmit.apply(this, arguments);
3327
+ }
3328
+ return signAndSubmit;
3329
+ }()
3059
3330
  /**
3060
3331
  * Returns the API instance used by the builder.
3061
3332
  *
@@ -3448,8 +3719,10 @@ var GeneralBuilder = /*#__PURE__*/function () {
3448
3719
  }, {
3449
3720
  key: "address",
3450
3721
  value: function address(_address) {
3722
+ var isPath = typeof _address === 'string' && _address.startsWith('//');
3723
+ var resolvedAddress = isPath ? this.api.deriveAddress(_address) : _address;
3451
3724
  return new GeneralBuilder(this.api, this.batchManager, _objectSpread2(_objectSpread2({}, this._options), {}, {
3452
- address: _address
3725
+ address: resolvedAddress
3453
3726
  }));
3454
3727
  }
3455
3728
  /**
@@ -3460,9 +3733,12 @@ var GeneralBuilder = /*#__PURE__*/function () {
3460
3733
  */
3461
3734
  }, {
3462
3735
  key: "senderAddress",
3463
- value: function senderAddress(address) {
3736
+ value: function senderAddress(addressOrPath) {
3737
+ var isPath = addressOrPath.startsWith('//');
3738
+ var address = isPath ? this.api.deriveAddress(addressOrPath) : addressOrPath;
3464
3739
  return new GeneralBuilder(this.api, this.batchManager, _objectSpread2(_objectSpread2({}, this._options), {}, {
3465
- senderAddress: address
3740
+ senderAddress: address,
3741
+ path: isPath ? addressOrPath : undefined
3466
3742
  }));
3467
3743
  }
3468
3744
  /**
@@ -3763,9 +4039,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
3763
4039
  }, {
3764
4040
  key: "getXcmFee",
3765
4041
  value: (function () {
3766
- var _getXcmFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(
3767
- // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
3768
- options) {
4042
+ var _getXcmFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(options) {
3769
4043
  var _options$disableFallb;
3770
4044
  var disableFallback, _yield$this$prepareNo2, normalizedOptions, buildTx, api, from, to, senderAddress, address, currency, feeAsset;
3771
4045
  return _regenerator().w(function (_context8) {
@@ -4186,13 +4460,36 @@ var GeneralBuilder = /*#__PURE__*/function () {
4186
4460
  return _getReceivableAmount.apply(this, arguments);
4187
4461
  }
4188
4462
  return getReceivableAmount;
4463
+ }())
4464
+ }, {
4465
+ key: "signAndSubmit",
4466
+ value: function () {
4467
+ var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
4468
+ var path, _yield$this$buildInte3, tx;
4469
+ return _regenerator().w(function (_context15) {
4470
+ while (1) switch (_context15.n) {
4471
+ case 0:
4472
+ path = this._options.path;
4473
+ assertDerivationPath(path);
4474
+ _context15.n = 1;
4475
+ return this.buildInternal();
4476
+ case 1:
4477
+ _yield$this$buildInte3 = _context15.v;
4478
+ tx = _yield$this$buildInte3.tx;
4479
+ return _context15.a(2, this.api.signAndSubmit(tx, path));
4480
+ }
4481
+ }, _callee15, this);
4482
+ }));
4483
+ function signAndSubmit() {
4484
+ return _signAndSubmit.apply(this, arguments);
4485
+ }
4486
+ return signAndSubmit;
4189
4487
  }()
4190
4488
  /**
4191
4489
  * Returns the API instance used by the builder.
4192
4490
  *
4193
4491
  * @returns The API instance.
4194
4492
  */
4195
- )
4196
4493
  }, {
4197
4494
  key: "getApi",
4198
4495
  value: function getApi() {
@@ -8023,21 +8320,28 @@ var getTransferableAmount = /*#__PURE__*/function () {
8023
8320
  };
8024
8321
  }();
8025
8322
 
8026
- var buildTypeAndThenCall = function buildTypeAndThenCall(_ref, isDotAsset, customXcm, assets) {
8323
+ var resolveTransferType = function resolveTransferType(_ref) {
8027
8324
  var origin = _ref.origin,
8028
- reserve = _ref.reserve,
8029
- dest = _ref.dest,
8030
- isSubBridge = _ref.isSubBridge,
8031
- assetInfo = _ref.assetInfo,
8032
- _ref$options = _ref.options,
8033
- version = _ref$options.version,
8034
- pallet = _ref$options.pallet,
8035
- method = _ref$options.method;
8325
+ reserve = _ref.reserve;
8326
+ if (origin.chain === reserve.chain) return 'LocalReserve';
8327
+ if (isTrustedChain(origin.chain) && isTrustedChain(reserve.chain)) return 'Teleport';
8328
+ return 'DestinationReserve';
8329
+ };
8330
+ var buildTypeAndThenCall = function buildTypeAndThenCall(context, isDotAsset, customXcm, assets) {
8331
+ var origin = context.origin,
8332
+ reserve = context.reserve,
8333
+ dest = context.dest,
8334
+ isSubBridge = context.isSubBridge,
8335
+ assetInfo = context.assetInfo,
8336
+ _context$options = context.options,
8337
+ version = _context$options.version,
8338
+ pallet = _context$options.pallet,
8339
+ method = _context$options.method;
8036
8340
  var feeAssetLocation = !isDotAsset ? RELAY_LOCATION : assetInfo.location;
8037
8341
  var finalDest = origin.chain === reserve.chain ? dest.chain : reserve.chain;
8038
8342
  var destLocation = createDestination(version, origin.chain, finalDest, getParaId(finalDest));
8039
- var reserveType = origin.chain === reserve.chain ? 'LocalReserve' : 'DestinationReserve';
8040
- var feeMultiAsset = createAsset(version, assetInfo.amount, isRelayChain(origin.chain) || isSubBridge ? localizeLocation(origin.chain, feeAssetLocation) : feeAssetLocation);
8343
+ var transferType = resolveTransferType(context);
8344
+ var feeMultiAsset = createAsset(version, assetInfo.amount, isRelayChain(origin.chain) || isSubBridge || origin.chain === 'Mythos' ? localizeLocation(origin.chain, feeAssetLocation) : feeAssetLocation);
8041
8345
  var module = pallet !== null && pallet !== void 0 ? pallet : isRelayChain(origin.chain) ? 'XcmPallet' : 'PolkadotXcm';
8042
8346
  var methodName = method !== null && method !== void 0 ? method : 'transfer_assets_using_type_and_then';
8043
8347
  return {
@@ -8046,9 +8350,9 @@ var buildTypeAndThenCall = function buildTypeAndThenCall(_ref, isDotAsset, custo
8046
8350
  params: {
8047
8351
  dest: addXcmVersionHeader(destLocation, version),
8048
8352
  assets: addXcmVersionHeader(assets, version),
8049
- assets_transfer_type: reserveType,
8353
+ assets_transfer_type: transferType,
8050
8354
  remote_fees_id: addXcmVersionHeader(feeMultiAsset.id, version),
8051
- fees_transfer_type: reserveType,
8355
+ fees_transfer_type: transferType,
8052
8356
  custom_xcm_on_dest: addXcmVersionHeader(customXcm, version),
8053
8357
  weight_limit: 'Unlimited'
8054
8358
  }
@@ -8072,7 +8376,7 @@ var resolveReserveChain = function resolveReserveChain(chain, destination, asset
8072
8376
  };
8073
8377
  var createTypeAndThenCallContext = /*#__PURE__*/function () {
8074
8378
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options, overrideReserve) {
8075
- var api, destination, assetInfo, destinationChain, isSubBridge, reserveChain, RELAY_ASSET_LOCATIONS, systemAsset, isRelayAsset, destApi, reserveApi;
8379
+ var api, destination, assetInfo, destinationChain, isSubBridge, reserveChain, NO_FEE_ASSET_LOCS, systemAsset, isRelayAsset, destApi, reserveApi;
8076
8380
  return _regenerator().w(function (_context) {
8077
8381
  while (1) switch (_context.n) {
8078
8382
  case 0:
@@ -8082,7 +8386,7 @@ var createTypeAndThenCallContext = /*#__PURE__*/function () {
8082
8386
  destinationChain = destination;
8083
8387
  isSubBridge = isSubstrateBridge(chain, destinationChain);
8084
8388
  reserveChain = resolveReserveChain(chain, destinationChain, assetInfo.location, isSubBridge, overrideReserve);
8085
- RELAY_ASSET_LOCATIONS = [RELAY_LOCATION, {
8389
+ NO_FEE_ASSET_LOCS = [RELAY_LOCATION, {
8086
8390
  parents: 2,
8087
8391
  interior: {
8088
8392
  X1: [{
@@ -8100,9 +8404,16 @@ var createTypeAndThenCallContext = /*#__PURE__*/function () {
8100
8404
  }
8101
8405
  }]
8102
8406
  }
8407
+ }, {
8408
+ parents: 1,
8409
+ interior: {
8410
+ X1: [{
8411
+ Parachain: 3369
8412
+ }]
8413
+ }
8103
8414
  }];
8104
8415
  systemAsset = findNativeAssetInfoOrThrow(getRelayChainOf(chain));
8105
- isRelayAsset = RELAY_ASSET_LOCATIONS.some(function (loc) {
8416
+ isRelayAsset = NO_FEE_ASSET_LOCS.some(function (loc) {
8106
8417
  return deepEqual(assetInfo.location, loc);
8107
8418
  }) || isSubBridge;
8108
8419
  destApi = api.clone();
@@ -8215,8 +8526,8 @@ var createCustomXcm = function createCustomXcm(context, assetCount, isForFeeCalc
8215
8526
  return [buyExecution, depositInstruction];
8216
8527
  }
8217
8528
  var destLoc = createDestination(version, origin.chain, destination, paraIdTo);
8218
- // If destination is a system chain, use teleport instead of reserve deposit
8219
- if (isSystemChain(dest.chain)) {
8529
+ // If destination is a trusted chain, use teleport instead of reserve deposit
8530
+ if (isTrustedChain(dest.chain)) {
8220
8531
  return [].concat(_toConsumableArray(refundInstruction ? [refundInstruction] : []), [{
8221
8532
  InitiateTeleport: {
8222
8533
  assets: filter,
@@ -8257,7 +8568,7 @@ var createRefundInstruction = function createRefundInstruction(api, senderAddres
8257
8568
 
8258
8569
  var buildAssets = function buildAssets(chain, asset, feeAmount, isRelayAsset, version) {
8259
8570
  var assets = [];
8260
- var shouldLocalizeAndSort = isRelayChain(chain) || chain.startsWith('AssetHub');
8571
+ var shouldLocalizeAndSort = isRelayChain(chain) || chain.startsWith('AssetHub') || chain === 'Mythos';
8261
8572
  if (!isRelayAsset) {
8262
8573
  assets.push(createAsset(version, feeAmount, RELAY_LOCATION));
8263
8574
  }
@@ -8628,7 +8939,7 @@ var Parachain = /*#__PURE__*/function () {
8628
8939
  key: "transfer",
8629
8940
  value: function () {
8630
8941
  var _transfer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(sendOptions) {
8631
- var api, asset, currency, feeAsset, feeCurrency, address, destination, paraIdTo, overriddenAsset, version, senderAddress, ahAddress, pallet, method, scenario, paraId, destChain, isLocalTransfer, isRelayAsset, supportsTypeThen, isSubBridge, useTypeAndThen, isBifrostOrigin, isJamtonOrigin, isAssetHubDest, useMultiAssets, input, _asset$location2, options, shouldUseTeleport, isAhToOtherPara, isOtherParaToAh, isAllowedAhTransfer, isAHOrigin, isAHDest, isExternalAsset, isEthDest, isExternalAssetViaAh, isExternalAssetToAh, call;
8942
+ var api, asset, currency, feeAsset, feeCurrency, address, destination, paraIdTo, overriddenAsset, version, senderAddress, ahAddress, pallet, method, scenario, paraId, destChain, isLocalTransfer, isRelayAsset, mythAsset, isMythAsset, assetNeedsTypeThen, supportsTypeThen, isSubBridge, useTypeAndThen, isBifrostOrigin, isJamtonOrigin, isAssetHubDest, useMultiAssets, input, _asset$location2, options, shouldUseTeleport, isAhToOtherPara, isOtherParaToAh, isAllowedAhTransfer, isAHOrigin, isAHDest, isExternalAsset, isEthDest, isExternalAssetViaAh, isExternalAssetToAh, call;
8632
8943
  return _regenerator().w(function (_context) {
8633
8944
  while (1) switch (_context.n) {
8634
8945
  case 0:
@@ -8646,18 +8957,21 @@ var Parachain = /*#__PURE__*/function () {
8646
8957
  this.throwIfTempDisabled(sendOptions, destChain);
8647
8958
  this.throwIfCantReceive(destChain);
8648
8959
  isRelayAsset = deepEqual(asset.location, RELAY_LOCATION) && isSymbolMatch(getRelayChainSymbol(this.chain), asset.symbol);
8960
+ mythAsset = findNativeAssetInfoOrThrow('Mythos');
8961
+ isMythAsset = isAssetXcEqual(mythAsset, asset);
8962
+ assetNeedsTypeThen = isRelayAsset || isMythAsset;
8649
8963
  _context.n = 2;
8650
8964
  return api.hasMethod('PolkadotXcm', 'transfer_assets_using_type_and_then');
8651
8965
  case 2:
8652
8966
  supportsTypeThen = _context.v;
8653
- if (!(isRelayAsset && !supportsTypeThen)) {
8967
+ if (!(assetNeedsTypeThen && !supportsTypeThen)) {
8654
8968
  _context.n = 3;
8655
8969
  break;
8656
8970
  }
8657
8971
  throw new UnsupportedOperationError('Relaychain assets require the type-and-then method which is not supported by this chain.');
8658
8972
  case 3:
8659
8973
  isSubBridge = !isTLocation(destination) && isSubstrateBridge(this.chain, destination);
8660
- useTypeAndThen = isRelayAsset && supportsTypeThen && destChain && !isExternalChain(destChain) && !feeAsset && (!isTrustedChain(this.chain) || !isTrustedChain(destChain)) || isSubBridge;
8974
+ useTypeAndThen = assetNeedsTypeThen && supportsTypeThen && destChain && !isExternalChain(destChain) && !feeAsset && (!isTrustedChain(this.chain) || !isTrustedChain(destChain)) || isSubBridge;
8661
8975
  if (!(supportsXTokens(this) && this.canUseXTokens(sendOptions) && !useTypeAndThen)) {
8662
8976
  _context.n = 5;
8663
8977
  break;
@@ -8744,7 +9058,7 @@ var Parachain = /*#__PURE__*/function () {
8744
9058
  }
8745
9059
  throw new TransferToAhNotSupported('Native asset transfers to or from AssetHub are temporarily disabled');
8746
9060
  case 7:
8747
- if (!(this.chain === 'Astar' && isRelayAsset)) {
9061
+ if (!(this.chain === 'Astar' && assetNeedsTypeThen)) {
8748
9062
  _context.n = 8;
8749
9063
  break;
8750
9064
  }
@@ -13200,6 +13514,15 @@ var BYPASS_MINT_AMOUNT = '1000';
13200
13514
  var MIN_AMOUNT = 2n;
13201
13515
  var AMOUNT_ALL = 'ALL';
13202
13516
 
13517
+ var EVM_DEV_PRIVATE_KEYS = {
13518
+ alith: '0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133',
13519
+ baltathar: '0x8075991ce870b93a8870eca0c0f91913d12f47948ca0fd25b49c6fa7cdbeee8b',
13520
+ charleth: '0x0b6e18cafb6ed99687ec547bd28139cafdd2bffe70e6b688025de6b445aa5c5b',
13521
+ dorothy: '0x39539ab1876910bbf3a223d84a29e28f1cb4e2e456503e7e91ed39b2e7223d68',
13522
+ ethan: '0x7dce9bc8babb68fec1409be38c8e1a52650206a7ed90ff956ae8a6d15eeaaef4',
13523
+ faith: '0xb9d2ea9a615f3165812e8d44de0d24da9bbd164b65c4f0573e1ce2c8dbd9c8df'
13524
+ };
13525
+
13203
13526
  /**
13204
13527
  * Retrieves the chain instance for a given chain.
13205
13528
  *
@@ -13409,6 +13732,14 @@ var resolveModuleError = function resolveModuleError(chain, error) {
13409
13732
  };
13410
13733
  };
13411
13734
 
13735
+ var getEvmPrivateKeyHex = function getEvmPrivateKeyHex(path) {
13736
+ var name = path.slice(2).toLowerCase();
13737
+ if (name in EVM_DEV_PRIVATE_KEYS) {
13738
+ return EVM_DEV_PRIVATE_KEYS[name];
13739
+ }
13740
+ return undefined;
13741
+ };
13742
+
13412
13743
  var normalizeAmount = function normalizeAmount(amount) {
13413
13744
  return amount < MIN_AMOUNT ? MIN_AMOUNT : amount;
13414
13745
  };
@@ -14107,4 +14438,4 @@ var getMoonbeamErc20Balance = /*#__PURE__*/function () {
14107
14438
  };
14108
14439
  }();
14109
14440
 
14110
- export { AmountTooLowError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiUnavailableError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, UnsupportedOperationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertHasId, assertHasLocation, assertSenderAddress, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, computeOverridenAmount, constructTypeAndThenCall, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createId, createTx, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, formatAssetIdToERC20, formatUnits, getAssetBalanceInternal, getAssetReserveChain, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getEthErc20Balance, getFailureInfo$1 as getFailureInfo, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginXcmFee, getOriginXcmFeeEstimate, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, overrideTxAmount, padFee, padValueBy, parseUnits, resolveDestChain, resolveModuleError, resolveParaId, reverseTransformLocation, send, sortAssets, throwUnsupportedCurrency, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, verifyEdOnDestination, wrapTxBypass };
14441
+ export { AmountTooLowError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiUnavailableError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, UnsupportedOperationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertDerivationPath, assertHasId, assertHasLocation, assertSenderAddress, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, computeOverridenAmount, constructTypeAndThenCall, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createClientCache, createClientPoolHelpers, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createId, createTx, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, formatAssetIdToERC20, formatUnits, getAssetBalanceInternal, getAssetReserveChain, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getEthErc20Balance, getEvmPrivateKeyHex, getFailureInfo$1 as getFailureInfo, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginXcmFee, getOriginXcmFeeEstimate, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, keyFromWs, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, overrideTxAmount, padFee, padValueBy, parseUnits, resolveDestChain, resolveModuleError, resolveParaId, reverseTransformLocation, send, sortAssets, throwUnsupportedCurrency, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, verifyEdOnDestination, wrapTxBypass };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-core",
3
- "version": "12.1.2",
3
+ "version": "12.2.1",
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.40.3",
29
- "@paraspell/assets": "12.1.2",
30
- "@paraspell/pallets": "12.1.2",
31
- "@paraspell/sdk-common": "12.1.2"
29
+ "@paraspell/sdk-common": "12.2.1",
30
+ "@paraspell/assets": "12.2.1",
31
+ "@paraspell/pallets": "12.2.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@babel/plugin-syntax-import-attributes": "^7.27.1",