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
Context
Distribution form state persists in
sessionStorageacross 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
clearPersistedState()method fromuse-distribution-state.tsis called during disconnectImplementation Guidance
apps/web/src/providers/StellarWalletProvider.tsx— thedisconnectcallback (line 85-91) currently only clears wallet-related localStorage keysapps/web/src/hooks/use-distribution-state.ts— has aclearPersistedState()internal function (line ~310) and the keyfundable_distribution_statein sessionStorageuseEffectin the distribution hook that watches the wallet address and clears state when it changes to null