@layerzerolabs/lz-definitions 3.0.15 → 3.0.17

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @layerzerolabs/lz-definitions
2
2
 
3
+ ## 3.0.17
4
+
5
+ ### Patch Changes
6
+
7
+ - 40f2269: islander mainnet
8
+ - 40f2269: testnets
9
+
10
+ ## 3.0.16
11
+
12
+ ### Patch Changes
13
+
14
+ - 87a4bc9: islander mainnet
15
+
3
16
  ## 3.0.15
4
17
 
5
18
  ### Patch Changes
package/README.md CHANGED
@@ -0,0 +1,376 @@
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
+ ```
package/dist/index.cjs CHANGED
@@ -188,6 +188,8 @@ var EvmChain = /* @__PURE__ */ ((EvmChain2) => {
188
188
  EvmChain2["EDU"] = "edu";
189
189
  EvmChain2["CITREA"] = "citrea";
190
190
  EvmChain2["ISLANDER"] = "islander";
191
+ EvmChain2["BL3"] = "bl3";
192
+ EvmChain2["MP1"] = "mp1";
191
193
  return EvmChain2;
192
194
  })(EvmChain || {});
193
195
 
@@ -500,6 +502,8 @@ var TestnetEndpointId = /* @__PURE__ */ ((TestnetEndpointId2) => {
500
502
  TestnetEndpointId2[TestnetEndpointId2["SOPHON_TESTNET"] = 10341] = "SOPHON_TESTNET";
501
503
  TestnetEndpointId2[TestnetEndpointId2["MOKSHA_TESTNET"] = 10342] = "MOKSHA_TESTNET";
502
504
  TestnetEndpointId2[TestnetEndpointId2["CITREA_TESTNET"] = 10344] = "CITREA_TESTNET";
505
+ TestnetEndpointId2[TestnetEndpointId2["MP1_TESTNET"] = 10345] = "MP1_TESTNET";
506
+ TestnetEndpointId2[TestnetEndpointId2["BL3_TESTNET"] = 10346] = "BL3_TESTNET";
503
507
  return TestnetEndpointId2;
504
508
  })(TestnetEndpointId || {});
505
509
  var SandboxEndpointId = /* @__PURE__ */ ((SandboxEndpointId2) => {
@@ -789,6 +793,8 @@ var TestnetV2EndpointId = /* @__PURE__ */ ((TestnetV2EndpointId2) => {
789
793
  TestnetV2EndpointId2[TestnetV2EndpointId2["MOKSHA_V2_TESTNET"] = 40342] = "MOKSHA_V2_TESTNET";
790
794
  TestnetV2EndpointId2[TestnetV2EndpointId2["TON_V2_TESTNET"] = 40343] = "TON_V2_TESTNET";
791
795
  TestnetV2EndpointId2[TestnetV2EndpointId2["CITREA_V2_TESTNET"] = 40344] = "CITREA_V2_TESTNET";
796
+ TestnetV2EndpointId2[TestnetV2EndpointId2["MP1_V2_TESTNET"] = 40345] = "MP1_V2_TESTNET";
797
+ TestnetV2EndpointId2[TestnetV2EndpointId2["BL3_V2_TESTNET"] = 40346] = "BL3_V2_TESTNET";
792
798
  return TestnetV2EndpointId2;
793
799
  })(TestnetV2EndpointId || {});
794
800
  var SandboxV2EndpointId = /* @__PURE__ */ ((SandboxV2EndpointId2) => {
@@ -1143,6 +1149,8 @@ var ChainKey = /* @__PURE__ */ ((ChainKey3) => {
1143
1149
  ChainKey3["HEMI"] = "hemi";
1144
1150
  ChainKey3["CITREA_TESTNET"] = "citrea-testnet";
1145
1151
  ChainKey3["ISLANDER"] = "islander";
1152
+ ChainKey3["BL3_TESTNET"] = "bl3-testnet";
1153
+ ChainKey3["MP1_TESTNET"] = "mp1-testnet";
1146
1154
  return ChainKey3;
1147
1155
  })(ChainKey || {});
1148
1156
 
@@ -1532,6 +1540,8 @@ var CHAIN_KEY = {
1532
1540
  [EndpointId.SOPHON_TESTNET]: "sophon-testnet" /* SOPHON_TESTNET */,
1533
1541
  [EndpointId.MOKSHA_TESTNET]: "moksha-testnet" /* MOKSHA_TESTNET */,
1534
1542
  [EndpointId.CITREA_TESTNET]: "citrea-testnet" /* CITREA_TESTNET */,
1543
+ [EndpointId.BL3_TESTNET]: "bl3-testnet" /* BL3_TESTNET */,
1544
+ [EndpointId.MP1_TESTNET]: "mp1-testnet" /* MP1_TESTNET */,
1535
1545
  // v2 testnet
1536
1546
  [EndpointId.ETHEREUM_V2_TESTNET]: "sepolia" /* SEPOLIA */,
1537
1547
  [EndpointId.POLYGON_V2_TESTNET]: "mumbai" /* MUMBAI */,
@@ -1692,6 +1702,8 @@ var CHAIN_KEY = {
1692
1702
  [EndpointId.MOKSHA_V2_TESTNET]: "moksha-testnet" /* MOKSHA_TESTNET */,
1693
1703
  [EndpointId.TON_V2_TESTNET]: "ton-testnet" /* TON_TESTNET */,
1694
1704
  [EndpointId.CITREA_V2_TESTNET]: "citrea-testnet" /* CITREA_TESTNET */,
1705
+ [EndpointId.BL3_V2_TESTNET]: "bl3-testnet" /* BL3_TESTNET */,
1706
+ [EndpointId.MP1_V2_TESTNET]: "mp1-testnet" /* MP1_TESTNET */,
1695
1707
  // sandbox
1696
1708
  [EndpointId.ETHEREUM_SANDBOX]: "ethereum-sandbox" /* ETHEREUM_SANDBOX */,
1697
1709
  [EndpointId.BSC_SANDBOX]: "bsc-sandbox" /* BSC_SANDBOX */,
@@ -2100,6 +2112,8 @@ var ENVIRONMENT = {
2100
2112
  [EndpointId.SOPHON_TESTNET]: "testnet" /* TESTNET */,
2101
2113
  [EndpointId.MOKSHA_TESTNET]: "testnet" /* TESTNET */,
2102
2114
  [EndpointId.CITREA_TESTNET]: "testnet" /* TESTNET */,
2115
+ [EndpointId.BL3_TESTNET]: "testnet" /* TESTNET */,
2116
+ [EndpointId.MP1_TESTNET]: "testnet" /* TESTNET */,
2103
2117
  // v2 testnet
2104
2118
  [EndpointId.ETHEREUM_V2_TESTNET]: "testnet" /* TESTNET */,
2105
2119
  [EndpointId.POLYGON_V2_TESTNET]: "testnet" /* TESTNET */,
@@ -2260,6 +2274,8 @@ var ENVIRONMENT = {
2260
2274
  [EndpointId.MOKSHA_V2_TESTNET]: "testnet" /* TESTNET */,
2261
2275
  [EndpointId.TON_V2_TESTNET]: "testnet" /* TESTNET */,
2262
2276
  [EndpointId.CITREA_V2_TESTNET]: "testnet" /* TESTNET */,
2277
+ [EndpointId.BL3_V2_TESTNET]: "testnet" /* TESTNET */,
2278
+ [EndpointId.MP1_V2_TESTNET]: "testnet" /* TESTNET */,
2263
2279
  // sandbox
2264
2280
  [EndpointId.ETHEREUM_SANDBOX]: "testnet" /* TESTNET */,
2265
2281
  [EndpointId.BSC_SANDBOX]: "testnet" /* TESTNET */,
@@ -2400,7 +2416,7 @@ function networkToChain(network) {
2400
2416
  }
2401
2417
  function networkToChainType(network) {
2402
2418
  const chain = networkToChain(network);
2403
- return getChainType(chain);
2419
+ return chainToChainType(chain);
2404
2420
  }
2405
2421
  function chainToChainType(chain) {
2406
2422
  switch (chain) {
@@ -2447,7 +2463,7 @@ function endpointIdToStage(endpointId) {
2447
2463
  }
2448
2464
  function endpointIdToChainType(endpointId) {
2449
2465
  const chain = endpointIdToChain(endpointId);
2450
- return getChainType(chain);
2466
+ return chainToChainType(chain);
2451
2467
  }
2452
2468
  function getNetworksForStage(stage) {
2453
2469
  const networks = [];
@@ -2525,16 +2541,16 @@ function isTronChain(chain) {
2525
2541
  return chain === Chain.TRON || chain === Chain.TRONDEV;
2526
2542
  }
2527
2543
  function isEvmChain(chain) {
2528
- return getChainType(chain) === "evm" /* EVM */;
2544
+ return chainToChainType(chain) === "evm" /* EVM */;
2529
2545
  }
2530
2546
  function isAptosChain(chain) {
2531
- return getChainType(chain) === "aptos" /* APTOS */;
2547
+ return chainToChainType(chain) === "aptos" /* APTOS */;
2532
2548
  }
2533
2549
  function isSolanaChain(chain) {
2534
- return getChainType(chain) === "solana" /* SOLANA */;
2550
+ return chainToChainType(chain) === "solana" /* SOLANA */;
2535
2551
  }
2536
2552
  function isInitiaChain(chain) {
2537
- return getChainType(chain) === "initia" /* INITIA */;
2553
+ return chainToChainType(chain) === "initia" /* INITIA */;
2538
2554
  }
2539
2555
  function isChain(value) {
2540
2556
  return Object.values(Chain).includes(value);
@@ -2565,9 +2581,23 @@ var chainSpecConfig = {
2565
2581
  }
2566
2582
  };
2567
2583
  var ChainSpecs = class {
2584
+ /**
2585
+ * Gets the address size in bytes for a given chain.
2586
+ *
2587
+ * @param {Chain} chain - The chain.
2588
+ * @returns {number} The address size in bytes.
2589
+ */
2568
2590
  static getAddressSizeInBytes(chain) {
2569
2591
  return this.getChainSpec(getChainType(chain), chain).addressSizeInBytes;
2570
2592
  }
2593
+ /**
2594
+ * Gets the chain specification for a given chain type and chain.
2595
+ *
2596
+ * @param {ChainType} chainType - The type of the chain.
2597
+ * @param {Chain | 'default'} chain - The chain or 'default'.
2598
+ * @returns {ChainSpec} The chain specification.
2599
+ * @throws {Error} If the configuration for the chain type is not found.
2600
+ */
2571
2601
  static getChainSpec(chainType, chain) {
2572
2602
  if (chainSpecConfig[chainType] === void 0) {
2573
2603
  throw new Error(`config for ${chainType} not found in staticConfig`);
@@ -2639,5 +2669,5 @@ exports.networkToChainType = networkToChainType;
2639
2669
  exports.networkToEndpointId = networkToEndpointId;
2640
2670
  exports.networkToEnv = networkToEnv;
2641
2671
  exports.networkToStage = networkToStage;
2642
- //# sourceMappingURL=out.js.map
2672
+ //# sourceMappingURL=index.cjs.map
2643
2673
  //# sourceMappingURL=index.cjs.map