Skip to content

feat(add-money): default Manteca deposit input to local currency#2511

Merged
jjramirezn merged 3 commits into
devfrom
feat/add-money-local-currency-default
Jul 24, 2026
Merged

feat(add-money): default Manteca deposit input to local currency#2511
jjramirezn merged 3 commits into
devfrom
feat/add-money-local-currency-default

Conversation

@jjramirezn

@jjramirezn jjramirezn commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Add-money via Manteca (Argentina / Brazil) opened the amount input USD-first (Brazil was special-cased to BRL on 2026-07-01, Argentina reverted to USD in the same commit). Users pay the bank transfer / QR in their local currency, so a USD-first input causes wrong-amount deposits — this matches the withdraw flow, which already defaults to local currency. USD stays one toggle away and an explicit ?currency= deep-link still wins.

Also fixes a latent URL-state bug: AmountInput reports the display symbol (R$) while the nuqs enum stores ISO codes, so Brazil wrote ?currency=R$ — silently rejected on parse, meaning the param never round-tripped. The handler now maps the symbol back to the country's ISO code before persisting.

Risks / breaking changes

  • Behavior change: Argentina's add-money input now opens in ARS instead of USD. isUsdDenominated in the deposit payload derives from the same currentDenomination, so API semantics are unchanged — just the default flips.
  • No cross-repo impact; single component touched.

Tests

New colocated suite __tests__/MantecaAddMoney.test.tsx pins the behavior (this default was silently flipped once before — 3ab0668):

  • AR opens ARS / BR opens BRL / explicit ?currency=USD deep-link wins
  • write-back maps R$BRL (valid enum value) and USDUSD

Screenshots

⚠️ NONE — sandbox on this machine won't boot (primary peanut-api-ts tree is pinned to main to match prod; its tsx + @zerodev/permissions resolution breaks the qa harness), so no authenticated add-money screen could be captured. Visual delta is a single default flip on an existing input: it opens showing ARS/BRL instead of USD. The new component tests assert the exact prop driving it.

QA

  • /add-money/argentina/manteca → input opens in ARS; toggle to USD → ?currency=USD; toggle back → ?currency=ARS (valid enum value, survives refresh).
  • /add-money/brazil/manteca → opens in BRL; toggling now writes ?currency=BRL instead of currency=R$.
  • Deep-link ?currency=USD still forces USD-first.

Summary by CodeRabbit

  • Bug Fixes
    • Updated URL-backed denomination defaults to use the selected country’s local ISO currency instead of defaulting to USD for non-BRL countries.
    • Clarified precedence so an explicitly set USD denomination in the URL remains authoritative.
    • Improved denomination updates to write standardized currency codes to the URL (avoiding non-code labels).
  • Tests
    • Added coverage to verify denomination read/write round-tripping for Argentina and Brazil via URL state.

Users pay the bank transfer / QR in ARS or BRL, but the input opened
USD-first (except Brazil), causing wrong-amount deposits. Match the
withdraw flow: local currency first, USD one toggle away.

Also map AmountInput's display symbol back to the ISO code before
persisting ?currency= — Brazil was writing currency=R$, which the
enum parser rejects, so the URL param never round-tripped.
@vercel

vercel Bot commented Jul 24, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
peanut-wallet Ready Ready Preview, Comment Jul 24, 2026 9:20pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

MantecaAddMoney now defaults denominations to the selected country’s currency, preserves explicit USD URL state, and writes ISO currency codes for UI denomination changes. Tests cover Argentina, Brazil, USD overrides, and URL synchronization.

Changes

Currency denomination synchronization

Layer / File(s) Summary
Country-based defaults and URL synchronization
src/components/AddMoney/components/MantecaAddMoney.tsx
Denomination defaults now use the selected country currency, while denomination changes write USD or the country’s configured currency code to query state.
Denomination behavior tests
src/components/AddMoney/components/__tests__/MantecaAddMoney.test.tsx
Adds isolated mocks and tests for country defaults, explicit USD overrides, and ISO currency URL write-back.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested labels: enhancement

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: defaulting the Manteca add-money input to the local currency.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/add-money-local-currency-default

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

@github-actions

Copy link
Copy Markdown
Contributor

Code-analysis diff

Painscore total: 6268.24 → 6268.39 (+0.15)
Findings: 0 net (+6 new, -6 resolved)

