Skip to content

chore(add-money): PIX-BR onramp recovery toggle + maintenance-flag cleanup#2269

Draft
Hugo0 wants to merge 2 commits into
mainfrom
chore/pix-brazil-onramp-recovery
Draft

chore(add-money): PIX-BR onramp recovery toggle + maintenance-flag cleanup#2269
Hugo0 wants to merge 2 commits into
mainfrom
chore/pix-brazil-onramp-recovery

Conversation

@Hugo0

@Hugo0 Hugo0 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Draft — parked on purpose. Merge this when the BRL-via-PIX onramp (Manteca Brazil) is stable again. Merging it flips PIX maintenance off in prod.

Follow-up to #2268.

Why

#2268 shipped the warn-only "PIX under maintenance" tag + in-flow banner with the flag on. This is the matching recovery PR — ready in advance so flipping PIX back to normal is a one-merge action, not a scramble. It also cleans up two smells from the #2268 review.

What

  1. Restore to not-under-maintenancepixBrazilOnrampMaintenance: true → false in underMaintenance.config.ts. The tag + banner disappear; the warn-only machinery stays in place, ready to flip back on (set the flag to true) if the onramp degrades again.
  2. One selector, no drift — both surfaces (the list "Maintenance" tag and the in-flow banner) now read the maintenance state through a single isPixBrazilOnrampUnderMaintenance() selector instead of two separate underMaintenanceConfig.pixBrazilOnrampMaintenance reads. The maintenance determination lives in one place, so if the rule ever gains complexity (a time window, more regions) the two surfaces can't diverge. Each caller still keeps its own context check (the pix-add method / country BR).
  3. Robust test restore — the maintenance test snapshots and restores the shipped flag value instead of hardcoding the afterEach restore to true. Previously, once the committed default became false (i.e. this PR), the old afterEach would have left the shared config singleton stuck at true for anything running after it.

Base

Cut onto main, not dev: the pixBrazilOnrampMaintenance flag + UI only exist on main so far (the #2268 main→dev back-merge is still pending), so main is the only base where this is a clean, minimal diff. When the back-merge lands, this change rides along with it.

Scope / notes

Tests (local gate, run in worktree)

  • prettier ✓ (all 4 files unchanged after --write)
  • tsc ✓ — 0 errors in changed files
  • jest ✓ — AddWithdrawCountriesList (7) + add-money-states (41) pass; maintenance tests pass with the flag both on and off
  • next build left to CI (authoritative — submodules + env)

…eanup

Draft follow-up to #2268, to merge once the BRL-via-PIX onramp (Manteca
Brazil) is stable again: flips pixBrazilOnrampMaintenance off so the
"Maintenance" tag + in-flow banner disappear. The warn-only machinery
stays in place, ready to flip back on if the onramp degrades again.

Also fixes two smells surfaced in the #2268 review:

- both surfaces (the list tag and the in-flow banner) now read the
  maintenance state through one isPixBrazilOnrampUnderMaintenance()
  selector instead of two separate flag reads that could drift apart if
  the rule ever gains complexity (e.g. a time window or extra regions).
- the maintenance test snapshots and restores the shipped flag instead
  of hardcoding the restore value to `true`, so it no longer corrupts
  shared module state now that the committed default is `false`.
@vercel

vercel Bot commented Jun 23, 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 Jun 23, 2026 5:03pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Configuration constants and flag naming are refactored in underMaintenance.config.ts: pixBrazilOnrampMaintenance is renamed to enablePixOnrampMaintenanceWarning with default flipped to false, and PIX_BRAZIL_ONRAMP_MAINTENANCE is renamed to PIX_ONRAMP_MAINTENANCE_COPY. Add-money and add-withdraw components, their tests, QR-pay page, and global components are updated to use the new names.

Changes

PIX Onramp Maintenance Configuration and Consumer Update

Layer / File(s) Summary
Config: flag rename, default flip, and copy constant update
src/config/underMaintenance.config.ts
Documentation updated to define naming conventions (enable<Behavior> vs disable<Feature>), flag renamed from pixBrazilOnrampMaintenance to enablePixOnrampMaintenanceWarning, default flipped from true to false, interface field updated, and PIX_BRAZIL_ONRAMP_MAINTENANCE constant renamed to PIX_ONRAMP_MAINTENANCE_COPY.
MantecaAddMoney: import and render updates
src/components/AddMoney/components/MantecaAddMoney.tsx
Import updated to use PIX_ONRAMP_MAINTENANCE_COPY, showPixMaintenance renamed to showPixMaintenanceBanner, and banner rendering switched to use the renamed copy constant's title and description properties.
AddWithdrawCountriesList: import and condition updates
src/components/AddWithdraw/AddWithdrawCountriesList.tsx
Import updated to use PIX_ONRAMP_MAINTENANCE_COPY, PIX maintenance condition replaced with showPixMaintenanceTag scoped to flow === 'add' and method.id === 'pix-add', and badge rendering switched to use PIX_ONRAMP_MAINTENANCE_COPY.badge.
AddWithdrawCountriesList tests: snapshot/restore flag
src/components/AddWithdraw/__tests__/AddWithdrawCountriesList.test.tsx
Test suite updated to capture current enablePixOnrampMaintenanceWarning value in beforeEach and restore it in afterEach, and flag-off test updated to toggle the renamed flag.
QR-pay page: import migration to underMaintenanceConfig
src/app/(mobile-ui)/qr-pay/page.tsx, src/app/(mobile-ui)/qr-pay/__tests__/qr-pay-states.test.tsx
Both page and test migrate from maintenanceConfig to underMaintenanceConfig for sourcing disabledPaymentProviders maintenance checks.
Global components: import migration to underMaintenanceConfig
src/components/Global/Banner/index.tsx, src/proxy.ts
Banner and proxy components migrate from maintenanceConfig to underMaintenanceConfig for accessing maintenance feature flags.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • peanutprotocol/peanut-ui#2268: Directly precedes this PR and introduces the initial BRL-via-PIX warn-only maintenance banner and badge wiring in the same components using the original pixBrazilOnrampMaintenance flag naming that this PR refactors.

Suggested labels

enhancement

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Title clearly summarizes the primary changes: PIX Brazil onramp recovery toggle flip and associated maintenance-flag cleanup work.
Description check ✅ Passed Description is comprehensive and directly related to the changeset, detailing the maintenance flag toggle, unified selector pattern, test improvements, and rationale.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 Jun 23, 2026

Copy link
Copy Markdown
Contributor

Code-analysis diff

Painscore total: 5762.17 → 5756.21 (-5.96)
Findings: 0 net (+11 new, -11 resolved)

🆕 New findings (11)

  • high hotspot — src/app/(mobile-ui)/qr-pay/page.tsx — 82 commits, +952/-932 lines since 6 months ago
  • high hotspot — src/components/AddWithdraw/AddWithdrawCountriesList.tsx — 43 commits, +703/-498 lines since 6 months ago
  • high hotspot — src/components/AddMoney/components/MantecaAddMoney.tsx — 38 commits, +376/-227 lines since 6 months ago
  • medium high-mdd — src/components/AddWithdraw/AddWithdrawCountriesList.tsx:44 — AddWithdrawCountriesList: MDD 137.3 (uses across many lines from declarations)
  • medium high-mdd — src/components/AddMoney/components/MantecaAddMoney.tsx:37 — MantecaAddMoney: MDD 112.4 (uses across many lines from declarations)
  • medium high-mdd — src/components/AddWithdraw/AddWithdrawCountriesList.tsx:430 — : MDD 29.5 (uses across many lines from declarations)
  • medium structural-dup — app/(mobile-ui)/withdraw/manteca/page.tsx:615 — 29 duplicate lines / 132 tokens with components/AddMoney/components/MantecaAddMoney.tsx:245
  • medium high-mdd — src/components/AddWithdraw/AddWithdrawCountriesList.tsx:421 — renderPaymentMethods: MDD 27.8 (uses across many lines from declarations)
  • medium hotspot — src/config/underMaintenance.config.ts — 21 commits, +95/-45 lines since 6 months ago
  • medium react-effect-derives-state — src/components/AddMoney/components/MantecaAddMoney.tsx:227 — small useEffect that only sets state from deps
  • low structural-dup — components/AddMoney/components/MantecaAddMoney.tsx:238 — 18 duplicate lines / 122 tokens with components/Claim/Link/MantecaFlowManager.tsx:145

✅ Resolved (11)

  • src/app/(mobile-ui)/qr-pay/page.tsx — 81 commits, +950/-930 lines since 6 months ago
  • src/components/AddWithdraw/AddWithdrawCountriesList.tsx — 41 commits, +692/-488 lines since 6 months ago
  • src/components/AddMoney/components/MantecaAddMoney.tsx — 36 commits, +367/-219 lines since 6 months ago
  • src/components/AddWithdraw/AddWithdrawCountriesList.tsx:44 — AddWithdrawCountriesList: MDD 137.1 (uses across many lines from declarations)
  • src/components/AddMoney/components/MantecaAddMoney.tsx:37 — MantecaAddMoney: MDD 112.0 (uses across many lines from declarations)
  • app/(mobile-ui)/withdraw/manteca/page.tsx:615 — 29 duplicate lines / 132 tokens with components/AddMoney/components/MantecaAddMoney.tsx:244
  • src/components/AddWithdraw/AddWithdrawCountriesList.tsx:430 — : MDD 28.5 (uses across many lines from declarations)
  • src/components/AddWithdraw/AddWithdrawCountriesList.tsx:421 — renderPaymentMethods: MDD 27.3 (uses across many lines from declarations)
  • src/app/shhhhh/ShhhhhLandingPage.tsx — 20 commits, +862/-271 lines since 6 months ago
  • src/components/AddMoney/components/MantecaAddMoney.tsx:226 — small useEffect that only sets state from deps
  • components/AddMoney/components/MantecaAddMoney.tsx:237 — 18 duplicate lines / 122 tokens with components/Claim/Link/MantecaFlowManager.tsx:145

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

🧪 UI test report — ✅ all green

Suites

  • unit: 1471 ran, 0 failed, 0 skipped, 23.5s

📊 Coverage (unit)

metric %
statements 52.5%
branches 35.0%
functions 39.6%
lines 52.4%
⏱ 10 slowest test cases
time test
0.5s src/app/actions/__tests__/api-headers.test.ts › should include Content-Type in updateUserById
0.4s src/app/actions/__tests__/api-headers-extended.test.ts › should not include apiKey in updateUserById body
0.3s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › every stamp stays within canvas at any count
0.2s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle valid ETH address
0.1s src/app/(mobile-ui)/qr-pay/__tests__/qr-pay-states.test.tsx › Manteca PIX form ready shows merchant card + amount input + pay button
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle valid Italian IBAN
0.1s src/components/Request/__tests__/request-states.test.tsx › after link creation, amount input is disabled
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
📍 Inline annotations are in the **Unit test report** check above. Coverage artifact: `coverage-unit`. Generated by `.github/workflows/tests.yml`.

…tenance surfaces

Self-review follow-up on the #2268 surfaces — the maintenance config had
drifted into mixed naming styles and read patterns. Make them consistent:

- enablePixOnrampMaintenanceWarning replaces the noun-shaped
  pixBrazilOnrampMaintenance so it reads like its true siblings
  (enableFullMaintenance, enableMaintenanceBanner): verb-first, true = the
  maintenance behavior is ON. The config header now documents the convention
  (enable<Behavior> vs disable<Feature>) so new flags can't reintroduce the
  ambiguity.
- drop the lone isPixBrazilOnrampUnderMaintenance() getter and read the flag
  inline like every other flag in the file. The shared copy constant already
  de-dupes the only thing worth sharing; each surface's context check
  (pix-add method / country BR) is legitimately local.
- PIX_ONRAMP_MAINTENANCE_COPY replaces PIX_BRAZIL_ONRAMP_MAINTENANCE — drops
  the redundant "Brazil" (PIX is Brazil-only) and marks it as copy.
- read the config under one name everywhere (underMaintenanceConfig); three
  files had aliased the default import to maintenanceConfig.

The enable*/disable* polarity of the existing flags is deliberately left
untouched: flipping booleans across a prod kill-switch file is an outage risk
and out of scope here. The new header convention documents that polarity
rather than changing it.
@coderabbitai coderabbitai Bot added the enhancement New feature or request label Jun 23, 2026

@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: 1

🤖 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/app/`(mobile-ui)/qr-pay/__tests__/qr-pay-states.test.tsx:
- Around line 869-870: Convert the dynamic require() statement for the
underMaintenance.config to an ES6 import statement at the top of the
qr-pay-states.test.tsx file to comply with the
`@typescript-eslint/no-require-imports` ESLint rule. Add the import statement at
the file level, then replace the require() call on line 869 with direct usage of
the imported underMaintenanceConfig object, keeping the mutation of the
disabledPaymentProviders property and its cleanup within the test function scope
as it is currently structured.
🪄 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: e38c99bf-c945-4a3d-8eac-a9ba41b2d32d

📥 Commits

Reviewing files that changed from the base of the PR and between 235e285 and 79f1341.

📒 Files selected for processing (8)
  • src/app/(mobile-ui)/qr-pay/__tests__/qr-pay-states.test.tsx
  • src/app/(mobile-ui)/qr-pay/page.tsx
  • src/components/AddMoney/components/MantecaAddMoney.tsx
  • src/components/AddWithdraw/AddWithdrawCountriesList.tsx
  • src/components/AddWithdraw/__tests__/AddWithdrawCountriesList.test.tsx
  • src/components/Global/Banner/index.tsx
  • src/config/underMaintenance.config.ts
  • src/proxy.ts
✅ Files skipped from review due to trivial changes (2)
  • src/components/Global/Banner/index.tsx
  • src/proxy.ts

Comment on lines +869 to +870
const underMaintenanceConfig = require('@/config/underMaintenance.config').default
underMaintenanceConfig.disabledPaymentProviders = ['MANTECA']

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.

📐 Maintainability & Code Quality | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify test structure around the config mutation lines
sed -n '860,890p' src/app/\(mobile-ui\)/qr-pay/__tests__/qr-pay-states.test.tsx | cat -n

Repository: peanutprotocol/peanut-ui

Length of output: 1497


🏁 Script executed:

# Find the describe block containing this test to see if other tests need the same config
sed -n '850,920p' 'src/app/(mobile-ui)/qr-pay/__tests__/qr-pay-states.test.tsx' | cat -n

Repository: peanutprotocol/peanut-ui

Length of output: 3140


Convert require() to ES6 import to comply with ESLint rules.

The dynamic require() call on line 869 violates the project's @typescript-eslint/no-require-imports rule. Since the setup and cleanup are already properly scoped within the test function, add an ES6 import at the top of the file and keep the mutation and cleanup within the test:

🔧 Suggested refactor

At the top of the test file, add:

import underMaintenanceConfig from '`@/config/underMaintenance.config`'

Then replace line 869 with direct usage:

- const underMaintenanceConfig = require('`@/config/underMaintenance.config`').default
  underMaintenanceConfig.disabledPaymentProviders = ['MANTECA']

Keep the cleanup at the end of the test as-is (line 881).

🧰 Tools
🪛 ESLint

[error] 869-869: A require() style import is forbidden.

(@typescript-eslint/no-require-imports)

🤖 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/app/`(mobile-ui)/qr-pay/__tests__/qr-pay-states.test.tsx around lines 869
- 870, Convert the dynamic require() statement for the underMaintenance.config
to an ES6 import statement at the top of the qr-pay-states.test.tsx file to
comply with the `@typescript-eslint/no-require-imports` ESLint rule. Add the
import statement at the file level, then replace the require() call on line 869
with direct usage of the imported underMaintenanceConfig object, keeping the
mutation of the disabledPaymentProviders property and its cleanup within the
test function scope as it is currently structured.

Source: Linters/SAST tools

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.

1 participant