Skip to content

Conversation

@cto-new
Copy link
Contributor

@cto-new cto-new bot commented Oct 30, 2025

Summary

This PR improves the wrong network modal by adding automatic network switching and showing user-friendly network names instead of just chain IDs.

Changes

  • Implements automatic network switching: when a network mismatch is detected, attempts to switch using wagmi's switchChainAsync before showing the modal
  • Modal now displays current and expected network names (e.g., "Base") in addition to chain IDs
  • Detailed modal fallback messages for cases where the switch cannot be performed automatically (user rejects, chain not configured, wallet doesn't support programswitch, etc)
  • Keeps modal hidden during auto-switch attempts to prevent flashing; shows it only when truly needed
  • Uses app config for expected network and user wallet info for current network name
  • No new dependencies or new configuration introduced

Testing

  • Verified network switching works with wallets that support switchChainAsync (e.g., MetaMask)
  • Confirmed fallback modals/messages appear when auto-switch fails, chain not configured, wallet does not support, or rejected by the user
  • Manual test: network mismatch triggers switch, modal only appears if needed
  • pnpm lint, format:check, and build all pass

Checklist

  • Code follows repository patterns
  • No console.log statements
  • pnpm lint/format pass
  • pnpm build succeeds

Related

  • References AAVE implementation patterns

Warning: Task VM test is not passing, cto.new will perform much better if you fix the setup

Linear issue

…me display to WrongNetworkModal

Enhances the user experience by automatically switching to the expected network
(Base/Mainnet or Base Sepolia) using wagmi when possible, displaying
user-friendly network names, and only showing the modal if auto-switch fails.

- Automatically triggers network switch via wagmi's switchChainAsync when
  a network mismatch is detected.
- Modal now displays current and expected network names, with chain IDs in a
  secondary, de-emphasized style.
- Handles wallet edge cases (not supporting auto-switch, not configured,
  user rejects, or fails), with friendly specific error messages.
- Hides modal during auto-switch attempt, showing it only as fallback if needed.
- No new dependencies added, consistent with app's existing hooks/config.

This improves onboarding and flow for users landing on the wrong network.
@vercel
Copy link
Contributor

vercel bot commented Oct 30, 2025

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

Project Deployment Preview Comments Updated (UTC)
comps Ready Ready Preview Comment Oct 30, 2025 3:51pm
comps-staging2 Ready Ready Preview Comment Oct 30, 2025 3:51pm

@github-actions
Copy link
Contributor

📊 Test Coverage Report

Package Lines Statements Functions Branches
apps/api 3.72% 3.72% 44.00% 53.20%
apps/comps 0.29% 0.29% 42.24% (+0.33%) 44.96% (+0.31%)
packages/conversions 100.00% 100.00% 100.00% 100.00%
packages/db 0.00% 0.00% 20.40% 20.40%
packages/rewards 100.00% 100.00% 100.00% 100.00%
packages/services 51.64% (+0.03%) 51.64% (+0.03%) 62.62% (+0.25%) 78.88% (+0.17%)
packages/staking-contracts 100.00% 100.00% 100.00% 100.00%

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.

1 participant