Add LZ Infra Constants#16
Conversation
There was a problem hiding this comment.
Pull request overview
This PR expands the scripts/constants/* network constant modules to include LayerZero infra addresses (endpoint + libs + block send lib + proxy admin) and adds LayerZero chain IDs + EVM chain IDs for additional networks in support of the frax-lz-mesh tooling.
Changes:
- Add
LayerZeroInfraconstants andLZ_CHAIN_ID/CHAIN_IDentries across many existing network constant files. - Add new constants modules for
stableandmonad, and export them fromscripts/constants/index.ts. - Update/normalize a few existing constants (e.g., Scroll OFT addresses; Solana semicolons) while adding the new infra constants.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/constants/abstract.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/aptos.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/arbitrum.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/aurora.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/avalanche.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/base.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/bera.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/blast.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/bsc.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/ethereum.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/fraxtal-l2.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/hyperliquid.ts | Fill in hop addresses; add LayerZero infra constants + chain IDs. |
| scripts/constants/ink.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/katana.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/linea.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/mode.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/monad.ts | New network constants module including infra + chain IDs. |
| scripts/constants/movement.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/optimism.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/plumephoenix.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/polygon.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/scroll.ts | Update OFT addresses; add LayerZero infra constants + chain IDs. |
| scripts/constants/sei.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/solana.ts | Add semicolons; add LayerZero infra constants + chain IDs. |
| scripts/constants/sonic.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/stable.ts | New network constants module including infra + chain IDs. |
| scripts/constants/unichain.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/worldchain.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/xlayer.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/zksync.ts | Add LayerZero infra constants + chain IDs. |
| scripts/constants/index.ts | Export new constants modules (Monad/Movement/Stable/Sei) and fix missing semicolons. |
Comments suppressed due to low confidence (1)
scripts/constants/fraxtal-l2.ts:1
- Assignment to variable CHAIN_ID, which is declared constant.
export const CHAIN_ID = 252;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export * as Unichain from "./unichain"; | ||
| export * as Worldchain from "./worldchain"; | ||
| export * as XLayer from "./xlayer"; | ||
| export * as ZkSync from "./zksync"; |
There was a problem hiding this comment.
scripts/generateConstants.ts relies on networkPrefixes[networkName] to build label strings, but this PR adds new exported networks (e.g., Monad/Movement/Stable) that do not exist in the networkPrefixes map. When npm run generate:constants runs, these will produce labels like Constants.undefined_<KEY>, and some existing entries also appear to differ in casing (e.g., Base vs BASE, ZkSync vs Zksync), which has the same effect. Consider updating networkPrefixes to include the new exports and align key casing with the names exported from this index file, or make the generator fall back to networkName when no prefix exists.
| export * as ZkSync from "./zksync"; | |
| export * as Zksync from "./zksync"; |
| // LayerZeroInfra | ||
| export const LZ_ENDPOINT = "76y77prsiCMvXMjuoZ5VRrhG5qYBrUMYTE5WgHqgjEn6"; | ||
| export const LZ_RECEIVE_LIB_302 = "7a4WjyR8VZ7yZz5XJAKm39BUGn5iT9CKcv2pmG9tdXVH"; | ||
| export const LZ_SEND_LIB_302 = "7a4WjyR8VZ7yZz5XJAKm39BUGn5iT9CKcv2pmG9tdXVH"; | ||
| export const LZ_BLOCK_SEND_LIB = "2XrYqmhBMPJgDsb4SVbjV1PnJBprurd5bzRCkHwiFCJB"; |
There was a problem hiding this comment.
These new Solana LayerZero infra values are non-0x strings (base58). scripts/generateConstants.ts currently emits vm.label(${value}, ...) without quotes for every non-number constant, which will generate invalid Solidity for these entries (e.g., vm.label(76y77..., ...)). Consider updating the generator to only label EVM address-shaped values (e.g., 0x + 40 hex chars) or skipping labeling for Solana/string constants.
| // LayerZeroInfra | ||
| export const LZ_ENDPOINT = "0xe60045e20fc2c99e869c1c34a65b9291c020cd12a0d37a00a53ac1348af4f43c"; | ||
| export const LZ_RECEIVE_LIB_302 = "0xc33752e0220faf79e45385dd73fb28d681dcd9f1569a1480725507c1f3c3aba9"; | ||
| export const LZ_SEND_LIB_302 = "0xc33752e0220faf79e45385dd73fb28d681dcd9f1569a1480725507c1f3c3aba9"; | ||
| export const LZ_BLOCK_SEND_LIB = "0x3ca0d187f1938cf9776a0aa821487a650fc7bb2ab1c1d241ba319192aae4afc6"; | ||
|
|
There was a problem hiding this comment.
These newly added LayerZero infra constants are 0x-prefixed 32-byte hex strings (not 20-byte EVM addresses). scripts/generateConstants.ts currently treats any 0x... string as a Solidity address literal and also passes it to vm.label(...), which will cause the generated Solidity to fail to compile for Aptos. Consider tightening the generator’s address detection (e.g., require 20-byte length) and emitting bytes32/string for non-address hex values, or excluding non-EVM networks from Solidity constant generation.
| // LayerZeroInfra | ||
| export const LZ_ENDPOINT = "0xe60045e20fc2c99e869c1c34a65b9291c020cd12a0d37a00a53ac1348af4f43c"; | ||
| export const LZ_RECEIVE_LIB_302 = "0xc33752e0220faf79e45385dd73fb28d681dcd9f1569a1480725507c1f3c3aba9"; | ||
| export const LZ_SEND_LIB_302 = "0xc33752e0220faf79e45385dd73fb28d681dcd9f1569a1480725507c1f3c3aba9"; | ||
| export const LZ_BLOCK_SEND_LIB = "0x3ca0d187f1938cf9776a0aa821487a650fc7bb2ab1c1d241ba319192aae4afc6"; | ||
|
|
There was a problem hiding this comment.
These newly added LayerZero infra constants are 0x-prefixed 32-byte hex strings (not 20-byte EVM addresses). scripts/generateConstants.ts currently treats any 0x... string as a Solidity address literal and also passes it to vm.label(...), which will cause the generated Solidity to fail to compile for Movement. Consider tightening the generator’s address detection (e.g., require 20-byte length) and emitting bytes32/string for non-address hex values, or excluding non-EVM networks from Solidity constant generation.
6741a2e to
cdf8d3b
Compare
cdf8d3b to
a717254
Compare
Remove LZ_ENDPOINT, LZ_SEND_LIB_302, LZ_RECEIVE_LIB_302, LZ_BLOCK_SEND_LIB, LZ_CHAIN_ID, and CHAIN_ID from all chain constant files. These values are now sourced at runtime from the LayerZero metadata API.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 88 out of 90 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Aurora: "AUR", | ||
| Avalanche: "AVAX", | ||
| BASE: "BASE", | ||
| BERA: "BERA", | ||
| BLAST: "BLAST", | ||
| BSC: "BSC", |
There was a problem hiding this comment.
networkPrefixes keys don't match the actual exported network names from scripts/constants/index (e.g., constants exposes Base, Bera, Blast, ZkSync, but this map uses BASE, BERA, BLAST, Zksync). This causes networkPrefixes[networkName] to be undefined for those networks, producing mislabeled constants in the generated Solidity. Align the keys with the module export names (or normalize networkName before lookup / provide a fallback).
| if (typeof value === "string") { | ||
| // Determine whether it is an address or a string | ||
| if (value.startsWith("0x")) { | ||
| return ` address internal constant ${key} = ${value};`; | ||
| } | ||
| return ` string internal constant ${key} = "${value}";`; | ||
| } else { | ||
| // number | ||
| // Note the value is a number | ||
| numberValues.push(value); | ||
| return ` uint256 internal constant ${key} = ${value};`; | ||
| } |
There was a problem hiding this comment.
Address detection is currently value.startsWith("0x"), which will misclassify non-address hex strings (e.g., 32-byte IDs in Aptos/Movement constants) as address and generate invalid Solidity literals. Consider validating EVM addresses by length/hex (0x + 40 hex chars) and handling other hex strings as bytes32/bytes/string as appropriate.
| const labelStrings = Object.entries(constantsToLabel) | ||
| .map(([key, value]) => { | ||
| // Add the value to the seen list | ||
| seenValues.push(value); | ||
| // Return the string | ||
| return ` vm.label(${value}, "Constants.${networkPrefixes[networkName]}_${key}");`; | ||
| }) |
There was a problem hiding this comment.
vm.label(${value}, ...) assumes value is an address literal. For constants that are plain strings (e.g., Solana base58 IDs) this will emit invalid Solidity (unquoted identifiers) and fail compilation. Restrict labeling to verified EVM address constants (and skip labeling for non-address types).
| // Canonicals | ||
| export const FRXUSD = "0xFc00000000000000000000000000000000000001"; | ||
| export const WFRAX = "0xFc00000000000000000000000000000000000002"; |
There was a problem hiding this comment.
CHAIN_ID was removed from this TS constants module, but other network modules (and the existing fraxtal-l2.js) export it. This creates an inconsistent API surface for FraxtalL2 and can break TypeScript consumers expecting CHAIN_ID. Re-add export const CHAIN_ID = 252; (or remove it everywhere consistently) and regenerate any derived JS if applicable.
- Add REMOTEHOPV2 + REMOTEADMINV2 to spoke chain constants - Add FRAXTALHOPV2 to fraxtal-l2 constants - Add HOP_V2_ABI.json with all HopV2 view functions + AccessControlEnumerable - Update abis index to export HOP_V2_ABI - Includes compiled JS output
…nix, scroll, stable, monad
|
in favour of #9 |
add LZ infra, chain IDs, hops, monad, stable constants for frax-lz-mesh