🆕 New findings (6)

  • critical complexity — src/components/AddMoney/components/MantecaAddMoney.tsx — CC 58, MI 56.71, SLOC 213
  • high hotspot — src/components/AddMoney/components/MantecaAddMoney.tsx — 32 commits, +340/-202 lines since 6 months ago
  • medium high-mdd — src/components/AddMoney/components/MantecaAddMoney.tsx:37 — MantecaAddMoney: MDD 126.9 (uses across many lines from declarations)
  • medium structural-dup — app/(mobile-ui)/withdraw/manteca/page.tsx:631 — 29 duplicate lines / 132 tokens with components/AddMoney/components/MantecaAddMoney.tsx:270
  • medium method-complexity — src/components/AddMoney/components/MantecaAddMoney.tsx:37 — CC 17 SLOC 97
  • low structural-dup — components/AddMoney/components/MantecaAddMoney.tsx:263 — 18 duplicate lines / 122 tokens with components/Claim/Link/MantecaFlowManager.tsx:145

✅ Resolved (6)

  • src/components/AddMoney/components/MantecaAddMoney.tsx — CC 58, MI 56.81, SLOC 212
  • src/components/AddMoney/components/MantecaAddMoney.tsx — 31 commits, +329/-196 lines since 6 months ago
  • src/components/AddMoney/components/MantecaAddMoney.tsx:37 — MantecaAddMoney: MDD 126.2 (uses across many lines from declarations)
  • app/(mobile-ui)/withdraw/manteca/page.tsx:631 — 29 duplicate lines / 132 tokens with components/AddMoney/components/MantecaAddMoney.tsx:265
  • src/components/AddMoney/components/MantecaAddMoney.tsx:37 — CC 18 SLOC 97
  • components/AddMoney/components/MantecaAddMoney.tsx:258 — 18 duplicate lines / 122 tokens with components/Claim/Link/MantecaFlowManager.tsx:145

@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

🧪 UI test report — ✅ all green

Suites

  • unit: 2142 ran, 0 failed, 0 skipped, 24.7s

📊 Coverage (unit)

metric %
statements 60.7%
branches 44.2%
functions 50.0%
lines 61.1%
⏱ 10 slowest test cases
time test
1.9s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › never places two stickers in heavy overlap (broad seed sweep)
0.9s src/utils/__tests__/demo-api.test.ts › isDemoMode() is false when not running under Capacitor
0.3s src/app/(mobile-ui)/withdraw/__tests__/withdraw-states.test.tsx › Bank withdrawal keeps the $1 minimum for sub-$1 amounts
0.2s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › every sticker stays within canvas at any count
0.2s src/app/actions/__tests__/api-headers-extended.test.ts › should not include apiKey in validateInviteCode body
0.2s src/app/actions/__tests__/api-headers.test.ts › should include Content-Type in validateInviteCode
0.2s src/app/(mobile-ui)/withdraw/__tests__/withdraw-states.test.tsx › Unresolved bank-account country shows an error instead of throwing (dead button)
0.2s src/utils/__tests__/demo-balance.test.ts › debits and floors at zero
0.1s src/utils/__tests__/demo-balance.test.ts › auto-refills a wallet older than the TTL on cold start
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle valid 9-digit US account
📍 Inline annotations are in the **Unit test report** check above. Coverage artifact: `coverage-unit`. Generated by `.github/workflows/tests.yml`.

The local-currency default was silently narrowed to Brazil-only once
(3ab0668); this suite makes the next flip fail loudly, and covers the
display-symbol → ISO-code mapping for the ?currency= param.
@jjramirezn

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/AddMoney/components/__tests__/MantecaAddMoney.test.tsx`:
- Line 94: Remove the eslint-disable-next-line import/first directive from the
test file, leaving the surrounding jest.mock and import statements unchanged.
- Around line 21-30: Replace the four any usages in the mockQueryState,
mockSetQueryState, and related test mocks with narrow types matching the
query-state fields and InputAmountStep props used by MantecaAddMoney tests.
Update the nuqs mock and mock state declarations while preserving their current
behavior and ensuring the test satisfies the no-explicit-any lint rule.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 04e1381b-68f6-4070-85f1-ce95e93caad1

📥 Commits

Reviewing files that changed from the base of the PR and between 46eb72c and d978b10.

📒 Files selected for processing (2)
  • src/components/AddMoney/components/MantecaAddMoney.tsx
  • src/components/AddMoney/components/__tests__/MantecaAddMoney.test.tsx

Comment thread src/components/AddMoney/components/__tests__/MantecaAddMoney.test.tsx Outdated
Comment thread src/components/AddMoney/components/__tests__/MantecaAddMoney.test.tsx Outdated
@jjramirezn

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@jjramirezn
jjramirezn marked this pull request as ready for review July 24, 2026 21:28
@jjramirezn
jjramirezn requested a review from Hugo0 July 24, 2026 21:28
@jjramirezn
jjramirezn merged commit 55d1bf2 into dev Jul 24, 2026
18 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant