From 3d7d24605ff1d8cc4df2a932dddf87a9fdefcbf7 Mon Sep 17 00:00:00 2001 From: Anil Kumar <150643132+anil-rome@users.noreply.github.com> Date: Thu, 23 Jul 2026 16:53:25 +0300 Subject: [PATCH] fix: honor the documented CHAIN_ID env in gen-config/deploy/demo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit .env.example documents CHAIN_ID as the chain selector, but none of the three scripts passed it to loadConfig — every scaffold silently targeted the default chain regardless of .env. The scripts (the env boundary per lib/config's environment-agnostic contract) now pass it through. CI gains a template-config job pinning the contract: CHAIN_ID=121214 gen-config must resolve chain 121214 (+ template typecheck). --- .github/workflows/ci.yml | 17 +++++++++++++++++ template/scripts/demo.ts | 2 +- template/scripts/deploy.ts | 2 +- template/scripts/gen-config.ts | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c7b09e7..31a25e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,3 +18,20 @@ jobs: node-version: ${{ matrix.node }} # The scaffolder is zero-dependency — the suite runs on bare node. - run: npm test + + # The template must honor its documented .env contract: CHAIN_ID selects the + # chain (regression: it used to be silently ignored — everything hit the default). + template-config: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + - run: npm ci + working-directory: template + - name: CHAIN_ID env must select the chain + run: CHAIN_ID=121214 npm run gen-config | grep -q "chain 121214" + working-directory: template + - run: npm run typecheck + working-directory: template diff --git a/template/scripts/demo.ts b/template/scripts/demo.ts index 331d447..d4f7263 100644 --- a/template/scripts/demo.ts +++ b/template/scripts/demo.ts @@ -10,7 +10,7 @@ import { eip1193FromAccount } from "../lib/eip1193Node.js"; import { deployVault } from "./deploy.js"; import * as rome from "../lib/rome.js"; -const cfg = loadConfig({ proxyUrl: process.env.PROXY_URL, solanaRpc: process.env.SOLANA_RPC }); +const cfg = loadConfig({ chainId: process.env.CHAIN_ID ? Number(process.env.CHAIN_ID) : undefined, proxyUrl: process.env.PROXY_URL, solanaRpc: process.env.SOLANA_RPC }); const evm = privateKeyToAccount(process.env.EVM_KEY as `0x${string}`); const sol = Keypair.fromSecretKey(Uint8Array.from(JSON.parse(process.env.SOLANA_KEY!))); const solSign = async (tx: any) => { tx.partialSign(sol); return tx; }; diff --git a/template/scripts/deploy.ts b/template/scripts/deploy.ts index 494fea3..08a1d02 100644 --- a/template/scripts/deploy.ts +++ b/template/scripts/deploy.ts @@ -38,7 +38,7 @@ export async function deployVault(cfg: RomeConfig, account: Account): Promise<`0 // `npm run deploy` if (import.meta.url === `file://${process.argv[1]}`) { - const cfg = loadConfig({ proxyUrl: process.env.PROXY_URL, solanaRpc: process.env.SOLANA_RPC }); + const cfg = loadConfig({ chainId: process.env.CHAIN_ID ? Number(process.env.CHAIN_ID) : undefined, proxyUrl: process.env.PROXY_URL, solanaRpc: process.env.SOLANA_RPC }); const account = privateKeyToAccount(process.env.EVM_KEY as `0x${string}`); const vault = await deployVault(cfg, account); console.log("Vault deployed:", vault); diff --git a/template/scripts/gen-config.ts b/template/scripts/gen-config.ts index cfa236b..a495aff 100644 --- a/template/scripts/gen-config.ts +++ b/template/scripts/gen-config.ts @@ -5,7 +5,7 @@ import "dotenv/config"; import { writeFileSync } from "node:fs"; import { loadConfig } from "../lib/config.js"; -const cfg = loadConfig({ proxyUrl: process.env.PROXY_URL, solanaRpc: process.env.SOLANA_RPC }); +const cfg = loadConfig({ chainId: process.env.CHAIN_ID ? Number(process.env.CHAIN_ID) : undefined, proxyUrl: process.env.PROXY_URL, solanaRpc: process.env.SOLANA_RPC }); const out = { ...cfg, vault: (process.env.VAULT_ADDRESS || null) as string | null }; writeFileSync(new URL("../src/config.generated.json", import.meta.url), JSON.stringify(out, null, 2) + "\n"); console.log("wrote src/config.generated.json —", `chain ${out.chainId}`, out.vault ? `vault ${out.vault}` : "(deploy a Vault, then set VAULT_ADDRESS)");