-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
difficulty: easySmall, bounded changesSmall, bounded changes
Description
Context
The app relies on several environment variables for contract IDs, network configuration, and RPC endpoints (lib/constants.ts). When these are missing or malformed, the app fails silently at runtime — contract calls return cryptic errors, balances don't load, and transactions fail. There is no startup validation that checks whether required env vars are present and valid before the app renders.
What Success Looks Like
- A validation step runs at app initialization that checks all required env vars
- Missing or malformed env vars produce a clear developer-facing error message listing exactly what's wrong
- The app shows a meaningful error page (not a white screen) if critical config is missing
- The
.env.examplefile is updated with all required variables and their expected formats - Optional env vars have documented defaults
Implementation Guidance
apps/web/src/lib/constants.ts— currently usesprocess.env.NEXT_PUBLIC_*with fallback values (lines 1-2), some fallbacks are placeholder contract IDs like"CB..."- Create a validation module (e.g.,
apps/web/src/lib/env.ts) using Zod to define and validate the env schema - Call the validation in the root layout (
apps/web/src/app/layout.tsx) or in a provider - Use
z.string().startsWith('C')for contract ID validation,z.enum(['testnet', 'public'])for network - Update
.env.exampleat the project root with all required variables, descriptions, and example values - Consider using the
t3-envpattern (server vs client env separation) or a simpler Zod-based approach
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
difficulty: easySmall, bounded changesSmall, bounded changes