Skip to content

feat(manteca): BRL PIX deposit QR screen (details.depositAddresses.PIX)#2335

Merged
Hugo0 merged 5 commits into
mainfrom
feat/pix-qr-deposit-main
Jul 2, 2026
Merged

feat(manteca): BRL PIX deposit QR screen (details.depositAddresses.PIX)#2335
Hugo0 merged 5 commits into
mainfrom
feat/pix-qr-deposit-main

Conversation

@jjramirezn

Copy link
Copy Markdown
Contributor

BRL PIX deposit — frontend · ✅ unblocked, wired to the prod-confirmed contract

Supersedes #2315 (same commits rebased onto main + the un-stub commit — repo rules block force-push, hence the new branch; targeting main since this fixes the currently-broken BRL deposit UX: Manteca stopped returning the static PIX key, so the old share-details screen shows nothing to pay).

Adds a showQR step to the Manteca Add-Money flow for BRL: renders the dynamic PIX QR from the ramp-on synthetic's details.depositAddresses.PIX (prod-confirmed 2026-07-02 via mono/ops/scripts/manteca/probe-brl-rampon-qr.ts), with a live m:ss countdown off priceExpireAt (the locked-rate guarantee — the QR string itself lives ~3 days) and a "copia e cola" copy button. Status polling advances QR → processing → "Deposit received!" via GET /manteca/deposit/:id/status. ARS keeps its existing bank-details screen, untouched.

Flow: POST /manteca/deposit (BRL) → ramp-on synthetic with details.depositAddresses.PIX.codeshowQR (routed by currency) → poll status → processing (settling) → success on COMPLETED.

Also in this PR:

  • Add money → Brazil defaults the input denomination to BRL (PIX is in BRL); other countries keep USD.
  • Retires the warn-only PIX maintenance surface — the QR flow replaces it. pixBrazilOnrampMaintenance flips false (machinery stays for future outages), the in-flow banner wiring is removed, unused banner copy trimmed to the badge. Makes chore(add-money): PIX-BR onramp recovery toggle + maintenance-flag cleanup #2269 obsolete.
  • The maintenance test now snapshots/restores the shipped flag value instead of hardcoding true (adopted from chore(add-money): PIX-BR onramp recovery toggle + maintenance-flag cleanup #2269) — flipping the committed default can't poison the config singleton.
  • details.depositAddress/depositAlias are now optional in the type (absent for BRL); the ARS share-details screen keeps a '' fallback and BRL never routes there.
  • QRCodeWrapper gains an optional className width-override (zero blast radius on other callers).

Cross-repo: depends on peanutprotocol/peanut-api-ts#1110 (status endpoint) — land BE first.

Local gate: prettier ✓ · tsc ✓ (0 errors) · jest 1650/1654 passed, 3 skipped, 1 failure pre-existing on main (add-money-states › loaded EVM deposit shows QR code and address — crypto-deposit limits copy, unrelated; reproduced on pristine main).

🤖 Generated with Claude Code

abalinda and others added 5 commits July 2, 2026 15:53
Companion to peanut-api-ts #1093. For BRL, Add Money now shows Manteca's dynamic
PIX QR instead of the static bank-details screen: render the copia-e-cola via
QRCodeWrapper, a copy button, a live m:ss expiry countdown, and poll the deposit
intent status to auto-advance to a success state. ARS path untouched.

- showQR step (nuqs) routed by the response discriminator (type === 'QR')
- useMantecaDepositPolling: read-only mirror of GET /manteca/deposit/:id/status
- QRCodeWrapper gains an optional className width-override (160 -> 280px here)
- hook + component tests
…'s details

Drops MantecaPixDepositData; the dynamic QR now reads from the existing
MantecaDepositResponseData.details.qr (the ramp-on synthetic), routed to showQR
by currency. Matches the BE pivot (api #1093) off deposit-request. details.qr is
a stub until Manteca confirms the field name.
…g screen

Two PIX-deposit polish items:
- Add money → Brazil now defaults the input denomination to BRL (Argentina → ARS)
  instead of USD — you deposit in your local currency.
- Show the branded CyclingLoading screen (spinning peanut + rotating messages,
  same as PIX-payment processing) while the BRL QR is being generated, and in
  place of the plain "Preparing your PIX QR…" fallback.
…lement screen

- Add money → Brazil defaults the denomination to BRL (PIX is in BRL); every
  other country keeps USD (Argentina reverts to USD).
- useMantecaDepositPolling now surfaces a 'processing' status for the
  payment-settling window (Manteca PROCESSING / AWAITING_SETTLEMENT); the QR
  screen shows the branded CyclingLoading during it, so the flow is
  QR → processing → "Deposit received!".
…ire the maintenance warn

Manteca shipped the dynamic BRL QR to prod today. Probe (mono
ops/scripts/manteca/probe-brl-rampon-qr.ts) pinned the real shape: the
EMVCo copia-e-cola rides in details.depositAddresses.PIX.{code,url,
expiresAt,bankId}; the old static depositAddress/depositAlias are gone
for BRL (now optional in the type — the ARS share-details screen keeps a
'' fallback but BRL never routes there).

With the QR flow live the warn-only maintenance surface comes off:
pixBrazilOnrampMaintenance flips false (machinery stays for future
outages), the unused banner copy is trimmed to the badge, and the
maintenance test now snapshots/restores the shipped flag instead of
hardcoding true — flipping the committed default no longer poisons the
config singleton for later tests.
@vercel

vercel Bot commented Jul 2, 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 2, 2026 7:10pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR adds a BRL PIX QR deposit flow to Manteca deposits: a new showQR step, a MantecaPixQrDeposit component, and a useMantecaDepositPolling hook backed by a new mantecaApi.getDepositStatus call. Types are relaxed for optional PIX/BRL fields, QRCodeWrapper supports custom className, and the PIX maintenance banner is removed in favor of a tag-only, warn-only default.

Changes

BRL PIX QR Deposit Feature

Layer / File(s) Summary
Deposit type and API contract updates
src/types/manteca.types.ts, src/services/manteca.ts
MantecaDepositResponseData gains optional PIX QR fields and relaxes BRL address fields to optional; mantecaApi.getDepositStatus added to fetch deposit status.
Deposit status polling hook
src/components/AddMoney/hooks/useMantecaDepositPolling.ts, src/components/AddMoney/hooks/__tests__/useMantecaDepositPolling.test.tsx
New hook polls deposit status every 5s until terminal, maps upstream status to local states, and fires onComplete once on completion; covered by tests.
MantecaPixQrDeposit component
src/components/AddMoney/components/MantecaPixQrDeposit.tsx, src/components/AddMoney/components/__tests__/MantecaPixQrDeposit.test.tsx, src/components/Global/QRCodeWrapper/index.tsx
New component renders PIX QR code, copy-to-clipboard code, countdown/expiry states, and completed/processing states; QRCodeWrapper now accepts a className override via twMerge.
MantecaAddMoney flow wiring for showQR step
src/components/AddMoney/components/MantecaAddMoney.tsx, src/components/AddMoney/components/MantecaDepositShareDetails.tsx
Adds showQR URL step, BRL denomination default, loading state during BRL deposit creation, showQR render branch, updated redirect logic, and a nullish fallback for depositAddress.
PIX maintenance banner removal and config update
src/config/underMaintenance.config.ts, src/components/AddWithdraw/__tests__/AddWithdrawCountriesList.test.tsx
Removes the maintenance banner prop from InputAmountStep, flips pixBrazilOnrampMaintenance default to false, trims PIX_BRAZIL_ONRAMP_MAINTENANCE to a badge-only object, and updates tests to restore the original flag instead of forcing it.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

  • peanutprotocol/peanut-ui#1249: Both PRs shift consumers to the updated MantecaDepositResponseData shape and wire MantecaAddMoney/MantecaDepositShareDetails deposit presentation.
  • peanutprotocol/peanut-ui#2268: Directly precedes this PR's underMaintenance.config.ts changes and removal of the maintenance banner prop from InputAmountStep.
  • peanutprotocol/peanut-ui#2273: Both PRs modify MantecaAddMoney/InputAmountStep PIX-via-BRL maintenance banner wiring.

Suggested labels: enhancement

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a BRL PIX deposit QR screen.
Description check ✅ Passed The description is directly related to the BRL PIX deposit QR flow and its supporting changes.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Code-analysis diff

Painscore total: 5856.19 → 5869.37 (+13.18)
Findings: +3 net (+19 new, -16 resolved)

🆕 New findings (19)

  • critical complexity — src/components/AddMoney/components/MantecaAddMoney.tsx — CC 58, MI 56.81, SLOC 212
  • high complexity — src/services/manteca.ts — CC 48, MI 56.59, SLOC 216
  • high hotspot — src/components/AddMoney/components/MantecaAddMoney.tsx — 35 commits, +315/-204 lines since 6 months ago
  • medium high-mdd — src/components/AddMoney/components/MantecaAddMoney.tsx:37 — MantecaAddMoney: MDD 126.2 (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:265
  • medium structural-dup — services/manteca.ts:151 — 29 duplicate lines / 56 tokens with services/manteca.ts:412
  • medium high-mdd — src/components/AddMoney/components/MantecaDepositShareDetails.tsx:22 — MantecaDepositShareDetails: MDD 29.1 (uses across many lines from declarations)
  • medium high-mdd — src/components/AddMoney/components/MantecaPixQrDeposit.tsx:20 — MantecaPixQrDeposit: MDD 29.3 (uses across many lines from declarations)
  • medium hotspot — src/config/underMaintenance.config.ts — 27 commits, +106/-46 lines since 6 months ago
  • medium complexity — src/components/AddMoney/components/MantecaDepositShareDetails.tsx — CC 21, MI 63.1, SLOC 68
  • medium method-complexity — src/components/AddMoney/components/MantecaAddMoney.tsx:37 — CC 18 SLOC 97
  • medium complexity — src/components/AddMoney/components/MantecaPixQrDeposit.tsx — CC 17, MI 65.07, SLOC 45
  • medium complexity — src/components/AddMoney/hooks/useMantecaDepositPolling.ts — CC 15, MI 65.25, SLOC 42
  • medium complexity — src/config/underMaintenance.config.ts — CC 1, MI 61.35, SLOC 13
  • low structural-dup — components/AddMoney/components/MantecaAddMoney.tsx:258 — 18 duplicate lines / 122 tokens with components/Claim/Link/MantecaFlowManager.tsx:145
  • low high-mdd — src/components/Global/QRCodeWrapper/index.tsx:18 — QRCodeWrapper: MDD 16.0 (uses across many lines from declarations)
  • low high-mdd — src/services/manteca.ts:403 — withdrawWithSignedTx: MDD 11.4 (uses across many lines from declarations)
  • low missing-return-type — src/components/AddMoney/hooks/useMantecaDepositPolling.ts:21 — useMantecaDepositPolling: exported fn missing return type annotation
  • low enum-usage — src/types/manteca.types.ts:70 — enum MercadoPagoStep — prefer as const object literals

✅ Resolved (16)

  • src/components/AddMoney/components/MantecaAddMoney.tsx — CC 50, MI 56.79, SLOC 191
  • src/services/manteca.ts — CC 44, MI 56.94, SLOC 201
  • src/components/AddMoney/components/MantecaAddMoney.tsx — 31 commits, +255/-167 lines since 6 months ago
  • src/components/AddMoney/components/MantecaAddMoney.tsx:37 — MantecaAddMoney: MDD 112.1 (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:246
  • services/manteca.ts:151 — 29 duplicate lines / 56 tokens with services/manteca.ts:399
  • src/components/AddMoney/components/MantecaDepositShareDetails.tsx:22 — MantecaDepositShareDetails: MDD 28.9 (uses across many lines from declarations)
  • src/config/underMaintenance.config.ts — 26 commits, +102/-38 lines since 6 months ago
  • src/components/AddMoney/components/MantecaDepositShareDetails.tsx — CC 21, MI 63.11, SLOC 68
  • src/components/AddMoney/components/MantecaAddMoney.tsx:37 — CC 15 SLOC 90
  • src/components/AddMoney/components/MantecaAddMoney.tsx:228 — small useEffect that only sets state from deps
  • src/config/underMaintenance.config.ts — CC 1, MI 59.86, SLOC 15
  • components/AddMoney/components/MantecaAddMoney.tsx:239 — 18 duplicate lines / 122 tokens with components/Claim/Link/MantecaFlowManager.tsx:145
  • src/components/Global/QRCodeWrapper/index.tsx:16 — QRCodeWrapper: MDD 16.0 (uses across many lines from declarations)
  • src/services/manteca.ts:390 — withdrawWithSignedTx: MDD 11.4 (uses across many lines from declarations)
  • src/types/manteca.types.ts:57 — enum MercadoPagoStep — prefer as const object literals

📈 Painscore deltas (top movers)

File Before After Δ
src/components/AddMoney/components/MantecaPixQrDeposit.tsx 0.0 6.5 +6.5
src/components/AddMoney/hooks/useMantecaDepositPolling.ts 0.0 5.4 +5.4

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

🧪 UI test report — ✅ all green

Suites

  • unit: 1654 ran, 0 failed, 0 skipped, 26.0s

📊 Coverage (unit)

metric %
statements 54.8%
branches 37.6%
functions 42.5%
lines 54.7%
⏱ 10 slowest test cases
time test
3.9s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › never places two stickers in heavy overlap (broad seed sweep)
0.4s src/app/actions/__tests__/api-headers.test.ts › should include Content-Type in updateUserById
0.4s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › every sticker stays within canvas at any count
0.3s src/app/actions/__tests__/api-headers-extended.test.ts › should not include apiKey in updateUserById body
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle valid 9-digit US account
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle valid US account with spaces 2
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle too long for US account
0.1s src/app/(mobile-ui)/qr-pay/__tests__/qr-pay-states.test.tsx › Perk claimed shows shake class + go home button
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle valid ENS name
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle valid ETH address with surrounding spaces
📍 Inline annotations are in the **Unit test report** check above. Coverage artifact: `coverage-unit`. Generated by `.github/workflows/tests.yml`.

@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

🧹 Nitpick comments (2)
src/components/AddMoney/hooks/useMantecaDepositPolling.ts (1)

29-32: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

No upper bound on polling duration.

refetchInterval only stops on a terminal status string; there's no time-based cutoff tied to priceExpireAt (available on MantecaDepositResponseData.details). If a user abandons the QR screen without completing or the backend never emits a terminal status, this will poll every 5s indefinitely for as long as the tab stays open.

Consider stopping (or slowing) polling once the deposit's price/QR has expired, independent of the terminal-status check.

🤖 Prompt for 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.

In `@src/components/AddMoney/hooks/useMantecaDepositPolling.ts` around lines 29 -
32, The polling in useMantecaDepositPolling currently only stops when
refetchInterval sees a terminal status, so it can run forever if the deposit
never completes. Update the refetchInterval logic to also inspect
MantecaDepositResponseData.details.priceExpireAt and stop or slow polling once
that expiration time has passed, even when status is still non-terminal. Keep
the existing TERMINAL_STATUSES check, but add the time-based cutoff in the same
polling decision path so the hook no longer refetches indefinitely.
src/components/AddMoney/components/__tests__/MantecaPixQrDeposit.test.tsx (1)

63-98: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Missing coverage for processing status and the qr-loading (no qr) branch.

Only pending, expired, and completed are exercised; the processing status branch (CyclingLoading) and the !qr loading branch are untested.

🤖 Prompt for 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.

In `@src/components/AddMoney/components/__tests__/MantecaPixQrDeposit.test.tsx`
around lines 63 - 98, Add test coverage in MantecaPixQrDeposit.test.tsx for the
missing MantecaPixQrDeposit branches: the deposit polling status 'processing'
should render the CyclingLoading state, and the branch where qr is absent should
render the loading/no-QR fallback. Update or add focused tests around the
existing mockUseMantecaDepositPolling setup to force these states and assert the
expected UI, alongside the current pending, expired, and completed cases.
🤖 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/hooks/useMantecaDepositPolling.ts`:
- Around line 35-41: The polling status in useMantecaDepositPolling is ignoring
transport/API errors because it only reads data?.data?.status, so persistent
failures never transition out of pending. Update the status derivation to also
inspect data?.error (and related fetch failure state) from getDepositStatus, and
map repeated failures to a terminal failed state instead of continuing to return
pending. Use the existing useMantecaDepositPolling hook, TERMINAL_STATUSES,
PROCESSING_STATUSES, and refetchInterval logic to stop polling and surface
failure after a reasonable number of consecutive errors.

---

Nitpick comments:
In `@src/components/AddMoney/components/__tests__/MantecaPixQrDeposit.test.tsx`:
- Around line 63-98: Add test coverage in MantecaPixQrDeposit.test.tsx for the
missing MantecaPixQrDeposit branches: the deposit polling status 'processing'
should render the CyclingLoading state, and the branch where qr is absent should
render the loading/no-QR fallback. Update or add focused tests around the
existing mockUseMantecaDepositPolling setup to force these states and assert the
expected UI, alongside the current pending, expired, and completed cases.

In `@src/components/AddMoney/hooks/useMantecaDepositPolling.ts`:
- Around line 29-32: The polling in useMantecaDepositPolling currently only
stops when refetchInterval sees a terminal status, so it can run forever if the
deposit never completes. Update the refetchInterval logic to also inspect
MantecaDepositResponseData.details.priceExpireAt and stop or slow polling once
that expiration time has passed, even when status is still non-terminal. Keep
the existing TERMINAL_STATUSES check, but add the time-based cutoff in the same
polling decision path so the hook no longer refetches indefinitely.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3cc91288-5b5d-440c-80f0-906e0fe84d4a

📥 Commits

Reviewing files that changed from the base of the PR and between 456a52a and 9d506bb.

📒 Files selected for processing (11)
  • src/components/AddMoney/components/MantecaAddMoney.tsx
  • src/components/AddMoney/components/MantecaDepositShareDetails.tsx
  • src/components/AddMoney/components/MantecaPixQrDeposit.tsx
  • src/components/AddMoney/components/__tests__/MantecaPixQrDeposit.test.tsx
  • src/components/AddMoney/hooks/__tests__/useMantecaDepositPolling.test.tsx
  • src/components/AddMoney/hooks/useMantecaDepositPolling.ts
  • src/components/AddWithdraw/__tests__/AddWithdrawCountriesList.test.tsx
  • src/components/Global/QRCodeWrapper/index.tsx
  • src/config/underMaintenance.config.ts
  • src/services/manteca.ts
  • src/types/manteca.types.ts

Comment on lines +87 to +88
{!qr ? (
<CyclingLoading />

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.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== File outline ==\n'
ast-grep outline src/components/AddMoney/components/MantecaPixQrDeposit.tsx --view expanded || true

printf '\n== Relevant search ==\n'
rg -n "depositAddresses\\.PIX|useMantecaDepositPolling|CyclingLoading|qrTimedOut|onBack" src/components/AddMoney -S || true

printf '\n== File excerpt ==\n'
sed -n '1,220p' src/components/AddMoney/components/MantecaPixQrDeposit.tsx

Repository: peanutprotocol/peanut-ui

Length of output: 13305


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== Test file ==\n'
sed -n '1,220p' src/components/AddMoney/components/__tests__/MantecaPixQrDeposit.test.tsx

printf '\n== Polling hook ==\n'
sed -n '1,220p' src/components/AddMoney/hooks/useMantecaDepositPolling.ts

printf '\n== Type definition search ==\n'
rg -n "type MantecaDepositResponseData|interface MantecaDepositResponseData|depositAddresses" src/types src/components/AddMoney -S

Repository: peanutprotocol/peanut-ui

Length of output: 7738


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== Type file excerpt ==\n'
sed -n '1,180p' src/types/manteca.types.ts

printf '\n== Component usage search ==\n'
rg -n "MantecaPixQrDeposit|depositDetails" src/components/AddMoney -S

printf '\n== MantecaAddMoney excerpt ==\n'
sed -n '1,380p' src/components/AddMoney/components/MantecaAddMoney.tsx

Repository: peanutprotocol/peanut-ui

Length of output: 24260


Add a fallback when the PIX code is missing.
depositAddresses.PIX?.code is optional here, and when it’s absent this screen stays on CyclingLoading forever. The expiry state never renders because it’s gated behind qr, and useMantecaDepositPolling only tracks settlement status. Add a timeout/error + retry/back state, or make the API guarantee the PIX code at creation time.

Comment on lines +35 to +41
const status: MantecaDepositPollStatus = useMemo(() => {
const s = data?.data?.status
if (s === 'COMPLETED') return 'completed'
if (s && TERMINAL_STATUSES.includes(s)) return 'failed'
if (s && PROCESSING_STATUSES.includes(s)) return 'processing'
return 'pending'
}, [data])

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.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Persistent API failures never surface as failed.

mantecaApi.getDepositStatus returns { error: data.error || 'Failed to fetch deposit status.' } on non-OK responses and { error: ... } on exceptions instead of throwing. But status here only inspects data?.data?.status — it never checks data?.error. If the status endpoint keeps erroring (bad depositId, 5xx, network blip), s stays undefined, so status resolves to 'pending' indefinitely, refetchInterval keeps polling every 5s forever, and onComplete/the failed state never fires. The user is stuck on the QR/processing screen with no failure feedback.

🔧 Proposed fix
     const status: MantecaDepositPollStatus = useMemo(() => {
-        const s = data?.data?.status
+        const s = data?.data?.status
+        if (!data?.data && data?.error) return 'failed'
         if (s === 'COMPLETED') return 'completed'
         if (s && TERMINAL_STATUSES.includes(s)) return 'failed'
         if (s && PROCESSING_STATUSES.includes(s)) return 'processing'
         return 'pending'
     }, [data])

Consider also capping consecutive failures (e.g. via failureCount) before giving up, rather than treating every fetch error as instantly terminal.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const status: MantecaDepositPollStatus = useMemo(() => {
const s = data?.data?.status
if (s === 'COMPLETED') return 'completed'
if (s && TERMINAL_STATUSES.includes(s)) return 'failed'
if (s && PROCESSING_STATUSES.includes(s)) return 'processing'
return 'pending'
}, [data])
const status: MantecaDepositPollStatus = useMemo(() => {
const s = data?.data?.status
if (!data?.data && data?.error) return 'failed'
if (s === 'COMPLETED') return 'completed'
if (s && TERMINAL_STATUSES.includes(s)) return 'failed'
if (s && PROCESSING_STATUSES.includes(s)) return 'processing'
return 'pending'
}, [data])
🤖 Prompt for 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.

In `@src/components/AddMoney/hooks/useMantecaDepositPolling.ts` around lines 35 -
41, The polling status in useMantecaDepositPolling is ignoring transport/API
errors because it only reads data?.data?.status, so persistent failures never
transition out of pending. Update the status derivation to also inspect
data?.error (and related fetch failure state) from getDepositStatus, and map
repeated failures to a terminal failed state instead of continuing to return
pending. Use the existing useMantecaDepositPolling hook, TERMINAL_STATUSES,
PROCESSING_STATUSES, and refetchInterval logic to stop polling and surface
failure after a reasonable number of consecutive errors.

@jjramirezn jjramirezn marked this pull request as ready for review July 2, 2026 19:43
@Hugo0 Hugo0 merged commit 126d1aa into main Jul 2, 2026
22 of 24 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.

3 participants