Skip to content

fix: wrong network indicator invisible on migrate#710

Open
ECWireless wants to merge 4 commits into
mainfrom
666-wrong-network-indicator-on-migrate-only-appears-after-page-refresh
Open

fix: wrong network indicator invisible on migrate#710
ECWireless wants to merge 4 commits into
mainfrom
666-wrong-network-indicator-on-migrate-only-appears-after-page-refresh

Conversation

@ECWireless

@ECWireless ECWireless commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Description

Fixes wallet state getting lost when navigating between / and /migrate.

The app now keeps one stable wagmi/RainbowKit provider with both supported chains instead of remounting providers per route, avoiding wagmi’s reconnect race. It also adds a route-aware “Wrong Network” pill so users still get the correct chain warning for migrate vs. explorer pages.

Type of Change

  • feat: New feature
  • fix: Bug fix
  • docs: Documentation update
  • style: Code style/formatting changes (no logic changes)
  • refactor: Code refactoring (no behavior change)
  • perf: Performance improvement
  • test: Adding or updating tests
  • build: Build system or dependency changes
  • ci: CI/CD changes
  • chore: Other changes

Related Issue(s)

Closes: #666

Changes Made

  • Adds a custom "wrong network" pill
  • Includes both Ethereum and Arbitrum as supported chains (before, it set this depending on page and remounted depending on the change)
  • Adds some custom logic for determining wrong network now that both chains mentioned above are listed as supported

Testing

  • Tested locally
  • Added/updated tests
  • All tests passing

How to test (optional unless test is not trivial)

  • Connect wallet
  • On homepage, switch to Arbitrum in your wallet
  • Go to Migrate page
  • See that "wrong network" is displayed in the top-right

Impact / Risk

Risk level: Medium

Impacted areas: UI

User impact: users correctly see that they are on the wrong network on the migrate page

Rollback plan: Vercel rollback, then manual git revert

Screenshots / Recordings

Screenshot 2026-06-25 at 7 48 17 PM

Additional Notes

NA

Summary by CodeRabbit

  • New Features

    • Added a “Wrong Network” experience for wallet connections and staking actions when the connected network doesn’t match the current route, including a one-click option to switch networks.
    • Automatically determines the expected chain based on the current route to drive the correct network context.
  • Bug Fixes

    • Reduced unnecessary page remounts and re-renders during navigation.
    • Simplified wallet/provider setup for more consistent behavior across routes.
    • Disabled or prevented delegate/undelegate interactions in the wrong-network context.

Copilot AI review requested due to automatic review settings June 26, 2026 01:49
@vercel

vercel Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
explorer-arbitrum-one Ready Ready Preview, Comment Jun 27, 2026 3:35pm

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes wallet state getting lost when navigating between / and /migrate by keeping a single stable Wagmi/RainbowKit provider across routes, and introduces a route-aware “Wrong Network” pill so the UI still warns when the connected chain doesn’t match the expected chain for the current page.

Changes:

  • Removes route-based provider remounting and uses a stable Web3 provider configuration that supports both Ethereum (L1) and Arbitrum (L2).
  • Updates Web3Providers to always include both supported chains in the RainbowKit/Wagmi config.
  • Adds a custom, route-aware “Wrong Network” indicator in the ConnectButton.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
pages/_app.tsx Stops remounting providers per route; passes only locale to a stable Web3Providers wrapper.
components/Web3Providers/index.tsx Builds a single Wagmi/RainbowKit config containing both supported chains (no per-route config swapping).
components/ConnectButton/index.tsx Adds route-aware wrong-network UI (custom pill) intended to replace RainbowKit’s default behavior under multi-chain support.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread components/ConnectButton/index.tsx
Comment thread components/ConnectButton/index.tsx Outdated
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@ECWireless, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 50 minutes and 57 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4bd60525-4c56-4f50-9ec5-b1e06b91c559

📥 Commits

Reviewing files that changed from the base of the PR and between e7010ca and a606e85.

📒 Files selected for processing (1)
  • components/DelegatingWidget/Footer.tsx
📝 Walkthrough

Walkthrough

The app now keeps provider state stable across route changes, derives an expected chain from the current route, and uses that state to show wrong-network handling in the connect button and delegating widget.

Changes

Route-aware wallet chain handling

Layer / File(s) Summary
App and provider wiring
pages/_app.tsx, components/Web3Providers/index.tsx, hooks/wallet.tsx
App now reads only locale, passes it to Web3Providers, and Web3Providers selects chains from chain ids without the route-key remount. The wallet hooks add expected-chain and wrong-chain detection from the current route.
Wrong-network connect button
components/ConnectButton/index.tsx
ConnectButton uses the wrong-chain hook to replace the normal RainbowKit button with a “Wrong Network” button that opens the chain modal.
Delegating widget chain guard
components/DelegatingWidget/index.tsx, components/DelegatingWidget/Footer.tsx
DelegatingWidget disables tab changes and action tabs on mismatched chains, passes that state to Footer, and Footer shows a disabled action with an expected-chain message.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change: fixing the wrong-network indicator on the migrate route.
Description check ✅ Passed The description follows the template well, covering the fix, type, related issue, changes, testing, impact, screenshots, and notes.
Linked Issues check ✅ Passed The changes satisfy #666 by keeping a stable provider and adding a route-aware wrong-network indicator.
Out of Scope Changes check ✅ Passed No clearly unrelated code changes stand out beyond the provider, wallet, and delegation updates needed for the bug fix.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 666-wrong-network-indicator-on-migrate-only-appears-after-page-refresh

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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

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

⚠️ Outside diff range comments (1)
components/Web3Providers/index.tsx (1)

28-58: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add a route-transition regression test for the stable wagmi config.

  • Problem: This change removes the route-driven remount and makes the wagmi config stable, but the diff does not add regression coverage for navigating between / and /migrate while a wallet is already connected.
  • Why it matters: The original bug was a route-change reconnect race. Without a navigation test, a later provider/layout change can silently reintroduce lost wallet state or the missing “Wrong Network” state.
  • Suggested fix: Add an integration test that mounts the app with a mocked connected wallet, navigates //migrate/, and asserts the account stays connected while the route-specific wrong-network UI updates correctly.

As per path instructions, code quality comments here should focus on reliability and future changes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@components/Web3Providers/index.tsx` around lines 28 - 58, Add regression
coverage for the stable wagmi config by adding an integration test around
Web3Providers that mounts the app with a mocked connected wallet, navigates from
“/” to “/migrate” and back, and verifies the connection state is preserved while
the route-specific wrong-network UI still updates correctly. Use the unique
symbols Web3Providers and getDefaultConfig to locate the provider setup, and
assert the route transition does not trigger a wallet reconnect or lose the
connected account.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@components/Web3Providers/index.tsx`:
- Around line 28-58: Add regression coverage for the stable wagmi config by
adding an integration test around Web3Providers that mounts the app with a
mocked connected wallet, navigates from “/” to “/migrate” and back, and verifies
the connection state is preserved while the route-specific wrong-network UI
still updates correctly. Use the unique symbols Web3Providers and
getDefaultConfig to locate the provider setup, and assert the route transition
does not trigger a wallet reconnect or lose the connected account.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: bda596cf-5561-4cca-aa24-825baeac948b

📥 Commits

Reviewing files that changed from the base of the PR and between 2c37a7e and 4ace5de.

📒 Files selected for processing (3)
  • components/ConnectButton/index.tsx
  • components/Web3Providers/index.tsx
  • pages/_app.tsx

@ECWireless

Copy link
Copy Markdown
Collaborator Author

In e7010ca, ensured that the delegation widget was disabled when using the wrong network.

Screenshot 2026-06-27 at 9 22 21 AM

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@components/DelegatingWidget/Footer.tsx`:
- Around line 64-71: The wrong-network footer branch in Footer is unreachable
because useAccountAddress() returns null on unsupported chains and the existing
!accountAddress early return fires first. Update the Footer component logic so
isWrongRouteChain is checked before the unauthenticated branch, or use
useAccount() to determine connection state while keeping useAccountAddress()
only for address-dependent reads. This ensures connected users on an unsupported
network see the wrong-network guidance instead of the generic connect-wallet
state.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 714e4786-60d1-4040-87a3-aa28ee5d7589

📥 Commits

Reviewing files that changed from the base of the PR and between 4ace5de and e7010ca.

📒 Files selected for processing (4)
  • components/ConnectButton/index.tsx
  • components/DelegatingWidget/Footer.tsx
  • components/DelegatingWidget/index.tsx
  • hooks/wallet.tsx

Comment thread components/DelegatingWidget/Footer.tsx
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.

Wrong Network indicator on /migrate only appears after page refresh

2 participants