Skip to content

Clear distribution session storage on wallet disconnect #11

@pragmaticAweds

Description

@pragmaticAweds

Context

Distribution form state persists in sessionStorage across wallet switches. When a user disconnects and reconnects with a different wallet, they see the previous wallet's draft distribution data (recipients, amounts, type). This is confusing and could lead to sending tokens to the wrong addresses from the wrong account.

What Success Looks Like

  • When a user disconnects their wallet, any persisted distribution form state in sessionStorage is cleared
  • Reconnecting with a new wallet starts with a fresh distribution form
  • The existing clearPersistedState() method from use-distribution-state.ts is called during disconnect

Implementation Guidance

  • apps/web/src/providers/StellarWalletProvider.tsx — the disconnect callback (line 85-91) currently only clears wallet-related localStorage keys
  • apps/web/src/hooks/use-distribution-state.ts — has a clearPersistedState() internal function (line ~310) and the key fundable_distribution_state in sessionStorage
  • Option A: Import and call the clear function in the disconnect handler
  • Option B: Add a useEffect in the distribution hook that watches the wallet address and clears state when it changes to null
  • Option B is cleaner as it doesn't couple the wallet provider to the distribution feature

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programdifficulty: easySmall, bounded changes

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions