Skip to content

Conversation

jjramirezn
Copy link
Contributor

@jjramirezn jjramirezn commented May 12, 2025

contributes to TASK-11169
contributes to TASK-9923

Summary by CodeRabbit

  • New Features

    • Users without a "peanut-wallet" account will now have one created automatically when accessing the Home page.
  • Improvements

    • Deposit links now use a dynamic base URL, allowing for better environment configuration.
    • Expanded support for public paths in the mobile layout, improving routing flexibility.
    • Centralized base URL configuration across the app for metadata, previews, and sitemap URLs.
    • Improved stability in claim link handling by preventing potential errors with safer data access.
  • Refactor

    • Toast notifications have been streamlined with a new toast system, and user profile update methods have been removed from the authentication context.

Copy link

Copy link

vercel bot commented May 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
peanut-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 12, 2025 6:39pm

Copy link

Copy link
Contributor

coderabbitai bot commented May 12, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The changes introduce automatic creation of a "peanut-wallet" account for users in the Home component, expand public path recognition in the mobile UI layout, update deposit link construction to use a configurable base URL, add a BASE_URL constant, refactor the authentication context to remove Chakra UI toasts and obsolete profile update methods, and centralize base URL usage across multiple modules by importing the new BASE_URL constant.

Changes

File(s) Change Summary
src/app/(mobile-ui)/home/page.tsx Added a useEffect to auto-create a "peanut-wallet" account for users if missing, using address from useWallet and addAccount from useAuth.
src/app/(mobile-ui)/layout.tsx Updated publicPathRegex to recognize /pay/ paths as public, affecting UI rendering logic for public routes.
src/components/AddFunds/index.tsx Changed deposit link construction to use a new BASE_URL constant instead of a hardcoded domain.
src/constants/general.consts.ts Introduced a new BASE_URL constant, using an environment variable or defaulting to 'https://peanut.me'.
src/context/authContext.tsx Replaced Chakra UI toasts with a custom toast hook, removed updateUserName and submitProfilePhoto methods from the context, and simplified logout toast notifications.
src/app/(mobile-ui)/claim/page.tsx, src/app/(mobile-ui)/link-account/page.tsx, src/app/(mobile-ui)/profile/page.tsx, src/app/(mobile-ui)/refund/page.tsx, src/app/[...recipient]/layout.tsx, src/app/metadata.ts, src/app/robots.ts Replaced hardcoded or environment variable-based base URL strings with the imported BASE_URL constant from the centralized constants module for metadata, preview URLs, and sitemap generation.
src/components/Claim/Claim.tsx Changed claim sender userId access to use optional chaining (sendLink.sender?.userId) to prevent runtime errors if sender is undefined.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant HomeComponent
    participant useWallet
    participant useAuth

    User->>HomeComponent: Loads Home page
    HomeComponent->>useWallet: Get wallet address
    HomeComponent->>useAuth: Get user info
    HomeComponent->>HomeComponent: useEffect checks accounts
    alt "peanut-wallet" account missing
        HomeComponent->>useAuth: addAccount(address, "peanut-wallet", userId)
    end
Loading

Poem

In the warren of code, a wallet appears,
Auto-created for users—no more fears!
Paths grow public, links get a new base,
Toasts now custom, with a streamlined face.
The rabbits rejoice, accounts set just right—
Hopping through updates, coding delight!
🐇✨

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 35d903b and 8fe9773.

📒 Files selected for processing (8)
  • src/app/(mobile-ui)/claim/page.tsx (2 hunks)
  • src/app/(mobile-ui)/link-account/page.tsx (1 hunks)
  • src/app/(mobile-ui)/profile/page.tsx (1 hunks)
  • src/app/(mobile-ui)/refund/page.tsx (1 hunks)
  • src/app/[...recipient]/layout.tsx (2 hunks)
  • src/app/metadata.ts (2 hunks)
  • src/app/robots.ts (2 hunks)
  • src/components/Claim/Claim.tsx (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

🧹 Nitpick comments (3)
src/components/AddFunds/index.tsx (1)

214-214: Consider handling potential undefined username.

The new deposit link uses the centralized BASE_URL which is good, but there's no fallback if user?.user?.username is undefined.

-const depositLink = `${BASE_URL}/pay/${user?.user?.username}`
+const depositLink = user?.user?.username ? `${BASE_URL}/pay/${user.user.username}` : BASE_URL
src/app/(mobile-ui)/home/page.tsx (1)

52-62: Good implementation of automatic peanut-wallet account creation.

This useEffect addresses the issue of users not having properly created peanut-wallet accounts. The dependencies array is correctly set to [user, address] to ensure the code runs when either changes.

Consider adding error handling to the account creation process:

useEffect(() => {
    // We have some users that didn't have the peanut wallet created
    // correctly, so we need to create it
    if (address && user && !user.accounts.some((a) => a.account_type === 'peanut-wallet')) {
+       try {
            addAccount({
                accountIdentifier: address,
                accountType: 'peanut-wallet',
                userId: user.user.userId,
            })
+       } catch (error) {
+           console.error('Failed to create peanut wallet account:', error)
+       }
    }
}, [user, address])
src/context/authContext.tsx (1)

95-134: Provide user feedback for the “Add account” flow

addAccount performs a network request but gives no visual cue on success or failure (except for thrown errors).
Consider adding optimistic UI or toast notifications similar to the logout flow so users know their new account was added.

+ try {
        const response = await fetchWithSentry('/api/peanut/user/add-account', { /* … */ })
        …
-        fetchUser()
+        fetchUser()
+        toast.success?.('Account added')
+ } catch (e) {
+        toast.error?.(e.message ?? 'Could not add account')
+        throw e
+ }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 237b37f and 35d903b.

📒 Files selected for processing (5)
  • src/app/(mobile-ui)/home/page.tsx (3 hunks)
  • src/app/(mobile-ui)/layout.tsx (1 hunks)
  • src/components/AddFunds/index.tsx (2 hunks)
  • src/constants/general.consts.ts (1 hunks)
  • src/context/authContext.tsx (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
src/components/AddFunds/index.tsx (1)
src/constants/general.consts.ts (1)
  • BASE_URL (36-36)
src/app/(mobile-ui)/home/page.tsx (2)
src/hooks/wallet/useWallet.ts (1)
  • useWallet (20-82)
src/context/authContext.tsx (1)
  • useAuth (195-201)
src/context/authContext.tsx (1)
src/components/0_Bruddle/Toast.tsx (1)
  • useToast (111-117)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Deploy-Preview
🔇 Additional comments (7)
src/constants/general.consts.ts (1)

36-36: Good addition of a centralized BASE_URL constant.

The addition of this configurable constant is a clean approach for centralizing URL construction across the application. It appropriately uses the environment variable with a sensible default fallback.

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

13-13: Good import of the BASE_URL constant.

Properly importing the centralized constant from constants file.

src/app/(mobile-ui)/layout.tsx (1)

19-19: Good extension of public path regex to support /pay/ URLs.

The regex now correctly captures the new URL pattern for payment links, aligning with the updated deposit link format being used in the AddFunds component.

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

21-21: Good addition of useEffect import.

Properly importing the required hook for the new account creation functionality.


25-25: Good destructuring of required dependencies.

Correctly extracting the wallet address and the addAccount function needed for the automatic account creation.

Also applies to: 34-34

src/context/authContext.tsx (2)

9-10: Wrap AuthProvider with ToastProvider to avoid runtime crashes

useToast now comes from your custom Bruddle implementation which will throw if it is used outside of a ToastProvider (see Toast.tsx, lines 111-117).
Double-check that every app entry-point where AuthProvider is rendered is already nested inside ToastProvider; otherwise navigation to any route that mounts AuthProvider first will raise an exception and take the whole app down.

Example (App Router – layout.tsx):

-<AuthProvider>
-  {children}
-</AuthProvider>
+<ToastProvider>
+  <AuthProvider>
+    {children}
+  </AuthProvider>
+</ToastProvider>

Also applies to: 49-50


160-168: Verify that the custom toast context exposes success / error helpers

The new calls

toast.success('Logged out successfully')
toast.error('Failed to log out')
toast.error('Error logging out')

assume the context object has success and error methods (previously Chakra’s useToast returned a callable function).
If the API surface is different (e.g. toast({ status: 'success', message: … })), this will result in a runtime TypeError.

Suggestion:

- toast.success('Logged out successfully')
+ toast?.success?.('Logged out successfully')

or, better, adapt to the exact API exported by the ToastProvider.

Please run a quick type-check / unit test to confirm these helpers exist.

Copy link
Contributor

@Hugo0 Hugo0 left a comment

Choose a reason for hiding this comment

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

one blocker comment pls check; apart from that lgtm, approved

Copy link
Contributor

@Hugo0 Hugo0 left a comment

Choose a reason for hiding this comment

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

Two issues:

(actually not a bug)
squid route failing handling:
image

bug: this userid (likely my address is in db relatedto user) 0xB92FCCCc63893856Da2a445d861f0942788D6479
https://peanut.me/claim?c=42161&v=v4.3&i=3761&t=ui#p=ee08BYdmYhcpYzvZ

@jjramirezn jjramirezn requested a review from Hugo0 May 12, 2025 18:35
@jjramirezn jjramirezn merged commit d5759fd into peanut-wallet May 12, 2025
5 checks passed
@jjramirezn jjramirezn deleted the fix/post-prod-release branch May 12, 2025 18:41
@coderabbitai coderabbitai bot mentioned this pull request Jun 28, 2025
@coderabbitai coderabbitai bot mentioned this pull request Sep 9, 2025
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