Repository navigation
fix(account): handle disconnection of injected wallets after a refresh - #7894
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughReown wallet initialization now reads wagmi’s recent connector state for reconnection, uses URL or persisted AppKit state to select the default network, and seeds account state from the restored AppKit network when no URL chain ID is present. ENS wagmi configuration and bundle-size records are also updated. ChangesReown wallet state
Token configuration and metrics
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant WalletApp
participant URL
participant Storage
participant getReownDefaultNetwork
participant AppKit
participant useAccountState
WalletApp->>URL: read raw chain id
getReownDefaultNetwork->>Storage: read persisted connector and namespace state
Storage-->>getReownDefaultNetwork: return wallet state
getReownDefaultNetwork->>AppKit: resolve selected network
WalletApp->>AppKit: read restored CAIP network
AppKit-->>useAccountState: provide restored network
URL-->>useAccountState: provide URL chain id when present
useAccountState->>useAccountState: map to supported chain id or mainnet
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
libs/wallet/src/wagmi/getReownDefaultNetwork.ts (1)
13-36: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd regression coverage for persisted namespace fallback.
Cover
/accountwith Solana as the active namespace, explicit EVM/Solana URLs overriding persisted state, Solana disabled, and unavailable storage. These cases directly cover the PR’s refresh-time wallet restoration contract.🤖 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 `@libs/wallet/src/wagmi/getReownDefaultNetwork.ts` around lines 13 - 36, Add regression tests for getReownDefaultNetwork covering /account with a persisted Solana namespace, explicit EVM and Solana URL chain IDs taking precedence, Solana-disabled behavior, and unavailable localStorage. Mock the relevant URL, feature-flag, namespace, and chain helpers so the tests verify the refresh-time fallback contract without relying on browser storage.
🤖 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.
Nitpick comments:
In `@libs/wallet/src/wagmi/getReownDefaultNetwork.ts`:
- Around line 13-36: Add regression tests for getReownDefaultNetwork covering
/account with a persisted Solana namespace, explicit EVM and Solana URL chain
IDs taking precedence, Solana-disabled behavior, and unavailable localStorage.
Mock the relevant URL, feature-flag, namespace, and chain helpers so the tests
verify the refresh-time fallback contract without relying on browser storage.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 56ecb6bc-4ecc-483d-9ba0-c5d30b89ce4f
📒 Files selected for processing (2)
libs/wallet/src/wagmi/config.tslibs/wallet/src/wagmi/getReownDefaultNetwork.ts
shoom3301
left a comment
There was a problem hiding this comment.
Thanks! Works as expected
shoom3301
left a comment
There was a problem hiding this comment.
@limitofzero sorry, it actually doesn't work
vdfvdfvdf.mov
elena-zh
left a comment
There was a problem hiding this comment.
Hey @limitofzero , the app still disconnets a wallet after refreshing
…ction after refresh
Hey @elena-zh, addressed it. Should works now |
There was a problem hiding this comment.
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 `@libs/common-utils/src/localStorage.ts`:
- Around line 5-8: Update getLocalStorageItem to wrap the
localStorage.getItem(key) access in exception handling, returning null when
storage access throws while preserving the existing undefined-global fallback
and successful string/null result.
🪄 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: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f6cfb8c8-f741-4d81-8d4f-54c21dd57470
📒 Files selected for processing (4)
libs/common-utils/src/localStorage.tslibs/wallet/src/wagmi/config.tslibs/wallet/src/wagmi/getReownDefaultNetwork.tslibs/wallet/src/wagmi/hooks/useAccountState.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- libs/wallet/src/wagmi/config.ts
elena-zh
left a comment
There was a problem hiding this comment.
Hey @limitofzero , the issue is still reproducible :(
|
@limitofzero I think the changes are valid, we should not loose them. |
…t-page # Conflicts: # bundle-size.jsonc
shoom3301
left a comment
There was a problem hiding this comment.
Let's merged it and keep the bug open to fix it in the future
elena-zh
left a comment
There was a problem hiding this comment.
The issue looks like is fixed

Summary
Fixes the wallet connection being dropped when refreshing the account page (
/account), and the follow-on "can't reconnect the same wallet". Two independent root causes are addressed — one for EVM wallets, one for Solana. Full context is hereThe account page is affected specifically because it has no chain in the URL, which is the condition both bugs depend on.
To Test
EVM wallet (MetaMask / Rabby)
/account./137/swap) → still connected (no regression).Solana wallet
?IS_SOLANA_ENABLED=truein the URL, refresh, then connect a Solana wallet and go to/account./accountstill connects/restores fine with Solana enabled (no cross-namespace regression).Summary by CodeRabbit
chainIdfrom restored connection state.localStorageis unavailable.