Skip to content

Conversation

kushagrasarathe
Copy link
Contributor

@kushagrasarathe kushagrasarathe commented Dec 18, 2024

Migration from Web3Modal to Reown AppKit

  • replaced Web3Modal with reown-appkit for wallet connection handling
  • restructured wallet configuration to use WagmiAdapter
  • optimized chain transport configuration for better performance
  • added dynamic URL support via environment variable
  • maintains existing wallet connection features including:
    • safe wallet integration
    • wallet-connect
    • coinbase-wallet
    • injected-wallets
  • updated useWeb3Modal to use useAppKit hook from reown-appkit

NOTE:

  1. @Hugo0 @jjramirezn had to update wagmi and viem versions to tackle some runtime errors caused by appkit, still trying to solve the issue with the previous versions, will update here once I find a better solution while keeping the same versions to avoid any random issues
  2. try clearing pnpm-lock cache in-case run into any error while testing :)

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced new wallet management integration using @reown/appkit.
    • Enhanced error handling and user feedback across various components.
    • Updated balance display logic in the Token Selector based on wallet type.
  • Bug Fixes

    • Improved error handling in transaction processes and user interactions.
  • Chores

    • Updated dependencies and devDependencies in the project configuration.
    • Removed outdated libraries and replaced them with new ones for better performance.

Copy link

vercel bot commented Dec 18, 2024

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 Dec 18, 2024 3:44pm

Copy link
Contributor

coderabbitai bot commented Dec 18, 2024

Walkthrough

This pull request introduces a comprehensive migration from web3modal to @reown/appkit across multiple components in the peanut-ui project. The changes primarily involve updating wallet connection mechanisms, import statements, and dependency versions. The modifications span various components like Cashout, Claim, Create, Header, TokenSelector, Profile, Refund, and Request views, ensuring a consistent transition to the new wallet management library.

Changes

File Change Summary
package.json - Added @reown/appkit and @reown/appkit-adapter-wagmi dependencies
- Updated @tanstack/react-query from ^5.61.0 to 5.8.4
- Downgraded @wagmi/core from ^2.14.6 to 2.14.3
- Added Jest-related dev dependencies
src/components/Cashout/Components/Initial.view.tsx - Replaced useWeb3Modal with useAppKit
- Updated wallet connection logic
- Refined error handling and state management
src/components/Claim/Link/Initial.view.tsx - Replaced useWeb3Modal with useAppKit
- Enhanced error handling in claim functions
src/components/Create/Link/Input.view.tsx - Replaced useWeb3Modal with useAppKit
- Updated wallet connection logic
src/components/Global/Header/index.tsx - Replaced web3modalOpen with walletModal
- Updated wallet connection import
src/components/Global/TokenSelector/TokenSelector.tsx - Replaced useWeb3Modal with useAppKit
- Updated balance filtering logic based on wallet type
src/components/Profile/Components/SkeletonPage.tsx - Replaced useWeb3Modal with useAppKit
- Maintained structure and functionality
src/components/Refund/index.tsx - Replaced useWeb3Modal with useAppKit
- Preserved transaction logic
src/components/Request/Pay/Views/Initial.view.tsx - Replaced useWeb3Modal with useAppKit
- Enhanced error handling and state management
src/config/wagmi.config.tsx - Replaced createWeb3Modal with createAppKit
- Introduced WagmiAdapter
- Updated configuration logic
src/components/Global/AddressInput/index.tsx - Simplified address validation logic
src/components/Global/GeneralRecipientInput/index.tsx - Updated Ethereum address validation logic

Possibly related PRs

Suggested Labels

Being worked on

Suggested Reviewers

  • jjramirezn

Poem

🐰 A Rabbit's Wallet Migration Tale 🌈
From web3modal's embrace, we take flight,
AppKit arrives with wallet's new might!
Dependencies dance, versions align,
Code transforms with each design.
A migration of magic, smooth and bright! 🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.

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. (Beta)
  • @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

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: 2

🧹 Nitpick comments (5)
src/config/wagmi.config.tsx (1)

28-43: Check domain allowance and initial shim settings
The domain list for the 'safe' connector and the shimDisconnect usage for injected wallets look correct. Be mindful of additional domains you may need to support if your product domain or partner domains change.

src/components/Cashout/Components/Initial.view.tsx (1)

