@layerzerolabs/lz-definitions 3.0.167 → 3.1.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/README.md DELETED
@@ -1,376 +0,0 @@
1
- # @layerzerolabs/lz-definitions
2
-
3
- The LayerZero Definitions package provides a comprehensive set of type definitions and utilities for interacting with various blockchains. It includes enums, types, and interfaces that facilitate the development and integration of applications with the LayerZero protocol.
4
-
5
- ## Features
6
-
7
- - **Enums**: Provides a set of enums representing various blockchain-related constants.
8
- - **Types**: Defines various types used across the LayerZero protocol.
9
- - **Interfaces**: Provides interfaces for different blockchain specifications and configurations.
10
- - **Utilities**: Includes utility functions for converting and handling blockchain-related data.
11
-
12
- ## Installation
13
-
14
- To install the LayerZero Definitions package, you can use npm or yarn:
15
-
16
- ```sh
17
- npm install @layerzerolabs/lz-definitions
18
- ```
19
-
20
- or
21
-
22
- ```sh
23
- yarn add @layerzerolabs/lz-definitions
24
- ```
25
-
26
- ## Utilities
27
-
28
- ### networkToEndpointId
29
-
30
- ```typescript
31
- import {
32
- networkToEndpointId,
33
- EndpointVersion,
34
- EndpointId,
35
- } from "@layerzerolabs/lz-definitions";
36
-
37
- // Converts a network name and version to an endpoint ID.
38
- const endpointId: EndpointId = networkToEndpointId(
39
- "ethereum-mainnet",
40
- EndpointVersion.V1,
41
- );
42
- console.log(endpointId);
43
- ```
44
-
45
- ### networkToEnv
46
-
47
- ```typescript
48
- import {
49
- networkToEnv,
50
- EndpointVersion,
51
- Environment,
52
- } from "@layerzerolabs/lz-definitions";
53
-
54
- // Converts a network name and version to an environment.
55
- const environment: Environment = networkToEnv(
56
- "ethereum-mainnet",
57
- EndpointVersion.V1,
58
- );
59
- console.log(environment);
60
- ```
61
-
62
- ### networkToStage
63
-
64
- ```typescript
65
- import { networkToStage, Stage } from "@layerzerolabs/lz-definitions";
66
-
67
- // Converts a network name to a stage.
68
- const stage: Stage = networkToStage("ethereum-mainnet");
69
- console.log(stage);
70
- ```
71
-
72
- ### endpointIdToNetwork
73
-
74
- ```typescript
75
- import {
76
- endpointIdToNetwork,
77
- Environment,
78
- Network,
79
- SandboxV2EndpointId,
80
- } from "@layerzerolabs/lz-definitions";
81
-
82
- // Converts an endpoint ID to a network name.
83
- const network: Network = endpointIdToNetwork(
84
- SandboxV2EndpointId.APTOS_V2_SANDBOX,
85
- Environment.MAINNET,
86
- );
87
- console.log(network);
88
- ```
89
-
90
- ### endpointIdToVersion
91
-
92
- ```typescript
93
- import {
94
- endpointIdToVersion,
95
- EndpointVersion,
96
- SandboxV2EndpointId,
97
- } from "@layerzerolabs/lz-definitions";
98
-
99
- // Converts an endpoint ID to an endpoint version.
100
- const version: EndpointVersion = endpointIdToVersion(
101
- SandboxV2EndpointId.APTOS_V2_SANDBOX,
102
- );
103
- console.log(version);
104
- ```
105
-
106
- ### endpointIdToChainKey
107
-
108
- ```typescript
109
- import {
110
- endpointIdToChainKey,
111
- ChainKey,
112
- SandboxV2EndpointId,
113
- } from "@layerzerolabs/lz-definitions";
114
-
115
- // Converts an endpoint ID to a chain key.
116
- const chainKey: ChainKey = endpointIdToChainKey(
117
- SandboxV2EndpointId.APTOS_V2_SANDBOX,
118
- );
119
- console.log(chainKey);
120
- ```
121
-
122
- ### chainAndStageToEndpointId
123
-
124
- ```typescript
125
- import {
126
- chainAndStageToEndpointId,
127
- Chain,
128
- Stage,
129
- EndpointVersion,
130
- EndpointId,
131
- } from "@layerzerolabs/lz-definitions";
132
-
133
- // Converts a chain and stage to an endpoint ID.
134
- const endpointId: EndpointId = chainAndStageToEndpointId(
135
- Chain.ETHEREUM,
136
- Stage.MAINNET,
137
- EndpointVersion.V1,
138
- );
139
- console.log(endpointId);
140
- ```
141
-
142
- ### chainAndStageToNetwork
143
-
144
- ```typescript
145
- import {
146
- chainAndStageToNetwork,
147
- Chain,
148
- Stage,
149
- Network,
150
- } from "@layerzerolabs/lz-definitions";
151
-
152
- // Converts a chain and stage to a network name.
153
- const network: Network = chainAndStageToNetwork(Chain.ETHEREUM, Stage.MAINNET);
154
- console.log(network);
155
- ```
156
-
157
- ### endpointSpecToNetwork
158
-
159
- ```typescript
160
- import {
161
- endpointSpecToNetwork,
162
- EndpointSpec,
163
- Network,
164
- } from "@layerzerolabs/lz-definitions";
165
-
166
- const spec: EndpointSpec = {
167
- chain: Chain.ETHEREUM,
168
- stage: Stage.MAINNET,
169
- version: EndpointVersion.V1,
170
- env: Environment.MAINNET,
171
- };
172
-
173
- // Converts an endpoint specification to a network name.
174
- const network: Network = endpointSpecToNetwork(spec);
175
- console.log(network);
176
- ```
177
-
178
- ### endpointSpecToEnv
179
-
180
- ```typescript
181
- import {
182
- endpointSpecToEnv,
183
- EndpointSpec,
184
- Environment,
185
- } from "@layerzerolabs/lz-definitions";
186
-
187
- const spec: EndpointSpec = {
188
- chain: Chain.ETHEREUM,
189
- stage: Stage.MAINNET,
190
- version: EndpointVersion.V1,
191
- env: Environment.MAINNET,
192
- };
193
-
194
- // Converts an endpoint specification to an environment.
195
- const environment: Environment = endpointSpecToEnv(spec);
196
- console.log(environment);
197
- ```
198
-
199
- ### endpointSpecToEndpointId
200
-
201
- ```typescript
202
- import {
203
- endpointSpecToEndpointId,
204
- EndpointSpec,
205
- EndpointId,
206
- } from "@layerzerolabs/lz-definitions";
207
-
208
- const spec: EndpointSpec = {
209
- chain: Chain.ETHEREUM,
210
- stage: Stage.MAINNET,
211
- version: EndpointVersion.V1,
212
- env: Environment.MAINNET,
213
- };
214
-
215
- // Converts an endpoint specification to an endpoint ID.
216
- const endpointId: EndpointId = endpointSpecToEndpointId(spec);
217
- console.log(endpointId);
218
- ```
219
-
220
- ### endpointIdToEndpointSpec
221
-
222
- ```typescript
223
- import {
224
- endpointIdToEndpointSpec,
225
- EndpointId,
226
- EndpointSpec,
227
- Environment,
228
- SandboxV2EndpointId,
229
- } from "@layerzerolabs/lz-definitions";
230
-
231
- // Converts an endpoint ID and environment to an endpoint specification.
232
- const spec: EndpointSpec = endpointIdToEndpointSpec(
233
- SandboxV2EndpointId.APTOS_V2_SANDBOX,
234
- Environment.MAINNET,
235
- );
236
- console.log(spec);
237
- ```
238
-
239
- ### networkToChain
240
-
241
- ```typescript
242
- import { networkToChain, Chain } from "@layerzerolabs/lz-definitions";
243
-
244
- // Converts a network name to a chain.
245
- const chain: Chain = networkToChain("ethereum-mainnet");
246
- console.log(chain);
247
- ```
248
-
249
- ### networkToChainType
250
-
251
- ```typescript
252
- import { networkToChainType, ChainType } from "@layerzerolabs/lz-definitions";
253
-
254
- // Converts a network name to a chain type.
255
- const chainType: ChainType = networkToChainType("ethereum-mainnet");
256
- console.log(chainType);
257
- ```
258
-
259
- ### chainToChainType
260
-
261
- ```typescript
262
- import {
263
- chainToChainType,
264
- Chain,
265
- ChainType,
266
- } from "@layerzerolabs/lz-definitions";
267
-
268
- // Returns the chain type for a given chain.
269
- const chainType: ChainType = chainToChainType(Chain.ETHEREUM);
270
- console.log(chainType);
271
- ```
272
-
273
- ### endpointIdToChain
274
-
275
- ```typescript
276
- import {
277
- endpointIdToChain,
278
- Chain,
279
- SandboxV2EndpointId,
280
- } from "@layerzerolabs/lz-definitions";
281
-
282
- // Converts an endpoint ID to a chain.
283
- const chain: Chain = endpointIdToChain(SandboxV2EndpointId.APTOS_V2_SANDBOX);
284
- console.log(chain);
285
- ```
286
-
287
- ### endpointIdToStage
288
-
289
- ```typescript
290
- import {
291
- endpointIdToStage,
292
- Stage,
293
- SandboxV2EndpointId,
294
- } from "@layerzerolabs/lz-definitions";
295
-
296
- // Converts an endpoint ID to a stage.
297
- const stage: Stage = endpointIdToStage(SandboxV2EndpointId.APTOS_V2_SANDBOX);
298
- console.log(stage);
299
- ```
300
-
301
- ### endpointIdToChainType
302
-
303
- ```typescript
304
- import {
305
- endpointIdToChainType,
306
- ChainType,
307
- SandboxV2EndpointId,
308
- } from "@layerzerolabs/lz-definitions";
309
-
310
- // Converts an endpoint ID to a chain type.
311
- const chainType: ChainType = endpointIdToChainType(
312
- SandboxV2EndpointId.APTOS_V2_SANDBOX,
313
- );
314
- console.log(chainType);
315
- ```
316
-
317
- ### getNetworksForStage
318
-
319
- ```typescript
320
- import { getNetworksForStage, Stage } from "@layerzerolabs/lz-definitions";
321
-
322
- // Gets the networks for a given stage.
323
- const networks: string[] = getNetworksForStage(Stage.MAINNET);
324
- console.log(networks);
325
- ```
326
-
327
- ### getChainIdForNetwork
328
-
329
- ```typescript
330
- import { getChainIdForNetwork } from "@layerzerolabs/lz-definitions";
331
-
332
- // Gets the chain ID for a given network.
333
- const chainId: string = getChainIdForNetwork("ethereum", "mainnet", "1.0.0");
334
- console.log(chainId);
335
- ```
336
-
337
- ### getNetworkForChainId
338
-
339
- ```typescript
340
- import {
341
- getNetworkForChainId,
342
- Chain,
343
- Stage,
344
- SandboxV2EndpointId,
345
- } from "@layerzerolabs/lz-definitions";
346
-
347
- // Gets the network for a given chain ID.
348
- const networkInfo = getNetworkForChainId(SandboxV2EndpointId.APTOS_V2_SANDBOX);
349
- console.log(networkInfo.chainName, networkInfo.env, networkInfo.ulnVersion);
350
- ```
351
-
352
- ### isNetworkEndpointIdSupported
353
-
354
- ```typescript
355
- import {
356
- isNetworkEndpointIdSupported,
357
- EndpointVersion,
358
- } from "@layerzerolabs/lz-definitions";
359
-
360
- // Checks if a network endpoint ID is supported.
361
- const isSupported: boolean = isNetworkEndpointIdSupported(
362
- "ethereum-mainnet",
363
- EndpointVersion.V1,
364
- );
365
- console.log(isSupported);
366
- ```
367
-
368
- ### isEvmChain
369
-
370
- ```typescript
371
- import { isEvmChain, Chain } from "@layerzerolabs/lz-definitions";
372
-
373
- // Determines if a chain is EVM based.
374
- const isEvm: boolean = isEvmChain(Chain.ETHEREUM);
375
- console.log(isEvm);
376
- ```