-
Notifications
You must be signed in to change notification settings - Fork 2
Feat/lzconstants #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
30401bb
db8620b
a375cc9
eed5483
c3d2096
dd9e1b4
1339745
8414c13
b0f76f4
2b160f8
b87c023
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| packages: [] | ||
|
|
||
| onlyBuiltDependencies: | ||
| - "frax-standard-solidity" | ||
| - "forge-std" | ||
| - "ds-test" | ||
| - "solmate" | ||
| - "solidity-bytes-utils" | ||
| - "@fraxfinance/layerzero-v2-upgradeable" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,3 +15,7 @@ | |
| // Multisigs | ||
|
|
||
| // PoolRelatedTokens | ||
|
|
||
| // LayerZero | ||
|
|
||
| // FraxtalLZHop | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,6 @@ | ||||||
| import * as fs from "fs/promises"; | ||||||
| import path from "path"; | ||||||
| import { isAddress } from "viem" | ||||||
|
|
||||||
| import * as constants from "./constants"; | ||||||
|
|
||||||
|
|
@@ -22,11 +23,14 @@ const networkPrefixes = { | |||||
| FraxtalTestnetL2: "FXTL_TN_L2", | ||||||
| Holesky: "HOLESKY", | ||||||
| Hyperliquid: "HYPE", | ||||||
| Ink: "INK", | ||||||
| Katana: "KTN", | ||||||
| Mainnet: "ETH", | ||||||
| Movement:"MOVE", | ||||||
| Moonbeam: "MNBM", | ||||||
| Moonriver: "MOVR", | ||||||
| Optimism: "OPTI", | ||||||
| Plumephoenix: "PLUME", | ||||||
| Polygon: "POLY", | ||||||
| PolygonzkEVM: "POLY_ZKEVM", | ||||||
| Scroll: "SCROLL", | ||||||
|
|
@@ -36,7 +40,8 @@ const networkPrefixes = { | |||||
| Unichain: "UNI", | ||||||
| Worldchain: "WRLD", | ||||||
| Linea: "LINEA", | ||||||
| Zksync:"ZKSYNC" | ||||||
| XLayer: "XLAYER", | ||||||
| Zksync: "ZKSYNC" | ||||||
|
Comment on lines
42
to
+44
|
||||||
| }; | ||||||
|
|
||||||
| const REMOVE_DUPLICATE_LABELS = false; | ||||||
|
|
@@ -48,22 +53,27 @@ async function main() { | |||||
| // Prepare seen/duplicate values | ||||||
| const seenValues = []; | ||||||
|
|
||||||
| // Generate the files | ||||||
| for (let n = 0; n < networks.length; n++) { | ||||||
| const networkName = networks[n]; | ||||||
| const outputString = await handleSingleNetwork(networkName, constants[networkName], seenValues); | ||||||
|
|
||||||
| const finalString = | ||||||
| `// SPDX-License-Identifier: ISC | ||||||
| const headerString = `// SPDX-License-Identifier: ISC | ||||||
| pragma solidity >=0.8.0; | ||||||
|
|
||||||
| // **NOTE** Generated code, do not modify. Run 'npm run generate:constants'. | ||||||
|
|
||||||
| import { TestBase } from "forge-std/Test.sol"; | ||||||
|
|
||||||
| ` + outputString; | ||||||
| ` | ||||||
|
|
||||||
| let finalConstantsString = headerString; | ||||||
|
|
||||||
| // Generate the files | ||||||
| for (let n = 0; n < networks.length; n++) { | ||||||
| const networkName = networks[n]; | ||||||
| const outputString = await handleSingleNetwork(networkName, constants[networkName], seenValues); | ||||||
|
|
||||||
| const finalString = headerString + outputString; | ||||||
| finalConstantsString = finalConstantsString + outputString; | ||||||
| await fs.writeFile(path.resolve("src/contracts/chain-constants", `${networkName}.sol`), finalString); | ||||||
| } | ||||||
| await fs.writeFile(path.resolve("src/", `Constants.sol`), finalConstantsString); | ||||||
| } | ||||||
|
|
||||||
| async function handleSingleNetwork(networkName, constants, seenValues) { | ||||||
|
|
@@ -73,7 +83,12 @@ async function handleSingleNetwork(networkName, constants, seenValues) { | |||||
| if (typeof value === "string") { | ||||||
| // Determine whether it is an address or a string | ||||||
| if (value.startsWith("0x")) { | ||||||
| return ` address internal constant ${key} = ${value};`; | ||||||
| if (isAddress(value)) { return ` address internal constant ${key} = ${value};`; } | ||||||
| else if (value.length === 66) { | ||||||
| return ` bytes32 internal constant ${key} = ${value};`; | ||||||
| } else { | ||||||
| throw new Error("Unidentifed constant type") | ||||||
|
||||||
| throw new Error("Unidentifed constant type") | |
| throw new Error(`Unidentified constant type for key "${key}" with value "${value}"`); |
Copilot
AI
Feb 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
labelStrings always emits vm.label(${value}, ...), but vm.label only accepts address. Since the generator now supports bytes32 (and some networks may have non-address strings), this can produce invalid Solidity. Consider filtering constantsToLabel so only isAddress(value) === true entries generate labels, and skip/omit everything else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI installs dependencies with
--no-frozen-lockfileeven though apnpm-lock.yamlis present. This can make builds non-reproducible (and can pull newer transitive deps than what was reviewed). Preferpnpm install --frozen-lockfilein CI and ensure the lockfile is kept up to date in PRs.