Fail production frontend builds when VITE_E2E_MOCK_WALLET is set #327
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:open_issues
agents
agent:security_audit
agent:verify
area
timecurve
arena
arena-v2
audit
block:feature_review
block:security
bug
contracts
design
devops
docs
documentation
enhancement
epic
feature
frontend
indexer
low priority
megaeth
operations
ops
performance
QA
qa checklist
referrals
removal
security
smart-contracts
tech-debt
testing
time-arena
timecurve
visual-qa
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
code/yieldomega#327
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent
GitLab #325 — Security review (audit finding F-05, approved recommendation #3).
Current codebase
frontend/src/wagmi-config.ts:VITE_E2E_MOCK_WALLET=1enables wagmimockconnector with Anvil account #0 (0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266). Comment at L119–121 says not to ship production builds with this flag.scripts/e2e-anvil.shsetsVITE_E2E_MOCK_WALLET=1for Playwright Anvil E2E.scripts/qa/build-frontend-for-rabby.shintentionally omits mock flag for Rabby QA.scripts/check-frontend-vite-env.shvalidates requiredVITE_*addresses but does not forbidVITE_E2E_MOCK_WALLET=1.scripts/verify-rabby-chain-mismatch.shgrep-checks builtfrontend/distfor leaked mock flag string..github/workflows/unit-tests.ymlrunsnpm run buildfor Playwright UI smoke but has no production mock-wallet gate.import.meta.env.VITE_*at build time; a mis-built artifact permanently embeds the flag (seefrontend/dist/when built with mock).Why needed
If
VITE_E2E_MOCK_WALLET=1is baked into a production static build, users may interact with a deterministic mock connector instead of a real wallet — catastrophic UX/confusion on staging or mis-deployed CDN artifacts. Parent #325 approved a build-pipeline guard.Constraints / guardrails
scripts/e2e-anvil.shandANVIL_E2E=1flows keep using mock wallet.build-frontend-for-rabby.sh) must remain mock-free.vite build/npm run build), notvite devon chain 31337.Co-authored-byor commit as bot identity perAGENTS.md.Relevant files
frontend/src/wagmi-config.ts,frontend/src/wagmi-config.test.tsfrontend/vite.config.ts,frontend/package.jsonscripts/check-frontend-vite-env.sh,scripts/e2e-anvil.sh,scripts/qa/build-frontend-for-rabby.sh,scripts/verify-rabby-chain-mismatch.sh.github/workflows/unit-tests.yml,.github/workflows/e2e-anvil.ymldocs/testing/e2e-anvil.md,docs/testing/ci.md,AGENTS.mdRecommended direction
scripts/check-frontend-production-env.shinvoked beforevite build, exit non-zero whenVITE_E2E_MOCK_WALLET=1and build mode is production (NODE_ENV=productionorvite build).scripts/check-frontend-vite-env.shwith optional--productionflag that rejects mock wallet (for deploy scripts).npm run buildin unit-tests workflow runs without mock flag; add explicit step or test thatVITE_E2E_MOCK_WALLET=1 npm run buildfails.docs/testing/ci.mdandfrontend/.env.example(already comments mock as E2E-only).Acceptance criteria
cd frontend && npm run buildwithVITE_E2E_MOCK_WALLET=1in env fails with a clear error message.bash scripts/e2e-anvil.shstill passes (mock allowed for E2E build path).bash scripts/qa/build-frontend-for-rabby.shstill produces mock-freefrontend/dist.useAnvilDevMockWalletwithoutVITE_E2E_MOCK_WALLET).Test plan
cd frontend && npm run typecheck && npm run lint && npm testcd frontend && VITE_E2E_MOCK_WALLET=1 npm run build→ expect non-zero exitcd frontendwith requiredVITE_*from stack →npm run build→ successbash scripts/e2e-anvil.sh(or CIe2e-anvil.ymlscope)bash scripts/verify-rabby-chain-mismatch.sh(when stack up; optional smoke)Attack / abuse test plan
VITE_E2E_MOCK_WALLET=1+ valid addresses, runnpm run build— build must abort before writingdist/.grep -r VITE_E2E_MOCK_WALLET frontend/distshould not find=1in production pipeline (Rabby script pattern).Verification criteria
VITE_E2E_MOCK_WALLET=1 npm run buildFAIL,e2e-anvil.shPASSmentioned in issue #325
mentioned in commit
a9bb2e219ementioned in merge request !500
mentioned in commit
ecb17aad3cVerification — GitLab #327 (PASS)
Verified production frontend build gate for
VITE_E2E_MOCK_WALLETonmain(no code/docs changes required).Acceptance criteria
VITE_E2E_MOCK_WALLET=1 npm run buildfails with clear errorcd frontend && VITE_*… VITE_E2E_MOCK_WALLET=1 npm run build→ exit 1; message: "Production build refused: VITE_E2E_MOCK_WALLET=1 enables the wagmi mock connector…"bash scripts/e2e-anvil.shstill passesANVIL_E2E=1) + Playwright — 7/7 specs greenbash scripts/qa/build-frontend-for-rabby.shmock-freedistgrepforVITE_E2E_MOCK_WALLET:"1"andmock({ accountsinfrontend/dist/assets/— no matchesunit-tests.ymlProduction mock-wallet build gate step locally — non-zero exit as expectedwagmi-config.tsstill usesuseAnvilDevMockWallet(DEV && chainId === 31337 && !browserHasInjectedProvider());wagmi-config.test.ts+viteProductionEnvGuard.test.tspassAdditional checks
cd frontend && npm run typecheck && npm run lint && npm test— 676 testsnpm run buildwith requiredVITE_*(no mock) — exit 0--productionguardbash scripts/check-frontend-vite-env.sh --productionrejects mock in.env.production.local; OK without mockvite.config.tsload (beforedist/write) when mock flag set withoutANVIL_E2E=1INV-FRONTEND-327-PRODUCTION-MOCK-WALLETindocs/testing/invariants-and-business-logic.mdImplementation summary (already on
main)frontend/src/lib/viteProductionEnvGuard.ts+frontend/vite.config.ts— fail-closed onvite buildunlessANVIL_E2E=1scripts/check-frontend-vite-env.sh --production— deploy-script guard.github/workflows/unit-tests.yml— explicit regression stepParent #325 recommendation #3 satisfied.
mentioned in issue #358