Skip to content

Conversation

Zishan-7
Copy link
Contributor

@Zishan-7 Zishan-7 commented Sep 4, 2025

No description provided.

Copy link

vercel bot commented Sep 4, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
peanut-wallet Ready Ready Preview Comment Sep 4, 2025 8:44am

Copy link
Contributor

coderabbitai bot commented Sep 4, 2025

Walkthrough

Adds 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

Cohort / File(s) Summary
AddMoney country/flow logic
src/components/AddMoney/consts/index.ts
Adds optional iso3 to CountryData; introduces countryCodeMap (ISO3→ISO2); builds enabledBankTransferCountries; adds isCountryEnabledForBankTransfer handling both ISO2/ISO3; augments per-country add/withdraw methods (SEPA Instant logic, default bank, crypto, LATAM/Mercado Pago positioning, isSoon flags).
Withdraw utils maintenance
src/utils/withdraw.utils.ts
Removes inline TODO comment in getCountryFromIban; no logic changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • kushagrasarathe
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/add-iso-codes

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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.

📥 Commits

Reviewing files that changed from the base of the PR and between b03f8aa and 34fd0f4.

📒 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 by src/app/(mobile-ui)/withdraw/[country]/bank/page.tsx, and add-money paths (/add-money/${country.path}/bank) by src/app/(mobile-ui)/add-money/[country]/bank/page.tsx (with a US-specific override at add-money/us/bank/page.tsx).

@Zishan-7 Zishan-7 requested review from kushagrasarathe and removed request for Hugo0 September 4, 2025 12:19
@Zishan-7 Zishan-7 merged commit 3032140 into peanut-wallet-dev Sep 5, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants