Skip to content

chore: sync main → dev#2064

Merged
kushagrasarathe merged 5 commits into
devfrom
main
May 19, 2026
Merged

chore: sync main → dev#2064
kushagrasarathe merged 5 commits into
devfrom
main

Conversation

@kushagrasarathe

Copy link
Copy Markdown
Contributor

Summary

kushagrasarathe and others added 5 commits May 19, 2026 14:35
Users with Bridge KYC status 'incomplete' (needs TOS acceptance) were
shown a dead-end 'Your verification is under review' modal because
AddWithdrawCountriesList checked isUserBridgeKycUnderReview before
consulting the transfer readiness gate. The gate correctly identifies
TOS as the blocker via rails metadata, but was never reached.

Changes:
- Split isBridgeUnderReview into isBridgeUnderReview (genuinely under
  review) and isBridgeIncomplete (user needs to act)
- AddWithdrawCountriesList now checks the gate first — TOS modal opens
  for incomplete users, 'under review' only for genuinely reviewing
- Added BridgeTosStep and InitiateKycModal to the country list view
- Updated useBridgeTransferReadiness to skip enrollment for incomplete
- Updated LimitsPageView and useHomeCarouselCTAs for the new flag
- Extract checkBridgeGate() helper — gate-check + under-review block
  was duplicated in handleAddMethodClick and handleWithdrawMethodClick
- Hoist InitiateKycModal, BridgeTosStep, SumsubKycModals into
  sharedModals fragment — rendered once instead of duplicated in
  form and list views
- Fix BridgeTosStep onComplete in list view: was a no-op (just
  hideTos). Now stores the interrupted method click in a ref and
  replays it after TOS acceptance. Form view falls back to
  formRef.current?.handleSubmit() as before.
- handleFormSubmit now checks isUserBridgeKycUnderReview after the gate
  check — prevents erroneously initiating sumsub for users whose bridge
  KYC is genuinely under review (reachable via deep-link or back nav)
- add explicit regression test for the main bug scenario: bridge
  incomplete + tos needed → gate returns accept_tos
fix: check transfer readiness gate before 'under review' modal
@vercel

vercel Bot commented May 19, 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 May 19, 2026 10:59am

Request Review

@coderabbitai

coderabbitai Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 225ed409-c997-4245-b54f-761607a3a975

📥 Commits

Reviewing files that changed from the base of the PR and between b7fed29 and a4dc842.

📒 Files selected for processing (7)
  • src/components/AddWithdraw/AddWithdrawCountriesList.tsx
  • src/features/limits/views/LimitsPageView.tsx
  • src/hooks/__tests__/useBridgeTransferReadiness.test.ts
  • src/hooks/useBridgeTransferReadiness.ts
  • src/hooks/useHomeCarouselCTAs.tsx
  • src/hooks/useKycStatus.tsx
  • src/hooks/useUnifiedKycStatus.ts

Walkthrough

The PR refines bridge KYC status tracking by splitting isBridgeUnderReview and isBridgeIncomplete states, exposing this new flag through the KYC hooks, then cascading it through bridge transfer readiness logic, UI component consumers, and AddWithdraw's gating callbacks and modal rendering.

Changes

Bridge KYC State Refinement

Layer / File(s) Summary
Core KYC state infrastructure
src/hooks/useUnifiedKycStatus.ts, src/hooks/useKycStatus.tsx
useUnifiedKycStatus introduces separate isBridgeUnderReview and isBridgeIncomplete memoized flags and updates isKycInProgress to depend on both bridge states; useKycStatus wrapper destructures and exposes isUserBridgeKycIncomplete to downstream consumers.
Bridge transfer readiness gate logic
src/hooks/useBridgeTransferReadiness.ts, src/hooks/__tests__/useBridgeTransferReadiness.test.ts
useBridgeTransferReadiness reads the new isUserBridgeKycIncomplete flag and refines the "needs_enrollment" gate condition to require bridge KYC not be incomplete; tests cover gate resolution when sumsub is approved with an incomplete bridge, and when bridge TOS is needed while incomplete.
UI consumers of bridge KYC state
src/features/limits/views/LimitsPageView.tsx, src/hooks/useHomeCarouselCTAs.tsx
LimitsPageView broadens the "bridge KYC pending" condition to include both isUserBridgeKycUnderReview and isUserBridgeKycIncomplete; useHomeCarouselCTAs withholds the kyc-prompt CTA when either bridge KYC state is true.
AddWithdraw gating callback and modal refactoring
src/components/AddWithdraw/AddWithdrawCountriesList.tsx
AddWithdrawCountriesList introduces checkBridgeGate callback to centralize bridge action gating, blocks form submission when bridge KYC is under review with a modal, routes withdraw and add method click handlers through the gate callback, and consolidates InitiateKycModal, BridgeTosStep, and SumsubKycModals into a shared sharedModals block rendered in both form and list views.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • peanutprotocol/peanut-ui#2063: Both PRs modify the same bridge/KYC gating flow—splitting isBridgeUnderReview vs isBridgeIncomplete, adding isUserBridgeKycIncomplete, and refactoring AddWithdrawCountriesList to route clicks through checkBridgeGate/TOS replay and adjust LimitsPageView, useBridgeTransferReadiness, and useHomeCarouselCTAs accordingly.
  • peanutprotocol/peanut-ui#2025: The main PR updates bridge gating/"needsBridgeTos" flow based on expanded bridge KYC readiness flags, which would rely on the same Bridge ToS requirement detection that useBridgeTosStatus corrects by skipping ENABLED rails—so the changes are tied to the bridge ToS gating behavior.

Suggested reviewers

  • jjramirezn
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'chore: sync main → dev' is unrelated to the actual changeset, which fixes KYC gate checking logic for Bridge transfers and does not involve syncing branches. Update the title to reflect the main changes, such as 'fix: check bridge transfer readiness gate before under-review modal' or similar.
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description is related to the changeset, clearly summarizing the KYC gate checking fix and the handling of incomplete vs. under-review states.
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 and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

Code-analysis diff

Painscore total: 5716.29 → 5718.73 (+2.44)
Findings: 0 net (+27 new, -27 resolved)

🆕 New findings (27)

  • critical complexity — src/components/AddWithdraw/AddWithdrawCountriesList.tsx — CC 109, MI 56.8, SLOC 323
  • critical complexity — src/hooks/useHomeCarouselCTAs.tsx — CC 51, MI 58.83, SLOC 227
  • high hotspot — src/hooks/useHomeCarouselCTAs.tsx — 37 commits, +462/-323 lines since 6 months ago
  • high hotspot — src/components/AddWithdraw/AddWithdrawCountriesList.tsx — 31 commits, +493/-361 lines since 6 months ago
  • medium high-mdd — src/hooks/useHomeCarouselCTAs.tsx:72 — useHomeCarouselCTAs: MDD 135.9 (uses across many lines from declarations)
  • medium high-mdd — src/components/AddWithdraw/AddWithdrawCountriesList.tsx:46 — AddWithdrawCountriesList: MDD 127.0 (uses across many lines from declarations)
  • medium high-mdd — src/hooks/useHomeCarouselCTAs.tsx:128 — : MDD 89.4 (uses across many lines from declarations)
  • medium high-dlt — src/components/AddWithdraw/AddWithdrawCountriesList.tsx:46 — AddWithdrawCountriesList: DLT 59 (calls 59 distinct functions — high context load)
  • medium high-mdd — src/features/limits/views/LimitsPageView.tsx:22 — LimitsPageView: MDD 35.2 (uses across many lines from declarations)
  • medium high-mdd — src/hooks/useBridgeTransferReadiness.ts:25 — useBridgeTransferReadiness: MDD 35.0 (uses across many lines from declarations)
  • medium complexity — src/features/limits/views/LimitsPageView.tsx — CC 26, MI 65.49, SLOC 82
  • medium complexity — src/hooks/useUnifiedKycStatus.ts — CC 26, MI 70.11, SLOC 85
  • medium method-complexity — src/hooks/useHomeCarouselCTAs.tsx:128 — CC 24 SLOC 84
  • medium high-mdd — src/hooks/useUnifiedKycStatus.ts:12 — useUnifiedKycStatus: MDD 24.3 (uses across many lines from declarations)
  • medium method-complexity — src/components/AddWithdraw/AddWithdrawCountriesList.tsx:46 — CC 20 SLOC 113
  • medium complexity — src/hooks/useBridgeTransferReadiness.ts — CC 17, MI 61.05, SLOC 47
  • medium react-effect-derives-state — src/components/AddWithdraw/AddWithdrawCountriesList.tsx:90 — small useEffect that only sets state from deps
  • low high-mdd — src/components/AddWithdraw/AddWithdrawCountriesList.tsx:380 — renderPaymentMethods: MDD 19.8 (uses across many lines from declarations)
  • low high-mdd — src/components/AddWithdraw/AddWithdrawCountriesList.tsx:389 — : MDD 19.8 (uses across many lines from declarations)
  • low high-mdd — src/features/limits/views/LimitsPageView.tsx:171 — LockedRegionsList: MDD 19.6 (uses across many lines from declarations)

…and 7 more.

✅ Resolved (27)

  • src/components/AddWithdraw/AddWithdrawCountriesList.tsx — CC 101, MI 56.73, SLOC 290
  • src/hooks/useHomeCarouselCTAs.tsx — CC 50, MI 58.9, SLOC 226
  • src/hooks/useHomeCarouselCTAs.tsx — 36 commits, +458/-321 lines since 6 months ago
  • src/hooks/useHomeCarouselCTAs.tsx:72 — useHomeCarouselCTAs: MDD 135.4 (uses across many lines from declarations)
  • src/components/AddWithdraw/AddWithdrawCountriesList.tsx:46 — AddWithdrawCountriesList: MDD 118.2 (uses across many lines from declarations)
  • src/hooks/useHomeCarouselCTAs.tsx:127 — : MDD 89.4 (uses across many lines from declarations)
  • src/components/AddWithdraw/AddWithdrawCountriesList.tsx:46 — AddWithdrawCountriesList: DLT 56 (calls 56 distinct functions — high context load)
  • src/features/limits/views/LimitsPageView.tsx:22 — LimitsPageView: MDD 34.0 (uses across many lines from declarations)
  • src/components/AddWithdraw/AddWithdrawCountriesList.tsx — 28 commits, +366/-267 lines since 6 months ago
  • src/features/limits/views/LimitsPageView.tsx — CC 25, MI 65.66, SLOC 81
  • src/hooks/useUnifiedKycStatus.ts — CC 25, MI 70.21, SLOC 80
  • src/hooks/useUnifiedKycStatus.ts:12 — useUnifiedKycStatus: MDD 24.9 (uses across many lines from declarations)
  • src/hooks/useBridgeTransferReadiness.ts:25 — useBridgeTransferReadiness: MDD 23.0 (uses across many lines from declarations)
  • src/hooks/useHomeCarouselCTAs.tsx:127 — CC 23 SLOC 84
  • src/components/AddWithdraw/AddWithdrawCountriesList.tsx:46 — CC 20 SLOC 107
  • src/hooks/useBridgeTransferReadiness.ts — CC 16, MI 61.4, SLOC 46
  • src/components/AddWithdraw/AddWithdrawCountriesList.tsx:87 — small useEffect that only sets state from deps
  • src/components/AddWithdraw/AddWithdrawCountriesList.tsx:347 — renderPaymentMethods: MDD 19.8 (uses across many lines from declarations)
  • src/components/AddWithdraw/AddWithdrawCountriesList.tsx:356 — : MDD 19.8 (uses across many lines from declarations)
  • src/features/limits/views/LimitsPageView.tsx:168 — LockedRegionsList: MDD 19.6 (uses across many lines from declarations)

…and 7 more.

📈 Painscore deltas (top movers)

File Before After Δ
src/components/AddWithdraw/AddWithdrawCountriesList.tsx 16.5 17.2 +0.7
src/hooks/useBridgeTransferReadiness.ts 6.2 6.7 +0.6

@github-actions

Copy link
Copy Markdown
Contributor

🧪 UI test report — ✅ all green

Suites

  • unit: 1083 ran, 0 failed, 0 skipped, 19.9s

📊 Coverage (unit)

metric %
statements 46.9%
branches 28.1%
functions 28.9%
lines 46.7%
⏱ 10 slowest test cases
time test
0.4s src/app/actions/__tests__/api-headers.test.ts › should include Content-Type in updateUserById
0.3s src/app/actions/__tests__/api-headers-extended.test.ts › should not include apiKey in updateUserById body
0.3s src/app/(mobile-ui)/add-money/__tests__/add-money-states.test.tsx › loaded EVM deposit shows QR code and address
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle valid 9-digit US account
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 too long for US account
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle maximum length (17 digits) US account
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle invalid ETH address (invalid characters)
0.1s src/components/Global/GeneralRecipientInput/__tests__/GeneralRecipientInput.test.tsx › should handle valid ETH address in lowercase
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`.

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.

2 participants