You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
src/hooks/useSorobanQuery.ts defines query keys as plain string constants (QUERY_KEYS.POOLS, QUERY_KEYS.USER_POSITION). As more queries are added (platform stats, boost config, leaderboard, credits, history) these flat keys will collide — e.g. useUserPosition('pool-a') and useUserPosition('pool-b') both use the key ['userPosition', poolId, publicKey] but if publicKey changes and the old queries are not invalidated correctly, stale data from a previous wallet session can bleed into the new session.
Acceptance Criteria
src/lib/queryKeys.ts exports a type-safe query key factory using the pattern from TanStack Query docs:
All useQuery and queryClient.invalidateQueries call sites in useSorobanQuery.ts switch to this factory
When publicKey changes in StellarWalletContext, a useEffect calls queryClient.removeQueries({ queryKey: ['userPosition'] }) and queryClient.removeQueries({ queryKey: ['userCredits'] }) so the previous wallet's data is never shown to the next connected wallet
ReactQueryDevtools imported from @tanstack/react-query-devtools is rendered inside AppShell.tsx only when process.env.NODE_ENV === 'development' (zero bundle cost in production via next/dynamic with ssr: false)
A Vitest test changes publicKey and verifies the user-scoped cache entries are removed
Relevant Files
src/lib/queryKeys.ts — create
src/hooks/useSorobanQuery.ts — migrate to key factory
src/context/StellarWalletContext.tsx — add queryClient.removeQueries on disconnect
Problem
src/hooks/useSorobanQuery.tsdefines query keys as plain string constants (QUERY_KEYS.POOLS,QUERY_KEYS.USER_POSITION). As more queries are added (platform stats, boost config, leaderboard, credits, history) these flat keys will collide — e.g.useUserPosition('pool-a')anduseUserPosition('pool-b')both use the key['userPosition', poolId, publicKey]but ifpublicKeychanges and the old queries are not invalidated correctly, stale data from a previous wallet session can bleed into the new session.Acceptance Criteria
src/lib/queryKeys.tsexports a type-safe query key factory using the pattern from TanStack Query docs:useQueryandqueryClient.invalidateQueriescall sites inuseSorobanQuery.tsswitch to this factorypublicKeychanges inStellarWalletContext, auseEffectcallsqueryClient.removeQueries({ queryKey: ['userPosition'] })andqueryClient.removeQueries({ queryKey: ['userCredits'] })so the previous wallet's data is never shown to the next connected walletReactQueryDevtoolsimported from@tanstack/react-query-devtoolsis rendered insideAppShell.tsxonly whenprocess.env.NODE_ENV === 'development'(zero bundle cost in production vianext/dynamicwithssr: false)publicKeyand verifies the user-scoped cache entries are removedRelevant Files
src/lib/queryKeys.ts— createsrc/hooks/useSorobanQuery.ts— migrate to key factorysrc/context/StellarWalletContext.tsx— addqueryClient.removeQuerieson disconnectsrc/components/AppShell/AppShell.tsx— lazy DevTools