[TASK-18810] fix: restrict send flow to supported countries + validate country par…#1764
[TASK-18810] fix: restrict send flow to supported countries + validate country par…#1764jjramirezn merged 2 commits intodevfrom
Conversation
…am on withdraw - Pass enforceSupportedCountries to CountryList when coming from send flow (unsupported countries show 'Soon' badge and are disabled) - Validate country param on withdraw/[country]/bank — redirect to /withdraw if country is not bridge-supported - Validate country param on withdraw/manteca — redirect to /withdraw if country is not in MANTECA_COUNTRIES_CONFIG
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@coderabbitai review in depth. Evaluate:
Also, write a very concise testing guide for QA |
WalkthroughAdds runtime country validation to the bank withdrawal flow and country selection logic, implementing redirect behavior for unsupported countries and enforcing country configuration checks before rendering. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/app/`(mobile-ui)/withdraw/manteca/page.tsx:
- Around line 434-440: The current useEffect only redirects when selectedCountry
exists but lacks a config; update the effect that references selectedCountry,
MANTECA_COUNTRIES_CONFIG and router.replace so it also triggers a redirect when
selectedCountry is falsy (meaning the query param was invalid/unresolved).
Specifically, inside the useEffect (the one watching [selectedCountry, router])
check for !selectedCountry OR missing
MANTECA_COUNTRIES_CONFIG[selectedCountry.id] and call
router.replace('/withdraw') in either case so invalid country query params don't
leave the component stuck on PeanutLoading.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0770a8be-e986-4c39-a9ce-880b3310a3ff
📒 Files selected for processing (3)
src/app/(mobile-ui)/withdraw/[country]/bank/page.tsxsrc/app/(mobile-ui)/withdraw/manteca/page.tsxsrc/components/AddWithdraw/AddWithdrawRouterView.tsx
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 3626 🏁 Script executed: Length of output: 481 🏁 Script executed: Length of output: 26083 🏁 Script executed: Length of output: 1044 🏁 Script executed: Length of output: 22481
🔍 In-Depth Review1. Risk of Bugs & Breaking Existing Functionality
The new
The
When // AddWithdrawRouterView.tsx — now unreachable from the send flow
if (flow === 'withdraw' && isBankFromSend) {
if (isMantecaCountry(country.path)) { // ← dead code: LATAM countries are disabled
const route = `/withdraw/manteca?method=bank-transfer&country=${country.path}`
...
}
}Since LATAM countries are disabled in 2. Performance Impact & LatencyNegligible. All three changes are:
3. Code Quality & DRY
🧪 QA Testing GuideSetup
Scenario 1 — Send flow: country restriction
Scenario 2 — Direct URL:
|
| URL | Expected |
|---|---|
/withdraw/germany/bank (Bridge country) |
Page loads normally |
/withdraw/argentina/bank (Manteca country, not Bridge) |
Redirects to /withdraw |
/withdraw/nonexistent-country/bank |
Redirects to /withdraw |
Scenario 3 — Direct URL: /withdraw/manteca validation
| URL | Expected |
|---|---|
/withdraw/manteca?country=argentina |
Page loads normally |
/withdraw/manteca?country=brazil |
Page loads normally |
/withdraw/manteca?country=mexico (Mexico uses Bridge, not in MANTECA_COUNTRIES_CONFIG) |
Redirects to /withdraw |
/withdraw/manteca?country=garbage |
Redirects to /withdraw |
/withdraw/manteca (no country param, defaults to argentina) |
Page loads normally |
Regression
| Scenario | Expected |
|---|---|
| Add-money flow country list | All countries enabled, no change |
Regular withdraw (no ?method=bank) country list |
All countries enabled, no change |
| Completing a full Bridge bank withdrawal from send flow | Works end-to-end |
Overall verdict: The PR is safe to merge. The main follow-up item is removing the now-unreachable Manteca routing branch inside the isBankFromSend handler in AddWithdrawRouterView.tsx.
🧠 Learnings used
Learnt from: Hugo0
Repo: peanutprotocol/peanut-ui PR: 852
File: src/hooks/useTransactionHistory.ts:177-239
Timestamp: 2025-05-14T21:16:06.369Z
Learning: When reviewing code, pay attention to and resolve CodeRabbit comments as they can contain useful refactoring suggestions and insights.
Learnt from: Hugo0
Repo: peanutprotocol/peanut-ui PR: 594
File: src/components/Request/Pay/Views/Initial.view.tsx:188-213
Timestamp: 2024-12-31T15:08:15.640Z
Learning: Always resolve coderabbit comments when reviewing code, since they can contain useful suggestions.
Learnt from: kushagrasarathe
Repo: peanutprotocol/peanut-ui PR: 869
File: src/app/(mobile-ui)/withdraw/page.tsx:82-88
Timestamp: 2025-05-22T15:38:48.586Z
Learning: The country-specific withdrawal route exists at src/app/(mobile-ui)/withdraw/[...country]/page.tsx and renders the AddWithdrawCountriesList component with flow="withdraw".
Learnt from: kushagrasarathe
Repo: peanutprotocol/peanut-ui PR: 869
File: src/app/(mobile-ui)/withdraw/page.tsx:82-88
Timestamp: 2025-05-22T15:38:48.586Z
Learning: The country-specific withdrawal route exists at src/app/(mobile-ui)/withdraw/[...country]/page.tsx and renders the AddWithdrawCountriesList component with flow="withdraw".
Learnt from: kushagrasarathe
Repo: peanutprotocol/peanut-ui PR: 0
File: :0-0
Timestamp: 2026-03-04T18:32:51.654Z
Learning: In peanutprotocol/peanut-ui, Bridge-specific add-money and withdraw flows (`src/app/(mobile-ui)/add-money/[country]/bank/page.tsx`, `src/components/AddWithdraw/AddWithdrawCountriesList.tsx`, `src/components/Claim/Link/views/BankFlowManager.view.tsx`) have been migrated (PR `#1713`) to use the unified `isUserKycApproved` from `useKycStatus()` hook instead of per-component `liveKycStatus` + WebSocket state. The migration is complete; no more direct `bridgeKycStatus === 'approved'` checks in those files.
Learnt from: kushagrasarathe
Repo: peanutprotocol/peanut-ui PR: 1693
File: src/app/(mobile-ui)/add-money/[country]/bank/page.tsx:206-207
Timestamp: 2026-03-04T18:35:17.673Z
Learning: In Bridge-specific add-money and withdraw flows (e.g., src/app/(mobile-ui)/add-money/[country]/bank/page.tsx), liveKycStatus from WebSocket tracks real-time bridge KYC status changes, and bridgeKycStatus is the persisted status. These flows use direct bridgeKycStatus === 'approved' checks instead of the unified isUserKycVerified helper. Migrating to the unified verifier requires careful testing of WebSocket-based real-time status tracking and is deferred to follow-up work.
…am on withdraw