Skip to content

fix: correctly route recent methods#1283

Merged
jjramirezn merged 3 commits intopeanut-wallet-devfrom
fix/withdraw-recent-methods
Oct 3, 2025
Merged

fix: correctly route recent methods#1283
jjramirezn merged 3 commits intopeanut-wallet-devfrom
fix/withdraw-recent-methods

Conversation

@jjramirezn
Copy link
Contributor

No description provided.

@vercel
Copy link

vercel bot commented Oct 3, 2025

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

Project Deployment Preview Comments Updated (UTC)
peanut-wallet Canceled Canceled Oct 3, 2025 7:25pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 3, 2025

Walkthrough

Adds getCountryFromAccount to map a saved bank Account to CountryData and updates the mobile withdraw page to consume selectedBankAccount, adjust initial step selection, and route to /withdraw/{country.path}/bank based on the derived country (errors if derivation fails).

Changes

Cohort / File(s) Summary
Withdraw flow page update
src/app/(mobile-ui)/withdraw/page.tsx
Consumes selectedBankAccount from withdraw flow; updates initialStep to consider a pre-selected bank account; handleAmountContinue derives country via getCountryFromAccount and routes to /withdraw/{country.path}/bank; throws on failed derivation.
Bridge utils addition
src/utils/bridge.utils.ts
Adds `export function getCountryFromAccount(account: Account): CountryData
Test config / Jest mapping
package.json
Updates jest.moduleNameMapper to add image file mapping (.svg, .png, .jpg, .jpeg, .gif) to jest-transform-stub and cleans up duplicate/conflicting SVG mappings.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • kushagrasarathe
  • beetrootw

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description Check ❓ Inconclusive No description was provided for this pull request, leaving reviewers without context on the changes or their rationale. Please add a brief summary of the changes and their purpose to help reviewers understand the intent and impact of this pull request.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title “fix: correctly route recent methods” concisely reflects the primary change, which adjusts the withdraw flow routing logic for previously used payment methods such as bank accounts. It clearly indicates a bug fix related to routing without unnecessary detail or unrelated terms. The wording is specific enough for teammates to understand the high-level intent at a glance.
✨ 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/withdraw-recent-methods

📜 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 6864ac2 and 3dabf06.

📒 Files selected for processing (2)
  • package.json (1 hunks)
  • src/app/(mobile-ui)/withdraw/page.tsx (3 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
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".
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".
📚 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/app/(mobile-ui)/withdraw/page.tsx
📚 Learning: 2025-09-18T09:30:42.901Z
Learnt from: Zishan-7
PR: peanutprotocol/peanut-ui#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/app/(mobile-ui)/withdraw/page.tsx
📚 Learning: 2025-10-02T15:23:01.405Z
Learnt from: Zishan-7
PR: peanutprotocol/peanut-ui#1266
File: src/app/(mobile-ui)/withdraw/[country]/bank/page.tsx:46-57
Timestamp: 2025-10-02T15:23:01.405Z
Learning: In the withdraw flow at src/app/(mobile-ui)/withdraw/[country]/bank/page.tsx, the points calculation query intentionally uses crypto.randomUUID() in the queryKey dependency array to bypass React Query caching, ensuring fresh points estimates on every render. This is the intended behavior.

Applied to files:

  • src/app/(mobile-ui)/withdraw/page.tsx
🧬 Code graph analysis (1)
src/app/(mobile-ui)/withdraw/page.tsx (2)
src/context/WithdrawFlowContext.tsx (1)
  • useWithdrawFlow (157-163)
src/utils/bridge.utils.ts (1)
  • getCountryFromAccount (83-95)
⏰ 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)
package.json (1)

140-140: LGTM!

The Jest moduleNameMapper configuration correctly handles static image assets by mapping them to jest-transform-stub. This is a standard practice for preventing Jest from attempting to parse non-JavaScript files during tests.

src/app/(mobile-ui)/withdraw/page.tsx (3)

13-13: LGTM!

The import of getCountryFromAccount is correctly added to support the new bank account routing logic.


31-31: LGTM!

The selectedBankAccount state is correctly destructured from the useWithdrawFlow context and used appropriately in the component.


36-36: LGTM!

The initial step logic correctly considers both selectedMethod and selectedBankAccount when determining whether to start at the amount input step. This provides a consistent user experience for pre-selected withdrawal methods.


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

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

@coderabbitai coderabbitai bot added the enhancement New feature or request label Oct 3, 2025
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/utils/bridge.utils.ts (1)

83-95: Function logic is sound; consider minor defensive improvements.

The lookup logic correctly handles US accounts specially and falls back to countryName or code-based lookups. The case-insensitive comparison for countryName is appropriate.

Optional refinements:

  1. The optional chaining on Line 91 (account.details.countryName?.toLowerCase()) is redundant since the ternary already checks for account.details.countryName. You can simplify to account.details.countryName.toLowerCase().

  2. Consider adding a defensive check for account.details to prevent potential runtime errors if the account object is malformed:

 export function getCountryFromAccount(account: Account): CountryData | undefined {
+    if (!account.details) {
+        return undefined
+    }
     const threeLetterCountryCode = (account.details.countryCode ?? '').toUpperCase()

Based on learnings regarding uppercase country code normalization in the codebase.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c45b2e4 and 6864ac2.

📒 Files selected for processing (2)
  • src/app/(mobile-ui)/withdraw/page.tsx (3 hunks)
  • src/utils/bridge.utils.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
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".
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".
📚 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/app/(mobile-ui)/withdraw/page.tsx
📚 Learning: 2025-09-18T09:30:42.901Z
Learnt from: Zishan-7
PR: peanutprotocol/peanut-ui#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/app/(mobile-ui)/withdraw/page.tsx
📚 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/bridge.utils.ts
🧬 Code graph analysis (2)
src/app/(mobile-ui)/withdraw/page.tsx (2)
src/context/WithdrawFlowContext.tsx (1)
  • useWithdrawFlow (157-163)
src/utils/bridge.utils.ts (1)
  • getCountryFromAccount (83-95)
src/utils/bridge.utils.ts (2)
src/interfaces/interfaces.ts (1)
  • Account (274-301)
src/components/AddMoney/consts/index.ts (1)
  • CountryData (153-162)
⏰ 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 (5)
src/utils/bridge.utils.ts (1)

1-2: LGTM!

The imports are appropriate for the new getCountryFromAccount function, bringing in the necessary types and data sources.

src/app/(mobile-ui)/withdraw/page.tsx (4)

13-13: LGTM!

The import of getCountryFromAccount is correctly placed and will be used for routing logic.


36-36: LGTM!

The updated initialStep logic correctly considers both selectedMethod and selectedBankAccount, allowing users to skip directly to amount input when a bank account is pre-selected.


186-186: Bank withdrawal route exists
src/app/(mobile-ui)/withdraw/[country]/bank/page.tsx handles /withdraw/${country.path}/bank.


31-31: selectedBankAccount is present in WithdrawFlowContextType No update needed.

@jjramirezn jjramirezn merged commit 05070b7 into peanut-wallet-dev Oct 3, 2025
4 of 5 checks passed
@vercel vercel bot temporarily deployed to Preview – peanut-wallet October 3, 2025 19:25 Inactive
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