@layerzerolabs/static-chain-info 0.2.68 → 0.2.70
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/{NN6FIT4I.js → BFJF22M7.js} +10 -3
- package/dist/BFJF22M7.js.map +1 -0
- package/dist/{IM5DOZQ3.cjs → HO5BEL2S.cjs} +10 -2
- package/dist/HO5BEL2S.cjs.map +1 -0
- package/dist/index.cjs +38 -34
- package/dist/index.js +2 -2
- package/dist/staticChainInfo.cjs +23 -19
- package/dist/staticChainInfo.d.ts +1 -0
- package/dist/staticChainInfo.d.ts.map +1 -1
- package/dist/staticChainInfo.js +1 -1
- package/package.json +12 -4
- package/.turbo/turbo-build.log +0 -27
- package/.turbo/turbo-lint.log +0 -8
- package/.turbo/turbo-test.log +0 -16
- package/dist/IM5DOZQ3.cjs.map +0 -1
- package/dist/NN6FIT4I.js.map +0 -1
- package/src/index.ts +0 -109
- package/src/staticChainInfo.ts +0 -2137
- package/tsconfig.json +0 -20
- package/tsup.config.ts +0 -8
package/src/index.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import type { Environment } from '@layerzerolabs/layerzero-definitions';
|
|
2
|
-
import { ChainName, chainNameSchema } from '@layerzerolabs/layerzero-definitions';
|
|
3
|
-
import { EndpointVersion, UlnVersion } from '@layerzerolabs/layerzero-definitions';
|
|
4
|
-
import type { Chain, EndpointId, Stage } from '@layerzerolabs/lz-definitions';
|
|
5
|
-
import {
|
|
6
|
-
chainAndStageToEndpointId,
|
|
7
|
-
ChannelId,
|
|
8
|
-
endpointIdToStage,
|
|
9
|
-
EndpointV2IdBase,
|
|
10
|
-
getNetworkForChainId,
|
|
11
|
-
} from '@layerzerolabs/lz-definitions';
|
|
12
|
-
|
|
13
|
-
import { ChainSubType, staticConfig } from './staticChainInfo';
|
|
14
|
-
|
|
15
|
-
export { ChainSubType };
|
|
16
|
-
|
|
17
|
-
export * from './staticChainInfo';
|
|
18
|
-
|
|
19
|
-
export const getChainNameFromEndpointId = (endpointId: EndpointId): ChainName => {
|
|
20
|
-
return chainNameSchema.parse(getNetworkForChainId(endpointId).chainName);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const isLzReadEndpointId = (endpointId: EndpointId) => {
|
|
24
|
-
return Object.values(ChannelId).includes(Number(endpointId));
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const getEndpointVersionFromEndpointId = (endpointId: EndpointId): EndpointVersion => {
|
|
28
|
-
if (isLzReadEndpointId(endpointId)) {
|
|
29
|
-
return EndpointVersion.V2;
|
|
30
|
-
}
|
|
31
|
-
return endpointId < EndpointV2IdBase ? EndpointVersion.V1 : EndpointVersion.V2;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const getEndpointVersionFromUlnVersion = (ulnVersion: UlnVersion): EndpointVersion => {
|
|
35
|
-
if (ulnVersion === UlnVersion.V1) {
|
|
36
|
-
throw new Error('UlnVersion.V1 is not supported');
|
|
37
|
-
}
|
|
38
|
-
switch (ulnVersion) {
|
|
39
|
-
case UlnVersion.V2:
|
|
40
|
-
case UlnVersion.V301:
|
|
41
|
-
return EndpointVersion.V1;
|
|
42
|
-
case UlnVersion.V300:
|
|
43
|
-
case UlnVersion.ReadV1002:
|
|
44
|
-
case UlnVersion.V302:
|
|
45
|
-
return EndpointVersion.V2;
|
|
46
|
-
default:
|
|
47
|
-
throw new Error(`Unknown UlnVersion: ${ulnVersion}`);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
// Note: This doesn't work for UlnVersion.V1
|
|
52
|
-
export const getEndpointId = (
|
|
53
|
-
chainName: ChainName,
|
|
54
|
-
environment: Environment,
|
|
55
|
-
version: EndpointVersion,
|
|
56
|
-
): EndpointId => {
|
|
57
|
-
return chainAndStageToEndpointId(
|
|
58
|
-
chainName as unknown as Chain,
|
|
59
|
-
environment as unknown as Stage,
|
|
60
|
-
version,
|
|
61
|
-
);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export const getEnvironmentFromEndpointId = (endpointId: EndpointId): Environment => {
|
|
65
|
-
return endpointIdToStage(endpointId) as unknown as Environment;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export const getVId = (chainName: ChainName, environment: Environment): string => {
|
|
69
|
-
// By convention the vid is always the endpointV1 endpoint id
|
|
70
|
-
// TODO: Monorepo doesn't have these chains for EndpointVersion.V1
|
|
71
|
-
if (['solana', 'ton', 'initia', 'movement', 'starknet', 'stellar'].includes(chainName)) {
|
|
72
|
-
const eid = getEndpointId(chainName, environment, EndpointVersion.V2);
|
|
73
|
-
return (parseInt(eid.toString()) % 30000).toString();
|
|
74
|
-
}
|
|
75
|
-
return getEndpointId(chainName, environment, EndpointVersion.V1).toString();
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export class StaticChainConfigs {
|
|
79
|
-
static getAddressSizeInBytes(chainName: ChainName): number {
|
|
80
|
-
return staticConfig[chainName].addressSizeInBytes;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
static getSymbol(chainName: ChainName): string {
|
|
84
|
-
return staticConfig[chainName].symbol;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
static getDecimals(chainName: ChainName): number {
|
|
88
|
-
return staticConfig[chainName].decimals;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
static getMptBaseFee(chainName: ChainName): number {
|
|
92
|
-
return staticConfig[chainName].mptBaseGas!;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
static getChainLayer(chainName: ChainName): number {
|
|
96
|
-
return staticConfig[chainName].chainLayer ?? 1;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
static getChainSubType(chainName: ChainName): ChainSubType | undefined {
|
|
100
|
-
return staticConfig[chainName].chainSubType;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
static getGasPriceDecimals(chainName: ChainName): number {
|
|
104
|
-
if (chainName === ChainName.HEDERA) {
|
|
105
|
-
return 18;
|
|
106
|
-
}
|
|
107
|
-
return staticConfig[chainName].decimals;
|
|
108
|
-
}
|
|
109
|
-
}
|