74-74: Connect wallet in handleConnectWallet
Calling open() can fail or reject if the user closes the modal or there’s an initialization error. You might want to capture that scenario to provide user feedback.

- const handleConnectWallet = async () => {
-   open()
- }
+ const handleConnectWallet = async () => {
+   try {
+     await open()
+   } catch (error) {
+     console.log("Wallet connection canceled or failed.", error)
+   }
+ }
src/components/Request/Pay/Views/Initial.view.tsx (1)

73-73: Open method usage
Similar to other components, consider adding some form of error handling around open() or a loading state to ensure a graceful fallback.

Want help implementing a “try/catch” pattern or a user-facing error message if the user closes the wallet modal unexpectedly?

src/components/Create/Link/Input.view.tsx (2)

Line range hint 74-76: Consider enhancing error handling for wallet connection

The handleConnectWallet function could benefit from try-catch error handling to provide better user feedback for wallet connection failures.

 const handleConnectWallet = async () => {
-    open()
+    try {
+        await open()
+    } catch (error) {
+        setErrorState({
+            showError: true,
+            errorMessage: 'Failed to connect wallet. Please try again.',
+        })
+    }
 }

Line range hint 1-324: Consider breaking down the component for better maintainability

The CreateLinkInputView component is quite large and handles multiple responsibilities. Consider breaking it down into smaller, more focused components:

  • TokenInputSection
  • WalletConnectionSection
  • TransactionPreparationSection
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 16eb9e8 and cc8d0e1.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • package.json (3 hunks)
  • src/components/Cashout/Components/Initial.view.tsx (2 hunks)
  • src/components/Claim/Link/Initial.view.tsx (2 hunks)
  • src/components/Create/Link/Input.view.tsx (2 hunks)
  • src/components/Global/Header/index.tsx (5 hunks)
  • src/components/Global/TokenSelector/TokenSelector.tsx (2 hunks)
  • src/components/Profile/Components/SkeletonPage.tsx (2 hunks)
  • src/components/Refund/index.tsx (1 hunks)
  • src/components/Request/Pay/Views/Initial.view.tsx (2 hunks)
  • src/config/wagmi.config.tsx (1 hunks)
