refactor: read banned-accounts list from Edge Config#995
Conversation
Move the banned-accounts source of truth out of the build-time NEXT_PUBLIC_BANNED_ACCOUNT_IDS env var into Vercel Edge Config (key: bannedAccountIds), so the list can be updated from the Vercel dashboard without a redeploy. The new isAccountBanned() service fails closed: any read or schema-parse failure returns true, so a temporary outage of the Edge Config cannot silently let banned accounts through. Ports defuse-protocol/defuse-near#464. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Updates to Preview Branch (refactor/banned-addresses) ↗︎
Tasks are run on every commit but only new migration files are pushed.
View logs for this Workflow Run ↗︎. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (1)
WalkthroughThis PR migrates banned account validation from an environment-variable list to a Vercel Edge Config-backed service. A new ChangesBanned Account Validation Migration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
NEXT_PUBLIC_BANNED_ACCOUNT_IDSenv var and into Vercel Edge Config (key:bannedAccountIds), so it can be updated from the dashboard without a redeploy.isAccountBanned()service fails closed — any read or schema-parse failure returnstrue, so an Edge Config outage cannot silently let banned accounts through.Deploy notes
EDGE_CONFIGconnection string in each deployment environment.bannedAccountIdskey in the Vercel Edge Config dashboard as a JSON array of strings (intent user IDs), e.g.["banned.near", "0xabc"]. If unset, the service logs a warn and treats the list as empty.NEXT_PUBLIC_BANNED_ACCOUNT_IDSis no longer read and can be removed from every environment.Follow-up (not in this PR)
.env.local.examplestill contains the now-unusedNEXT_PUBLIC_BANNED_ACCOUNT_IDS=line (lines 29-30). My local tooling blocks edits under that path, so it needs a manual one-line removal before merge — happy to do it in a follow-up commit if preferred.Test plan
pnpm vitest run src/services/bannedAccounts.test.ts— 5/5 pass (includes fail-closed cases for thrown errors, wrong shape, and non-string entries).pnpm typecheck— clean.pnpm check(biome) on touched files — clean.rg BANNED_ACCOUNT_IDS— no remaining references in source (only the.env.local.exampleline called out above).EDGE_CONFIGunset,GET /api/account/validate-banned?address=…&chainType=nearreturnsisBanned: falseand emits a warn log.EDGE_CONFIGvalue, the same request returnsisBanned: true(fail-closed) and emits an error log.🤖 Generated with Claude Code