Skip to content

Peanut wallet sync #2 #1427

Merged
Hugo0 merged 12 commits intopeanut-wallet-devfrom
peanut-wallet
Nov 8, 2025
Merged

Peanut wallet sync #2 #1427
Hugo0 merged 12 commits intopeanut-wallet-devfrom
peanut-wallet

Conversation

@Hugo0
Copy link
Contributor

@Hugo0 Hugo0 commented Nov 8, 2025

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 8, 2025

Walkthrough

This PR removes the Add Money Prompt modal logic, deletes multiple Peanut API routes and related claim-link submission functions, introduces a new QrCodeContext for QR scanner state management, removes user search and public transaction history features, and updates various UI components with modified props and simplified logic.

Changes

Cohort / File(s) Summary
Mobile Home Page
src/app/(mobile-ui)/home/page.tsx
Removes showAddMoneyPromptModal state, related effects, and rendering; simplifies balance-related modal logic by removing Add Money Prompt references.
QR Pay Error Handling
src/app/(mobile-ui)/qr-pay/page.tsx
Adds special-case error handling for PIX qrType in MANTECA flow; updates useEffect dependency to include qrType; redesigns errorInitiatingPayment UI with leading alert icon.
Disabled Peanut API Routes
src/app/api/peanut/get-attachment-info/route.ts
POST handler short-circuited to always return 405; original attachment-fetching logic commented out behind future /send-link migration note.
Removed Peanut API Routes
src/app/api/peanut/submit-claim-link/confirm/route.ts, src/app/api/peanut/submit-claim-link/init/route.ts, src/app/api/peanut/submit-direct-transfer/route.ts
Deleted Next.js API route handlers that previously handled claim-link submission, initialization, and direct-transfer flows.
Create Link Hook
src/components/Create/useCreateLink.tsx
Removed public functions submitClaimLinkInit and submitClaimLinkConfirm; removed related imports (PEANUT_API_URL, fetchWithSentry, captureException).
Balance Warning Modal & Slider
src/components/Global/BalanceWarningModal/index.tsx, src/components/Slider/index.tsx
Updated modal copy from "High Balance Warning" to "High Balance" with new preface paragraph; added optional title prop to Slider component.
QR Context & State Management
src/context/QrCodeContext.tsx, src/context/contextProvider.tsx, src/components/Global/DirectSendQR/index.tsx
Introduced new QrCodeContext for managing QR scanner open state; replaced local useState in DirectSendQR with context-based state; integrated QrCodeProvider into ContextProvider tree.
QR Icon Props
src/components/Global/Icons/qr-code.tsx
Updated SVG component to spread all remaining props ({...props}) enabling external SVGProps application.
Carousel CTA Props & Integration
src/components/Home/HomeCarouselCTA/CarouselCTA.tsx, src/components/Home/HomeCarouselCTA/index.tsx, src/hooks/useHomeCarouselCTAs.tsx
Added optional iconSize prop to CarouselCTA; passes iconSize={16} from parent; added QR code CTA with iconSize when Bridge or Manteca KYC approved.
History & Transaction Features
src/components/Home/HomeHistory.tsx, src/hooks/useTransactionHistory.ts
Removed isPublic prop from HomeHistory and hardcoded mode to 'latest'/limit to 5; removed 'public' mode from useTransactionHistory hook signature; always include Authorization header.
User Search Removal
src/hooks/useUserSearch.ts, src/services/users.ts
Deleted entire useUserSearch hook; removed search() method from usersApi object.
Public Profile
src/components/Profile/components/PublicProfile.tsx
Simplified HomeHistory call by removing isPublic={false} prop; now passes only username={username}.
Payment Form Button Text
src/components/Payment/PaymentForm/index.tsx
Changes button text from "Pay" to "Choose payment method" when showRequestPotInitialView is true.
Login Redirects
src/hooks/useLogin.tsx
Replaced router.push() with window.location.assign() for redirect_uri and localStorage redirect branches; maintains router.push('/home') for else path.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

  • Removed API route verification: Confirm no remaining client-side or server-side callers exist for deleted Peanut endpoints (submit-claim-link init/confirm, submit-direct-transfer, get-attachment-info short-circuit).
  • QrCodeContext integration: Verify proper provider wrapping hierarchy and all intended components successfully access the context hook.
  • User search removal impact: Check for any remaining references or UI components depending on useUserSearch or usersApi.search.
  • Transaction history public mode removal: Confirm all public/view-only history consumption has been properly migrated or removed.
  • HomeHistory prop changes: Validate that PublicProfile and other consumers correctly handle the removed isPublic prop.
  • Navigation redirect behavior: Test window.location.assign() redirects vs. router.push() to ensure proper history and loading state handling.

Possibly related PRs

Suggested labels

enhancement, Being worked on

Suggested reviewers

  • jjramirezn
  • kushagrasarathe

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 2 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'Peanut wallet sync #2' is vague and generic, using a broad term 'sync' without conveying specific information about the changeset's primary purpose. Replace with a more descriptive title that clearly indicates the main changes, e.g., 'Remove deprecated Peanut claim-link and user search APIs' or 'Refactor QR code context and payment flows'.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess whether the description relates to the changeset. Add a pull request description that explains the objectives, motivation, and scope of changes to help reviewers understand the purpose of these modifications.
✨ 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 peanut-wallet

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

@coderabbitai coderabbitai bot added Being worked on Being worked on enhancement New feature or request labels Nov 8, 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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/hooks/useHomeCarouselCTAs.tsx (1)

103-112: Add missing dependencies to useCallback.

The generateCarouselCTAs callback uses setIsQRScannerOpen and isUserMantecaKycApproved but they are not included in the dependency array. This could lead to stale closure issues.

Apply this diff:

     }, [
         showReminderBanner,
         isPermissionDenied,
         isUserKycApproved,
         isUserBridgeKycUnderReview,
+        isUserMantecaKycApproved,
+        setIsQRScannerOpen,
         router,
         requestPermission,
         afterPermissionAttempt,
         snoozeReminderBanner,
     ])
🧹 Nitpick comments (3)
src/app/(mobile-ui)/home/page.tsx (1)

22-22: Optional: Remove unused import.

AddMoneyPromptModal is imported but no longer used after the modal was disabled. Consider removing this import to keep the codebase clean.

-import AddMoneyPromptModal from '@/components/Home/AddMoneyPromptModal'
src/hooks/useHomeCarouselCTAs.tsx (1)

40-61: Simplify the KYC approval check.

The condition isUserKycApproved || isUserMantecaKycApproved is redundant because isUserKycApproved is computed as isUserBridgeKycApproved || isUserMantecaKycApproved in the useKycStatus hook. You can simplify this to just isUserKycApproved.

Apply this diff:

-        if (isUserKycApproved || isUserMantecaKycApproved) {
+        if (isUserKycApproved) {
src/app/api/peanut/get-attachment-info/route.ts (1)

11-50: Consider removing commented-out code in favor of version control.

This ~40-line block of commented code can be recovered from git history when needed. If the re-enablement mentioned in the TODO is planned for the near term (within weeks), keeping it temporarily may be acceptable. However, for longer-term changes, removing it would improve code cleanliness.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c64475c and 6c8ac2b.

📒 Files selected for processing (23)
  • src/app/(mobile-ui)/home/page.tsx (2 hunks)
  • src/app/(mobile-ui)/qr-pay/page.tsx (2 hunks)
  • src/app/api/peanut/get-attachment-info/route.ts (2 hunks)
  • src/app/api/peanut/submit-claim-link/confirm/route.ts (0 hunks)
  • src/app/api/peanut/submit-claim-link/init/route.ts (0 hunks)
  • src/app/api/peanut/submit-direct-transfer/route.ts (0 hunks)
  • src/components/Create/useCreateLink.tsx (1 hunks)
  • src/components/Global/BalanceWarningModal/index.tsx (1 hunks)
  • src/components/Global/DirectSendQR/index.tsx (2 hunks)
  • src/components/Global/Icons/qr-code.tsx (1 hunks)
  • src/components/Home/HomeCarouselCTA/CarouselCTA.tsx (3 hunks)
  • src/components/Home/HomeCarouselCTA/index.tsx (1 hunks)
  • src/components/Home/HomeHistory.tsx (5 hunks)
  • src/components/Payment/PaymentForm/index.tsx (1 hunks)
  • src/components/Profile/components/PublicProfile.tsx (1 hunks)
  • src/components/Slider/index.tsx (2 hunks)
  • src/context/QrCodeContext.tsx (1 hunks)
  • src/context/contextProvider.tsx (2 hunks)
  • src/hooks/useHomeCarouselCTAs.tsx (3 hunks)
  • src/hooks/useLogin.tsx (1 hunks)
  • src/hooks/useTransactionHistory.ts (2 hunks)
  • src/hooks/useUserSearch.ts (0 hunks)
  • src/services/users.ts (0 hunks)
💤 Files with no reviewable changes (5)
  • src/hooks/useUserSearch.ts
  • src/app/api/peanut/submit-claim-link/init/route.ts
  • src/services/users.ts
  • src/app/api/peanut/submit-claim-link/confirm/route.ts
  • src/app/api/peanut/submit-direct-transfer/route.ts
🧰 Additional context used
🧠 Learnings (40)
📓 Common learnings
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 1190
File: src/app/(mobile-ui)/qr-pay/page.tsx:156-176
Timestamp: 2025-09-08T03:13:09.111Z
Learning: In the peanut-ui mobile app, the `/qr-pay` route is only accessed through the DirectSendQR component which always includes the qrCode parameter in the URL when redirecting users to the QR pay page.
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 1190
File: src/app/(mobile-ui)/qr-pay/page.tsx:156-176
Timestamp: 2025-09-08T03:13:09.111Z
Learning: In the peanut-ui mobile app, the `/qr-pay` route is only accessed through the DirectSendQR component which always includes the qrCode parameter in the URL when redirecting users to the QR pay page after scanning MERCADO_PAGO or PIX QR codes.
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1185
File: src/components/Claim/useClaimLink.tsx:14-0
Timestamp: 2025-09-05T07:31:11.396Z
Learning: In the peanut-ui codebase, `window.history.replaceState` is preferred over `router.replace` when immediate/synchronous URL parameter updates are required, as `router.replace` is asynchronous and doesn't guarantee instant URL changes that subsequent code can rely on. This pattern is used consistently across usePaymentInitiator.ts, Confirm.payment.view.tsx, and useClaimLink.tsx.
Learnt from: Hugo0
Repo: peanutprotocol/peanut-ui PR: 942
File: src/components/AddMoney/consts/index.ts:2151-2162
Timestamp: 2025-06-30T10:44:08.048Z
Learning: Hugo0 often agrees with refactoring suggestions but defers implementation due to time constraints, preferring to track improvements as follow-up issues when they're part of larger architectural changes.
📚 Learning: 2024-10-07T15:25:45.170Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 422
File: src/components/Request/Pay/Views/Initial.view.tsx:76-78
Timestamp: 2024-10-07T15:25:45.170Z
Learning: In `src/components/Request/Pay/Views/Initial.view.tsx`, both `txFee` and `utils.formatTokenAmount(...)` return strings, ensuring that `calculatedFee` consistently returns a string without the need for additional type conversion.

Applied to files:

  • src/components/Payment/PaymentForm/index.tsx
  • src/app/(mobile-ui)/qr-pay/page.tsx
📚 Learning: 2024-10-08T20:13:42.967Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 422
File: src/components/Request/Pay/Pay.consts.ts:34-34
Timestamp: 2024-10-08T20:13:42.967Z
Learning: In `src/components/Request/Pay` components, the `tokenPrice` property in the `IPayScreenProps` interface is only relevant to these views. Other components using `IPayScreenProps` do not need to handle `tokenPriceData` when it's updated in these components.

Applied to files:

  • src/components/Payment/PaymentForm/index.tsx
📚 Learning: 2024-10-07T15:28:25.280Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 422
File: src/components/Request/Pay/Views/Initial.view.tsx:76-78
Timestamp: 2024-10-07T15:28:25.280Z
Learning: In `src/components/Request/Pay/Views/Initial.view.tsx`, both `txFee` and `utils.formatTokenAmount(estimatedGasCost, 3)` return strings, ensuring consistent return types for `calculatedFee`.

Applied to files:

  • src/components/Payment/PaymentForm/index.tsx
  • src/app/(mobile-ui)/qr-pay/page.tsx
📚 Learning: 2024-10-08T20:13:42.967Z
Learnt from: Hugo0
Repo: peanutprotocol/peanut-ui PR: 413
File: src/components/Request/Pay/Views/Initial.view.tsx:71-72
Timestamp: 2024-10-08T20:13:42.967Z
Learning: In `src/components/Request/Pay/Views/Initial.view.tsx`, it's acceptable to use the `!` operator in TypeScript to assert that `selectedTokenData` is not `null` or `undefined`, and potential runtime errors from accessing its properties without checks can be disregarded.

Applied to files:

  • src/components/Payment/PaymentForm/index.tsx
📚 Learning: 2024-12-11T10:13:22.806Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 564
File: src/components/Request/Pay/Views/Initial.view.tsx:430-430
Timestamp: 2024-12-11T10:13:22.806Z
Learning: In the React TypeScript file `src/components/Request/Pay/Views/Initial.view.tsx`, when reviewing the `InitialView` component, do not flag potential issues with using non-null assertion `!` on the `slippagePercentage` variable, as handling undefined values in this context is considered out of scope.

Applied to files:

  • src/components/Payment/PaymentForm/index.tsx
📚 Learning: 2024-10-22T18:10:56.955Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 469
File: src/app/request/pay/page.tsx:25-25
Timestamp: 2024-10-22T18:10:56.955Z
Learning: In the `src/app/request/pay/page.tsx` file, the `PreviewType` enum values are strings, so when adding `previewType` to `URLSearchParams`, there's no need to convert them to strings.

Applied to files:

  • src/components/Payment/PaymentForm/index.tsx
📚 Learning: 2025-08-22T07:28:32.281Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1104
File: src/components/Payment/PaymentForm/index.tsx:522-545
Timestamp: 2025-08-22T07:28:32.281Z
Learning: In `src/components/Payment/PaymentForm/index.tsx`, the `handleCompleteDaimoPayment` function is only for updating payment status in the backend after a successful Daimo payment. Payment success/failure is handled by Daimo itself, so try/catch error handling and error display are not needed for backend sync failures - users shouldn't see errors if payment succeeded but database update failed.

Applied to files:

  • src/components/Payment/PaymentForm/index.tsx
  • src/app/(mobile-ui)/qr-pay/page.tsx
📚 Learning: 2025-09-18T09:30:42.901Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 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/components/Payment/PaymentForm/index.tsx
  • src/app/(mobile-ui)/home/page.tsx
  • src/components/Global/DirectSendQR/index.tsx
  • src/app/(mobile-ui)/qr-pay/page.tsx
  • src/components/Home/HomeHistory.tsx
📚 Learning: 2025-06-18T19:56:55.443Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 919
File: src/components/Withdraw/views/Initial.withdraw.view.tsx:87-87
Timestamp: 2025-06-18T19:56:55.443Z
Learning: In withdraw flows for Peanut Wallet, the PeanutActionDetailsCard should always display "USDC" as the token symbol because it shows the amount being withdrawn from the Peanut Wallet (which holds USDC), regardless of the destination token/chain selected by the user. The TokenSelector is used for choosing the withdrawal destination, not the source display.

Applied to files:

  • src/components/Payment/PaymentForm/index.tsx
📚 Learning: 2024-10-07T13:42:07.299Z
Learnt from: Hugo0
Repo: peanutprotocol/peanut-ui PR: 422
File: src/components/Request/Pay/Pay.tsx:113-123
Timestamp: 2024-10-07T13:42:07.299Z
Learning: In the `PayRequestLink` component (`src/components/Request/Pay/Pay.tsx`), when resolving ENS names, handle errors by displaying an appropriate error message to the user if the ENS cannot be resolved.

Applied to files:

  • src/components/Payment/PaymentForm/index.tsx
  • src/app/(mobile-ui)/qr-pay/page.tsx
📚 Learning: 2024-10-23T09:38:27.670Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 469
File: src/app/request/pay/page.tsx:32-64
Timestamp: 2024-10-23T09:38:27.670Z
Learning: In `src/app/request/pay/page.tsx`, if `linkRes` is not OK in the `generateMetadata` function, the desired behavior is to use the standard title and preview image without throwing an error.

Applied to files:

  • src/components/Payment/PaymentForm/index.tsx
  • src/app/(mobile-ui)/qr-pay/page.tsx
  • src/components/Create/useCreateLink.tsx
📚 Learning: 2025-11-04T17:47:06.328Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1396
File: src/app/(mobile-ui)/home/page.tsx:295-304
Timestamp: 2025-11-04T17:47:06.328Z
Learning: In src/app/(mobile-ui)/home/page.tsx, when closing the KycCompletedModal, updateUserById is called without awaiting to provide instant feedback to the user. This fire-and-forget pattern for modal dismissals and UI preference updates is intentional and consistent across the codebase—user experience with instant UI feedback takes priority over waiting for backend sync operations.

Applied to files:

  • src/app/(mobile-ui)/home/page.tsx
  • src/components/Home/HomeHistory.tsx
📚 Learning: 2024-10-25T11:33:46.776Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 484
File: src/components/Cashout/Components/Initial.view.tsx:273-274
Timestamp: 2024-10-25T11:33:46.776Z
Learning: In the `InitialCashoutView` component (`src/components/Cashout/Components/Initial.view.tsx`), linked bank accounts should not generate error states, and the `ValidatedInput` component will clear any error messages if needed. Therefore, it's unnecessary to manually clear the error state when selecting or clearing linked bank accounts.

Applied to files:

  • src/app/(mobile-ui)/home/page.tsx
  • src/components/Create/useCreateLink.tsx
📚 Learning: 2025-10-29T11:27:59.248Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1368
File: src/components/Common/ActionList.tsx:109-111
Timestamp: 2025-10-29T11:27:59.248Z
Learning: In `src/components/Common/ActionList.tsx`, the `balance` from `useWallet()` hook is always in USDC (as a formatted string), making it directly comparable to USD amounts without conversion. The comparison `Number(balance) >= amountInUsd` is intentional and correct.

Applied to files:

  • src/app/(mobile-ui)/home/page.tsx
  • src/components/Global/BalanceWarningModal/index.tsx
📚 Learning: 2025-11-07T11:51:58.861Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1419
File: src/components/Global/BalanceWarningModal/index.tsx:94-94
Timestamp: 2025-11-07T11:51:58.861Z
Learning: In `src/components/Global/BalanceWarningModal/index.tsx`, the casual and congratulatory phrase "You're rich! Congrats on having a high balance." is intentional and by design.

Applied to files:

  • src/app/(mobile-ui)/home/page.tsx
  • src/components/Global/BalanceWarningModal/index.tsx
📚 Learning: 2025-05-22T15:38:48.586Z
Learnt from: kushagrasarathe
Repo: peanutprotocol/peanut-ui PR: 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)/home/page.tsx
  • src/context/contextProvider.tsx
📚 Learning: 2025-08-26T15:25:53.328Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1132
File: src/app/[...recipient]/client.tsx:394-397
Timestamp: 2025-08-26T15:25:53.328Z
Learning: In `src/components/Common/ActionListDaimoPayButton.tsx`, the `handleCompleteDaimoPayment` function should not display error messages to users when DB update fails because the Daimo payment itself has succeeded - showing errors would be confusing since the payment was successful.

Applied to files:

  • src/app/(mobile-ui)/home/page.tsx
  • src/app/(mobile-ui)/qr-pay/page.tsx
📚 Learning: 2024-10-29T12:20:47.207Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 495
File: src/components/Create/Link/Input.view.tsx:244-248
Timestamp: 2024-10-29T12:20:47.207Z
Learning: In the `TokenAmountInput` component within `src/components/Global/TokenAmountInput/index.tsx`, when `balance` is undefined, the `maxValue` prop should be set to an empty string `''`.

Applied to files:

  • src/app/(mobile-ui)/home/page.tsx
  • src/components/Global/BalanceWarningModal/index.tsx
📚 Learning: 2025-07-07T20:22:11.092Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 958
File: src/app/actions/tokens.ts:266-266
Timestamp: 2025-07-07T20:22:11.092Z
Learning: In `src/app/actions/tokens.ts`, within the `fetchWalletBalances` function, using the non-null assertion operator `!` on `process.env.MOBULA_API_KEY!` is intentional and correct, and should not be flagged for replacement with explicit validation.

Applied to files:

  • src/app/(mobile-ui)/home/page.tsx
📚 Learning: 2024-12-02T17:19:18.532Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 551
File: src/components/Request/Create/Views/Initial.view.tsx:151-156
Timestamp: 2024-12-02T17:19:18.532Z
Learning: In the `InitialView` component at `src/components/Request/Create/Views/Initial.view.tsx`, when setting the default chain and token in the `useEffect` triggered by `isPeanutWallet`, it's acceptable to omit the setters from the dependency array and not include additional error handling for invalid defaults.

Applied to files:

  • src/app/(mobile-ui)/home/page.tsx
  • src/components/Create/useCreateLink.tsx
📚 Learning: 2025-10-15T06:45:22.055Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1241
File: src/components/ForceIOSPWAInstall/index.tsx:6-51
Timestamp: 2025-10-15T06:45:22.055Z
Learning: In the ForceIOSPWAInstall component (src/components/ForceIOSPWAInstall/index.tsx), the blocking behavior without a skip/dismiss option is intentional by design to force PWA installation on iOS devices.

Applied to files:

  • src/app/(mobile-ui)/home/page.tsx
📚 Learning: 2024-10-08T20:13:42.967Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 413
File: src/context/tokenSelector.context.tsx:118-123
Timestamp: 2024-10-08T20:13:42.967Z
Learning: In the `TokenContextProvider` component within `src/context/tokenSelector.context.tsx`, in the TypeScript React application, when data changes and before calling `fetchAndSetTokenPrice`, it is necessary to reset `selectedTokenData`, `selectedTokenPrice`, `selectedTokenDecimals`, and `inputDenomination` to discard stale data.

Applied to files:

  • src/context/contextProvider.tsx
  • src/components/Global/DirectSendQR/index.tsx
📚 Learning: 2025-09-08T03:13:09.111Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 1190
File: src/app/(mobile-ui)/qr-pay/page.tsx:156-176
Timestamp: 2025-09-08T03:13:09.111Z
Learning: In the peanut-ui mobile app, the `/qr-pay` route is only accessed through the DirectSendQR component which always includes the qrCode parameter in the URL when redirecting users to the QR pay page.

Applied to files:

  • src/components/Global/DirectSendQR/index.tsx
  • src/app/(mobile-ui)/qr-pay/page.tsx
📚 Learning: 2025-09-08T03:13:09.111Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 1190
File: src/app/(mobile-ui)/qr-pay/page.tsx:156-176
Timestamp: 2025-09-08T03:13:09.111Z
Learning: In the peanut-ui mobile app, the `/qr-pay` route is only accessed through the DirectSendQR component which always includes the qrCode parameter in the URL when redirecting users to the QR pay page after scanning MERCADO_PAGO or PIX QR codes.

Applied to files:

  • src/components/Global/DirectSendQR/index.tsx
  • src/app/(mobile-ui)/qr-pay/page.tsx
📚 Learning: 2024-11-18T21:36:11.486Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 535
File: src/components/Claim/Claim.tsx:142-146
Timestamp: 2024-11-18T21:36:11.486Z
Learning: In `src/components/Claim/Claim.tsx`, external calls like token price fetching and cross-chain details retrieval are already encapsulated within existing `try...catch` blocks, so additional error handling may be unnecessary.

Applied to files:

  • src/app/(mobile-ui)/qr-pay/page.tsx
  • src/components/Create/useCreateLink.tsx
📚 Learning: 2024-10-07T13:42:00.443Z
Learnt from: Hugo0
Repo: peanutprotocol/peanut-ui PR: 422
File: src/components/Request/Pay/Pay.tsx:103-111
Timestamp: 2024-10-07T13:42:00.443Z
Learning: When the token price cannot be fetched in `src/components/Request/Pay/Pay.tsx` within the `PayRequestLink` component, set `tokenPriceData.price` to 0 to ensure the UI remains functional. Since Squid uses their own price engine for x-chain fulfillment transactions, this approach will not affect the transaction computation.

Applied to files:

  • src/app/(mobile-ui)/qr-pay/page.tsx
📚 Learning: 2025-09-08T03:11:00.114Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 1190
File: src/app/(mobile-ui)/qr-pay/page.tsx:31-41
Timestamp: 2025-09-08T03:11:00.114Z
Learning: In QR payment flows, the `createPayment` API call for payment tracking can be non-awaited when called after successful transaction execution, as it's a non-blocking logging operation and doesn't affect the user's success state.

Applied to files:

  • src/app/(mobile-ui)/qr-pay/page.tsx
📚 Learning: 2024-10-29T16:06:38.812Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 495
File: src/components/Create/useCreateLink.tsx:647-657
Timestamp: 2024-10-29T16:06:38.812Z
Learning: In the React code for `useCreateLink` in `src/components/Create/useCreateLink.tsx`, the `switchNetwork` function used within `useCallback` hooks is stable and does not need to be included in the dependency arrays.

Applied to files:

  • src/components/Create/useCreateLink.tsx
  • src/hooks/useLogin.tsx
📚 Learning: 2024-10-18T01:51:35.247Z
Learnt from: Hugo0
Repo: peanutprotocol/peanut-ui PR: 458
File: src/components/Offramp/Confirm.view.tsx:141-141
Timestamp: 2024-10-18T01:51:35.247Z
Learning: The `handleConfirm` function in `src/components/Create/Link/Confirm.view.tsx` is separate from the one in `src/components/Offramp/Confirm.view.tsx` and does not need to be renamed when refactoring `handleConfirm` in `src/components/Offramp/Confirm.view.tsx`.

Applied to files:

  • src/components/Create/useCreateLink.tsx
📚 Learning: 2025-07-24T13:26:10.290Z
Learnt from: Hugo0
Repo: peanutprotocol/peanut-ui PR: 1014
File: src/components/Claim/Link/Initial.view.tsx:413-413
Timestamp: 2025-07-24T13:26:10.290Z
Learning: In the peanut-ui repository, the change from `${SQUID_API_URL}/route` to `${SQUID_API_URL}/v2/route` in src/components/Claim/Link/Initial.view.tsx was a typo fix, not an API migration, as the codebase was already using Squid API v2.

Applied to files:

  • src/components/Create/useCreateLink.tsx
  • src/app/api/peanut/get-attachment-info/route.ts
  • src/hooks/useLogin.tsx
📚 Learning: 2025-09-05T07:31:11.396Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1185
File: src/components/Claim/useClaimLink.tsx:14-0
Timestamp: 2025-09-05T07:31:11.396Z
Learning: In the peanut-ui codebase, `window.history.replaceState` is preferred over `router.replace` when immediate/synchronous URL parameter updates are required, as `router.replace` is asynchronous and doesn't guarantee instant URL changes that subsequent code can rely on. This pattern is used consistently across usePaymentInitiator.ts, Confirm.payment.view.tsx, and useClaimLink.tsx.

Applied to files:

  • src/components/Create/useCreateLink.tsx
  • src/hooks/useLogin.tsx
📚 Learning: 2025-04-30T21:31:27.790Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 827
File: src/components/Claim/Link/Initial.view.tsx:120-126
Timestamp: 2025-04-30T21:31:27.790Z
Learning: The `sendLinksApi.claim` function in the Peanut Protocol UI accepts both username and wallet address as the first parameter.

Applied to files:

  • src/components/Create/useCreateLink.tsx
📚 Learning: 2025-01-16T13:14:40.363Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 631
File: src/components/Create/Create.tsx:108-112
Timestamp: 2025-01-16T13:14:40.363Z
Learning: In the Peanut UI codebase, the `resetTokenContextProvider` function from `tokenSelectorContext` is a stable function reference that doesn't change, so it doesn't need to be included in useEffect dependencies.

Applied to files:

  • src/components/Create/useCreateLink.tsx
📚 Learning: 2025-09-15T16:22:58.382Z
Learnt from: Hugo0
Repo: peanutprotocol/peanut-ui PR: 1190
File: src/services/manteca.ts:1-1
Timestamp: 2025-09-15T16:22:58.382Z
Learning: In the manteca service, PEANUT_API_KEY should not be imported in a module that's used by client-side components. The getPrices function that requires the API key should be moved to a server-only module to prevent exposing secrets in the client bundle.

Applied to files:

  • src/components/Create/useCreateLink.tsx
📚 Learning: 2025-05-15T14:47:26.891Z
Learnt from: jjramirezn
Repo: peanutprotocol/peanut-ui PR: 857
File: src/hooks/useWebSocket.ts:77-82
Timestamp: 2025-05-15T14:47:26.891Z
Learning: The useWebSocket hook in src/hooks/useWebSocket.ts is designed to provide raw history entries, while the components using it (such as HomeHistory.tsx) are responsible for implementing deduplication logic based on UUID to prevent duplicate entries when combining WebSocket data with other data sources.

Applied to files:

  • src/hooks/useTransactionHistory.ts
  • src/components/Home/HomeHistory.tsx
📚 Learning: 2025-04-11T11:33:53.245Z
Learnt from: kushagrasarathe
Repo: peanutprotocol/peanut-ui PR: 798
File: src/components/Home/HomeHistory.tsx:138-192
Timestamp: 2025-04-11T11:33:53.245Z
Learning: In the HomeHistory component, infinite scrolling is intentionally not implemented despite the presence of useInfiniteQuery and IntersectionObserver code. The component is designed to only display the first 5 entries with a "View all transactions" link for viewing the complete history.

Applied to files:

  • src/hooks/useTransactionHistory.ts
  • src/components/Profile/components/PublicProfile.tsx
  • src/components/Home/HomeHistory.tsx
📚 Learning: 2025-07-05T16:58:25.340Z
Learnt from: Hugo0
Repo: peanutprotocol/peanut-ui PR: 0
File: :0-0
Timestamp: 2025-07-05T16:58:25.340Z
Learning: Hugo0 successfully refactored sessionStorage usage to React Context in the onramp flow, demonstrating preference for centralized state management over browser storage for component-shared state in React applications.

Applied to files:

  • src/hooks/useLogin.tsx
📚 Learning: 2025-05-13T10:05:24.057Z
Learnt from: kushagrasarathe
Repo: peanutprotocol/peanut-ui PR: 845
File: src/components/Request/link/views/Create.request.link.view.tsx:81-81
Timestamp: 2025-05-13T10:05:24.057Z
Learning: In the peanut-ui project, pages that handle request flows (like Create.request.link.view.tsx) are only accessible to logged-in users who will always have a username, making null checks for user?.user.username unnecessary in these contexts.

Applied to files:

  • src/hooks/useLogin.tsx
  • src/components/Profile/components/PublicProfile.tsx
📚 Learning: 2025-09-05T07:31:11.396Z
Learnt from: Zishan-7
Repo: peanutprotocol/peanut-ui PR: 1185
File: src/components/Claim/useClaimLink.tsx:14-0
Timestamp: 2025-09-05T07:31:11.396Z
Learning: In the peanut-ui codebase, `window.history.replaceState` is used instead of `router.replace` in URL manipulation functions when immediate/synchronous URL updates are required for subsequent actions to read the updated URL parameters.

Applied to files:

  • src/hooks/useLogin.tsx
🧬 Code graph analysis (8)
src/components/Home/HomeCarouselCTA/CarouselCTA.tsx (1)
src/components/Global/Icons/Icon.tsx (1)
  • Icon (209-218)
src/context/contextProvider.tsx (2)
src/context/SupportModalContext.tsx (1)
  • SupportModalProvider (15-37)
src/context/QrCodeContext.tsx (1)
  • QrCodeProvider (12-15)
src/components/Global/DirectSendQR/index.tsx (1)
src/context/QrCodeContext.tsx (1)
  • useQrCodeContext (17-23)
src/app/(mobile-ui)/qr-pay/page.tsx (1)
src/components/Global/Icons/Icon.tsx (1)
  • Icon (209-218)
src/hooks/useHomeCarouselCTAs.tsx (2)
src/hooks/useKycStatus.tsx (1)
  • useKycStatus (12-36)
src/context/QrCodeContext.tsx (1)
  • useQrCodeContext (17-23)
src/hooks/useTransactionHistory.ts (1)
src/constants/general.consts.ts (1)
  • PEANUT_API_URL (51-55)
src/hooks/useLogin.tsx (1)
src/utils/general.utils.ts (2)
  • clearRedirectUrl (796-800)
  • getValidRedirectUrl (899-915)
src/components/Home/HomeHistory.tsx (1)
src/hooks/useTransactionHistory.ts (1)
  • useTransactionHistory (51-106)
🔇 Additional comments (20)
src/components/Create/useCreateLink.tsx (2)

3-5: LGTM!

The import cleanup correctly removes dependencies (PEANUT_API_URL, fetchWithSentry, captureException) that were used by the removed claim-link submission functions. All remaining imports are properly utilized in the code.


286-295: No remaining references to removed functions—change is safe.

Verification confirms submitClaimLinkInit and submitClaimLinkConfirm are not referenced elsewhere in the codebase. The return object correctly excludes these functions, aligning with the PR's goal of removing claim-link submission functionality. No breaking changes detected.

src/components/Payment/PaymentForm/index.tsx (1)

542-544: LGTM! Clear and descriptive button text.

The button text change from "Pay" to "Choose payment method" accurately describes the action for the request pot initial view, improving user clarity.

src/components/Global/Icons/qr-code.tsx (1)

4-4: LGTM! Enhanced SVG flexibility.

Spreading {...props} enables additional SVG properties (e.g., width, height, aria-* attributes) to be passed from parent components, improving reusability. Note that spread props can override the explicit className, viewBox, fill, and xmlns values, which appears intentional for customization.

src/hooks/useLogin.tsx (1)

36-42: Verify the need for full-page navigation.

The redirect logic now uses window.location.assign(validRedirectUrl) for redirect_uri and localStorage redirects (lines 36, 40), but continues to use router.push('/home') for the fallback (line 42). This creates an inconsistency where some redirects trigger full page loads while others use SPA navigation.

Full-page navigation is slower and loses React state. If the goal is to ensure a clean state after login, consider applying it consistently to all paths. If not required, reverting to router.push for all cases would improve UX.

Can you confirm whether full-page navigation is necessary for these specific redirect scenarios?

src/components/Home/HomeCarouselCTA/index.tsx (1)

35-35: LGTM! Icon size now configurable.

Adding iconSize={16} enables explicit icon sizing for carousel CTAs. Note that this applies the same size to all CTAs; if different CTAs require different icon sizes in the future, consider passing iconSize from the cta object data rather than hardcoding it here.

src/components/Profile/components/PublicProfile.tsx (1)

218-218: LGTM! Aligns with updated HomeHistory API.

Removing the isPublic={false} prop correctly reflects the API changes in HomeHistory, which no longer uses this flag. The component now relies solely on the username prop for history retrieval.

src/components/Slider/index.tsx (1)

17-17: LGTM! Backward-compatible enhancement.

The optional title prop allows customization of the slider label while maintaining backward compatibility with the default "Slide to Proceed" text. Implementation is clean and straightforward.

Also applies to: 21-21, 70-70

src/components/Global/DirectSendQR/index.tsx (1)

21-21: LGTM! Improved state management with context.

Migrating from local useState to useQrCodeContext enables shared QR scanner state across components, which aligns with the broader QR flow enhancements in this PR. The existing logic and component behavior remain unchanged, only the state source has been centralized.

Also applies to: 199-199

src/app/(mobile-ui)/home/page.tsx (1)

222-223: Clarify re-enable timeline for Add Money Prompt Modal.

The TODO comment indicates the Add Money Prompt Modal is temporarily disabled pending fixes. Users who would have been prompted to add funds based on balance/session conditions will no longer see this modal.

Can you provide context on:

  1. What issue prompted this temporary disablement?
  2. What fixes are needed before re-enabling?
  3. Is there an issue tracking this work?

This will help ensure the feature is properly restored when ready.

src/context/contextProvider.tsx (1)

12-12: LGTM!

Clean integration of the new QrCodeProvider into the context hierarchy. The nesting order is appropriate and maintains existing provider structure.

Also applies to: 26-28

src/hooks/useHomeCarouselCTAs.tsx (1)

10-10: LGTM!

Clean integration of the QR code context and extension of the CarouselCTA type to support configurable icon sizes.

Also applies to: 24-24, 35-35

src/components/Global/BalanceWarningModal/index.tsx (1)

92-121: LGTM!

The content updates improve clarity while maintaining the intentional casual and friendly tone. The addition of the title prop to the Slider component enhances the UX by providing clear instructions.

src/components/Home/HomeCarouselCTA/CarouselCTA.tsx (1)

23-23: LGTM!

Clean addition of a configurable iconSize prop with a sensible default value (22) that maintains backward compatibility. The implementation correctly applies the prop when rendering icons without logos.

Also applies to: 36-36, 100-100

src/app/(mobile-ui)/qr-pay/page.tsx (2)

436-449: LGTM!

The PIX-specific error handling is appropriate given the external provider issues. The addition of qrType to the dependency array ensures the effect re-runs when the QR type changes, which is correct.


845-857: LGTM!

The simplified error UI structure is cleaner and more consistent with the rest of the application's error handling patterns.

src/context/QrCodeContext.tsx (1)

1-23: LGTM!

Clean and minimal context implementation for managing QR scanner state. The error handling in useQrCodeContext properly enforces that the hook is used within the provider, following React best practices.

src/hooks/useTransactionHistory.ts (1)

25-25: LGTM!

The removal of the public mode is implemented consistently throughout the hook. The simplified authorization flow always requires authentication, which aligns with the PR's goal of deprecating public transaction history access.

Also applies to: 33-38, 58-70

src/components/Home/HomeHistory.tsx (1)

27-27: LGTM!

The removal of the isPublic prop and associated logic is implemented consistently throughout the component. The component now operates in a single mode, which simplifies the codebase while maintaining all necessary functionality for viewing transaction history.

Also applies to: 31-31, 37-37, 168-187, 200-200, 210-210, 302-302

src/app/api/peanut/get-attachment-info/route.ts (1)

8-10: No callers found—verification complete and code is safe as-is.

Comprehensive search of the codebase confirms zero references to the get-attachment-info endpoint. The disabled endpoint with 405 response poses no risk of active code failures. The TODO comment is clear about the intended future direction using /send-link.

@Hugo0 Hugo0 merged commit 7ee7fd3 into peanut-wallet-dev Nov 8, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Being worked on Being worked on enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants