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)");