Skip to content

Clear server-state cache on wallet disconnect #17

Description

@Lakes41

Difficulty: Hard

Type: Bug

Summary

Ensure wallet-specific query data is cleared when the user disconnects or resets the app. This prevents data from a previous wallet from remaining visible after account changes.

Current Behaviour

The wallet store clears walletAddress and isConnected, but TanStack Query cache entries for memberships, guild details, roles, or access checks are not explicitly cleared.

Expected Behaviour

Disconnecting or resetting the app should remove wallet-scoped cached data and prevent stale membership or role information from appearing for the next user.

Suggested Implementation

Add a wallet-aware cache clearing flow. This can be implemented by calling queryClient.removeQueries or queryClient.clear from a logout/reset service, then routing the user back to onboarding or profile.

Files or Areas Likely Affected

  • src/features/wallet/wallet.store.ts
  • src/features/wallet/useWallet.ts
  • src/lib/queryClient.ts
  • app/settings.tsx
  • app/profile.tsx
  • tests/

Acceptance Criteria

  • Disconnect clears wallet-scoped membership queries
  • Disconnect clears wallet-scoped role queries
  • Disconnect clears previous access check results
  • The user is not shown stale data after reconnecting with another address
  • Reset app state has the same cache-clearing behaviour
  • Tests cover wallet switch and disconnect scenarios

Additional Notes

Use targeted cache removal if global cache clearing would remove non-sensitive app configuration unnecessarily.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaign

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions