@moonbeam-network/xcm-types 2.5.5 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/build/index.d.mts +171 -0
- package/build/index.d.ts +141 -168
- package/build/index.mjs +311 -1
- package/build/index.mjs.map +1 -1
- package/package.json +16 -28
- package/build/index.cjs +0 -2
- package/build/index.cjs.map +0 -1
- package/build/index.d.cts +0 -141
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright
|
|
1
|
+
Copyright 2024 Moonbeam Foundation
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import Big, { RoundingMode } from 'big.js';
|
|
2
|
+
import { Chain as Chain$3 } from '@wormhole-foundation/sdk-connect';
|
|
3
|
+
import { Chain as Chain$1, Address } from 'viem';
|
|
4
|
+
import { Chain as Chain$2 } from 'viem/chains';
|
|
5
|
+
|
|
6
|
+
interface AssetConstructorParams {
|
|
7
|
+
key: string;
|
|
8
|
+
originSymbol: string;
|
|
9
|
+
}
|
|
10
|
+
declare class Asset {
|
|
11
|
+
readonly key: string;
|
|
12
|
+
readonly originSymbol: string;
|
|
13
|
+
constructor({ key, originSymbol }: AssetConstructorParams);
|
|
14
|
+
copyWith(params: Partial<AssetConstructorParams>): Asset;
|
|
15
|
+
isEqual(asset: Asset): boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface ChainAssetConstructorParams extends AssetConstructorParams {
|
|
19
|
+
address?: string;
|
|
20
|
+
decimals: number;
|
|
21
|
+
ids?: ChainAssetIds;
|
|
22
|
+
min?: number | bigint;
|
|
23
|
+
symbol?: string;
|
|
24
|
+
}
|
|
25
|
+
interface ChainAssetIds {
|
|
26
|
+
balanceId?: ChainAssetId;
|
|
27
|
+
id?: ChainAssetId;
|
|
28
|
+
minId?: ChainAssetId;
|
|
29
|
+
palletInstance?: number;
|
|
30
|
+
}
|
|
31
|
+
type ChainAssetId = string | number | bigint | {
|
|
32
|
+
[key: string]: ChainAssetId;
|
|
33
|
+
};
|
|
34
|
+
declare class ChainAsset extends Asset {
|
|
35
|
+
readonly address?: string;
|
|
36
|
+
readonly decimals: number;
|
|
37
|
+
readonly ids?: ChainAssetIds;
|
|
38
|
+
readonly min?: bigint;
|
|
39
|
+
readonly symbol?: string;
|
|
40
|
+
constructor({ address, decimals, ids, min, symbol, ...other }: ChainAssetConstructorParams);
|
|
41
|
+
static fromAsset(asset: Asset, params: Omit<ChainAssetConstructorParams, keyof AssetConstructorParams>): ChainAsset;
|
|
42
|
+
copyWith(params: Partial<ChainAssetConstructorParams>): ChainAsset;
|
|
43
|
+
getSymbol(): string;
|
|
44
|
+
getAssetId(): ChainAssetId;
|
|
45
|
+
getBalanceAssetId(): ChainAssetId;
|
|
46
|
+
getMinAssetId(): ChainAssetId;
|
|
47
|
+
getAssetPalletInstance(): number | undefined;
|
|
48
|
+
getAssetMin(): bigint;
|
|
49
|
+
hasOnlyAddress(): this is {
|
|
50
|
+
address: string;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface AssetAmountConstructorParams extends ChainAssetConstructorParams {
|
|
55
|
+
amount: number | bigint;
|
|
56
|
+
decimals: number;
|
|
57
|
+
symbol?: string;
|
|
58
|
+
}
|
|
59
|
+
declare class AssetAmount extends ChainAsset {
|
|
60
|
+
readonly amount: bigint;
|
|
61
|
+
constructor({ amount, ...other }: AssetAmountConstructorParams);
|
|
62
|
+
static fromChainAsset(asset: ChainAsset, params: Omit<AssetAmountConstructorParams, keyof ChainAssetConstructorParams>): AssetAmount;
|
|
63
|
+
isSame(asset: ChainAsset | AssetAmount): boolean;
|
|
64
|
+
isEqual(asset: AssetAmount): boolean;
|
|
65
|
+
copyWith(params: Partial<AssetAmountConstructorParams>): AssetAmount;
|
|
66
|
+
convertDecimals(decimals: number): AssetAmount;
|
|
67
|
+
toBig(): Big;
|
|
68
|
+
toBigDecimal(maxDecimal?: number, roundType?: RoundingMode): Big;
|
|
69
|
+
toDecimal(maxDecimal?: number, roundType?: RoundingMode): string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
type AnyAsset = Asset | ChainAsset | AssetAmount;
|
|
73
|
+
|
|
74
|
+
interface EvmChainConstructorParams extends ChainConstructorParams {
|
|
75
|
+
id: number;
|
|
76
|
+
rpc: string;
|
|
77
|
+
}
|
|
78
|
+
declare class EvmChain extends Chain {
|
|
79
|
+
readonly id: number;
|
|
80
|
+
readonly rpc: string;
|
|
81
|
+
static is(obj: unknown): obj is EvmChain;
|
|
82
|
+
constructor({ id, rpc, ...others }: EvmChainConstructorParams);
|
|
83
|
+
getViemChain(): Chain$1;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
interface ParachainConstructorParams extends ChainConstructorParams {
|
|
87
|
+
checkSovereignAccountBalances?: boolean;
|
|
88
|
+
genesisHash: string;
|
|
89
|
+
isRelay?: boolean;
|
|
90
|
+
parachainId: number;
|
|
91
|
+
ss58Format: number;
|
|
92
|
+
usesChainDecimals?: boolean;
|
|
93
|
+
weight?: number;
|
|
94
|
+
ws: string[];
|
|
95
|
+
}
|
|
96
|
+
declare class Parachain extends Chain {
|
|
97
|
+
readonly checkSovereignAccountBalances: boolean;
|
|
98
|
+
readonly genesisHash: string;
|
|
99
|
+
readonly isRelay: boolean;
|
|
100
|
+
readonly parachainId: number;
|
|
101
|
+
readonly ss58Format: number;
|
|
102
|
+
readonly usesChainDecimals: boolean;
|
|
103
|
+
readonly weight: number | undefined;
|
|
104
|
+
readonly ws: string[];
|
|
105
|
+
static is(obj: unknown): obj is Parachain;
|
|
106
|
+
constructor({ checkSovereignAccountBalances, genesisHash, isRelay, parachainId, usesChainDecimals, ss58Format, weight, ws, ...others }: ParachainConstructorParams);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
interface EvmParachainConstructorParams extends ParachainConstructorParams {
|
|
110
|
+
id: number;
|
|
111
|
+
rpc: string;
|
|
112
|
+
isEvmSigner?: boolean;
|
|
113
|
+
contracts?: Contracts;
|
|
114
|
+
}
|
|
115
|
+
type Contracts = {
|
|
116
|
+
Batch?: Address;
|
|
117
|
+
XcmUtils?: Address;
|
|
118
|
+
Xtokens?: Address;
|
|
119
|
+
};
|
|
120
|
+
declare class EvmParachain extends Parachain {
|
|
121
|
+
readonly id: number;
|
|
122
|
+
readonly rpc: string;
|
|
123
|
+
readonly isEvmSigner: boolean;
|
|
124
|
+
readonly contracts?: Contracts;
|
|
125
|
+
static is(obj: unknown): obj is EvmParachain;
|
|
126
|
+
static isAnyParachain(obj: unknown): obj is EvmParachain | Parachain;
|
|
127
|
+
static isAnyEvmChain(obj: unknown): obj is EvmParachain | EvmChain;
|
|
128
|
+
constructor({ id, rpc, isEvmSigner, contracts, ...others }: EvmParachainConstructorParams);
|
|
129
|
+
getViemChain(): Chain$2;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
type AnyChain = EvmChain | Parachain | EvmParachain;
|
|
133
|
+
type AnyParachain = Parachain | EvmParachain;
|
|
134
|
+
declare enum Ecosystem {
|
|
135
|
+
Polkadot = "polkadot",
|
|
136
|
+
Kusama = "kusama",
|
|
137
|
+
AlphanetRelay = "alphanet-relay"
|
|
138
|
+
}
|
|
139
|
+
interface WormholeConfig {
|
|
140
|
+
name?: Chain$3;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
interface ChainConstructorParams {
|
|
144
|
+
assets: Map<string, ChainAsset> | ChainAsset[];
|
|
145
|
+
ecosystem?: Ecosystem;
|
|
146
|
+
explorer?: string;
|
|
147
|
+
isTestChain?: boolean;
|
|
148
|
+
key: string;
|
|
149
|
+
name: string;
|
|
150
|
+
nativeAsset: Asset;
|
|
151
|
+
wh?: WormholeConfig;
|
|
152
|
+
}
|
|
153
|
+
declare abstract class Chain {
|
|
154
|
+
#private;
|
|
155
|
+
readonly assets: Map<string, ChainAsset>;
|
|
156
|
+
readonly ecosystem?: Ecosystem;
|
|
157
|
+
readonly explorer?: string;
|
|
158
|
+
readonly isTestChain: boolean;
|
|
159
|
+
readonly key: string;
|
|
160
|
+
readonly name: string;
|
|
161
|
+
readonly wh?: WormholeConfig;
|
|
162
|
+
constructor({ assets, ecosystem, explorer, isTestChain, key, name, nativeAsset, wh, }: ChainConstructorParams);
|
|
163
|
+
get nativeAsset(): ChainAsset;
|
|
164
|
+
isEqual<T extends Chain>(chain: T): boolean;
|
|
165
|
+
getChainAsset(keyOrAsset: string | Asset | AssetAmount): ChainAsset;
|
|
166
|
+
getWormholeName(): Chain$3;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
type SetOptional<Base, Keys extends keyof Base> = Omit<Base, Keys> & Partial<Pick<Base, Keys>>;
|
|
170
|
+
|
|
171
|
+
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, Parachain, type ParachainConstructorParams, type SetOptional, type WormholeConfig };
|
package/build/index.d.ts
CHANGED
|
@@ -1,198 +1,171 @@
|
|
|
1
1
|
import Big, { RoundingMode } from 'big.js';
|
|
2
|
-
import {
|
|
3
|
-
import { Chain as Chain$1 } from 'viem
|
|
2
|
+
import { Chain as Chain$3 } from '@wormhole-foundation/sdk-connect';
|
|
3
|
+
import { Chain as Chain$1, Address } from 'viem';
|
|
4
|
+
import { Chain as Chain$2 } from 'viem/chains';
|
|
4
5
|
|
|
5
6
|
interface AssetConstructorParams {
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
key: string;
|
|
8
|
+
originSymbol: string;
|
|
8
9
|
}
|
|
9
10
|
declare class Asset {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
readonly key: string;
|
|
12
|
+
readonly originSymbol: string;
|
|
13
|
+
constructor({ key, originSymbol }: AssetConstructorParams);
|
|
14
|
+
copyWith(params: Partial<AssetConstructorParams>): Asset;
|
|
15
|
+
isEqual(asset: Asset): boolean;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
interface
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
18
|
+
interface ChainAssetConstructorParams extends AssetConstructorParams {
|
|
19
|
+
address?: string;
|
|
20
|
+
decimals: number;
|
|
21
|
+
ids?: ChainAssetIds;
|
|
22
|
+
min?: number | bigint;
|
|
23
|
+
symbol?: string;
|
|
24
|
+
}
|
|
25
|
+
interface ChainAssetIds {
|
|
26
|
+
balanceId?: ChainAssetId;
|
|
27
|
+
id?: ChainAssetId;
|
|
28
|
+
minId?: ChainAssetId;
|
|
29
|
+
palletInstance?: number;
|
|
30
|
+
}
|
|
31
|
+
type ChainAssetId = string | number | bigint | {
|
|
32
|
+
[key: string]: ChainAssetId;
|
|
33
|
+
};
|
|
34
|
+
declare class ChainAsset extends Asset {
|
|
35
|
+
readonly address?: string;
|
|
36
|
+
readonly decimals: number;
|
|
37
|
+
readonly ids?: ChainAssetIds;
|
|
38
|
+
readonly min?: bigint;
|
|
39
|
+
readonly symbol?: string;
|
|
40
|
+
constructor({ address, decimals, ids, min, symbol, ...other }: ChainAssetConstructorParams);
|
|
41
|
+
static fromAsset(asset: Asset, params: Omit<ChainAssetConstructorParams, keyof AssetConstructorParams>): ChainAsset;
|
|
42
|
+
copyWith(params: Partial<ChainAssetConstructorParams>): ChainAsset;
|
|
43
|
+
getSymbol(): string;
|
|
44
|
+
getAssetId(): ChainAssetId;
|
|
45
|
+
getBalanceAssetId(): ChainAssetId;
|
|
46
|
+
getMinAssetId(): ChainAssetId;
|
|
47
|
+
getAssetPalletInstance(): number | undefined;
|
|
48
|
+
getAssetMin(): bigint;
|
|
49
|
+
hasOnlyAddress(): this is {
|
|
50
|
+
address: string;
|
|
51
|
+
};
|
|
41
52
|
}
|
|
42
53
|
|
|
43
|
-
|
|
44
|
-
|
|
54
|
+
interface AssetAmountConstructorParams extends ChainAssetConstructorParams {
|
|
55
|
+
amount: number | bigint;
|
|
56
|
+
decimals: number;
|
|
57
|
+
symbol?: string;
|
|
58
|
+
}
|
|
59
|
+
declare class AssetAmount extends ChainAsset {
|
|
60
|
+
readonly amount: bigint;
|
|
61
|
+
constructor({ amount, ...other }: AssetAmountConstructorParams);
|
|
62
|
+
static fromChainAsset(asset: ChainAsset, params: Omit<AssetAmountConstructorParams, keyof ChainAssetConstructorParams>): AssetAmount;
|
|
63
|
+
isSame(asset: ChainAsset | AssetAmount): boolean;
|
|
64
|
+
isEqual(asset: AssetAmount): boolean;
|
|
65
|
+
copyWith(params: Partial<AssetAmountConstructorParams>): AssetAmount;
|
|
66
|
+
convertDecimals(decimals: number): AssetAmount;
|
|
67
|
+
toBig(): Big;
|
|
68
|
+
toBigDecimal(maxDecimal?: number, roundType?: RoundingMode): Big;
|
|
69
|
+
toDecimal(maxDecimal?: number, roundType?: RoundingMode): string;
|
|
70
|
+
}
|
|
45
71
|
|
|
46
|
-
type
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
id?: ChainAssetId;
|
|
59
|
-
metadataId?: ChainAssetId;
|
|
60
|
-
minId?: ChainAssetId;
|
|
61
|
-
palletInstance?: number;
|
|
62
|
-
min?: number;
|
|
72
|
+
type AnyAsset = Asset | ChainAsset | AssetAmount;
|
|
73
|
+
|
|
74
|
+
interface EvmChainConstructorParams extends ChainConstructorParams {
|
|
75
|
+
id: number;
|
|
76
|
+
rpc: string;
|
|
77
|
+
}
|
|
78
|
+
declare class EvmChain extends Chain {
|
|
79
|
+
readonly id: number;
|
|
80
|
+
readonly rpc: string;
|
|
81
|
+
static is(obj: unknown): obj is EvmChain;
|
|
82
|
+
constructor({ id, rpc, ...others }: EvmChainConstructorParams);
|
|
83
|
+
getViemChain(): Chain$1;
|
|
63
84
|
}
|
|
64
85
|
|
|
65
|
-
interface ParachainConstructorParams
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
weight?: number;
|
|
75
|
-
ws: string[];
|
|
86
|
+
interface ParachainConstructorParams extends ChainConstructorParams {
|
|
87
|
+
checkSovereignAccountBalances?: boolean;
|
|
88
|
+
genesisHash: string;
|
|
89
|
+
isRelay?: boolean;
|
|
90
|
+
parachainId: number;
|
|
91
|
+
ss58Format: number;
|
|
92
|
+
usesChainDecimals?: boolean;
|
|
93
|
+
weight?: number;
|
|
94
|
+
ws: string[];
|
|
76
95
|
}
|
|
77
96
|
declare class Parachain extends Chain {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
assetsData,
|
|
89
|
-
checkSovereignAccountBalances,
|
|
90
|
-
genesisHash,
|
|
91
|
-
isRelay,
|
|
92
|
-
parachainId,
|
|
93
|
-
usesChainDecimals,
|
|
94
|
-
ss58Format,
|
|
95
|
-
weight,
|
|
96
|
-
ws,
|
|
97
|
-
type,
|
|
98
|
-
...others
|
|
99
|
-
}: ParachainConstructorParams);
|
|
100
|
-
getAssetId(asset: Asset): ChainAssetId;
|
|
101
|
-
getBalanceAssetId(asset: Asset): ChainAssetId;
|
|
102
|
-
getMinAssetId(asset: Asset): ChainAssetId;
|
|
103
|
-
getMetadataAssetId(asset: Asset): ChainAssetId;
|
|
104
|
-
getRegisteredAssetIdOrAddress(asset: Asset): ChainAssetId;
|
|
105
|
-
getAssetPalletInstance(asset: Asset): number | undefined;
|
|
106
|
-
getAssetDecimals(asset: Asset): number | undefined;
|
|
107
|
-
getAssetMin(asset: Asset): number;
|
|
97
|
+
readonly checkSovereignAccountBalances: boolean;
|
|
98
|
+
readonly genesisHash: string;
|
|
99
|
+
readonly isRelay: boolean;
|
|
100
|
+
readonly parachainId: number;
|
|
101
|
+
readonly ss58Format: number;
|
|
102
|
+
readonly usesChainDecimals: boolean;
|
|
103
|
+
readonly weight: number | undefined;
|
|
104
|
+
readonly ws: string[];
|
|
105
|
+
static is(obj: unknown): obj is Parachain;
|
|
106
|
+
constructor({ checkSovereignAccountBalances, genesisHash, isRelay, parachainId, usesChainDecimals, ss58Format, weight, ws, ...others }: ParachainConstructorParams);
|
|
108
107
|
}
|
|
109
108
|
|
|
110
|
-
interface EvmParachainConstructorParams
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
contracts?: Contracts;
|
|
117
|
-
}
|
|
118
|
-
type NativeCurrency = {
|
|
119
|
-
decimals: number;
|
|
120
|
-
name: string;
|
|
121
|
-
symbol: string;
|
|
122
|
-
};
|
|
109
|
+
interface EvmParachainConstructorParams extends ParachainConstructorParams {
|
|
110
|
+
id: number;
|
|
111
|
+
rpc: string;
|
|
112
|
+
isEvmSigner?: boolean;
|
|
113
|
+
contracts?: Contracts;
|
|
114
|
+
}
|
|
123
115
|
type Contracts = {
|
|
124
|
-
|
|
116
|
+
Batch?: Address;
|
|
117
|
+
XcmUtils?: Address;
|
|
118
|
+
Xtokens?: Address;
|
|
125
119
|
};
|
|
126
120
|
declare class EvmParachain extends Parachain {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
rpc,
|
|
135
|
-
|
|
136
|
-
isEvmSigner,
|
|
137
|
-
contracts,
|
|
138
|
-
...others
|
|
139
|
-
}: EvmParachainConstructorParams);
|
|
140
|
-
getViemChain(): Chain$1;
|
|
121
|
+
readonly id: number;
|
|
122
|
+
readonly rpc: string;
|
|
123
|
+
readonly isEvmSigner: boolean;
|
|
124
|
+
readonly contracts?: Contracts;
|
|
125
|
+
static is(obj: unknown): obj is EvmParachain;
|
|
126
|
+
static isAnyParachain(obj: unknown): obj is EvmParachain | Parachain;
|
|
127
|
+
static isAnyEvmChain(obj: unknown): obj is EvmParachain | EvmChain;
|
|
128
|
+
constructor({ id, rpc, isEvmSigner, contracts, ...others }: EvmParachainConstructorParams);
|
|
129
|
+
getViemChain(): Chain$2;
|
|
141
130
|
}
|
|
142
131
|
|
|
143
|
-
type AnyChain = Parachain | EvmParachain;
|
|
132
|
+
type AnyChain = EvmChain | Parachain | EvmParachain;
|
|
144
133
|
type AnyParachain = Parachain | EvmParachain;
|
|
145
|
-
declare enum ChainType {
|
|
146
|
-
'Parachain' = 'parachain',
|
|
147
|
-
'EvmParachain' = 'evm-parachain',
|
|
148
|
-
}
|
|
149
134
|
declare enum Ecosystem {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
135
|
+
Polkadot = "polkadot",
|
|
136
|
+
Kusama = "kusama",
|
|
137
|
+
AlphanetRelay = "alphanet-relay"
|
|
138
|
+
}
|
|
139
|
+
interface WormholeConfig {
|
|
140
|
+
name?: Chain$3;
|
|
153
141
|
}
|
|
154
142
|
|
|
155
143
|
interface ChainConstructorParams {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
144
|
+
assets: Map<string, ChainAsset> | ChainAsset[];
|
|
145
|
+
ecosystem?: Ecosystem;
|
|
146
|
+
explorer?: string;
|
|
147
|
+
isTestChain?: boolean;
|
|
148
|
+
key: string;
|
|
149
|
+
name: string;
|
|
150
|
+
nativeAsset: Asset;
|
|
151
|
+
wh?: WormholeConfig;
|
|
161
152
|
}
|
|
162
153
|
declare abstract class Chain {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
key,
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
isEvmParachain(): this is EvmParachain;
|
|
154
|
+
#private;
|
|
155
|
+
readonly assets: Map<string, ChainAsset>;
|
|
156
|
+
readonly ecosystem?: Ecosystem;
|
|
157
|
+
readonly explorer?: string;
|
|
158
|
+
readonly isTestChain: boolean;
|
|
159
|
+
readonly key: string;
|
|
160
|
+
readonly name: string;
|
|
161
|
+
readonly wh?: WormholeConfig;
|
|
162
|
+
constructor({ assets, ecosystem, explorer, isTestChain, key, name, nativeAsset, wh, }: ChainConstructorParams);
|
|
163
|
+
get nativeAsset(): ChainAsset;
|
|
164
|
+
isEqual<T extends Chain>(chain: T): boolean;
|
|
165
|
+
getChainAsset(keyOrAsset: string | Asset | AssetAmount): ChainAsset;
|
|
166
|
+
getWormholeName(): Chain$3;
|
|
177
167
|
}
|
|
178
168
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
Asset,
|
|
183
|
-
AssetAmount,
|
|
184
|
-
type AssetAmountConstructorParams,
|
|
185
|
-
type AssetAmountParams,
|
|
186
|
-
type AssetConstructorParams,
|
|
187
|
-
Chain,
|
|
188
|
-
type ChainAssetId,
|
|
189
|
-
type ChainAssetsData,
|
|
190
|
-
type ChainConstructorParams,
|
|
191
|
-
ChainType,
|
|
192
|
-
Ecosystem,
|
|
193
|
-
EvmParachain,
|
|
194
|
-
type EvmParachainConstructorParams,
|
|
195
|
-
Parachain,
|
|
196
|
-
type ParachainConstructorParams,
|
|
197
|
-
type SetOptional,
|
|
198
|
-
};
|
|
169
|
+
type SetOptional<Base, Keys extends keyof Base> = Omit<Base, Keys> & Partial<Pick<Base, Keys>>;
|
|
170
|
+
|
|
171
|
+
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, Parachain, type ParachainConstructorParams, type SetOptional, type WormholeConfig };
|
package/build/index.mjs
CHANGED
|
@@ -1,2 +1,312 @@
|
|
|
1
|
-
|
|
1
|
+
// src/asset/Asset.ts
|
|
2
|
+
var Asset = class _Asset {
|
|
3
|
+
key;
|
|
4
|
+
originSymbol;
|
|
5
|
+
constructor({ key, originSymbol }) {
|
|
6
|
+
this.key = key;
|
|
7
|
+
this.originSymbol = originSymbol;
|
|
8
|
+
}
|
|
9
|
+
copyWith(params) {
|
|
10
|
+
return new _Asset({
|
|
11
|
+
...this,
|
|
12
|
+
...params
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
isEqual(asset) {
|
|
16
|
+
return this.key === asset.key && this.originSymbol === asset.originSymbol;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// src/asset/AssetAmount.ts
|
|
21
|
+
import {
|
|
22
|
+
convertDecimals,
|
|
23
|
+
toBigInt as toBigInt2,
|
|
24
|
+
toDecimal
|
|
25
|
+
} from "@moonbeam-network/xcm-utils";
|
|
26
|
+
import Big from "big.js";
|
|
27
|
+
|
|
28
|
+
// src/asset/ChainAsset.ts
|
|
29
|
+
import { toBigInt } from "@moonbeam-network/xcm-utils";
|
|
30
|
+
var ChainAsset = class _ChainAsset extends Asset {
|
|
31
|
+
address;
|
|
32
|
+
decimals;
|
|
33
|
+
ids;
|
|
34
|
+
min;
|
|
35
|
+
symbol;
|
|
36
|
+
constructor({
|
|
37
|
+
address,
|
|
38
|
+
decimals,
|
|
39
|
+
ids,
|
|
40
|
+
min,
|
|
41
|
+
symbol,
|
|
42
|
+
...other
|
|
43
|
+
}) {
|
|
44
|
+
super(other);
|
|
45
|
+
this.address = address;
|
|
46
|
+
this.decimals = decimals;
|
|
47
|
+
this.ids = ids;
|
|
48
|
+
this.min = min ? toBigInt(min, decimals) : void 0;
|
|
49
|
+
this.symbol = symbol;
|
|
50
|
+
}
|
|
51
|
+
static fromAsset(asset, params) {
|
|
52
|
+
return new _ChainAsset({
|
|
53
|
+
...asset,
|
|
54
|
+
...params
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
copyWith(params) {
|
|
58
|
+
return new _ChainAsset({
|
|
59
|
+
...this,
|
|
60
|
+
...params
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
getSymbol() {
|
|
64
|
+
return this.symbol || this.originSymbol;
|
|
65
|
+
}
|
|
66
|
+
getAssetId() {
|
|
67
|
+
return this.ids?.id ?? this.originSymbol;
|
|
68
|
+
}
|
|
69
|
+
getBalanceAssetId() {
|
|
70
|
+
return this.ids?.balanceId ?? this.getAssetId();
|
|
71
|
+
}
|
|
72
|
+
getMinAssetId() {
|
|
73
|
+
return this.ids?.minId ?? this.getAssetId();
|
|
74
|
+
}
|
|
75
|
+
getAssetPalletInstance() {
|
|
76
|
+
return this.ids?.palletInstance;
|
|
77
|
+
}
|
|
78
|
+
getAssetMin() {
|
|
79
|
+
return this.min ?? 0n;
|
|
80
|
+
}
|
|
81
|
+
hasOnlyAddress() {
|
|
82
|
+
return !!this.address && !this.ids?.id;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// src/asset/AssetAmount.ts
|
|
87
|
+
Big.NE = -18;
|
|
88
|
+
var AssetAmount = class _AssetAmount extends ChainAsset {
|
|
89
|
+
amount;
|
|
90
|
+
constructor({ amount, ...other }) {
|
|
91
|
+
super(other);
|
|
92
|
+
this.amount = toBigInt2(amount, other.decimals);
|
|
93
|
+
}
|
|
94
|
+
static fromChainAsset(asset, params) {
|
|
95
|
+
return new _AssetAmount({
|
|
96
|
+
...asset,
|
|
97
|
+
...params
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
isSame(asset) {
|
|
101
|
+
return super.isEqual(asset) && this.decimals === asset.decimals;
|
|
102
|
+
}
|
|
103
|
+
isEqual(asset) {
|
|
104
|
+
return this.isSame(asset) && this.amount === asset.amount;
|
|
105
|
+
}
|
|
106
|
+
copyWith(params) {
|
|
107
|
+
return new _AssetAmount({
|
|
108
|
+
...this,
|
|
109
|
+
...params
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
convertDecimals(decimals) {
|
|
113
|
+
if (this.decimals === decimals) {
|
|
114
|
+
return this.copyWith({});
|
|
115
|
+
}
|
|
116
|
+
return this.copyWith({
|
|
117
|
+
amount: convertDecimals(this.amount, this.decimals, decimals),
|
|
118
|
+
decimals
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
toBig() {
|
|
122
|
+
return Big(this.amount.toString());
|
|
123
|
+
}
|
|
124
|
+
toBigDecimal(maxDecimal, roundType) {
|
|
125
|
+
return Big(this.toDecimal(maxDecimal, roundType));
|
|
126
|
+
}
|
|
127
|
+
toDecimal(maxDecimal, roundType) {
|
|
128
|
+
return toDecimal(this.amount, this.decimals, maxDecimal, roundType);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// src/chain/Chain.ts
|
|
133
|
+
var Chain = class {
|
|
134
|
+
assets;
|
|
135
|
+
ecosystem;
|
|
136
|
+
explorer;
|
|
137
|
+
isTestChain;
|
|
138
|
+
key;
|
|
139
|
+
name;
|
|
140
|
+
#nativeAsset;
|
|
141
|
+
wh;
|
|
142
|
+
constructor({
|
|
143
|
+
assets,
|
|
144
|
+
ecosystem,
|
|
145
|
+
explorer,
|
|
146
|
+
isTestChain = false,
|
|
147
|
+
key,
|
|
148
|
+
name,
|
|
149
|
+
nativeAsset,
|
|
150
|
+
wh
|
|
151
|
+
}) {
|
|
152
|
+
this.assets = assets instanceof Map ? assets : new Map(assets?.map((data) => [data.key, data]));
|
|
153
|
+
this.ecosystem = ecosystem;
|
|
154
|
+
this.explorer = explorer;
|
|
155
|
+
this.isTestChain = isTestChain;
|
|
156
|
+
this.key = key;
|
|
157
|
+
this.name = name;
|
|
158
|
+
this.#nativeAsset = nativeAsset;
|
|
159
|
+
this.wh = wh;
|
|
160
|
+
}
|
|
161
|
+
get nativeAsset() {
|
|
162
|
+
return this.getChainAsset(this.#nativeAsset);
|
|
163
|
+
}
|
|
164
|
+
isEqual(chain) {
|
|
165
|
+
return this.key === chain.key;
|
|
166
|
+
}
|
|
167
|
+
getChainAsset(keyOrAsset) {
|
|
168
|
+
const key = typeof keyOrAsset === "string" ? keyOrAsset : keyOrAsset.key;
|
|
169
|
+
const chainAsset = this.assets.get(key);
|
|
170
|
+
if (!chainAsset) {
|
|
171
|
+
throw new Error(
|
|
172
|
+
`No ChainAsset found by the key ${key} for chain ${this.name} (${this.key})`
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
return chainAsset;
|
|
176
|
+
}
|
|
177
|
+
getWormholeName() {
|
|
178
|
+
if (!this.wh?.name) {
|
|
179
|
+
throw new Error(`Chain ${this.name} does not have a wormhole name`);
|
|
180
|
+
}
|
|
181
|
+
return this.wh.name;
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
// src/chain/Chain.interfaces.ts
|
|
186
|
+
var Ecosystem = /* @__PURE__ */ ((Ecosystem2) => {
|
|
187
|
+
Ecosystem2["Polkadot"] = "polkadot";
|
|
188
|
+
Ecosystem2["Kusama"] = "kusama";
|
|
189
|
+
Ecosystem2["AlphanetRelay"] = "alphanet-relay";
|
|
190
|
+
return Ecosystem2;
|
|
191
|
+
})(Ecosystem || {});
|
|
192
|
+
|
|
193
|
+
// src/chain/Chain.utils.ts
|
|
194
|
+
import { defineChain } from "viem";
|
|
195
|
+
function getViemChain({
|
|
196
|
+
id,
|
|
197
|
+
name,
|
|
198
|
+
nativeAsset,
|
|
199
|
+
rpc
|
|
200
|
+
}) {
|
|
201
|
+
return defineChain({
|
|
202
|
+
id,
|
|
203
|
+
name,
|
|
204
|
+
nativeCurrency: {
|
|
205
|
+
decimals: nativeAsset.decimals,
|
|
206
|
+
name: nativeAsset.originSymbol,
|
|
207
|
+
symbol: nativeAsset.originSymbol
|
|
208
|
+
},
|
|
209
|
+
rpcUrls: {
|
|
210
|
+
default: {
|
|
211
|
+
http: [rpc]
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// src/chain/EvmChain.ts
|
|
218
|
+
var EvmChain = class _EvmChain extends Chain {
|
|
219
|
+
id;
|
|
220
|
+
rpc;
|
|
221
|
+
static is(obj) {
|
|
222
|
+
return obj instanceof _EvmChain;
|
|
223
|
+
}
|
|
224
|
+
constructor({ id, rpc, ...others }) {
|
|
225
|
+
super(others);
|
|
226
|
+
this.id = id;
|
|
227
|
+
this.rpc = rpc;
|
|
228
|
+
}
|
|
229
|
+
getViemChain() {
|
|
230
|
+
return getViemChain(this);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
// src/chain/parachain/Parachain.ts
|
|
235
|
+
var Parachain = class _Parachain extends Chain {
|
|
236
|
+
checkSovereignAccountBalances;
|
|
237
|
+
genesisHash;
|
|
238
|
+
isRelay;
|
|
239
|
+
parachainId;
|
|
240
|
+
ss58Format;
|
|
241
|
+
usesChainDecimals;
|
|
242
|
+
weight;
|
|
243
|
+
ws;
|
|
244
|
+
static is(obj) {
|
|
245
|
+
return obj instanceof _Parachain;
|
|
246
|
+
}
|
|
247
|
+
constructor({
|
|
248
|
+
checkSovereignAccountBalances,
|
|
249
|
+
genesisHash,
|
|
250
|
+
isRelay,
|
|
251
|
+
parachainId,
|
|
252
|
+
usesChainDecimals,
|
|
253
|
+
ss58Format,
|
|
254
|
+
weight,
|
|
255
|
+
ws,
|
|
256
|
+
...others
|
|
257
|
+
}) {
|
|
258
|
+
super(others);
|
|
259
|
+
this.checkSovereignAccountBalances = !!checkSovereignAccountBalances;
|
|
260
|
+
this.genesisHash = genesisHash;
|
|
261
|
+
this.isRelay = !!isRelay;
|
|
262
|
+
this.parachainId = parachainId;
|
|
263
|
+
this.ss58Format = ss58Format;
|
|
264
|
+
this.usesChainDecimals = !!usesChainDecimals;
|
|
265
|
+
this.weight = weight;
|
|
266
|
+
this.ws = ws;
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
// src/chain/parachain/EvmParachain.ts
|
|
271
|
+
var EvmParachain = class _EvmParachain extends Parachain {
|
|
272
|
+
id;
|
|
273
|
+
rpc;
|
|
274
|
+
isEvmSigner;
|
|
275
|
+
contracts;
|
|
276
|
+
static is(obj) {
|
|
277
|
+
return obj instanceof _EvmParachain;
|
|
278
|
+
}
|
|
279
|
+
static isAnyParachain(obj) {
|
|
280
|
+
return obj instanceof _EvmParachain || obj instanceof Parachain;
|
|
281
|
+
}
|
|
282
|
+
static isAnyEvmChain(obj) {
|
|
283
|
+
return obj instanceof _EvmParachain || obj instanceof EvmChain;
|
|
284
|
+
}
|
|
285
|
+
constructor({
|
|
286
|
+
id,
|
|
287
|
+
rpc,
|
|
288
|
+
isEvmSigner = false,
|
|
289
|
+
contracts,
|
|
290
|
+
...others
|
|
291
|
+
}) {
|
|
292
|
+
super(others);
|
|
293
|
+
this.contracts = contracts;
|
|
294
|
+
this.id = id;
|
|
295
|
+
this.rpc = rpc;
|
|
296
|
+
this.isEvmSigner = isEvmSigner;
|
|
297
|
+
}
|
|
298
|
+
getViemChain() {
|
|
299
|
+
return getViemChain(this);
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
export {
|
|
303
|
+
Asset,
|
|
304
|
+
AssetAmount,
|
|
305
|
+
Chain,
|
|
306
|
+
ChainAsset,
|
|
307
|
+
Ecosystem,
|
|
308
|
+
EvmChain,
|
|
309
|
+
EvmParachain,
|
|
310
|
+
Parachain
|
|
311
|
+
};
|
|
2
312
|
//# sourceMappingURL=index.mjs.map
|
package/build/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/asset/Asset.ts","../src/asset/AssetAmount.ts","../src/chain/Chain.interfaces.ts","../src/chain/Chain.ts","../src/chain/parachain/EvmParachain.ts","../src/chain/parachain/Parachain.ts"],"sourcesContent":["export interface AssetConstructorParams {\n key: string;\n originSymbol: string;\n}\n\nexport class Asset {\n readonly key: string;\n\n readonly originSymbol: string;\n\n constructor({ key, originSymbol }: AssetConstructorParams) {\n this.key = key;\n this.originSymbol = originSymbol;\n }\n\n isEqual(asset: Asset): boolean {\n return this.key === asset.key && this.originSymbol === asset.originSymbol;\n }\n}\n","import { toDecimal } from '@moonbeam-network/xcm-utils';\nimport Big, { RoundingMode } from 'big.js';\nimport { Asset, AssetConstructorParams } from './Asset';\n\nBig.NE = -18;\n\nexport interface AssetAmountParams {\n amount: bigint;\n decimals: number;\n symbol?: string;\n}\n\nexport interface AssetAmountConstructorParams\n extends AssetConstructorParams,\n AssetAmountParams {}\n\nexport class AssetAmount extends Asset {\n readonly amount: bigint;\n\n readonly decimals: number;\n\n readonly symbol: string;\n\n constructor({\n amount,\n decimals,\n symbol,\n ...other\n }: AssetAmountConstructorParams) {\n super(other);\n\n this.amount = BigInt(amount);\n this.decimals = decimals;\n this.symbol = symbol || this.originSymbol;\n }\n\n static fromAsset(asset: Asset, params: AssetAmountParams) {\n return new AssetAmount({\n ...asset,\n ...params,\n });\n }\n\n isSame(asset: AssetAmount): boolean {\n return super.isEqual(asset) && this.decimals === asset.decimals;\n }\n\n isEqual(asset: AssetAmount): boolean {\n return this.isSame(asset) && this.amount === asset.amount;\n }\n\n copyWith(params: Partial<AssetAmountConstructorParams>) {\n return new AssetAmount({\n ...this,\n ...params,\n });\n }\n\n toBig(): Big {\n return Big(this.amount.toString());\n }\n\n toBigDecimal(maxDecimal?: number, roundType?: RoundingMode): Big {\n return Big(this.toDecimal(maxDecimal, roundType));\n }\n\n toDecimal(maxDecimal?: number, roundType?: RoundingMode): string {\n return toDecimal(this.amount, this.decimals, maxDecimal, roundType);\n }\n}\n","import type { EvmParachain, Parachain } from './parachain';\n\nexport type AnyChain = Parachain | EvmParachain;\nexport type AnyParachain = Parachain | EvmParachain;\n\nexport enum ChainType {\n 'Parachain' = 'parachain',\n 'EvmParachain' = 'evm-parachain',\n}\n\nexport enum Ecosystem {\n Polkadot = 'polkadot',\n Kusama = 'kusama',\n AlphanetRelay = 'alphanet-relay',\n}\n","import { ChainType, Ecosystem } from './Chain.interfaces';\nimport type { EvmParachain, Parachain } from './parachain';\n\nexport interface ChainConstructorParams {\n ecosystem?: Ecosystem;\n isTestChain?: boolean;\n key: string;\n name: string;\n type: ChainType;\n}\n\nexport abstract class Chain {\n readonly ecosystem?: Ecosystem;\n\n readonly isTestChain: boolean;\n\n readonly key: string;\n\n readonly name: string;\n\n readonly type: ChainType;\n\n constructor({\n ecosystem,\n isTestChain = false,\n key,\n name,\n type,\n }: ChainConstructorParams) {\n this.ecosystem = ecosystem;\n this.isTestChain = isTestChain;\n this.key = key;\n this.name = name;\n this.type = type;\n }\n\n isParachain(): this is Parachain {\n return this.type === ChainType.Parachain;\n }\n\n isEvmParachain(): this is EvmParachain {\n return this.type === ChainType.EvmParachain;\n }\n}\n","import { Address, defineChain } from 'viem';\nimport { Chain } from 'viem/chains';\nimport { ChainType } from '../Chain.interfaces';\nimport { Parachain, ParachainConstructorParams } from './Parachain';\n\nexport interface EvmParachainConstructorParams\n extends Omit<ParachainConstructorParams, 'type'> {\n id: number;\n rpc: string;\n nativeCurrency: NativeCurrency;\n isEvmSigner?: boolean;\n contracts?: Contracts;\n}\n\ntype NativeCurrency = {\n decimals: number;\n name: string;\n symbol: string;\n};\n\ntype Contracts = {\n Xtokens?: Address;\n};\n\nexport class EvmParachain extends Parachain {\n readonly id: number;\n\n readonly rpc: string;\n\n readonly nativeCurrency: NativeCurrency;\n\n readonly isEvmSigner: boolean;\n\n readonly contracts?: Contracts;\n\n constructor({\n id,\n rpc,\n nativeCurrency,\n isEvmSigner = false,\n contracts,\n ...others\n }: EvmParachainConstructorParams) {\n super({ type: ChainType.EvmParachain, ...others });\n\n this.contracts = contracts;\n this.id = id;\n this.rpc = rpc;\n this.nativeCurrency = nativeCurrency;\n this.isEvmSigner = isEvmSigner;\n }\n\n getViemChain(): Chain {\n return defineChain({\n id: this.id,\n name: this.name,\n nativeCurrency: this.nativeCurrency,\n rpcUrls: {\n default: {\n http: [this.rpc],\n webSocket: Array.isArray(this.ws) ? this.ws : [this.ws],\n },\n },\n });\n }\n}\n","import { Asset } from '../../asset';\nimport { SetOptional } from '../../common.interfaces';\nimport { Chain, ChainConstructorParams } from '../Chain';\nimport { ChainType } from '../Chain.interfaces';\nimport { ChainAssetId, ChainAssetsData } from './Parachain.interfaces';\n\nexport interface ParachainConstructorParams\n extends SetOptional<ChainConstructorParams, 'type'> {\n assetsData?: Map<string, ChainAssetsData> | ChainAssetsData[];\n checkSovereignAccountBalances?: boolean;\n genesisHash: string;\n isRelay?: boolean;\n parachainId: number;\n ss58Format: number;\n usesChainDecimals?: boolean;\n weight?: number;\n ws: string[];\n}\n\nexport class Parachain extends Chain {\n readonly assetsData: Map<string, ChainAssetsData>;\n\n readonly checkSovereignAccountBalances: boolean;\n\n readonly genesisHash: string;\n\n readonly isRelay: boolean;\n\n readonly parachainId: number;\n\n readonly ss58Format: number;\n\n readonly usesChainDecimals: boolean;\n\n readonly weight: number | undefined;\n\n readonly ws: string[];\n\n constructor({\n assetsData,\n checkSovereignAccountBalances,\n genesisHash,\n isRelay,\n parachainId,\n usesChainDecimals,\n ss58Format,\n weight,\n ws,\n type = ChainType.Parachain,\n ...others\n }: ParachainConstructorParams) {\n super({ type, ...others });\n\n this.assetsData =\n assetsData instanceof Map\n ? assetsData\n : new Map(assetsData?.map((data) => [data.asset.key, data]));\n this.checkSovereignAccountBalances = !!checkSovereignAccountBalances;\n this.genesisHash = genesisHash;\n this.isRelay = !!isRelay;\n this.parachainId = parachainId;\n this.ss58Format = ss58Format;\n this.usesChainDecimals = !!usesChainDecimals;\n this.weight = weight;\n this.ws = ws;\n }\n\n getAssetId(asset: Asset): ChainAssetId {\n return this.assetsData.get(asset.key)?.id ?? asset.originSymbol;\n }\n\n getBalanceAssetId(asset: Asset): ChainAssetId {\n return this.assetsData.get(asset.key)?.balanceId ?? this.getAssetId(asset);\n }\n\n getMinAssetId(asset: Asset): ChainAssetId {\n return this.assetsData.get(asset.key)?.minId ?? this.getAssetId(asset);\n }\n\n getMetadataAssetId(asset: Asset): ChainAssetId {\n return this.assetsData.get(asset.key)?.metadataId ?? this.getAssetId(asset);\n }\n\n getRegisteredAssetIdOrAddress(asset: Asset): ChainAssetId {\n const metadataId = this.assetsData.get(asset.key)?.metadataId;\n return metadataId && metadataId !== 0 ? metadataId : this.getAssetId(asset);\n }\n\n getAssetPalletInstance(asset: Asset): number | undefined {\n return this.assetsData.get(asset.key)?.palletInstance;\n }\n\n getAssetDecimals(asset: Asset): number | undefined {\n return this.assetsData.get(asset.key)?.decimals;\n }\n\n getAssetMin(asset: Asset): number {\n return this.assetsData.get(asset.key)?.min ?? 0;\n }\n}\n"],"mappings":"AAKO,IAAMA,EAAN,KAAY,CACR,IAEA,aAET,YAAY,CAAE,IAAAC,EAAK,aAAAC,CAAa,EAA2B,CACzD,KAAK,IAAMD,EACX,KAAK,aAAeC,CACtB,CAEA,QAAQC,EAAuB,CAC7B,OAAO,KAAK,MAAQA,EAAM,KAAO,KAAK,eAAiBA,EAAM,YAC/D,CACF,EClBA,OAAS,aAAAC,MAAiB,8BAC1B,OAAOC,MAA2B,SAGlCC,EAAI,GAAK,IAYF,IAAMC,EAAN,MAA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AAgC,aAAc,KAAK,WAAWD,CAAK,CAC5E,CAEA,8BAA8BA,EAA4B,CAnF5D,IAAAC,EAoFI,IAAMC,GAAaD,EAAA,KAAK,WAAW,IAAID,EAAM,GAAG,IAA7B,YAAAC,EAAgC,WACnD,OAAOC,GAAcA,IAAe,EAAIA,EAAa,KAAK,WAAWF,CAAK,CAC5E,CAEA,uBAAuBA,EAAkC,CAxF3D,IAAAC,EAyFI,OAAOA,EAAA,KAAK,WAAW,IAAID,EAAM,GAAG,IAA7B,YAAAC,EAAgC,cACzC,CAEA,iBAAiBD,EAAkC,CA5FrD,IAAAC,EA6FI,OAAOA,EAAA,KAAK,WAAW,IAAID,EAAM,GAAG,IAA7B,YAAAC,EAAgC,QACzC,CAEA,YAAYD,EAAsB,CAhGpC,IAAAC,EAiGI,QAAOA,EAAA,KAAK,WAAW,IAAID,EAAM,GAAG,IAA7B,YAAAC,EAAgC,MAAO,CAChD,CACF,ED3EO,IAAME,EAAN,cAA2BC,CAAU,CACjC,GAEA,IAEA,eAEA,YAEA,UAET,YAAY,CACV,GAAAC,EACA,IAAAC,EACA,eAAAC,EACA,YAAAC,EAAc,GACd,UAAAC,EACA,GAAGC,CACL,EAAkC,CAChC,MAAM,CAAE,qBAA8B,GAAGA,CAAO,CAAC,EAEjD,KAAK,UAAYD,EACjB,KAAK,GAAKJ,EACV,KAAK,IAAMC,EACX,KAAK,eAAiBC,EACtB,KAAK,YAAcC,CACrB,CAEA,cAAsB,CACpB,OAAOG,EAAY,CACjB,GAAI,KAAK,GACT,KAAM,KAAK,KACX,eAAgB,KAAK,eACrB,QAAS,CACP,QAAS,CACP,KAAM,CAAC,KAAK,GAAG,EACf,UAAW,MAAM,QAAQ,KAAK,EAAE,EAAI,KAAK,GAAK,CAAC,KAAK,EAAE,CACxD,CACF,CACF,CAAC,CACH,CACF","names":["Asset","key","originSymbol","asset","toDecimal","Big","Big","AssetAmount","_AssetAmount","Asset","amount","decimals","symbol","other","asset","params","maxDecimal","roundType","toDecimal","ChainType","Ecosystem","Chain","ecosystem","isTestChain","key","name","type","defineChain","Parachain","Chain","assetsData","checkSovereignAccountBalances","genesisHash","isRelay","parachainId","usesChainDecimals","ss58Format","weight","ws","type","others","data","asset","_a","metadataId","EvmParachain","Parachain","id","rpc","nativeCurrency","isEvmSigner","contracts","others","defineChain"]}
|
|
1
|
+
{"version":3,"sources":["../src/asset/Asset.ts","../src/asset/AssetAmount.ts","../src/asset/ChainAsset.ts","../src/chain/Chain.ts","../src/chain/Chain.interfaces.ts","../src/chain/Chain.utils.ts","../src/chain/EvmChain.ts","../src/chain/parachain/Parachain.ts","../src/chain/parachain/EvmParachain.ts"],"sourcesContent":["export interface AssetConstructorParams {\n key: string;\n originSymbol: string;\n}\n\nexport class Asset {\n readonly key: string;\n\n readonly originSymbol: string;\n\n constructor({ key, originSymbol }: AssetConstructorParams) {\n this.key = key;\n this.originSymbol = originSymbol;\n }\n\n copyWith(params: Partial<AssetConstructorParams>): Asset {\n return new Asset({\n ...this,\n ...params,\n });\n }\n\n isEqual(asset: Asset): boolean {\n return this.key === asset.key && this.originSymbol === asset.originSymbol;\n }\n}\n","import {\n convertDecimals,\n toBigInt,\n toDecimal,\n} from '@moonbeam-network/xcm-utils';\nimport Big, { type RoundingMode } from 'big.js';\nimport { ChainAsset, type ChainAssetConstructorParams } from './ChainAsset';\n\nBig.NE = -18;\n\nexport interface AssetAmountConstructorParams\n extends ChainAssetConstructorParams {\n amount: number | bigint;\n decimals: number;\n symbol?: string;\n}\n\nexport class AssetAmount extends ChainAsset {\n readonly amount: bigint;\n\n constructor({ amount, ...other }: AssetAmountConstructorParams) {\n super(other);\n\n this.amount = toBigInt(amount, other.decimals);\n }\n\n static fromChainAsset(\n asset: ChainAsset,\n params: Omit<\n AssetAmountConstructorParams,\n keyof ChainAssetConstructorParams\n >,\n ): AssetAmount {\n return new AssetAmount({\n ...asset,\n ...params,\n });\n }\n\n isSame(asset: ChainAsset | AssetAmount): boolean {\n return super.isEqual(asset) && this.decimals === asset.decimals;\n }\n\n isEqual(asset: AssetAmount): boolean {\n return this.isSame(asset) && this.amount === asset.amount;\n }\n\n copyWith(params: Partial<AssetAmountConstructorParams>): AssetAmount {\n return new AssetAmount({\n ...this,\n ...params,\n });\n }\n\n convertDecimals(decimals: number): AssetAmount {\n if (this.decimals === decimals) {\n return this.copyWith({});\n }\n\n return this.copyWith({\n amount: convertDecimals(this.amount, this.decimals, decimals),\n decimals,\n });\n }\n\n toBig(): Big {\n return Big(this.amount.toString());\n }\n\n toBigDecimal(maxDecimal?: number, roundType?: RoundingMode): Big {\n return Big(this.toDecimal(maxDecimal, roundType));\n }\n\n toDecimal(maxDecimal?: number, roundType?: RoundingMode): string {\n return toDecimal(this.amount, this.decimals, maxDecimal, roundType);\n }\n}\n","import { toBigInt } from '@moonbeam-network/xcm-utils';\nimport { Asset, type AssetConstructorParams } from './Asset';\n\nexport interface ChainAssetConstructorParams extends AssetConstructorParams {\n address?: string;\n decimals: number;\n ids?: ChainAssetIds;\n min?: number | bigint;\n symbol?: string;\n}\n\nexport interface ChainAssetIds {\n balanceId?: ChainAssetId;\n id?: ChainAssetId;\n minId?: ChainAssetId;\n palletInstance?: number;\n}\n\nexport type ChainAssetId =\n | string\n | number\n | bigint\n | { [key: string]: ChainAssetId };\n\nexport class ChainAsset extends Asset {\n readonly address?: string;\n\n readonly decimals: number;\n\n readonly ids?: ChainAssetIds;\n\n readonly min?: bigint;\n\n readonly symbol?: string;\n\n constructor({\n address,\n decimals,\n ids,\n min,\n symbol,\n ...other\n }: ChainAssetConstructorParams) {\n super(other);\n\n this.address = address;\n this.decimals = decimals;\n this.ids = ids;\n this.min = min ? toBigInt(min, decimals) : undefined;\n this.symbol = symbol;\n }\n\n static fromAsset(\n asset: Asset,\n params: Omit<ChainAssetConstructorParams, keyof AssetConstructorParams>,\n ): ChainAsset {\n return new ChainAsset({\n ...asset,\n ...params,\n });\n }\n\n copyWith(params: Partial<ChainAssetConstructorParams>): ChainAsset {\n return new ChainAsset({\n ...this,\n ...params,\n });\n }\n\n getSymbol(): string {\n return this.symbol || this.originSymbol;\n }\n\n getAssetId(): ChainAssetId {\n return this.ids?.id ?? this.originSymbol;\n }\n\n getBalanceAssetId(): ChainAssetId {\n return this.ids?.balanceId ?? this.getAssetId();\n }\n\n getMinAssetId(): ChainAssetId {\n return this.ids?.minId ?? this.getAssetId();\n }\n\n getAssetPalletInstance(): number | undefined {\n return this.ids?.palletInstance;\n }\n\n getAssetMin(): bigint {\n return this.min ?? 0n;\n }\n\n hasOnlyAddress(): this is { address: string } {\n return !!this.address && !this.ids?.id;\n }\n}\n","import type { Chain as WhChain } from '@wormhole-foundation/sdk-connect';\nimport type { Asset, AssetAmount, ChainAsset } from '../asset';\nimport type { Ecosystem, WormholeConfig } from './Chain.interfaces';\n\nexport interface ChainConstructorParams {\n assets: Map<string, ChainAsset> | ChainAsset[];\n ecosystem?: Ecosystem;\n explorer?: string;\n isTestChain?: boolean;\n key: string;\n name: string;\n nativeAsset: Asset;\n wh?: WormholeConfig;\n}\n\nexport abstract class Chain {\n readonly assets: Map<string, ChainAsset>;\n\n readonly ecosystem?: Ecosystem;\n\n readonly explorer?: string;\n\n readonly isTestChain: boolean;\n\n readonly key: string;\n\n readonly name: string;\n\n readonly #nativeAsset: Asset;\n\n readonly wh?: WormholeConfig;\n\n constructor({\n assets,\n ecosystem,\n explorer,\n isTestChain = false,\n key,\n name,\n nativeAsset,\n wh,\n }: ChainConstructorParams) {\n this.assets =\n assets instanceof Map\n ? assets\n : new Map(assets?.map((data) => [data.key, data]));\n this.ecosystem = ecosystem;\n this.explorer = explorer;\n this.isTestChain = isTestChain;\n this.key = key;\n this.name = name;\n this.#nativeAsset = nativeAsset;\n this.wh = wh;\n }\n\n get nativeAsset(): ChainAsset {\n return this.getChainAsset(this.#nativeAsset);\n }\n\n isEqual<T extends Chain>(chain: T): boolean {\n return this.key === chain.key;\n }\n\n getChainAsset(keyOrAsset: string | Asset | AssetAmount): ChainAsset {\n const key = typeof keyOrAsset === 'string' ? keyOrAsset : keyOrAsset.key;\n const chainAsset = this.assets.get(key);\n\n if (!chainAsset) {\n throw new Error(\n `No ChainAsset found by the key ${key} for chain ${this.name} (${this.key})`,\n );\n }\n\n return chainAsset;\n }\n\n getWormholeName(): WhChain {\n if (!this.wh?.name) {\n throw new Error(`Chain ${this.name} does not have a wormhole name`);\n }\n\n return this.wh.name;\n }\n}\n","import type { Chain } from '@wormhole-foundation/sdk-connect';\nimport type { EvmChain } from './EvmChain';\nimport type { EvmParachain, Parachain } from './parachain';\n\nexport type AnyChain = EvmChain | Parachain | EvmParachain;\nexport type AnyParachain = Parachain | EvmParachain;\n\nexport enum Ecosystem {\n Polkadot = 'polkadot',\n Kusama = 'kusama',\n AlphanetRelay = 'alphanet-relay',\n}\n\nexport interface WormholeConfig {\n name?: Chain;\n}\n","import { type Chain, defineChain } from 'viem';\nimport type { ChainAsset } from '../asset';\n\ninterface GetViemChainParams {\n id: number;\n name: string;\n nativeAsset: ChainAsset;\n rpc: string;\n}\n\nexport function getViemChain({\n id,\n name,\n nativeAsset,\n rpc,\n}: GetViemChainParams): Chain {\n return defineChain({\n id,\n name,\n nativeCurrency: {\n decimals: nativeAsset.decimals,\n name: nativeAsset.originSymbol,\n symbol: nativeAsset.originSymbol,\n },\n rpcUrls: {\n default: {\n http: [rpc],\n },\n },\n });\n}\n","import type { Chain as ViemChain } from 'viem';\nimport { Chain, type ChainConstructorParams } from './Chain';\nimport { getViemChain } from './Chain.utils';\n\nexport interface EvmChainConstructorParams extends ChainConstructorParams {\n id: number;\n rpc: string;\n}\n\nexport class EvmChain extends Chain {\n readonly id: number;\n\n readonly rpc: string;\n\n static is(obj: unknown): obj is EvmChain {\n return obj instanceof EvmChain;\n }\n\n constructor({ id, rpc, ...others }: EvmChainConstructorParams) {\n super(others);\n\n this.id = id;\n this.rpc = rpc;\n }\n\n getViemChain(): ViemChain {\n return getViemChain(this);\n }\n}\n","import { Chain, type ChainConstructorParams } from '../Chain';\n\nexport interface ParachainConstructorParams extends ChainConstructorParams {\n checkSovereignAccountBalances?: boolean;\n genesisHash: string;\n isRelay?: boolean;\n parachainId: number;\n ss58Format: number;\n usesChainDecimals?: boolean;\n weight?: number;\n ws: string[];\n}\n\nexport class Parachain extends Chain {\n readonly checkSovereignAccountBalances: boolean;\n\n readonly genesisHash: string;\n\n readonly isRelay: boolean;\n\n readonly parachainId: number;\n\n readonly ss58Format: number;\n\n readonly usesChainDecimals: boolean;\n\n readonly weight: number | undefined;\n\n readonly ws: string[];\n\n static is(obj: unknown): obj is Parachain {\n return obj instanceof Parachain;\n }\n\n constructor({\n checkSovereignAccountBalances,\n genesisHash,\n isRelay,\n parachainId,\n usesChainDecimals,\n ss58Format,\n weight,\n ws,\n ...others\n }: ParachainConstructorParams) {\n super(others);\n\n this.checkSovereignAccountBalances = !!checkSovereignAccountBalances;\n this.genesisHash = genesisHash;\n this.isRelay = !!isRelay;\n this.parachainId = parachainId;\n this.ss58Format = ss58Format;\n this.usesChainDecimals = !!usesChainDecimals;\n this.weight = weight;\n this.ws = ws;\n }\n}\n","import type { Address } from 'viem';\nimport type { Chain } from 'viem/chains';\nimport { getViemChain } from '../Chain.utils';\nimport { EvmChain } from '../EvmChain';\nimport { Parachain, type ParachainConstructorParams } from './Parachain';\n\nexport interface EvmParachainConstructorParams\n extends ParachainConstructorParams {\n id: number;\n rpc: string;\n isEvmSigner?: boolean;\n contracts?: Contracts;\n}\n\ntype Contracts = {\n Batch?: Address;\n XcmUtils?: Address;\n Xtokens?: Address;\n};\n\nexport class EvmParachain extends Parachain {\n readonly id: number;\n\n readonly rpc: string;\n\n readonly isEvmSigner: boolean;\n\n readonly contracts?: Contracts;\n\n static is(obj: unknown): obj is EvmParachain {\n return obj instanceof EvmParachain;\n }\n\n static isAnyParachain(obj: unknown): obj is EvmParachain | Parachain {\n return obj instanceof EvmParachain || obj instanceof Parachain;\n }\n\n static isAnyEvmChain(obj: unknown): obj is EvmParachain | EvmChain {\n return obj instanceof EvmParachain || obj instanceof EvmChain;\n }\n\n constructor({\n id,\n rpc,\n isEvmSigner = false,\n contracts,\n ...others\n }: EvmParachainConstructorParams) {\n super(others);\n\n this.contracts = contracts;\n this.id = id;\n this.rpc = rpc;\n this.isEvmSigner = isEvmSigner;\n }\n\n getViemChain(): Chain {\n return getViemChain(this);\n }\n}\n"],"mappings":";AAKO,IAAM,QAAN,MAAM,OAAM;AAAA,EACR;AAAA,EAEA;AAAA,EAET,YAAY,EAAE,KAAK,aAAa,GAA2B;AACzD,SAAK,MAAM;AACX,SAAK,eAAe;AAAA,EACtB;AAAA,EAEA,SAAS,QAAgD;AACvD,WAAO,IAAI,OAAM;AAAA,MACf,GAAG;AAAA,MACH,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,QAAQ,OAAuB;AAC7B,WAAO,KAAK,QAAQ,MAAM,OAAO,KAAK,iBAAiB,MAAM;AAAA,EAC/D;AACF;;;ACzBA;AAAA,EACE;AAAA,EACA,YAAAA;AAAA,EACA;AAAA,OACK;AACP,OAAO,SAAgC;;;ACLvC,SAAS,gBAAgB;AAwBlB,IAAM,aAAN,MAAM,oBAAmB,MAAM;AAAA,EAC3B;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAET,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GAAgC;AAC9B,UAAM,KAAK;AAEX,SAAK,UAAU;AACf,SAAK,WAAW;AAChB,SAAK,MAAM;AACX,SAAK,MAAM,MAAM,SAAS,KAAK,QAAQ,IAAI;AAC3C,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,OAAO,UACL,OACA,QACY;AACZ,WAAO,IAAI,YAAW;AAAA,MACpB,GAAG;AAAA,MACH,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,SAAS,QAA0D;AACjE,WAAO,IAAI,YAAW;AAAA,MACpB,GAAG;AAA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AAO,eAAe;AAAA,EACxB;AAAA,EAEA,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GAA+B;AAC7B,UAAM,MAAM;AAEZ,SAAK,gCAAgC,CAAC,CAAC;AACvC,SAAK,cAAc;AACnB,SAAK,UAAU,CAAC,CAAC;AACjB,SAAK,cAAc;AACnB,SAAK,aAAa;AAClB,SAAK,oBAAoB,CAAC,CAAC;AAC3B,SAAK,SAAS;AACd,SAAK,KAAK;AAAA,EACZ;AACF;;;ACpCO,IAAM,eAAN,MAAM,sBAAqB,UAAU;AAAA,EACjC;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAET,OAAO,GAAG,KAAmC;AAC3C,WAAO,eAAe;AAAA,EACxB;AAAA,EAEA,OAAO,eAAe,KAA+C;AACnE,WAAO,eAAe,iBAAgB,eAAe;AAAA,EACvD;AAAA,EAEA,OAAO,cAAc,KAA8C;AACjE,WAAO,eAAe,iBAAgB,eAAe;AAAA,EACvD;AAAA,EAEA,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd;AAAA,IACA,GAAG;AAAA,EACL,GAAkC;AAChC,UAAM,MAAM;AAEZ,SAAK,YAAY;AACjB,SAAK,KAAK;AACV,SAAK,MAAM;AACX,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,eAAsB;AACpB,WAAO,aAAa,IAAI;AAAA,EAC1B;AACF;","names":["toBigInt","toBigInt","Ecosystem"]}
|
package/package.json
CHANGED
|
@@ -1,57 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonbeam-network/xcm-types",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Moonbeam XCM Types",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsup",
|
|
7
|
-
"dev": "
|
|
8
|
-
"link": "
|
|
9
|
-
"lint": "eslint ./src --ext .js,.ts",
|
|
10
|
-
"lint:fix": "npm run lint -- --fix",
|
|
7
|
+
"dev": "tsup --watch",
|
|
8
|
+
"link": "pnpm ln --global",
|
|
11
9
|
"test": "vitest --run",
|
|
12
10
|
"test:watch": "vitest",
|
|
13
|
-
"test:update": "vitest -u"
|
|
14
|
-
"prepack": "prettier --write build/index.d.ts"
|
|
11
|
+
"test:update": "vitest -u"
|
|
15
12
|
},
|
|
16
13
|
"repository": {
|
|
17
14
|
"directory": "packages/types",
|
|
18
15
|
"type": "git",
|
|
19
16
|
"url": "git+https://github.com/moonbeam-foundation/xcm-sdk.git"
|
|
20
17
|
},
|
|
21
|
-
"keywords": [
|
|
22
|
-
"moonbeam",
|
|
23
|
-
"moonriver",
|
|
24
|
-
"xcm"
|
|
25
|
-
],
|
|
18
|
+
"keywords": ["moonbeam", "moonriver", "xcm"],
|
|
26
19
|
"author": "moonbeam-foundation",
|
|
27
20
|
"license": "MIT",
|
|
28
21
|
"bugs": {
|
|
29
22
|
"url": "https://github.com/moonbeam-foundation/xcm-sdk/issues"
|
|
30
23
|
},
|
|
31
24
|
"homepage": "https://moonbeam-foundation.github.io/xcm-sdk/latest",
|
|
32
|
-
"files": [
|
|
33
|
-
"build"
|
|
34
|
-
],
|
|
25
|
+
"files": ["build"],
|
|
35
26
|
"type": "module",
|
|
36
27
|
"exports": {
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"default": "./build/index.mjs"
|
|
41
|
-
},
|
|
42
|
-
"require": {
|
|
43
|
-
"types": "./build/index.d.ts",
|
|
44
|
-
"default": "./build/index.cjs"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
28
|
+
"import": "./build/index.mjs",
|
|
29
|
+
"types": "./build/index.d.ts",
|
|
30
|
+
"default": "./build/index.mjs"
|
|
47
31
|
},
|
|
48
32
|
"types": "./build/index.d.ts",
|
|
49
|
-
"main": "./build/index.
|
|
33
|
+
"main": "./build/index.mjs",
|
|
50
34
|
"dependencies": {
|
|
51
|
-
"@moonbeam-network/xcm-utils": "
|
|
35
|
+
"@moonbeam-network/xcm-utils": "3.0.0",
|
|
52
36
|
"big.js": "^6.2.1"
|
|
53
37
|
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/big.js": "^6.2.2",
|
|
40
|
+
"@wormhole-foundation/sdk-connect": "^0.10.7"
|
|
41
|
+
},
|
|
54
42
|
"peerDependencies": {
|
|
55
|
-
"viem": "^2.
|
|
43
|
+
"viem": "^2.21.7"
|
|
56
44
|
}
|
|
57
45
|
}
|
package/build/index.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var v=Object.create;var h=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var B=(a,t)=>{for(var e in t)h(a,e,{get:t[e],enumerable:!0})},g=(a,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of D(t))!w.call(a,r)&&r!==e&&h(a,r,{get:()=>t[r],enumerable:!(s=S(t,r))||s.enumerable});return a};var M=(a,t,e)=>(e=a!=null?v(E(a)):{},g(t||!a||!a.__esModule?h(e,"default",{value:a,enumerable:!0}):e,a)),R=a=>g(h({},"__esModule",{value:!0}),a);var T={};B(T,{Asset:()=>i,AssetAmount:()=>d,Chain:()=>m,ChainType:()=>o,Ecosystem:()=>C,EvmParachain:()=>y,Parachain:()=>c});module.exports=R(T);var i=class{key;originSymbol;constructor({key:t,originSymbol:e}){this.key=t,this.originSymbol=e}isEqual(t){return this.key===t.key&&this.originSymbol===t.originSymbol}};var A=require("@moonbeam-network/xcm-utils"),u=M(require("big.js"),1);u.default.NE=-18;var d=class a extends i{amount;decimals;symbol;constructor({amount:t,decimals:e,symbol:s,...r}){super(r),this.amount=BigInt(t),this.decimals=e,this.symbol=s||this.originSymbol}static fromAsset(t,e){return new a({...t,...e})}isSame(t){return super.isEqual(t)&&this.decimals===t.decimals}isEqual(t){return this.isSame(t)&&this.amount===t.amount}copyWith(t){return new a({...this,...t})}toBig(){return(0,u.default)(this.amount.toString())}toBigDecimal(t,e){return(0,u.default)(this.toDecimal(t,e))}toDecimal(t,e){return(0,A.toDecimal)(this.amount,this.decimals,t,e)}};var o=(e=>(e.Parachain="parachain",e.EvmParachain="evm-parachain",e))(o||{}),C=(s=>(s.Polkadot="polkadot",s.Kusama="kusama",s.AlphanetRelay="alphanet-relay",s))(C||{});var m=class{ecosystem;isTestChain;key;name;type;constructor({ecosystem:t,isTestChain:e=!1,key:s,name:r,type:n}){this.ecosystem=t,this.isTestChain=e,this.key=s,this.name=r,this.type=n}isParachain(){return this.type==="parachain"}isEvmParachain(){return this.type==="evm-parachain"}};var P=require("viem");var c=class extends m{assetsData;checkSovereignAccountBalances;genesisHash;isRelay;parachainId;ss58Format;usesChainDecimals;weight;ws;constructor({assetsData:t,checkSovereignAccountBalances:e,genesisHash:s,isRelay:r,parachainId:n,usesChainDecimals:l,ss58Format:b,weight:f,ws:x,type:I="parachain",...k}){super({type:I,...k}),this.assetsData=t instanceof Map?t:new Map(t==null?void 0:t.map(p=>[p.asset.key,p])),this.checkSovereignAccountBalances=!!e,this.genesisHash=s,this.isRelay=!!r,this.parachainId=n,this.ss58Format=b,this.usesChainDecimals=!!l,this.weight=f,this.ws=x}getAssetId(t){var e;return((e=this.assetsData.get(t.key))==null?void 0:e.id)??t.originSymbol}getBalanceAssetId(t){var e;return((e=this.assetsData.get(t.key))==null?void 0:e.balanceId)??this.getAssetId(t)}getMinAssetId(t){var e;return((e=this.assetsData.get(t.key))==null?void 0:e.minId)??this.getAssetId(t)}getMetadataAssetId(t){var e;return((e=this.assetsData.get(t.key))==null?void 0:e.metadataId)??this.getAssetId(t)}getRegisteredAssetIdOrAddress(t){var s;let e=(s=this.assetsData.get(t.key))==null?void 0:s.metadataId;return e&&e!==0?e:this.getAssetId(t)}getAssetPalletInstance(t){var e;return(e=this.assetsData.get(t.key))==null?void 0:e.palletInstance}getAssetDecimals(t){var e;return(e=this.assetsData.get(t.key))==null?void 0:e.decimals}getAssetMin(t){var e;return((e=this.assetsData.get(t.key))==null?void 0:e.min)??0}};var y=class extends c{id;rpc;nativeCurrency;isEvmSigner;contracts;constructor({id:t,rpc:e,nativeCurrency:s,isEvmSigner:r=!1,contracts:n,...l}){super({type:"evm-parachain",...l}),this.contracts=n,this.id=t,this.rpc=e,this.nativeCurrency=s,this.isEvmSigner=r}getViemChain(){return(0,P.defineChain)({id:this.id,name:this.name,nativeCurrency:this.nativeCurrency,rpcUrls:{default:{http:[this.rpc],webSocket:Array.isArray(this.ws)?this.ws:[this.ws]}}})}};0&&(module.exports={Asset,AssetAmount,Chain,ChainType,Ecosystem,EvmParachain,Parachain});
|
|
2
|
-
//# sourceMappingURL=index.cjs.map
|
package/build/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/asset/Asset.ts","../src/asset/AssetAmount.ts","../src/chain/Chain.interfaces.ts","../src/chain/Chain.ts","../src/chain/parachain/EvmParachain.ts","../src/chain/parachain/Parachain.ts"],"sourcesContent":["export * from './asset';\nexport * from './chain';\nexport * from './common.interfaces';\n","export interface AssetConstructorParams {\n key: string;\n originSymbol: string;\n}\n\nexport class Asset {\n readonly key: string;\n\n readonly originSymbol: string;\n\n constructor({ key, originSymbol }: AssetConstructorParams) {\n this.key = key;\n this.originSymbol = originSymbol;\n }\n\n isEqual(asset: Asset): boolean {\n return this.key === asset.key && this.originSymbol === asset.originSymbol;\n }\n}\n","import { toDecimal } from '@moonbeam-network/xcm-utils';\nimport Big, { RoundingMode } from 'big.js';\nimport { Asset, AssetConstructorParams } from './Asset';\n\nBig.NE = -18;\n\nexport interface AssetAmountParams {\n amount: bigint;\n decimals: number;\n symbol?: string;\n}\n\nexport interface AssetAmountConstructorParams\n extends AssetConstructorParams,\n AssetAmountParams {}\n\nexport class AssetAmount extends Asset {\n readonly amount: bigint;\n\n readonly decimals: number;\n\n readonly symbol: string;\n\n constructor({\n amount,\n decimals,\n symbol,\n ...other\n }: AssetAmountConstructorParams) {\n super(other);\n\n this.amount = BigInt(amount);\n this.decimals = decimals;\n this.symbol = symbol || this.originSymbol;\n }\n\n static fromAsset(asset: Asset, params: AssetAmountParams) {\n return new AssetAmount({\n ...asset,\n ...params,\n });\n }\n\n isSame(asset: AssetAmount): boolean {\n return super.isEqual(asset) && this.decimals === asset.decimals;\n }\n\n isEqual(asset: AssetAmount): boolean {\n return this.isSame(asset) && this.amount === asset.amount;\n }\n\n copyWith(params: Partial<AssetAmountConstructorParams>) {\n return new AssetAmount({\n ...this,\n ...params,\n });\n }\n\n toBig(): Big {\n return Big(this.amount.toString());\n }\n\n toBigDecimal(maxDecimal?: number, roundType?: RoundingMode): Big {\n return Big(this.toDecimal(maxDecimal, roundType));\n }\n\n toDecimal(maxDecimal?: number, roundType?: RoundingMode): string {\n return toDecimal(this.amount, this.decimals, maxDecimal, roundType);\n }\n}\n","import type { EvmParachain, Parachain } from './parachain';\n\nexport type AnyChain = Parachain | EvmParachain;\nexport type AnyParachain = Parachain | EvmParachain;\n\nexport enum ChainType {\n 'Parachain' = 'parachain',\n 'EvmParachain' = 'evm-parachain',\n}\n\nexport enum Ecosystem {\n Polkadot = 'polkadot',\n Kusama = 'kusama',\n AlphanetRelay = 'alphanet-relay',\n}\n","import { ChainType, Ecosystem } from './Chain.interfaces';\nimport type { EvmParachain, Parachain } from './parachain';\n\nexport interface ChainConstructorParams {\n ecosystem?: Ecosystem;\n isTestChain?: boolean;\n key: string;\n name: string;\n type: ChainType;\n}\n\nexport abstract class Chain {\n readonly ecosystem?: Ecosystem;\n\n readonly isTestChain: boolean;\n\n readonly key: string;\n\n readonly name: string;\n\n readonly type: ChainType;\n\n constructor({\n ecosystem,\n isTestChain = false,\n key,\n name,\n type,\n }: ChainConstructorParams) {\n this.ecosystem = ecosystem;\n this.isTestChain = isTestChain;\n this.key = key;\n this.name = name;\n this.type = type;\n }\n\n isParachain(): this is Parachain {\n return this.type === ChainType.Parachain;\n }\n\n isEvmParachain(): this is EvmParachain {\n return this.type === ChainType.EvmParachain;\n }\n}\n","import { Address, defineChain } from 'viem';\nimport { Chain } from 'viem/chains';\nimport { ChainType } from '../Chain.interfaces';\nimport { Parachain, ParachainConstructorParams } from './Parachain';\n\nexport interface EvmParachainConstructorParams\n extends Omit<ParachainConstructorParams, 'type'> {\n id: number;\n rpc: string;\n nativeCurrency: NativeCurrency;\n isEvmSigner?: boolean;\n contracts?: Contracts;\n}\n\ntype NativeCurrency = {\n decimals: number;\n name: string;\n symbol: string;\n};\n\ntype Contracts = {\n Xtokens?: Address;\n};\n\nexport class EvmParachain extends Parachain {\n readonly id: number;\n\n readonly rpc: string;\n\n readonly nativeCurrency: NativeCurrency;\n\n readonly isEvmSigner: boolean;\n\n readonly contracts?: Contracts;\n\n constructor({\n id,\n rpc,\n nativeCurrency,\n isEvmSigner = false,\n contracts,\n ...others\n }: EvmParachainConstructorParams) {\n super({ type: ChainType.EvmParachain, ...others });\n\n this.contracts = contracts;\n this.id = id;\n this.rpc = rpc;\n this.nativeCurrency = nativeCurrency;\n this.isEvmSigner = isEvmSigner;\n }\n\n getViemChain(): Chain {\n return defineChain({\n id: this.id,\n name: this.name,\n nativeCurrency: this.nativeCurrency,\n rpcUrls: {\n default: {\n http: [this.rpc],\n webSocket: Array.isArray(this.ws) ? this.ws : [this.ws],\n },\n },\n });\n }\n}\n","import { Asset } from '../../asset';\nimport { SetOptional } from '../../common.interfaces';\nimport { Chain, ChainConstructorParams } from '../Chain';\nimport { ChainType } from '../Chain.interfaces';\nimport { ChainAssetId, ChainAssetsData } from './Parachain.interfaces';\n\nexport interface ParachainConstructorParams\n extends SetOptional<ChainConstructorParams, 'type'> {\n assetsData?: Map<string, ChainAssetsData> | ChainAssetsData[];\n checkSovereignAccountBalances?: boolean;\n genesisHash: string;\n isRelay?: boolean;\n parachainId: number;\n ss58Format: number;\n usesChainDecimals?: boolean;\n weight?: number;\n ws: string[];\n}\n\nexport class Parachain extends Chain {\n readonly assetsData: Map<string, ChainAssetsData>;\n\n readonly checkSovereignAccountBalances: boolean;\n\n readonly genesisHash: string;\n\n readonly isRelay: boolean;\n\n readonly parachainId: number;\n\n readonly ss58Format: number;\n\n readonly usesChainDecimals: boolean;\n\n readonly weight: number | undefined;\n\n readonly ws: string[];\n\n constructor({\n assetsData,\n checkSovereignAccountBalances,\n genesisHash,\n isRelay,\n parachainId,\n usesChainDecimals,\n ss58Format,\n weight,\n ws,\n type = ChainType.Parachain,\n ...others\n }: ParachainConstructorParams) {\n super({ type, ...others });\n\n this.assetsData =\n assetsData instanceof Map\n ? assetsData\n : new Map(assetsData?.map((data) => [data.asset.key, data]));\n this.checkSovereignAccountBalances = !!checkSovereignAccountBalances;\n this.genesisHash = genesisHash;\n this.isRelay = !!isRelay;\n this.parachainId = parachainId;\n this.ss58Format = ss58Format;\n this.usesChainDecimals = !!usesChainDecimals;\n this.weight = weight;\n this.ws = ws;\n }\n\n getAssetId(asset: Asset): ChainAssetId {\n return this.assetsData.get(asset.key)?.id ?? asset.originSymbol;\n }\n\n getBalanceAssetId(asset: Asset): ChainAssetId {\n return this.assetsData.get(asset.key)?.balanceId ?? this.getAssetId(asset);\n }\n\n getMinAssetId(asset: Asset): ChainAssetId {\n return this.assetsData.get(asset.key)?.minId ?? this.getAssetId(asset);\n }\n\n getMetadataAssetId(asset: Asset): ChainAssetId {\n return this.assetsData.get(asset.key)?.metadataId ?? this.getAssetId(asset);\n }\n\n getRegisteredAssetIdOrAddress(asset: Asset): ChainAssetId {\n const metadataId = this.assetsData.get(asset.key)?.metadataId;\n return metadataId && metadataId !== 0 ? metadataId : this.getAssetId(asset);\n }\n\n getAssetPalletInstance(asset: Asset): number | undefined {\n return this.assetsData.get(asset.key)?.palletInstance;\n }\n\n getAssetDecimals(asset: Asset): number | undefined {\n return this.assetsData.get(asset.key)?.decimals;\n }\n\n getAssetMin(asset: Asset):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,UAAAC,EACA,GAAGC,CACL,EAAkC,CAChC,MAAM,CAAE,qBAA8B,GAAGA,CAAO,CAAC,EAEjD,KAAK,UAAYD,EACjB,KAAK,GAAKJ,EACV,KAAK,IAAMC,EACX,KAAK,eAAiBC,EACtB,KAAK,YAAcC,CACrB,CAEA,cAAsB,CACpB,SAAO,eAAY,CACjB,GAAI,KAAK,GACT,KAAM,KAAK,KACX,eAAgB,KAAK,eACrB,QAAS,CACP,QAAS,CACP,KAAM,CAAC,KAAK,GAAG,EACf,UAAW,MAAM,QAAQ,KAAK,EAAE,EAAI,KAAK,GAAK,CAAC,KAAK,EAAE,CACxD,CACF,CACF,CAAC,CACH,CACF","names":["src_exports","__export","Asset","AssetAmount","Chain","ChainType","Ecosystem","EvmParachain","Parachain","__toCommonJS","Asset","key","originSymbol","asset","import_xcm_utils","import_big","Big","AssetAmount","_AssetAmount","Asset","amount","decimals","symbol","other","asset","params","maxDecimal","roundType","ChainType","Ecosystem","Chain","ecosystem","isTestChain","key","name","type","import_viem","Parachain","Chain","assetsData","checkSovereignAccountBalances","genesisHash","isRelay","parachainId","usesChainDecimals","ss58Format","weight","ws","type","others","data","asset","_a","metadataId","EvmParachain","Parachain","id","rpc","nativeCurrency","isEvmSigner","contracts","others"]}
|
package/build/index.d.cts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import Big, { RoundingMode } from 'big.js';
|
|
2
|
-
import { Address } from 'viem';
|
|
3
|
-
import { Chain as Chain$1 } from 'viem/chains';
|
|
4
|
-
|
|
5
|
-
interface AssetConstructorParams {
|
|
6
|
-
key: string;
|
|
7
|
-
originSymbol: string;
|
|
8
|
-
}
|
|
9
|
-
declare class Asset {
|
|
10
|
-
readonly key: string;
|
|
11
|
-
readonly originSymbol: string;
|
|
12
|
-
constructor({ key, originSymbol }: AssetConstructorParams);
|
|
13
|
-
isEqual(asset: Asset): boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface AssetAmountParams {
|
|
17
|
-
amount: bigint;
|
|
18
|
-
decimals: number;
|
|
19
|
-
symbol?: string;
|
|
20
|
-
}
|
|
21
|
-
interface AssetAmountConstructorParams extends AssetConstructorParams, AssetAmountParams {
|
|
22
|
-
}
|
|
23
|
-
declare class AssetAmount extends Asset {
|
|
24
|
-
readonly amount: bigint;
|
|
25
|
-
readonly decimals: number;
|
|
26
|
-
readonly symbol: string;
|
|
27
|
-
constructor({ amount, decimals, symbol, ...other }: AssetAmountConstructorParams);
|
|
28
|
-
static fromAsset(asset: Asset, params: AssetAmountParams): AssetAmount;
|
|
29
|
-
isSame(asset: AssetAmount): boolean;
|
|
30
|
-
isEqual(asset: AssetAmount): boolean;
|
|
31
|
-
copyWith(params: Partial<AssetAmountConstructorParams>): AssetAmount;
|
|
32
|
-
toBig(): Big;
|
|
33
|
-
toBigDecimal(maxDecimal?: number, roundType?: RoundingMode): Big;
|
|
34
|
-
toDecimal(maxDecimal?: number, roundType?: RoundingMode): string;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
type SetOptional<Base, Keys extends keyof Base> = Omit<Base, Keys> & Partial<Pick<Base, Keys>>;
|
|
38
|
-
|
|
39
|
-
type ChainAssetId = string | number | bigint | {
|
|
40
|
-
[key: string]: ChainAssetId;
|
|
41
|
-
};
|
|
42
|
-
interface ChainAssetsData {
|
|
43
|
-
asset: Asset;
|
|
44
|
-
address?: string;
|
|
45
|
-
balanceId?: ChainAssetId;
|
|
46
|
-
decimals?: number;
|
|
47
|
-
id?: ChainAssetId;
|
|
48
|
-
metadataId?: ChainAssetId;
|
|
49
|
-
minId?: ChainAssetId;
|
|
50
|
-
palletInstance?: number;
|
|
51
|
-
min?: number;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
interface ParachainConstructorParams extends SetOptional<ChainConstructorParams, 'type'> {
|
|
55
|
-
assetsData?: Map<string, ChainAssetsData> | ChainAssetsData[];
|
|
56
|
-
checkSovereignAccountBalances?: boolean;
|
|
57
|
-
genesisHash: string;
|
|
58
|
-
isRelay?: boolean;
|
|
59
|
-
parachainId: number;
|
|
60
|
-
ss58Format: number;
|
|
61
|
-
usesChainDecimals?: boolean;
|
|
62
|
-
weight?: number;
|
|
63
|
-
ws: string[];
|
|
64
|
-
}
|
|
65
|
-
declare class Parachain extends Chain {
|
|
66
|
-
readonly assetsData: Map<string, ChainAssetsData>;
|
|
67
|
-
readonly checkSovereignAccountBalances: boolean;
|
|
68
|
-
readonly genesisHash: string;
|
|
69
|
-
readonly isRelay: boolean;
|
|
70
|
-
readonly parachainId: number;
|
|
71
|
-
readonly ss58Format: number;
|
|
72
|
-
readonly usesChainDecimals: boolean;
|
|
73
|
-
readonly weight: number | undefined;
|
|
74
|
-
readonly ws: string[];
|
|
75
|
-
constructor({ assetsData, checkSovereignAccountBalances, genesisHash, isRelay, parachainId, usesChainDecimals, ss58Format, weight, ws, type, ...others }: ParachainConstructorParams);
|
|
76
|
-
getAssetId(asset: Asset): ChainAssetId;
|
|
77
|
-
getBalanceAssetId(asset: Asset): ChainAssetId;
|
|
78
|
-
getMinAssetId(asset: Asset): ChainAssetId;
|
|
79
|
-
getMetadataAssetId(asset: Asset): ChainAssetId;
|
|
80
|
-
getRegisteredAssetIdOrAddress(asset: Asset): ChainAssetId;
|
|
81
|
-
getAssetPalletInstance(asset: Asset): number | undefined;
|
|
82
|
-
getAssetDecimals(asset: Asset): number | undefined;
|
|
83
|
-
getAssetMin(asset: Asset): number;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
interface EvmParachainConstructorParams extends Omit<ParachainConstructorParams, 'type'> {
|
|
87
|
-
id: number;
|
|
88
|
-
rpc: string;
|
|
89
|
-
nativeCurrency: NativeCurrency;
|
|
90
|
-
isEvmSigner?: boolean;
|
|
91
|
-
contracts?: Contracts;
|
|
92
|
-
}
|
|
93
|
-
type NativeCurrency = {
|
|
94
|
-
decimals: number;
|
|
95
|
-
name: string;
|
|
96
|
-
symbol: string;
|
|
97
|
-
};
|
|
98
|
-
type Contracts = {
|
|
99
|
-
Xtokens?: Address;
|
|
100
|
-
};
|
|
101
|
-
declare class EvmParachain extends Parachain {
|
|
102
|
-
readonly id: number;
|
|
103
|
-
readonly rpc: string;
|
|
104
|
-
readonly nativeCurrency: NativeCurrency;
|
|
105
|
-
readonly isEvmSigner: boolean;
|
|
106
|
-
readonly contracts?: Contracts;
|
|
107
|
-
constructor({ id, rpc, nativeCurrency, isEvmSigner, contracts, ...others }: EvmParachainConstructorParams);
|
|
108
|
-
getViemChain(): Chain$1;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
type AnyChain = Parachain | EvmParachain;
|
|
112
|
-
type AnyParachain = Parachain | EvmParachain;
|
|
113
|
-
declare enum ChainType {
|
|
114
|
-
'Parachain' = "parachain",
|
|
115
|
-
'EvmParachain' = "evm-parachain"
|
|
116
|
-
}
|
|
117
|
-
declare enum Ecosystem {
|
|
118
|
-
Polkadot = "polkadot",
|
|
119
|
-
Kusama = "kusama",
|
|
120
|
-
AlphanetRelay = "alphanet-relay"
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
interface ChainConstructorParams {
|
|
124
|
-
ecosystem?: Ecosystem;
|
|
125
|
-
isTestChain?: boolean;
|
|
126
|
-
key: string;
|
|
127
|
-
name: string;
|
|
128
|
-
type: ChainType;
|
|
129
|
-
}
|
|
130
|
-
declare abstract class Chain {
|
|
131
|
-
readonly ecosystem?: Ecosystem;
|
|
132
|
-
readonly isTestChain: boolean;
|
|
133
|
-
readonly key: string;
|
|
134
|
-
readonly name: string;
|
|
135
|
-
readonly type: ChainType;
|
|
136
|
-
constructor({ ecosystem, isTestChain, key, name, type, }: ChainConstructorParams);
|
|
137
|
-
isParachain(): this is Parachain;
|
|
138
|
-
isEvmParachain(): this is EvmParachain;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export { type AnyChain, type AnyParachain, Asset, AssetAmount, type AssetAmountConstructorParams, type AssetAmountParams, type AssetConstructorParams, Chain, type ChainAssetId, type ChainAssetsData, type ChainConstructorParams, ChainType, Ecosystem, EvmParachain, type EvmParachainConstructorParams, Parachain, type ParachainConstructorParams, type SetOptional };
|