UNPKG

@moonbeam-network/xcm-types

Version:
190 lines (178 loc) 6.79 kB
import Big, { RoundingMode } from 'big.js'; import { Chain as Chain$3 } from '@wormhole-foundation/sdk-connect'; import { Chain as Chain$1, Address } from 'viem'; import { Chain as Chain$2 } from 'viem/chains'; interface AssetConstructorParams { key: string; originSymbol: string; } declare class Asset { readonly key: string; readonly originSymbol: string; constructor({ key, originSymbol }: AssetConstructorParams); copyWith(params: Partial<AssetConstructorParams>): Asset; isEqual(asset: Asset): boolean; } interface ChainAssetConstructorParams extends AssetConstructorParams { address?: string; decimals: number; ids?: ChainAssetIds; min?: number | bigint; symbol?: string; } interface ChainAssetIds { balanceId?: ChainAssetId; id?: ChainAssetId; minId?: ChainAssetId; palletInstance?: number; generalKey?: GeneralKey; } type ChainAssetId = string | number | bigint | { [key: string]: ChainAssetId; }; interface GeneralKey { length: number; data: string; } declare class ChainAsset extends Asset { readonly address?: string; readonly decimals: number; readonly ids?: ChainAssetIds; readonly min?: bigint; readonly symbol?: string; constructor({ address, decimals, ids, min, symbol, ...other }: ChainAssetConstructorParams); static fromAsset(asset: Asset, params: Omit<ChainAssetConstructorParams, keyof AssetConstructorParams>): ChainAsset; copyWith(params: Partial<ChainAssetConstructorParams>): ChainAsset; getSymbol(): string; getAssetId(): ChainAssetId; getAssetRegisteredId(): ChainAssetId | undefined; getBalanceAssetId(): ChainAssetId; getMinAssetId(): ChainAssetId; getAssetPalletInstance(): number; getAssetMin(): bigint; getGeneralKey(): GeneralKey | undefined; hasOnlyAddress(): this is { address: string; }; } interface AssetAmountConstructorParams extends ChainAssetConstructorParams { amount: number | bigint; decimals: number; symbol?: string; } declare class AssetAmount extends ChainAsset { readonly amount: bigint; constructor({ amount, ...other }: AssetAmountConstructorParams); static fromChainAsset(asset: ChainAsset, params: Omit<AssetAmountConstructorParams, keyof ChainAssetConstructorParams>): AssetAmount; isSame(asset: ChainAsset | AssetAmount): boolean; isEqual(asset: AssetAmount): boolean; copyWith(params: Partial<AssetAmountConstructorParams>): AssetAmount; convertDecimals(decimals: number): AssetAmount; toBig(): Big; toBigDecimal(maxDecimal?: number, roundType?: RoundingMode): Big; toDecimal(maxDecimal?: number, roundType?: RoundingMode): string; } type AnyAsset = Asset | ChainAsset | AssetAmount; interface EvmChainConstructorParams extends ChainConstructorParams { id: number; rpc: string; } declare class EvmChain extends Chain { readonly id: number; readonly rpc: string; static is(obj: unknown): obj is EvmChain; constructor({ id, rpc, ...others }: EvmChainConstructorParams); getViemChain(): Chain$1; copyWith(params: Partial<EvmChainConstructorParams>): EvmChain; } interface ParachainConstructorParams extends ChainConstructorParams { checkSovereignAccountBalances?: boolean; genesisHash: string; isRelay?: boolean; parachainId: number; relayGenesisHash?: string; ss58Format: number; usesChainDecimals?: boolean; weight?: number; ws: string[]; } declare class Parachain extends Chain { readonly checkSovereignAccountBalances: boolean; readonly genesisHash: string; readonly isRelay: boolean; readonly parachainId: number; readonly ss58Format: number; readonly usesChainDecimals: boolean; readonly relayGenesisHash?: string; readonly weight: number | undefined; readonly ws: string[]; static is(obj: unknown): obj is Parachain; constructor({ checkSovereignAccountBalances, genesisHash, isRelay, parachainId, relayGenesisHash, usesChainDecimals, ss58Format, weight, ws, ...others }: ParachainConstructorParams); copyWith(params: Partial<ParachainConstructorParams>): Parachain; } interface EvmParachainConstructorParams extends ParachainConstructorParams { id?: number; rpc?: string; isEvmSigner?: boolean; contracts?: Contracts; } type Contracts = { Batch?: Address; XcmUtils?: Address; Xtokens?: Address; }; declare class EvmParachain extends Parachain { readonly id: number; readonly rpc: string; readonly isEvmSigner: boolean; readonly contracts?: Contracts; readonly ws: string[]; static is(obj: unknown): obj is EvmParachain; static isAnyParachain(obj: unknown): obj is EvmParachain | Parachain; static isAnyEvmChain(obj: unknown): obj is EvmParachain | EvmChain; constructor({ id, rpc, isEvmSigner, contracts, ...others }: EvmParachainConstructorParams); getViemChain(): Chain$2; copyWith(params: Partial<EvmParachainConstructorParams>): EvmParachain; } type AnyChain = EvmChain | Parachain | EvmParachain; type AnyParachain = Parachain | EvmParachain; declare enum Ecosystem { Polkadot = "polkadot", Kusama = "kusama", AlphanetRelay = "alphanet-relay", StagenetRelay = "stagenet-relay" } interface WormholeConfig { name?: Chain$3; } interface ChainConstructorParams { assets: Map<string, ChainAsset> | ChainAsset[]; ecosystem?: Ecosystem; explorer?: Explorer; isTestChain?: boolean; key: string; name: string; nativeAsset: Asset; wh?: WormholeConfig; } interface Explorer { base: string; txPath?: string; } declare abstract class Chain { #private; readonly assets: Map<string, ChainAsset>; readonly ecosystem?: Ecosystem; readonly explorer?: Explorer; readonly isTestChain: boolean; readonly key: string; readonly name: string; readonly wh?: WormholeConfig; constructor({ assets, ecosystem, explorer, isTestChain, key, name, nativeAsset, wh, }: ChainConstructorParams); get nativeAsset(): ChainAsset; isEqual<T extends Chain>(chain: T): boolean; getChainAsset(keyOrAsset: string | Asset | AssetAmount): ChainAsset; getWormholeName(): Chain$3; } type SetOptional<Base, Keys extends keyof Base> = Omit<Base, Keys> & Partial<Pick<Base, Keys>>; export { type AnyAsset, type AnyChain, type AnyParachain, Asset, AssetAmount, type AssetAmountConstructorParams, type AssetConstructorParams, Chain, ChainAsset, type ChainAssetConstructorParams, type ChainAssetId, type ChainAssetIds, type ChainConstructorParams, Ecosystem, EvmChain, type EvmChainConstructorParams, EvmParachain, type EvmParachainConstructorParams, type GeneralKey, Parachain, type ParachainConstructorParams, type SetOptional, type WormholeConfig };