Skip to content

Bug: disconnect() calls a blanket localStorage.clear()/sessionStorage.clear(), wiping unrelated app state like the theme preference #237

Description

@Jaydbrown

Location

contexts/WalletContext.tsx:397-398 (disconnect)

Description

disconnect() calls localStorage.clear() and sessionStorage.clear() unconditionally, not scoped to the wallet-specific storage key. Confirmed via next-themes (a real package.json dependency, used in components/ThemeToggle.tsx) that this also wipes the user's persisted theme preference — an unrelated feature — every time they disconnect their wallet.

Why it matters

Disconnecting a wallet is a routine, frequent action; resetting the user's theme (and any other unrelated localStorage/sessionStorage state any future feature might add) every single time is a surprising, unintended side effect with a growing blast radius as more features start using storage.

Suggested fix

Remove only the specific wallet-session storage key(s) instead of calling a blanket clear().

Acceptance criteria

  • disconnect() only removes wallet-specific storage entries
  • Theme preference (and other unrelated storage) survives a disconnect
  • Test covering that unrelated storage keys are preserved across disconnect

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions