Skip to content

fix: disable sepa non euro currency withdrwals and claims#1384

Merged
kushagrasarathe merged 2 commits intopeanut-wallet-devfrom
fix/disable-sepa-non-euro
Nov 3, 2025
Merged

fix: disable sepa non euro currency withdrwals and claims#1384
kushagrasarathe merged 2 commits intopeanut-wallet-devfrom
fix/disable-sepa-non-euro

Conversation

@kushagrasarathe
Copy link
Contributor

  • fixes TASK-16347 : disable sepa non euro currency withdrwals and claims

@vercel
Copy link

vercel bot commented Oct 31, 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 Nov 3, 2025 1:05pm

@notion-workspace
Copy link

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 31, 2025

Walkthrough

Added NON_EUR_SEPA_ALPHA2 and internal isCountryEnabledForBankTransfer; updated AddMoney country processing to disable bank-withdraw for SEPA corridors whose local currency is not EUR and adjusted CountryList to reflect this in the claim-request view.

Changes

Cohort / File(s) Summary
AddMoney constants & logic
src/components/AddMoney/consts/index.ts
Exported NON_EUR_SEPA_ALPHA2 (Set of ISO2 codes for SEPA corridors whose local currency ≠ EUR); added internal isCountryEnabledForBankTransfer(countryCode, direction); changed per-country withdraw/deposit method assembly to exclude SEPA bank-withdraw for codes in NON_EUR_SEPA_ALPHA2, preserved crypto handling and routing flags.
Country list / UI usage
src/components/Common/CountryList.tsx
Imported NON_EUR_SEPA_ALPHA2 and tightened claim-request view logic to mark SEPA corridors with non-EUR local currency disabled; other view modes unchanged.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Check correctness of ISO3→ISO2 mapping usage and construction of NON_EUR_SEPA_ALPHA2.
  • Verify isCountryEnabledForBankTransfer handles both 2-letter and 3-letter inputs and both directions.
  • Confirm per-country method list changes avoid duplications and preserve routing/enabled flags.
  • Validate CountryList change only affects claim-request view as intended.

Possibly related PRs

Suggested reviewers

  • Zishan-7
  • jjramirezn

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title clearly and specifically describes the main change: disabling SEPA non-euro currency withdrawals and claims. This directly aligns with the changeset, which introduces NON_EUR_SEPA_ALPHA2 to exclude SEPA corridors with non-EUR currencies from withdrawals and updates claim logic accordingly. The title is concise and accurately reflects the primary objective.
Description check ✅ Passed The pull request description directly relates to the changeset by referencing the specific task (TASK-16347) and stating the intent to disable SEPA non-euro currency withdrawals and claims. While brief, it provides meaningful context that aligns with the actual changes made to the codebase.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/disable-sepa-non-euro

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 48ed7a9 and 0e64d37.

📒 Files selected for processing (1)
  • src/components/AddMoney/consts/index.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 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: 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: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1173
File: src/components/Common/SavedAccountsView.tsx:86-87
Timestamp: 2025-09-03T12:23:31.845Z
Learning: In the ALL_METHODS_DATA structure from src/components/AddMoney/consts, the path field is required (not optional) for all country entries.
📚 Learning: 2025-08-14T14:42:54.411Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 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/components/AddMoney/consts/index.ts
📚 Learning: 2025-05-22T15:38:48.586Z
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".

Applied to files:

  • src/components/AddMoney/consts/index.ts
📚 Learning: 2025-09-03T12:23:31.845Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1173
File: src/components/Common/SavedAccountsView.tsx:86-87
Timestamp: 2025-09-03T12:23:31.845Z
Learning: In the ALL_METHODS_DATA structure from src/components/AddMoney/consts, the path field is required (not optional) for all country entries.

Applied to files:

  • src/components/AddMoney/consts/index.ts
📚 Learning: 2025-08-14T14:36:18.758Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 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").

Applied to files:

  • src/components/AddMoney/consts/index.ts
⏰ 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/components/AddMoney/consts/index.ts (4)

2543-2558: LGTM! Previous critical bug has been fixed.

The logic now correctly uses c.iso3 instead of c.id.length === 3, which ensures Poland (id='PL', iso3='POL') and Sweden (id='SE', iso3='SWE') are properly included in the non-EUR SEPA set. The explicit USA exclusion is appropriate since it's in the BRIDGE map but not a SEPA country.


2560-2562: Correct logic for disabling non-EUR SEPA withdrawals.

The filter correctly excludes non-EUR SEPA countries from bank withdrawals while preserving EUR SEPA countries and non-SEPA countries (US, MX, AR).


2566-2578: Well-designed helper function.

The function correctly handles both 2-letter and 3-letter country codes with appropriate fallback logic. The dual direction support (withdraw vs deposit) provides good reusability.


2665-2665: Correct implementation of the PR requirement.

The helper usage correctly distinguishes between withdraw (line 2665) and deposit (line 2694) flows:

  • Non-EUR SEPA countries are disabled for withdrawals (isSoon=true)
  • Non-EUR SEPA countries remain enabled for deposits (isSoon=false)

This matches the PR objective to "disable SEPA non-euro currency withdrawals and claims" while preserving add-money functionality.

Also applies to: 2694-2694


Comment @coderabbitai help to get the list of available commands and usage tips.

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

🧹 Nitpick comments (1)
src/components/AddMoney/consts/index.ts (1)

2553-2555: Consider removing redundant 'US' for clarity.

The logic correctly filters out non-EUR SEPA countries from withdrawals. However, 'US' is already included in Object.values(BRIDGE_ALPHA3_TO_ALPHA2) (from the 'USA': 'US' mapping at line 2530), making the explicit 'US' redundant.

Apply this diff to remove the redundancy:

 const enabledBankWithdrawCountries = new Set(
-    [...Object.values(BRIDGE_ALPHA3_TO_ALPHA2), 'US', 'MX', 'AR'].filter((code) => !NON_EUR_SEPA_ALPHA2.has(code))
+    [...Object.values(BRIDGE_ALPHA3_TO_ALPHA2), 'MX', 'AR'].filter((code) => !NON_EUR_SEPA_ALPHA2.has(code))
 )
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2655492 and 48ed7a9.

📒 Files selected for processing (2)
  • src/components/AddMoney/consts/index.ts (1 hunks)
  • src/components/Common/CountryList.tsx (2 hunks)
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 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.
📚 Learning: 2025-08-14T14:42:54.411Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 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/components/Common/CountryList.tsx
  • src/components/AddMoney/consts/index.ts
📚 Learning: 2025-05-22T15:38:48.586Z
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".

Applied to files:

  • src/components/Common/CountryList.tsx
  • src/components/AddMoney/consts/index.ts
📚 Learning: 2025-09-03T12:23:31.845Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1173
File: src/components/Common/SavedAccountsView.tsx:86-87
Timestamp: 2025-09-03T12:23:31.845Z
Learning: In the CountryData interface from src/components/AddMoney/consts, the path field is required (not optional) for all country entries.

Applied to files:

  • src/components/Common/CountryList.tsx
📚 Learning: 2025-09-03T12:23:31.845Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1173
File: src/components/Common/SavedAccountsView.tsx:86-87
Timestamp: 2025-09-03T12:23:31.845Z
Learning: In the ALL_METHODS_DATA structure from src/components/AddMoney/consts, the path field is required (not optional) for all country entries.

Applied to files:

  • src/components/Common/CountryList.tsx
  • src/components/AddMoney/consts/index.ts
📚 Learning: 2025-09-18T09:30:42.901Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1230
File: src/app/(mobile-ui)/withdraw/page.tsx:92-97
Timestamp: 2025-09-18T09:30:42.901Z
Learning: In src/app/(mobile-ui)/withdraw/page.tsx, the useEffect that calls setShowAllWithdrawMethods(true) when amountFromContext exists is intentionally designed to run only on component mount (empty dependency array), not when amountFromContext changes. This is the correct behavior for the withdraw flow where showing all methods should only happen on initial load when an amount is already present.

Applied to files:

  • src/components/AddMoney/consts/index.ts
📚 Learning: 2025-08-14T14:36:18.758Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 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").

Applied to files:

  • src/components/AddMoney/consts/index.ts
🧬 Code graph analysis (1)
src/components/Common/CountryList.tsx (1)
src/components/AddMoney/consts/index.ts (1)
  • NON_EUR_SEPA_ALPHA2 (2545-2551)
⏰ 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 (2)
src/components/AddMoney/consts/index.ts (1)

2559-2571: LGTM! Helper function correctly handles both code formats.

The function elegantly handles the inconsistent ID formats in countryData (2-letter vs 3-letter) by checking the enabled set directly and falling back to mapped codes. The implementation is clean and will work correctly when used at lines 2658 and 2687.

src/components/Common/CountryList.tsx (1)

8-8: LGTM! Correctly implements non-EUR SEPA filtering for claim-request flow.

The implementation properly disables non-EUR SEPA countries for the claim-request view while preserving existing behavior for other flows. The .toUpperCase() call at line 164 is essential for correct Set lookup, since twoLetterCountryCode may be lowercase from the fallback at line 133.

The logic (bridge AND not disabled) OR manteca correctly allows Manteca-supported countries regardless of SEPA status, which is appropriate for the withdrawal/claim flows.

Also applies to: 162-166

@kushagrasarathe kushagrasarathe merged commit a4de20b into peanut-wallet-dev Nov 3, 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