@paraspell/sdk-core 12.2.0 → 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 +71 -41
- package/dist/index.mjs +224 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _paraspell_sdk_common from '@paraspell/sdk-common';
|
|
2
|
-
import { TChain,
|
|
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,
|
|
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>;
|
|
@@ -1460,43 +1520,13 @@ type TTypeAndThenFees = {
|
|
|
1460
1520
|
destFee: bigint;
|
|
1461
1521
|
};
|
|
1462
1522
|
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
deserializeExtrinsics(serialized: TSerializedExtrinsics): TRes;
|
|
1471
|
-
queryState<T>(serialized: TSerializedStateQuery): Promise<T>;
|
|
1472
|
-
queryRuntimeApi<T>(serialized: TSerializedRuntimeApiQuery): Promise<T>;
|
|
1473
|
-
callBatchMethod(calls: TRes[], mode: BatchMode): TRes;
|
|
1474
|
-
callDispatchAsMethod(call: TRes, address: string): TRes;
|
|
1475
|
-
objectToHex(obj: unknown, typeName: string): Promise<string>;
|
|
1476
|
-
hexToUint8a(hex: string): Uint8Array;
|
|
1477
|
-
stringToUint8a(str: string): Uint8Array;
|
|
1478
|
-
getMethod(tx: TRes): string;
|
|
1479
|
-
getTypeThenAssetCount(tx: TRes): number | undefined;
|
|
1480
|
-
hasMethod(pallet: TPallet, method: string): Promise<boolean>;
|
|
1481
|
-
calculateTransactionFee(tx: TRes, address: string): Promise<bigint>;
|
|
1482
|
-
quoteAhPrice(fromMl: TLocation, toMl: TLocation, amountIn: bigint, includeFee?: boolean): Promise<bigint | undefined>;
|
|
1483
|
-
getXcmWeight(xcm: any): Promise<TWeight>;
|
|
1484
|
-
getXcmPaymentApiFee(chain: TSubstrateChain, localXcm: any, forwardedXcm: any, asset: TAssetInfo, transformXcm: boolean): Promise<bigint>;
|
|
1485
|
-
getEvmStorage(contract: string, slot: string): Promise<string>;
|
|
1486
|
-
getFromRpc(module: string, method: string, key: string): Promise<string>;
|
|
1487
|
-
blake2AsHex(data: Uint8Array): string;
|
|
1488
|
-
clone(): IPolkadotApi<TApi, TRes>;
|
|
1489
|
-
createApiForChain(chain: TSubstrateChain): Promise<IPolkadotApi<TApi, TRes>>;
|
|
1490
|
-
getDryRunCall(options: TDryRunCallBaseOptions<TRes>): Promise<TDryRunChainResult>;
|
|
1491
|
-
getDryRunXcm(options: TDryRunXcmBaseOptions<TRes>): Promise<TDryRunChainResult>;
|
|
1492
|
-
getBridgeStatus(): Promise<TBridgeStatus>;
|
|
1493
|
-
setDisconnectAllowed(allowed: boolean): void;
|
|
1494
|
-
getDisconnectAllowed(): boolean;
|
|
1495
|
-
disconnect(force?: boolean): Promise<void>;
|
|
1496
|
-
validateSubstrateAddress(address: string): boolean;
|
|
1497
|
-
deriveAddress(path: string): string;
|
|
1498
|
-
signAndSubmit(tx: TRes, path: string): Promise<string>;
|
|
1499
|
-
}
|
|
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>;
|
|
1500
1530
|
|
|
1501
1531
|
declare const blake2b256: (msg: Uint8Array) => Uint8Array<ArrayBufferLike>;
|
|
1502
1532
|
declare const blake2b512: (msg: Uint8Array) => Uint8Array<ArrayBufferLike>;
|
|
@@ -2333,5 +2363,5 @@ declare const formatUnits: typeof formatUnits$1;
|
|
|
2333
2363
|
|
|
2334
2364
|
declare const validateAddress: <TApi, TRes>(api: IPolkadotApi<TApi, TRes>, address: TAddress, chain: TChain, isDestination?: boolean) => void;
|
|
2335
2365
|
|
|
2336
|
-
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, 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, 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 };
|
|
2337
|
-
export type { BuildHopInfoOptions, HopProcessParams, HopTraversalConfig, HopTraversalResult, IPolkadotApi, IPolkadotXCMTransfer, IXTokensTransfer, IXTransferTransfer, OneKey, TAddress, TApiOrUrl, TAssetClaimInternalOptions, TAssetClaimOptions, TAssetClaimOptionsBase, TBatchOptions, TBatchedSendOptions, TBifrostToken, TBridgeStatus, TBuildDestInfoOptions, TBuildInternalRes, TBuilderConfig, TBuilderInternalOptions, 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
|
@@ -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;
|
|
@@ -14215,4 +14438,4 @@ var getMoonbeamErc20Balance = /*#__PURE__*/function () {
|
|
|
14215
14438
|
};
|
|
14216
14439
|
}();
|
|
14217
14440
|
|
|
14218
|
-
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, 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, 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.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/sdk-common": "12.2.
|
|
30
|
-
"@paraspell/assets": "12.2.
|
|
31
|
-
"@paraspell/pallets": "12.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",
|