Skip to content

feat: clear decentraland-connect storage on wallet disconnect#45

Merged
LautaroPetaccio merged 1 commit intomasterfrom
feat/clear-connection-storage-on-disconnect
Apr 2, 2026
Merged

feat: clear decentraland-connect storage on wallet disconnect#45
LautaroPetaccio merged 1 commit intomasterfrom
feat/clear-connection-storage-on-disconnect

Conversation

@LautaroPetaccio
Copy link
Copy Markdown
Contributor

Summary

  • Other Decentraland sites that use decentraland-connect clear the decentraland-connect-storage-key localStorage entry when a user disconnects their wallet. Without matching this behavior in core-web3, a disconnect here leaves stale connection metadata (provider type and chain ID) behind, which can cause those sites to still see the user as connected.
  • This adds a clearConnectionStorage function (mirroring decentraland-connect's ConnectionManager.clearConnectionData) and calls it from the useWallet disconnect callback so both libraries stay in sync.
  • The function is also exported for consumers that need to call it outside of useWallet.

How it works

  1. A new clearConnectionStorage() in src/config/wagmi.ts removes the decentraland-connect-storage-key from localStorage, with SSR safety guards.
  2. The disconnect callback in useWallet now calls clearConnectionStorage() right after wagmiDisconnect().

Test plan

  • clearConnectionStorage unit tests: removes the expected key, no-ops when window is undefined
  • useWallet disconnect test: verifies clearConnectionStorage is called on disconnect
  • All existing tests continue to pass

Sites using decentraland-connect clear the `decentraland-connect-storage-key`
localStorage entry when disconnecting. Without this, users who disconnect
through core-web3 leave stale connection metadata behind, which can cause
those sites to mistakenly believe a wallet is still connected.
@coveralls
Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 23925396945

Details

  • 5 of 6 (83.33%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.2%) to 92.768%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/config/wagmi.ts 3 4 75.0%
Totals Coverage Status
Change from base Build 23925046621: -0.2%
Covered Lines: 467
Relevant Lines: 494

💛 - Coveralls

@LautaroPetaccio LautaroPetaccio merged commit 10109cf into master Apr 2, 2026
5 checks passed
@LautaroPetaccio LautaroPetaccio deleted the feat/clear-connection-storage-on-disconnect branch April 2, 2026 22:46
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.

3 participants