Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(web): migrate-to-reown #1866

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from
Open

Conversation

Harman-singh-waraich
Copy link
Contributor

@Harman-singh-waraich Harman-singh-waraich commented Jan 29, 2025

⚠️ Only testing


PR-Codex overview

This PR focuses on updating dependencies related to wagmi, integrating @reown/appkit, and making various adjustments in the codebase to accommodate these changes, enhancing wallet connection functionalities and overall compatibility.

Detailed summary

  • Updated wagmi version to ^2.14.0 across multiple files.
  • Added @reown/appkit and @reown/appkit-adapter-wagmi dependencies.
  • Refactored AtlasProvider to include wagmiConfig.
  • Replaced useWeb3Modal with useAppKit in wallet connection components.
  • Modified chain-related constants to use AppKitNetwork.
  • Adjusted Web3Provider to utilize the new WagmiAdapter.
  • Updated various TypeScript types and configurations for better compatibility with the new packages.

The following files were skipped due to too many changes: yarn.lock

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • Dependencies

    • Updated @lifi/wallet-management and @lifi/widget to newer versions.
    • Added new dependencies: @bigmi/react, @reown/appkit, @reown/appkit-adapter-wagmi, @solana/wallet-adapter-react.
    • Removed @web3modal/wagmi.
    • Updated wagmi to version 2.14.10.
  • Wallet Management

    • Replaced Web3Modal configuration with AppKit-based implementation.
    • Updated wallet connection and chain management components.
  • Configuration

    • Modified chain and network type definitions to use AppKitNetwork.
    • Updated Web3 provider and wallet provider configurations.
    • Enhanced configuration capabilities for the AtlasProvider and related components.

@Harman-singh-waraich Harman-singh-waraich requested review from a team as code owners January 29, 2025 12:13
Copy link
Contributor

coderabbitai bot commented Jan 29, 2025

Walkthrough

This pull request introduces a comprehensive update to the web application's dependency management and wallet connection infrastructure. The changes primarily involve migrating from Web3Modal to AppKit, updating various dependencies across multiple packages, and refactoring wallet-related components to use the new @reown/appkit library. The modifications span several files, including package.json, component files, and provider configurations, with a focus on updating wallet connection and network management approaches.

Changes

File Change Summary
web/package.json - Added @bigmi/react, @reown/appkit, @reown/appkit-adapter-wagmi, @solana/wallet-adapter-react
- Updated @lifi/wallet-management, @lifi/widget, wagmi
- Removed @web3modal/wagmi
web/src/components/ConnectWallet/index.tsx, web-devtools/src/components/ConnectWallet/index.tsx Replaced Web3Modal hooks with AppKit hooks
web/src/consts/chains.ts, web-devtools/src/consts/chains.ts Updated chain type imports and definitions from Chain to AppKitNetwork
web/src/context/Web3Provider.tsx, web-devtools/src/context/Web3Provider.tsx Completely refactored Web3 provider to use AppKit and WagmiAdapter
web/src/pages/GetPnk/WalletProvider.tsx Replaced Wagmi configuration with AppKit adapter
kleros-app/package.json, web-devtools/package.json Updated wagmi dependency to ^2.14.0
kleros-app/README.md, kleros-app/src/lib/atlas/providers/AtlasProvider.tsx, web/src/context/AtlasProvider.tsx Enhanced configuration for AtlasProvider with wagmiConfig

Possibly related PRs

  • DevTools and Ruler deployment on arbitrum #1812: The changes in the main PR, which involve updating dependencies and transitioning to the @reown/appkit library, are related to the modifications in the retrieved PR that also focus on enhancing the configuration and functionality of the Kleros ecosystem, particularly with respect to the Web3Provider and chain handling.
  • Devtools build fix #1795: The changes in the main PR, which involve the addition and updates of various dependencies including the removal of @web3modal/wagmi, are related to the retrieved PR that downgrades the @web3modal/wagmi dependency, indicating a direct connection in their handling of the @web3modal/wagmi package.
  • Fix/kleros app resolution #1833: The changes in the main PR, which involve updating various dependencies including wagmi, are related to the retrieved PR as both involve modifications to the wagmi package version in their respective package.json files.

Suggested Labels

Type: Maintenance :construction:, Type: Toolchain ⚒️, Type: Enhancement :sparkles:

Suggested Reviewers

  • alcercu
  • kemuru

Poem

🐰 Hop, hop, through the code we go,
Wallets dancing, libraries in tow,
AppKit sparkles, Wagmi takes flight,
Connections leap with pure delight!
A rabbit's dance of web3 glee! 🌐✨

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

🪧 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 or @coderabbitai title 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

netlify bot commented Jan 29, 2025

Deploy Preview for kleros-v2-testnet ready!

Name Link
🔨 Latest commit d594c19
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-testnet/deploys/67a4cb0f2412fa00082b1498
😎 Deploy Preview https://deploy-preview-1866--kleros-v2-testnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 29, 2025

Deploy Preview for kleros-v2-neo ready!

Name Link
🔨 Latest commit d594c19
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-neo/deploys/67a4cb0fa2e97b0008cb508b
😎 Deploy Preview https://deploy-preview-1866--kleros-v2-neo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 29, 2025

Deploy Preview for kleros-v2-university ready!

Name Link
🔨 Latest commit d594c19
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-university/deploys/67a4cb0ff56a8200070c20e3
😎 Deploy Preview https://deploy-preview-1866--kleros-v2-university.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 29, 2025

Deploy Preview for kleros-v2-testnet-devtools ready!

Name Link
🔨 Latest commit d594c19
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-testnet-devtools/deploys/67a4cb0fa40d3900088ea8d4
😎 Deploy Preview https://deploy-preview-1866--kleros-v2-testnet-devtools.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

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

🧹 Nitpick comments (2)
web/src/pages/GetPnk/WalletProvider.tsx (2)

24-27: Lazy initialization of adapter.current.
This is a neat pattern. Make sure to handle any potential concurrency issues if another part of the app needs to prime this adapter simultaneously.


45-46: Nitpick: Clarify the overlay z-index.
Consider referencing a constants file for layering or theming to avoid “magic numbers.”

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 474605b and 3ce6bd2.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (6)
  • web/package.json (1 hunks)
  • web/src/components/ConnectWallet/index.tsx (2 hunks)
  • web/src/consts/chains.ts (1 hunks)
  • web/src/consts/eip712-messages.ts (2 hunks)
  • web/src/context/Web3Provider.tsx (3 hunks)
  • web/src/pages/GetPnk/WalletProvider.tsx (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • web/src/consts/eip712-messages.ts
⏰ Context from checks skipped due to timeout of 90000ms (15)
  • GitHub Check: Redirect rules - kleros-v2-university
  • GitHub Check: Header rules - kleros-v2-university
  • GitHub Check: Pages changed - kleros-v2-university
  • GitHub Check: Redirect rules - kleros-v2-neo
  • GitHub Check: Header rules - kleros-v2-neo
  • GitHub Check: Pages changed - kleros-v2-neo
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: contracts-testing
  • GitHub Check: SonarCloud
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (19)
web/src/pages/GetPnk/WalletProvider.tsx (6)

5-7: Imports from @reown/appkit appear correct.
Nicely aligns with the new Reown-based architecture and replaces the old Wagmi imports.


10-10: Confirm that this WagmiProvider is still needed.
Can you confirm whether the WagmiProvider from the original package is indeed essential, now that we are using WagmiAdapter?


22-22: useRef for adapter is fine.
Using a ref to persist the adapter instance is a valid approach and helps preserve state across re-renders.


34-34: Syncing wagmiConfig with connectors and chains.
Please ensure that the connectors array includes all necessary connectors for your use cases, especially if you plan to integrate more wallets.


36-41: createAppKit parameters look consistent with environment logic.
Check that the selected production network truly aligns with your QA environment. If this is “only testing,” consider making the environment toggles more explicit (e.g., staging vs production).


51-51: WagmiProvider reconnectOnMount={false}.
Be aware that users may have to manually reconnect each session. Confirm that this is the intended behavior.

web/src/context/Web3Provider.tsx (6)

3-11: Imports from @reown/appkit/networks
Good to see you migrating chain constants to the new library. Verify that all relevant chain data (explorers, block time, etc.) is present if your dApp depends on it.


12-14: Including Wagmi’s fallback, http, and webSocket.
Retaining Wagmi utilities may be helpful for bridging. Confirm if the fallback approach is practical for all targeted networks.


76-76: Casting ALL_CHAINS to [AppKitNetwork, ...AppKitNetwork[]]
Verify that ALL_CHAINS is never empty at runtime to avoid type mismatch.


84-86: wagmiAdapter initialization
This is a clear approach to unify networks, projectId, and transports. Make sure each chain’s RPCs are stable under high load or fail gracefully.


97-114: createAppKit call
The added features key and the commented-out items can be toggled anytime. Good for future expansions. Confirm you’re comfortable with allowUnsupportedChain: true if your dApp must strictly limit supported networks.


118-118: Wrapping children with <WagmiProvider>.
Ensure you have tested the end-to-end re-render flows after this migration, especially if children rely on Wagmi context.

web/src/consts/chains.ts (3)

1-2: Switch to AppKitNetwork and Chain from viem.
The new type references look correct for the Reown migration.


9-9: SUPPORTED_CHAINS recorded as AppKitNetwork.
Ensure contracts or watchers referencing old Wagmi chain definitions are updated accordingly.


14-14: QUERY_CHAINS changed to AppKitNetwork.
This aligns read-only flow with the new app kit approach. Check any offchain data queries for chain mismatch.

web/src/components/ConnectWallet/index.tsx (2)

3-3: LGTM! Import changes align with migration objective.

The migration from Web3Modal to AppKit imports is correctly implemented.


38-39: Verify AppKit API compatibility.

The migration from Web3Modal to AppKit looks correct, but since this is marked as "Only testing", please verify:

  1. The open method signature matches between Web3Modal and AppKit
  2. The state management behavior remains consistent
  3. No breaking changes in the modal behavior
✅ Verification successful

AppKit integration verified successfully

The migration from Web3Modal to AppKit is safe and compatible:

  • Hook patterns and state management are identical
  • Built on the same foundations (WalletConnect, viem)
  • Using stable version (1.6.5) with proper wagmi adapter
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any other Web3Modal usages that might need migration
rg -l "@web3modal" .

# Search for AppKit usage patterns to ensure consistency
rg "useAppKit|useAppKitState" .

# Look for any migration guides or breaking changes
rg -l "migration|breaking.+changes" .

Length of output: 682


Script:

#!/bin/bash
# Check Web3Modal implementation in web-devtools
cat ./web-devtools/src/components/ConnectWallet/index.tsx

# Check Web3Provider implementation
cat ./web-devtools/src/context/Web3Provider.tsx

# Look for AppKit documentation or type definitions
fd "appkit.*d.ts|appkit.*md" .

Length of output: 5110


Script:

#!/bin/bash
# Check if AppKit is a published package and examine its details
npm info @reown/appkit

# Look for local AppKit implementation
fd -g "*appkit*" .

# Check package.json for AppKit dependency
cat ./web/package.json

Length of output: 6345

web/package.json (2)

82-82: Verify stability of @bigmi/react.

The package version (^0.1.0) indicates an early release. Since this is a testing phase:

  1. Verify package stability
  2. Check for breaking changes in future releases
  3. Consider pinning the version

90-91: Verify LIFI dependency updates.

The updates to LIFI packages (@lifi/wallet-management, @lifi/widget) should be reviewed:

  1. Check changelog for breaking changes
  2. Verify compatibility with new wallet adapters
✅ Verification successful

LIFI dependency updates are safe to proceed.

The updates to @lifi/widget (3.14.2) and @lifi/wallet-management (3.6.0) contain only bug fixes and non-breaking features that improve address handling, UI components, and wallet support. The changes are compatible with current usage in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for LIFI-related issues
gh api -X GET search/issues -f q="repo:kleros/kleros-v2 lifi"

# Look for LIFI integration points
rg "@lifi" .

Length of output: 66992


Script:

#!/bin/bash
# Check LIFI widget changelog
curl -s https://raw.githubusercontent.com/lifinance/widget/main/CHANGELOG.md

# Check LIFI wallet management changelog  
curl -s https://raw.githubusercontent.com/lifinance/widget/main/packages/wallet-management/CHANGELOG.md

# Look for LIFI integration points to verify compatibility
rg -A 5 "import.*@lifi" .

Length of output: 78034


Script:

#!/bin/bash
# Find LIFI widget usage
ast-grep --pattern 'import { LiFiWidget } from "@lifi/widget"'

# Find LIFI wallet management usage
ast-grep --pattern 'import { $_ } from "@lifi/wallet-management"'

# Look for LIFI configuration
rg -A 5 "LiFiWidget" .

Length of output: 923

web/package.json Show resolved Hide resolved
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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3ce6bd2 and cb912a5.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (3)
  • kleros-app/package.json (1 hunks)
  • web-devtools/package.json (1 hunks)
  • web/package.json (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/package.json
⏰ Context from checks skipped due to timeout of 90000ms (15)
  • GitHub Check: Redirect rules - kleros-v2-neo
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-neo
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-neo
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: Redirect rules - kleros-v2-university
  • GitHub Check: Header rules - kleros-v2-university
  • GitHub Check: Pages changed - kleros-v2-university
  • GitHub Check: SonarCloud
  • GitHub Check: contracts-testing
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
kleros-app/package.json (1)

64-64: Verify wagmi version compatibility with @reown/appkit.

Let's ensure the wagmi version is compatible with @reown/appkit requirements.

✅ Verification successful

wagmi v2.14.0 is compatible with @reown/appkit

@reown/appkit uses viem 2.x, which is the same foundation that wagmi 2.x is built upon, ensuring compatibility between these packages.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check @reown/appkit's wagmi version requirements

# Get @reown/appkit package.json
curl -s "https://registry.npmjs.org/@reown/appkit/latest" | jq -r '.peerDependencies.wagmi'

Length of output: 94


Script:

#!/bin/bash
# Description: Check @reown/appkit package details

# Get full package.json to examine all dependency fields
curl -s "https://registry.npmjs.org/@reown/appkit/latest" | jq '{ 
  name: .name,
  version: .version,
  dependencies,
  peerDependencies,
  devDependencies
}'

Length of output: 1090

kleros-app/package.json Show resolved Hide resolved
web-devtools/package.json Outdated Show resolved Hide resolved
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)
kleros-app/README.md (1)

30-30: Fix syntax error in the example code.

The example code has a syntax error in the return statement. The return statement should include parentheses.

-  return
+  return (
     <WagmiProvider config={config}>
         <QueryClientProvider client={queryClient}>
             <AtlasProvider config={{ uri: import.meta.env.REACT_APP_ATLAS_URI, product: Products.CourtV2, wagmiConfig: wagmiConfig }}>
             ...
             </AtlasProvider>
         </QueryClientProvider>
     </WagmiProvider>
+  )

Also applies to: 35-36, 40-40

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3cd5189 and 41365fe.

📒 Files selected for processing (3)
  • kleros-app/README.md (1 hunks)
  • kleros-app/src/lib/atlas/providers/AtlasProvider.tsx (3 hunks)
  • web/src/context/AtlasProvider.tsx (1 hunks)
🧰 Additional context used
📓 Learnings (1)
web/src/context/AtlasProvider.tsx (1)
Learnt from: Harman-singh-waraich
PR: kleros/kleros-v2#1687
File: web/src/context/AtlasProvider.tsx:225-244
Timestamp: 2024-11-12T04:49:48.060Z
Learning: In `web/src/context/AtlasProvider.tsx`, the `atlasUri` variable comes from environment variables and does not change, so it does not need to be included in dependency arrays.
⏰ Context from checks skipped due to timeout of 90000ms (14)
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Redirect rules - kleros-v2-university
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-university
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-university
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: Redirect rules - kleros-v2-testnet-devtools
  • GitHub Check: Header rules - kleros-v2-testnet-devtools
  • GitHub Check: Pages changed - kleros-v2-testnet-devtools
  • GitHub Check: contracts-testing
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (5)
web/src/context/AtlasProvider.tsx (2)

3-3: LGTM: Import statement is correctly placed.

The import of useConfig from wagmi is appropriately placed with other imports.


8-8: LGTM: Proper usage of wagmi configuration.

The useConfig hook is correctly used to obtain the wagmi configuration, and it's properly passed to the _AtlasProvider component.

Also applies to: 10-10

kleros-app/src/lib/atlas/providers/AtlasProvider.tsx (3)

5-5: LGTM: Import statement includes necessary types.

The import statement correctly includes the Config type from wagmi.


56-56: LGTM: Interface properly extended.

The AtlasConfig interface is correctly extended with the wagmiConfig property.


