Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ jobs:
ARBITRUM_URL: ${{ secrets.ARBITRUM_MAINNET_URL }}
FRAXTAL_MAINNET_URL: ${{ secrets.FRAXTAL_MAINNET_RPC_URL }}
steps:
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16.x
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2
node-version: 20.x
- uses: pnpm/action-setup@v4
with:
version: 8.11.0
version: 10

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: stable
- run: forge --version
- run: pnpm i
- run: pnpm install --no-frozen-lockfile
Copy link

Copilot AI Feb 18, 2026

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-lockfile even though a pnpm-lock.yaml is present. This can make builds non-reproducible (and can pull newer transitive deps than what was reviewed). Prefer pnpm install --frozen-lockfile in CI and ensure the lockfile is kept up to date in PRs.

Suggested change
- run: pnpm install --no-frozen-lockfile
- run: pnpm install --frozen-lockfile

Copilot uses AI. Check for mistakes.
- run: pnpm lint:check
- run: forge build --sizes
# - run: forge test
Empty file modified .husky/pre-commit
100755 → 100644
Empty file.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"forge-std": "github:foundry-rs/forge-std#60acb7aaadcce2d68e52986a0a66fe79f07d138f",
"frax-standard-solidity": "github:FraxFinance/frax-standard-solidity#v1.1.3",
"solidity-bytes-utils": "github:GNSPS/solidity-bytes-utils",
"viem": "^2.37.8",
"solmate": "github:transmissions11/solmate#fadb2e2778adbf01c80275bfb99e5c14969d964b",
"@fraxfinance/layerzero-v2-upgradeable": "github:fraxfinance/LayerZero-v2-upgradeable#deps/pin-oz",
"@openzeppelin/contracts-4.8.1": "npm:@openzeppelin/contracts@4.8.1",
Expand Down
2,512 changes: 1,155 additions & 1,357 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions pnpm-workspace.yaml
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"
4 changes: 4 additions & 0 deletions scripts/constants/TEMPLATE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@
// Multisigs

// PoolRelatedTokens

// LayerZero

// FraxtalLZHop
1 change: 1 addition & 0 deletions scripts/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export * as Mainnet from "./mainnet";
export * as Mode from "./mode";
export * as Moonbeam from "./moonbeam";
export * as Moonriver from "./moonriver";
export * as Movement from "./movement";
export * as Optimism from "./optimism";
export * as Plumephoenix from "./plumephoenix";
export * as Polygon from "./polygon";
Expand Down
12 changes: 12 additions & 0 deletions scripts/constants/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1032,3 +1032,15 @@ export const KYBERSWAP_ELASTIC_TICK_FEES_READER_V2 = "0x8Fd8Cb948965d9305999D767
export const NON_FUNGIBLE_POSITION_MANAGER = "0xC36442b4a4522E871399CD717aBDD847Ab11FE88";
export const SWAPROUTER = "0xE592427A0AEce92De3Edee1F18E0157C05861564";
export const UNISWAP_V3_FACTORY = "0x1F98431c8aD98523631AE4a59f267346ea31F984";

// LayerZero
export const FPIOFT = "0x9033BAD7aA130a2466060A2dA71fAe2219781B4b";
export const FRXETHOFT = "0x1c1649A38f4A3c5A0c4a24070f688C525AB7D6E6";
export const FRXUSDOFT = "0x566a6442A5A6e9895B9dCA97cC7879D632c6e4B0";
export const SFRXETHOFT = "0xbBc424e58ED38dd911309611ae2d7A23014Bd960";
export const SFRXUSDOFT = "0x7311CEA93ccf5f4F7b789eE31eBA5D9B9290E126";
export const WFRAXOFT = "0x04ACaF8D2865c0714F79da09645C13FD2888977f";

// FraxtalLZHop
export const REMOTEHOP = "0x3ad4dC2319394bB4BE99A0e4aE2AbF7bCEbD648E";
export const REMOTEMINTREDEEMHOP = "0x99B5587ab54A49e3F827D10175Caf69C0187bfA8";
2 changes: 1 addition & 1 deletion scripts/constants/solana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export const FRXETH = "5sDrwVNiHMM2jC78hRBH1CtysDQYiNKihubgW2zNu8tf"
export const FRXUSD = "GzX1ireZDU865FiMaKrdVB1H6AE8LAqWYCg6chrMrfBw"
export const SFRXETH = "58zpC9acE6F4FBtd88L64NoWHJcmzLsQSy5bjz35Ydgv"
export const SFRXUSD = "DUvWQMyASSkLNJFwsMDA4kwxEvmfaqpPGrvUVKtitX45"
export const WFRAX = "zZbQjiRg8uSxZaPu996XuviuZeSY6nsaMuutKZQBJga"
export const WFRAX = "zZbQjiRg8uSxZaPu996XuviuZeSY6nsaMuutKZQBJga"
51 changes: 35 additions & 16 deletions scripts/generateConstants.ts
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";

Expand All @@ -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",
Expand All @@ -36,7 +40,8 @@ const networkPrefixes = {
Unichain: "UNI",
Worldchain: "WRLD",
Linea: "LINEA",
Zksync:"ZKSYNC"
XLayer: "XLAYER",
Zksync: "ZKSYNC"
Comment on lines 42 to +44
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ZkSync is exported with that casing, but networkPrefixes uses Zksync. This mismatch causes networkPrefixes[networkName] to be undefined and results in Constants.undefined_* labels in generated Solidity. Rename the key to ZkSync and consider failing generation when a prefix is missing.

Copilot uses AI. Check for mistakes.
};

const REMOVE_DUPLICATE_LABELS = false;
Expand All @@ -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) {
Expand All @@ -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")
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in error message: "Unidentifed" → "Unidentified". Also consider including the key/value in the error to make debugging generation failures easier.

Suggested change
throw new Error("Unidentifed constant type")
throw new Error(`Unidentified constant type for key "${key}" with value "${value}"`);

Copilot uses AI. Check for mistakes.
}
}
return ` string internal constant ${key} = "${value}";`;
} else {
Expand Down Expand Up @@ -109,6 +124,11 @@ async function handleSingleNetwork(networkName, constants, seenValues) {
}
});

const contractString = `library ${networkName} {
${constantString}
}
`;

// Generate the labels for the entries
const labelStrings = Object.entries(constantsToLabel)
.map(([key, value]) => {
Expand All @@ -119,13 +139,11 @@ async function handleSingleNetwork(networkName, constants, seenValues) {
return ` vm.label(${value}, "Constants.${networkPrefixes[networkName]}_${key}");`;
})
Comment on lines 139 to 140
Copy link

Copilot AI Feb 18, 2026

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.

Copilot uses AI. Check for mistakes.
.join("\n");
const contractString = `library ${networkName} {
${constantString}
}
`;

// if (networkName == "Mainnet") {
const constantsHelper = `
let constantsHelper = "";

if (networkName != "Aptos" && networkName != "Movement" && networkName != "Solana") {
constantsHelper = constantsHelper + `
abstract contract AddressHelper${networkName} is TestBase {
constructor() {
labelConstants();
Expand All @@ -136,6 +154,7 @@ ${labelStrings}
}
}
`;
}
return contractString + constantsHelper;
// }
// return contractString;
Expand Down
Loading
Loading