🧰 Additional context used
📓 Learnings (1)
src/components/Request/Pay/Views/Initial.view.tsx (1)
Learnt from: jjramirezn
PR: peanutprotocol/peanut-ui#422
File: src/components/Request/Pay/Views/Initial.view.tsx:76-78
Timestamp: 2024-11-12T09:39:20.720Z
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`.
🔇 Additional comments (26)
src/config/wagmi.config.tsx (5)

4-5: Switching from Web3Modal to AppKit
Great job replacing the imports from "@Web3Modal" with "@reown/appkit". This step sets the foundation for your new wallet infrastructure.


45-50: SSR usage with WagmiAdapter
You've enabled SSR (server-side rendering) here. Ensure that the rest of your components also handle SSR properly (e.g., checking window references).
[approve]


72-87: Review repeated createAppKit block
Double check if you truly need to call createAppKit again here. If you need distinct configurations, consider clarifying them; otherwise, consolidate into one call.


91-91: WagmiProvider usage
Using wagmiAdapter.wagmiConfig directly is a clean approach. Good job migrating from a custom config to the WagmiAdapter.


25-26: Verify transport creation for each chain
You're creating transports with "http(chain.rpcUrls.default.http[0])". Confirm that each chain's first HTTP endpoint is guaranteed to be valid and secure.

✅ Verification successful

Let me search for the chain definitions to verify the RPC URLs configuration.


Let me check the chain definitions and RPC URL configurations in more detail.


Chain transport configuration appears secure

The chain configurations are well-defined and use secure sources:

  • Custom chains (Milkomeda, Base, Taiko, zkSync) use official RPC endpoints
  • Other chains are imported from the official wagmi/chains package which maintains a vetted list of RPC endpoints
  • All chains have both public and default RPC URLs properly configured
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Searching for all chain definitions to confirm they have default http endpoints
rg 'chains.*rpcUrls.*default' -A 5

Length of output: 439


Script:

#!/bin/bash
# Search for chain constants or configurations
rg -g '!*.test.*' -g '!*.spec.*' "const.*chains.*=" -A 10

# Also search for chain imports to understand where they might be defined
rg -g '!*.test.*' -g '!*.spec.*' "import.*chain" -B 2 -A 2

Length of output: 5996


Script:

#!/bin/bash
# Check the custom chain definitions
rg -g '!*.test.*' -g '!*.spec.*' "const.*milkomeda.*=" -A 15

# Check the wagmi chains import usage
cat src/constants/chains.consts.ts

Length of output: 4910

src/components/Global/TokenSelector/TokenSelector.tsx (1)

16-16: Migration to useAppKit
Properly replacing the useWeb3Modal import with useAppKit is consistent with the rest of the PR. Good work!

src/components/Cashout/Components/Initial.view.tsx (1)

7-7: useAppKit import
The shift to "useAppKit" lines up with your new approach. The hook is used consistently throughout the component.

src/components/Request/Pay/Views/Initial.view.tsx (1)

3-3: useAppKit import
Smooth transition from useWeb3Modal to useAppKit. This ensures consistent wallet management across the app.

src/components/Claim/Link/Initial.view.tsx (2)

7-7: Successfully migrated to useAppKit.
This aligns perfectly with the PR objective of transitioning away from web3Modal. No issues detected.


87-87: Double-check the “open” method usage.
Ensure any relevant errors are caught or handled when invoking the wallet modal.

package.json (7)

31-32: Added @reown/appkit dependencies.
These packages are crucial for the new wallet integration; everything looks consistent with the PR objective.


36-36: Upgraded @tanstack/react-query to 5.8.4.
Confirm that the new version remains compatible with existing query logic and testing.


39-39: Downgraded @wagmi/core to 2.14.3.
Please verify whether any features from 2.14.6 are used. If not, this should be safe.


66-67: Adjusted “viem” and “wagmi” versions.
Ensure there are no compatibility issues with the rest of the wagmi ecosystem.


70-71: Added testing library dependencies.
Jest DOM and type definitions look good; confirm that they’re fully integrated into your test suite.


80-81: Introduced Jest & jest-environment-jsdom.
These additions align well with front-end testing practices.


88-89: Updated ts-jest & TypeScript versions.
Please confirm proper compatibility with the existing codebase and ensure type definitions remain accurate.

src/components/Refund/index.tsx (2)

13-13: Migration to useAppKit.
Replacing web3Modal import is consistent with the overall wallet integration approach.


19-19: Check for additional error handling with “open.”
The call to “open()” appears correct; consider adding try/catch if additional fallback is needed.

src/components/Global/Header/index.tsx (5)

9-10: Replaced web3Modal import with useAppKit.
This is aligned with the new wallet strategy in the PR. No issues found.


225-225: Renamed open to walletModal.
A consistent, readable naming convention that matches the new library usage.


262-262: Wallet modal invocation.
Looks clear. Confirm whether you need to handle errors if the modal fails to open.


278-278: Imported useAppKit again for the SocialLinks.
Ensures consistent usage across all components in the Header.


289-289: Triggering walletModal in SocialLinks.
Good job consolidating this approach. Confirm error states or fallback UI if the user cancels.

src/components/Profile/Components/SkeletonPage.tsx (1)

4-4: LGTM: Wallet connection migration looks good

The migration from web3Modal to reown-appkit has been implemented correctly, maintaining the existing functionality while updating the wallet connection mechanism.

Also applies to: 31-31

src/components/Create/Link/Input.view.tsx (1)

6-6: LGTM: Wallet connection migration implemented correctly

The migration from web3Modal to reown-appkit has been implemented properly, maintaining the existing functionality.

Also applies to: 72-72

Comment on lines +55 to +65
createAppKit({
adapters: [wagmiAdapter],
networks: consts.chains,
metadata,
projectId,
enableAnalytics: true, // Optional - defaults to your Cloud configuration
features: {
analytics: true,
email: false,
socials: false,
onramp: true,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Potential duplication in createAppKit calls
You initialize createAppKit at lines 55-65 and again at lines 72-87. If the intention is to override or reinit after certain logic, confirm it’s necessary, as repeated initialization might cause confusion or re-initialization overhead.

- createAppKit({
-   adapters: [wagmiAdapter],
-   ...
- })
-
+// Consider removing the duplicate call if not strictly needed.

Committable suggestion skipped: line range outside the PR's diff.

} = useContext(context.tokenSelectorContext)
const { isConnected } = useAccount()
const { open } = useWeb3Modal()
const { open } = useAppKit()
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Add error handling for wallet connection
The open() call in TokenSelector.tsx lacks error handling. While most usages of open() in the codebase are direct calls, there is a precedent in Request/Pay/Views/Initial.view.tsx that uses .finally(). Consider adding error handling using .catch() to handle potential wallet connection failures gracefully and provide feedback to users.

Example locations needing attention:

  • src/components/Global/TokenSelector/TokenSelector.tsx:189 - Add .catch() handler for the open() call
🔗 Analysis chain

Open wallet flow
Using “open()” to trigger the wallet connection from reown-appkit is straightforward. Ensure appropriate error handling or fallback in case the wallet configuration fails.


Let me gather more information about error handling around these open() calls.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Checking if 'open()' calls are handled with try/catch or appropriate error boundaries
rg 'open\(' -A 5

Length of output: 10560


Script:

#!/bin/bash
# Check for try-catch blocks or error handling around open() calls
ast-grep --pattern 'try {
  $$$
  open()
  $$$
}'

# Also check for .catch() or .finally() usage with open()
rg 'open\(\).*\.(catch|finally)'

Length of output: 167

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 (1)
src/components/Global/GeneralRecipientInput/index.tsx (1)

66-66: Consider consolidating address validation logic

The address validation change matches the one in AddressInput, but both components maintain separate validation logic. Consider extracting this into a shared utility function to ensure consistent validation across the application.

Example implementation:

// src/utils/validation.ts
export const validateEthereumAddress = (address: string): boolean => {
  return isAddress(address);
};

This would help maintain consistency as the codebase migrates to reown-appkit and reduce duplication.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cc8d0e1 and 5e3c8a1.

📒 Files selected for processing (2)
  • src/components/Global/AddressInput/index.tsx (1 hunks)
  • src/components/Global/GeneralRecipientInput/index.tsx (1 hunks)
🔇 Additional comments (2)
src/components/Global/AddressInput/index.tsx (1)

21-21: Verify the impact of stricter address validation

Removing { strict: false } from isAddress makes the validation more stringent. This could potentially affect existing valid addresses that previously passed validation.

Let's verify the impact:

✅ Verification successful

Let me analyze the impact of stricter address validation by checking how isAddress is used in the codebase.


Removing { strict: false } from isAddress is safe

The stricter address validation is safe to implement because:

  1. All addresses found in the codebase are properly formatted EIP-55 compliant addresses
  2. The isAddress function is used consistently across components (AddressInput, AddressLink, GeneralRecipientInput) without any special options
  3. The addresses used in constants and utils are all valid checksummed addresses that will pass strict validation
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for existing address patterns in the codebase that might be affected by stricter validation
rg -l '[0-9a-fA-F]{40}' | while read -r file; do
  echo "=== $file ==="
  rg -A 1 '[0-9a-fA-F]{40}' "$file"
done

Length of output: 8432


Script:

#!/bin/bash
# Search for all usages of isAddress function
rg -A 2 "isAddress\(" 

# Also check for any test cases or validation patterns
ast-grep --pattern 'isAddress($_)'

Length of output: 1402

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

Line range hint 37-68: Verify ENS resolution compatibility with reown-appkit

The ENS resolution logic is intertwined with address validation. Since we're migrating to reown-appkit, we should verify that the ENS resolution process is compatible with the new setup.

Let's check for any potential conflicts:

name: 'Peanut Protocol',
description: 'Peanut protocol - send crypto with links',
url: 'https://peanut.to', // origin must match your domain & subdomain
url: process.env.NEXT_PUBLIC_BASE_URL || 'https://peanut.to', // origin must match your domain & subdomain
Copy link
Contributor

Choose a reason for hiding this comment

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

🔥🔥🔥🔥

Copy link
Contributor

@jjramirezn jjramirezn left a comment

Choose a reason for hiding this comment

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

Changes look good, but right now the image is not building, check errors by doing a pnpm build

This is the error I'm getting:

./src/config/wagmi.config.tsx:50:5
Type error: Type 'import("/home/juan/Programming/peanut/peanut-ui/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]_typescript@5._txfnpea6k26ediztrzq6synpsa/node_modules/@wagmi/core/dist/types/connectors/createConnector").CreateConnectorFn[]' is not assignable to type 'import("/home/juan/Programming/peanut/peanut-ui/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]_typescript@5._ejk5cqydnu66zcolkw7v3fb5z4/node_modules/@wagmi/core/dist/types/connectors/createConnector").CreateConnectorFn[]'.
  Type 'import("/home/juan/Programming/peanut/peanut-ui/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]_typescript@5._txfnpea6k26ediztrzq6synpsa/node_modules/@wagmi/core/dist/types/connectors/createConnector").CreateConnectorFn' is not assignable to type 'import("/home/juan/Programming/peanut/peanut-ui/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]_typescript@5._ejk5cqydnu66zcolkw7v3fb5z4/node_modules/@wagmi/core/dist/types/connectors/createConnector").CreateConnectorFn'.
    Types of parameters 'config' and 'config' are incompatible.
      Type '{ chains: readonly [import("/home/juan/Programming/peanut/peanut-ui/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/viem/_types/types/chain").Chain, ...import("/home/juan/Programming/peanut/peanut-ui/node_modules/.pnpm/[email protected][email protected]_typescri...' is not assignable to type '{ chains: readonly [import("/home/juan/Programming/peanut/peanut-ui/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/viem/_types/types/chain").Chain, ...import("/home/juan/Programming/peanut/peanut-ui/node_modules/.pnpm/[email protected][email protected]_typescri...'. Two different types with this name exist, but they are unrelated.
        Types of property 'transports' are incompatible.
          Type 'Record<number, import("/home/juan/Programming/peanut/peanut-ui/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]_typescript@5._ejk5cqydnu66zcolkw7v3fb5z4/node_modules/@wagmi/core/dist/types/createConfig").Transport> | undefined' is not assignable to type 'Record<number, import("/home/juan/Programming/peanut/peanut-ui/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]_typescript@5._txfnpea6k26ediztrzq6synpsa/node_modules/@wagmi/core/dist/types/createConfig").Transport> | undefined'.
            Type 'Record<number, import("/home/juan/Programming/peanut/peanut-ui/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]_typescript@5._ejk5cqydnu66zcolkw7v3fb5z4/node_modules/@wagmi/core/dist/types/createConfig").Transport>' is not assignable to type 'Record<number, import("/home/juan/Programming/peanut/peanut-ui/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]_typescript@5._txfnpea6k26ediztrzq6synpsa/node_modules/@wagmi/core/dist/types/createConfig").Transport>'.
              'number' index signatures are incompatible.
                Type 'import("/home/juan/Programming/peanut/peanut-ui/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]_typescript@5._ejk5cqydnu66zcolkw7v3fb5z4/node_modules/@wagmi/core/dist/types/createConfig").Transport' is not assignable to type 'import("/home/juan/Programming/peanut/peanut-ui/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]_typescript@5._txfnpea6k26ediztrzq6synpsa/node_modules/@wagmi/core/dist/types/createConfig").Transport'.
                  Types of parameters 'params' and 'params' are incompatible.
                    Type '{ chain?: Chain | undefined; pollingInterval?: number | undefined; retryCount?: number | undefined; timeout?: number | undefined; } & { connectors?: StoreApi<Connector<CreateConnectorFn>[]> | undefined; }' is not assignable to type '{ chain?: Chain | undefined; pollingInterval?: number | undefined; retryCount?: number | undefined; timeout?: number | undefined; } & { connectors?: StoreApi<Connector[]> | undefined; }'.
                      Type '{ chain?: Chain | undefined; pollingInterval?: number | undefined; retryCount?: number | undefined; timeout?: number | undefined; } & { connectors?: StoreApi<Connector<CreateConnectorFn>[]> | undefined; }' is not assignable to type '{ connectors?: StoreApi<Connector[]> | undefined; }'.
                        Types of property 'connectors' are incompatible.
                          Type 'StoreApi<Connector<CreateConnectorFn>[]> | undefined' is not assignable to type 'StoreApi<Connector[]> | undefined'.
                            Type 'StoreApi<Connector<CreateConnectorFn>[]>' is not assignable to type 'StoreApi<Connector[]>'.
                              The types returned by 'getState()' are incompatible between these types.
                                Type 'Connector<CreateConnectorFn>[]' is not assignable to type 'Connector[]'.
                                  Type 'Connector<CreateConnectorFn>' is not assignable to type 'Connector'.
                                    Type 'Connector<CreateConnectorFn>' is not assignable to type '{ [x: string]: unknown; readonly icon?: string | undefined; readonly id: string; readonly name: string; readonly rdns?: string | undefined; readonly supportsSimulation?: boolean | undefined; ... 14 more ...; onMessage?: ((message: ProviderMessage) => void) | undefined; }'.
                                      Types of property 'rdns' are incompatible.
                                        Type 'string | readonly string[] | undefined' is not assignable to type 'string | undefined'.
                                          Type 'readonly string[]' is not assignable to type 'string'.

  48 |     projectId,
  49 |     transports,
> 50 |     connectors,
     |     ^
  51 |     ssr: true,
  52 | })
  53 |

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: 2

🧹 Nitpick comments (1)
src/config/wagmi.config.tsx (1)

20-20: Consider environment-specific fallback URL

The hardcoded fallback URL 'https://peanut.to' might not be suitable for all environments (development, staging, etc.).

-    url: process.env.NEXT_PUBLIC_BASE_URL || 'https://peanut.to',
+    url: process.env.NEXT_PUBLIC_BASE_URL || process.env.NEXT_PUBLIC_FALLBACK_URL || 'https://peanut.to',
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5e3c8a1 and 1899f61.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • package.json (4 hunks)
  • src/config/wagmi.config.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json
🔇 Additional comments (4)
src/config/wagmi.config.tsx (4)

4-6: LGTM: Imports correctly updated for reown-appkit migration

The imports have been appropriately updated to replace web3modal with reown-appkit and its wagmi adapter.


45-52: Verify SSR configuration impact

The WagmiAdapter is configured with ssr: true. Please ensure this aligns with your server-side rendering requirements and test the application in both SSR and client-side contexts.


55-65: Remove duplicate AppKit initialization

The createAppKit initialization appears to be duplicated in the codebase.


74-74: LGTM: Provider configuration updated correctly

The WagmiProvider has been properly updated to use the new wagmiAdapter configuration.

✅ Verification successful

LGTM: Single WagmiProvider instance correctly updated

The verification confirms that there is only one instance of WagmiProvider in the codebase, located in src/config/wagmi.config.tsx. The configuration update is properly contained to this single location, and no other instances require attention.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any other WagmiProvider configurations that might need updating
rg "WagmiProvider" --type typescript --type javascript -B 2 -A 2

Length of output: 99


Script:

#!/bin/bash
# Search for WagmiProvider usage with proper file extensions
rg "WagmiProvider" -t tsx -t jsx -t js -B 2 -A 2

Length of output: 76


Script:

#!/bin/bash
# Find all TypeScript/JavaScript files that might contain WagmiProvider
fd -e tsx -e jsx -e js -e ts | xargs grep -l "WagmiProvider" || true

Length of output: 88


Script:

#!/bin/bash
# Use ast-grep to find WagmiProvider component usage
ast-grep --pattern '<WagmiProvider $$$>$$$</WagmiProvider>'

Length of output: 324

Comment on lines +24 to +25
// 3. Create transports for each chain
const transports = Object.fromEntries(consts.chains.map((chain) => [chain.id, http(chain.rpcUrls.default.http[0])]))
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling for RPC URL configuration

Consider adding validation and error handling for RPC URLs to prevent runtime issues with invalid configurations.

-const transports = Object.fromEntries(consts.chains.map((chain) => [chain.id, http(chain.rpcUrls.default.http[0])]))
+const transports = Object.fromEntries(
+  consts.chains.map((chain) => {
+    const rpcUrl = chain.rpcUrls.default.http[0]
+    if (!rpcUrl) {
+      throw new Error(`No RPC URL configured for chain ${chain.id}`)
+    }
+    return [chain.id, http(rpcUrl)]
+  })
+)
📝 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
// 3. Create transports for each chain
const transports = Object.fromEntries(consts.chains.map((chain) => [chain.id, http(chain.rpcUrls.default.http[0])]))
// 3. Create transports for each chain
const transports = Object.fromEntries(
consts.chains.map((chain) => {
const rpcUrl = chain.rpcUrls.default.http[0]
if (!rpcUrl) {
throw new Error(`No RPC URL configured for chain ${chain.id}`)
}
return [chain.id, http(rpcUrl)]
})
)

@jjramirezn jjramirezn merged commit 8212aa4 into develop Dec 18, 2024
4 checks passed
@jjramirezn jjramirezn deleted the fix/migrate-to-reown branch December 18, 2024 15:59
This was referenced Dec 18, 2024
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