Skip to content

feat(wallet): ensure proper session cleanup on disconnect - #52

Merged
johdanike merged 1 commit into
SwiftChainn:mainfrom
Wisdom2788:feat/wallet-cleanup
Apr 24, 2026
Merged

feat(wallet): ensure proper session cleanup on disconnect#52
johdanike merged 1 commit into
SwiftChainn:mainfrom
Wisdom2788:feat/wallet-cleanup

Conversation

@Wisdom2788

Copy link
Copy Markdown
Contributor

Summary

Implements secure wallet disconnection with full session cleanup per issue #38.

What was built

  • store/walletStore.ts — Zustand store holding wallet state (address, isConnected, chainId) with a clearWalletState action and shared WALLET_STORAGE_KEY constant
  • services/walletService.ts — API service layer that notifies the backend to invalidate the wallet session via POST /api/wallet/disconnect
  • hooks/useWallet.ts — orchestration hook: calls service → clears Zustand state → removes localStorage cache → redirects to /login. Cleanup runs unconditionally via finally so a network failure can never leave stale wallet data on the client
  • components/wallet/DisconnectButton.tsx — UI component consuming useWallet, renders wallet address + active disconnect button when connected, disabled state when not connected
  • app/(dashboard)/admin/page.tsx — wired DisconnectButton into admin dashboard
  • store/__tests__/walletStore.test.ts + hooks/__tests__/useWallet.test.ts — 10 unit tests covering all disconnect scenarios including API failure resilience

Acceptance Criteria

  • ✅ Disconnecting wallet strips all public keys from DOM — Zustand clearWalletState resets address to null
  • ✅ Zustand state cleared on disconnect
  • ✅ localStorage wallet cache removed on disconnect
  • ✅ User redirected to /login (safe page) after disconnect
  • ✅ Strict Component → Hook → Service layered architecture
  • ✅ Backend API called via walletService.disconnect() — no inline mock objects
  • ✅ 10/10 unit tests passing (screenshot attached)
  • ✅ Implementation screenshot attached

Screenshots

Disconnect wallet Disconnect wallet test pass test pass

Closes #38

@drips-wave

drips-wave Bot commented Apr 24, 2026

Copy link
Copy Markdown

@Wisdom2788 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@johdanike
johdanike merged commit 5fbdb74 into SwiftChainn:main Apr 24, 2026
0 of 2 checks passed
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.

Frontend: Wallet Disconnect & Session Cleanup

2 participants