60-61: LGTM: Consistent wagmi hook configuration.

The wagmi hooks (useAccount, useChainId, useSignMessage) are consistently configured with the provided wagmiConfig.

Also applies to: 70-70

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

🔭 Outside diff range comments (1)
web-devtools/src/context/Web3Provider.tsx (1)

68-69: Update chains type to AppKitNetwork[] for compatibility

Currently, chains is defined as ALL_CHAINS as [Chain, ...Chain[]];. Since AppKit expects networks to be of type AppKitNetwork[], consider updating the type to ensure compatibility and prevent type errors.

Apply this diff to update the type:

-const chains = ALL_CHAINS as [Chain, ...Chain[]];
+import { type AppKitNetwork } from "@reown/appkit";
+
+const chains = ALL_CHAINS as [AppKitNetwork, ...AppKitNetwork[]];
🧹 Nitpick comments (1)
web-devtools/src/consts/chains.ts (1)

11-14: Consider documenting the purpose of QUERY_CHAINS.

The type migration looks good. However, it would be helpful to add a comment explaining why certain chains are included in QUERY_CHAINS vs SUPPORTED_CHAINS.

+// QUERY_CHAINS represents chains used for data querying purposes,
+// while SUPPORTED_CHAINS represents chains where the application can be deployed
 export const QUERY_CHAINS: Record<number, AppKitNetwork> = {
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 41365fe and d36eaad.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (4)
  • web-devtools/package.json (2 hunks)
  • web-devtools/src/components/ConnectWallet/index.tsx (2 hunks)
  • web-devtools/src/consts/chains.ts (1 hunks)
  • web-devtools/src/context/Web3Provider.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web-devtools/package.json
⏰ Context from checks skipped due to timeout of 90000ms (16)
  • GitHub Check: Redirect rules - kleros-v2-neo
  • GitHub Check: Redirect rules - kleros-v2-testnet-devtools
  • GitHub Check: Header rules - kleros-v2-neo
  • GitHub Check: Header rules - kleros-v2-testnet-devtools
  • GitHub Check: Pages changed - kleros-v2-testnet-devtools
  • GitHub Check: Pages changed - kleros-v2-neo
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: SonarCloud
  • GitHub Check: contracts-testing
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Mend Security Check
🔇 Additional comments (10)
web-devtools/src/components/ConnectWallet/index.tsx (3)

3-3: LGTM! Import changes align with AppKit migration.

The new imports from @reown/appkit/react correctly replace the Web3Modal imports as part of the migration to AppKit.


49-55: LGTM! Component logic remains appropriately unchanged.

The component correctly maintains its decision-making logic while integrating with AppKit through the ConnectButton component.


35-47: Verify the AppKit view parameter.

The migration to AppKit hooks looks good, but let's verify that "Connect" is a valid value for the view parameter in AppKit's documentation.

✅ Verification successful

🌐 Web query:

What are the valid view values for @reown/appkit's open method?

💡 Result:

The valid view values for `@reown/appkit`'s `open` method include:  

- **Core wallet interactions**:  
  - `Connect` (default when disconnected)  
  - `Account` (default when connected)  
  - `AllWallets` (wallet selection list)  
  - `Networks` (network selection)  

- **Educational views**:  
  - `WhatIsAWallet`  
  - `WhatIsANetwork`  

- **Transaction features**:  
  - `Swap` (on-ramp/crypto exchange interface)  
  - `WalletSend` (asset transfer screen)  
  - `OnRampProviders`  

These views enable granular control over modal content[1][4][7]. Developers can trigger specific flows programmatically using:  

```javascript
modal.open({ view: 'Swap' })  // Example for crypto swap interface
```  

The views vary slightly between frameworks (React/Vue/React Native) but maintain consistent core options[2][5][7]. Some views like `Networks` allow pre-connection network selection[4][8].

Citations:

- 1: https://github.com/reown-com/appkit/releases
- 2: https://docs.reown.com/appkit/next/core/installation
- 3: https://github.com/reown-com/reown-docs/blob/main/docs/appkit/upgrade/to-reown-appkit-ethers-web.mdx
- 4: https://docs.reown.com/appkit/react-native/core/hooks
- 5: https://docs.reown.com/appkit/react/core/installation
- 6: https://developer.apple.com/documentation/appkit/nsview/previousvalidkeyview
- 7: https://docs.reown.com/appkit/vue/core/composables
- 8: https://docs.reown.com/appkit/upgrade/to-reown-appkit-web
- 9: https://developer.apple.com/documentation/macos-release-notes/appkit-release-notes-for-macos-10_14
- 10: https://github.com/reown-com/reown-docs/blob/main/docs/appkit/upgrade/to-reown-appkit-web.mdx

The "Connect" view parameter is valid.
The web documentation confirms that "Connect" is among the valid values for the open method in @reown/appkit (default when disconnected). The migration to AppKit hooks, including the use of open({ view: "Connect" }), is correct.

web-devtools/src/context/Web3Provider.tsx (5)

4-5: Appropriate imports for AppKit migration

The updated imports from wagmi and @reown/appkit/networks are correctly included for the AppKit integration.


11-12: Correctly importing createAppKit and WagmiAdapter

The addition of createAppKit and WagmiAdapter imports is necessary for the new AppKit-based implementation.


76-78: Ensure wagmiAdapter receives correct network types

After updating chains to AppKitNetwork[], the wagmiAdapter will receive networks of the expected type, ensuring type compatibility.


89-92: Verify network types in createAppKit configuration

Ensure that networks and defaultNetwork provided to createAppKit are of the correct AppKitNetwork types. This will align with AppKit's requirements and prevent potential runtime issues.


100-100: Confirm correct configuration passed to WagmiProvider

Using wagmiAdapter.wagmiConfig in WagmiProvider appears appropriate. Verify that wagmiConfig contains all necessary configurations for the provider to function correctly.

web-devtools/src/consts/chains.ts (2)

7-9: LGTM! Type migration looks good.

The update to use AppKitNetwork type is consistent with the migration strategy while maintaining the same logical structure.


1-1: LGTM! Verify @reown/appkit version.

The migration from viem/chains to @reown/appkit/networks aligns with the PR objectives.

Let's verify the package version and its compatibility:

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Check the installed version of @reown/appkit
jq '.dependencies["@reown/appkit"]' package.json

# Check if there are any peer dependency conflicts
npm ls @reown/appkit

Length of output: 126


I'll run an additional script to search throughout the repository for any references or declarations of @reown/appkit to ensure that it’s properly listed as a dependency (or otherwise pulled in transitively).


🏁 Script executed:

#!/bin/bash
echo "Searching for '@reown/appkit' in package.json..."
rg '@reown/appkit' package.json

echo "Searching for '@reown/appkit' in package-lock.json..."
rg '@reown/appkit' package-lock.json || echo "package-lock.json not found."

echo "Searching for '@reown/appkit' in yarn.lock..."
rg '@reown/appkit' yarn.lock || echo "yarn.lock not found."

echo "Searching for '@reown/appkit' in the entire repository (excluding node_modules)..."
rg '@reown/appkit' --glob '!node_modules'

Length of output: 7711


LGTM – @reown/appkit version verified.

The search confirms that the dependency is declared with version ^1.6.5 (as seen in the relevant package.json files and the lock file), and no peer dependency conflicts were detected. This supports the import change in web-devtools/src/consts/chains.ts.

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 6, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 6, 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

🔭 Outside diff range comments (1)
web-devtools/src/context/Web3Provider.tsx (1)

68-69: Update chain type casting for AppKit compatibility.

The chain type casting should be updated to use AppKit types for better type safety.

-const chains = ALL_CHAINS as [Chain, ...Chain[]];
+import { type AppKitNetwork } from "@reown/appkit";
+const chains = ALL_CHAINS as [AppKitNetwork, ...AppKitNetwork[]];
🧹 Nitpick comments (1)
web-devtools/src/context/Web3Provider.tsx (1)

23-30: Consider enhancing type safety for chain mapping.

While the mapping is correct, we can improve type safety by using the network types from AppKit.

-const alchemyToViemChain: Record<number, string> = {
+import { type AppKitNetwork } from "@reown/appkit";
+const alchemyToViemChain: Record<AppKitNetwork['id'], string> = {
  [arbitrumSepolia.id]: "arb-sepolia",
  [arbitrum.id]: "arb-mainnet",
  // ... rest of the mapping
};
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between beb44c8 and 9e9d62e.

📒 Files selected for processing (2)
  • web-devtools/src/context/Web3Provider.tsx (3 hunks)
  • web-devtools/src/utils/getDisputeRequestParamsFromTxn.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: contracts-testing
  • GitHub Check: Analyze (javascript)
  • GitHub Check: SonarCloud
🔇 Additional comments (5)
web-devtools/src/utils/getDisputeRequestParamsFromTxn.ts (2)

8-35: LGTM! Function logic remains correct.

The core functionality of extracting dispute request parameters from transactions is preserved, with proper error handling and type safety.


4-4: LGTM! Correctly adapted to use wagmiAdapter.

The changes align with the PR's objective of migrating to AppKit, properly updating the import and usage of the wagmi configuration.

Let's verify that the wagmiAdapter export exists in the Web3Provider:

Also applies to: 10-10

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Verify the wagmiAdapter export in Web3Provider
ast-grep --pattern 'export const wagmiAdapter = $$$'

Length of output: 377


Verified: The wagmiAdapter export exists and is correctly used.

The shell script confirms the export in web-devtools/src/context/Web3Provider.tsx, matching the usage in getDisputeRequestParamsFromTxn.ts. This implementation aligns with the migration objectives.

web-devtools/src/context/Web3Provider.tsx (3)

4-5: LGTM! Clean migration of imports.

The import changes correctly align with the migration from Web3Modal to AppKit while maintaining type safety.

Also applies to: 11-12


99-101: LGTM! Clean provider implementation.

The Web3Provider component correctly uses the wagmiAdapter configuration.


76-80: Verify AppKit configuration across the application.

The AppKit configuration looks correct, but ensure that all wallet-related components in the application are updated to use the new AppKit APIs.

Also applies to: 89-98

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Search for any remaining Web3Modal usage that needs to be migrated
rg -l "Web3Modal|@web3modal" --type ts --type tsx

Length of output: 79


🏁 Script executed:

#!/bin/bash
# Re-run search for any remaining Web3Modal usage with glob patterns to include TS and TSX files.
rg -l "Web3Modal|@web3modal" --glob "*.ts" --glob "*.tsx"

Length of output: 59


🏁 Script executed:

#!/bin/bash
# Searching for references to WagmiAdapter to verify that the new AppKit API usage is consistent across the codebase.
rg -l "WagmiAdapter" --glob "*.ts" --glob "*.tsx"

Length of output: 164


AppKit configuration verification complete.

The new AppKit API usage with WagmiAdapter is consistently integrated in all relevant wallet provider components, and no residual references to Web3Modal were found.

  • Confirmed usage in:
    • web-devtools/src/context/Web3Provider.tsx
    • web/src/context/Web3Provider.tsx
    • web/src/pages/GetPnk/WalletProvider.tsx

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 6, 2025
Copy link

codeclimate bot commented Feb 6, 2025

Code Climate has analyzed commit d594c19 and detected 0 issues on this pull request.

View more on Code Climate.

Copy link

sonarqubecloud bot commented Feb 6, 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

🧹 Nitpick comments (2)
web/src/context/Web3Provider.tsx (2)

79-88: Consider moving projectId validation before adapter setup.

While the adapter configuration is correct, consider moving the projectId validation before line 84 to fail fast and prevent potential runtime errors.

+const projectId = import.meta.env.WALLETCONNECT_PROJECT_ID;
+if (!projectId) {
+  throw new Error("WalletConnect project ID is not set in WALLETCONNECT_PROJECT_ID environment variable.");
+}
+
const chains = ALL_CHAINS as [AppKitNetwork, ...AppKitNetwork[]];
const transports = getTransports();

-const projectId = import.meta.env.WALLETCONNECT_PROJECT_ID;
-if (!projectId) {
-  throw new Error("WalletConnect project ID is not set in WALLETCONNECT_PROJECT_ID environment variable.");
-}

const wagmiAdapter = new WagmiAdapter({
  networks: chains,
  projectId,
  transports,
});

97-116: Document feature flag configuration options.

The commented feature flags indicate future toggle options. Consider adding a comment block explaining when and why these features might be enabled/disabled.

 createAppKit({
   adapters: [wagmiAdapter],
   networks: chains,
   defaultNetwork: isProduction ? arbitrum : arbitrumSepolia,
   projectId,
   allowUnsupportedChain: true,
   themeVariables: {
     "--w3m-color-mix": lightTheme.primaryPurple,
     "--w3m-color-mix-strength": 20,
     // overlay portal is at 9999
     "--w3m-z-index": 10000,
   },
+  /**
+   * Feature flags for AppKit configuration
+   * - email: Enable/disable email login
+   * - socials: Enable/disable social login options
+   * - onramp: Enable/disable fiat onramp
+   * - swap: Enable/disable token swap functionality
+   */
   features: {
     // adding these here to toggle in futute if needed
     // email: false,
     // socials: false,
     // onramp:false,
     // swap: false
   },
 });
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9e9d62e and d594c19.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (2)
  • web/package.json (2 hunks)
  • web/src/context/Web3Provider.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/package.json
⏰ Context from checks skipped due to timeout of 90000ms (16)
  • GitHub Check: Redirect rules - kleros-v2-neo
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-neo
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-neo
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: Redirect rules - kleros-v2-testnet-devtools
  • GitHub Check: Header rules - kleros-v2-testnet-devtools
  • GitHub Check: Pages changed - kleros-v2-testnet-devtools
  • GitHub Check: contracts-testing
  • GitHub Check: SonarCloud
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Mend Security Check
🔇 Additional comments (4)
web/src/context/Web3Provider.tsx (4)

3-15: LGTM! Import statements align with AppKit migration.

The updated imports correctly reflect the migration from Web3Modal to AppKit, including the necessary chain definitions and adapter components.


60-63: Type safety improvement with AppKitNetwork.

The transport configuration has been properly updated to use the more specific AppKitNetwork type instead of the generic Chain type, improving type safety.


117-119: LGTM! Provider implementation correctly uses WagmiAdapter.

The Web3Provider component correctly uses the wagmiAdapter.wagmiConfig with WagmiProvider.


12-13: Verify AppKit package versions.

Let's ensure we're using the latest stable versions of AppKit packages.

✅ Verification successful

🌐 Web query:

What is the latest version of @reown/appkit and @reown/appkit-adapter-wagmi?

💡 Result:

The latest version of **@reown/appkit** is **v4.2.3** or higher based on documentation updated on January 29, 2025[6][7]. For **@reown/appkit-adapter-wagmi**, the most recent version listed in official sources is **v1.6.5**, published to NPM on January 22, 2025[5][9].

Key details:
- The AppKit core library received updates through February 2025 including WalletConnect package upgrades and new wallet button features[10]
- The Wagmi adapter specifically shows active maintenance with its latest NPM release being v1.6.5[5]
- Documentation recommends using `@tanstack/react-query` v5+ and `wagmi` v2+ when working with these versions[1][2]

For production use, always verify compatibility between AppKit core and adapter versions through Reown's official migration guides[1][7].

Citations:

- 1: https://docs.reown.com/appkit/upgrade/to-reown-appkit-web
- 2: https://docs.reown.com/appkit/javascript/core/installation
- 3: https://docs.reown.com/appkit/upgrade/to-reown-appkit-ethers-web
- 4: https://docs.reown.com/appkit/upgrade/to-reown-appkit-solana-web
- 5: https://www.npmjs.com/package/@reown/appkit-adapter-wagmi
- 6: https://docs.reown.com/appkit/react/core/options
- 7: https://docs.reown.com/appkit/upgrade/from-w3m-to-reown
- 8: https://docs.reown.com/appkit/next/core/installation
- 9: https://socket.dev/npm/package/@reown/appkit-adapter-wagmi/files
- 10: https://github.com/reown-com/appkit/releases

Package Versions OK - Verify in package.json

  • The latest version for @reown/appkit is v4.2.3 or higher.
  • The latest version for @reown/appkit-adapter-wagmi is v1.6.5.

Please ensure that your package.json reflects these versions (or later) to maintain compatibility with the migration.

@@ -49,7 +49,8 @@
"typescript": "^5.6.3",
"vite": "^5.4.11",
"vite-plugin-dts": "^4.3.0",
"vite-plugin-node-polyfills": "^0.22.0"
"vite-plugin-node-polyfills": "^0.22.0",
"wagmi": "^2.14.0"
Copy link
Member

Choose a reason for hiding this comment

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

wagmi doesn't need to be a devDep, it's already a dep

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants