-
Notifications
You must be signed in to change notification settings - Fork 13
[TASK-14408] Add ISO2 and ISO3 code for all countries #1179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughAdds ISO3 support and a 3↔2 letter country code map, updates per-country add/withdraw method construction with SEPA and bank-transfer enablement logic, and ensures crypto/default methods. Also removes a TODO comment in IBAN country lookup without changing behavior. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
src/utils/withdraw.utils.ts (2)
110-128
: Fix CLABE check-digit algorithm (missing per-digit mod 10).CLABE requires (digit * weight) % 10 at each step before summation. Current code sums raw products, yielding wrong validations.
Apply:
- let sum = 0 - for (let i = 0; i < 17; i++) { - sum += digits[i] * weights[i] - } - - const remainder = sum % 10 - const calculatedCheckDigit = remainder === 0 ? 0 : 10 - remainder + let sum = 0 + for (let i = 0; i < 17; i++) { + sum += (digits[i] * weights[i]) % 10 + } + const calculatedCheckDigit = (10 - (sum % 10)) % 10
136-147
: Normalize input and fix “digit”→“letter” in comment for ISO codes.countryCodeMap keys are uppercase ISO3; make lookups case-insensitive and correct the comment.
-// Returns the 3-letter country code for the given country code +// Returns the 3-letter country code for the given country code export const getCountryCodeForWithdraw = (country: string) => { - // If the input is already a 3-digit code and exists in the map, return it - if (countryCodeMap[country]) { - return country + const code = country.toUpperCase() + // If the input is already a 3-letter code and exists in the map, return it + if (countryCodeMap[code]) { + return code } - // If the input is a 2-digit code, find the corresponding 3-digit code - const threeDigitCode = Object.keys(countryCodeMap).find((key) => countryCodeMap[key] === country) - - return threeDigitCode || country + // If the input is a 2-letter code, find the corresponding 3-letter code + const threeLetterCode = Object.keys(countryCodeMap).find((key) => countryCodeMap[key] === code) + return threeLetterCode || code }src/components/AddMoney/consts/index.ts (1)
2536-2549
: SEPA condition never true: 'Germany' key is missing in countrySpecificWithdrawMethods.The proxy check makes the whole block dead; SEPA Instant won’t be added for EUR countries.
Use currency-only gating (or a proper feature flag), e.g.:
- // 2. add SEPA for EUR countries if not already present from specifics - if (country.currency === 'EUR' && countrySpecificWithdrawMethods['Germany']) { - // Germany as proxy for SEPA availability + // 2. add SEPA for EUR countries if not already present from specifics + if (country.currency === 'EUR') { const sepaExists = withdrawList.some((m) => m.title === 'SEPA Instant') if (!sepaExists) { withdrawList.push({ id: `${countryCode.toLowerCase()}-sepa-instant-withdraw`, icon: 'bank' as IconName, title: 'SEPA Instant', description: 'EU-wide real-time bank transfers.', isSoon: false, }) } }
🧹 Nitpick comments (2)
src/components/AddMoney/consts/index.ts (2)
2522-2534
: Avoid title-based lookups for country-specific methods.Indexing by display name is brittle (renames/translations). Prefer iso2/iso3 keys.
Example direction: change countrySpecificWithdrawMethods to be keyed by iso2, and here use country.iso2 ?? country.iso3.
2455-2499
: Consider deriving countryCodeMap from countryData to avoid drift.Map iso3→iso2 directly from countryData at build/init to keep a single source of truth.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
src/components/AddMoney/consts/index.ts
(3 hunks)src/utils/withdraw.utils.ts
(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: Zishan-7
PR: peanutprotocol/peanut-ui#1094
File: src/utils/withdraw.utils.ts:181-191
Timestamp: 2025-08-14T14:42:54.411Z
Learning: The countryCodeMap in src/components/AddMoney/consts/index.ts uses uppercase 3-letter country codes as keys (like 'AUT', 'BEL', 'CZE') that map to 2-letter country codes, requiring input normalization to uppercase for proper lookups.
Learnt from: Zishan-7
PR: peanutprotocol/peanut-ui#1094
File: src/components/Claim/Link/views/BankFlowManager.view.tsx:0-0
Timestamp: 2025-08-14T14:36:18.758Z
Learning: Bridge API requires ISO3 country codes (3-letter codes like "USA", "GBR") while flag display components need ISO2 codes (2-letter codes like "US", "GB").
📚 Learning: 2025-08-14T14:42:54.411Z
Learnt from: Zishan-7
PR: peanutprotocol/peanut-ui#1094
File: src/utils/withdraw.utils.ts:181-191
Timestamp: 2025-08-14T14:42:54.411Z
Learning: The countryCodeMap in src/components/AddMoney/consts/index.ts uses uppercase 3-letter country codes as keys (like 'AUT', 'BEL', 'CZE') that map to 2-letter country codes, requiring input normalization to uppercase for proper lookups.
Applied to files:
src/utils/withdraw.utils.ts
src/components/AddMoney/consts/index.ts
📚 Learning: 2025-05-22T15:38:48.586Z
Learnt from: kushagrasarathe
PR: peanutprotocol/peanut-ui#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".
Applied to files:
src/utils/withdraw.utils.ts
🧬 Code graph analysis (1)
src/utils/withdraw.utils.ts (1)
src/components/AddMoney/consts/index.ts (1)
countryData
(257-2425)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Deploy-Preview
🔇 Additional comments (4)
src/utils/withdraw.utils.ts (1)
16-16
: LGTM on 2-letter lookup removal of TODO.No behavior change; the condition still correctly checks id and iso2.
src/components/AddMoney/consts/index.ts (3)
147-148
: LGTM: iso3 added to CountryData.This aligns the type with the new dataset.
2566-2568
: MX gating differs between add and withdraw.Add sets MX bank transfer as “Soon”; withdraw does not. Confirm product intent.
Would you like me to align both or keep asymmetric?
Also applies to: 2588-2590
2564-2568
: No changes needed: both bank routes exist
Verified that withdraw paths (/withdraw/${countryCode.toLowerCase()}/bank
) are handled bysrc/app/(mobile-ui)/withdraw/[country]/bank/page.tsx
, and add-money paths (/add-money/${country.path}/bank
) bysrc/app/(mobile-ui)/add-money/[country]/bank/page.tsx
(with a US-specific override atadd-money/us/bank/page.tsx
).
No description provided.