@@ -4,7 +4,7 @@ import { formatUnits } from 'viem';
44import { fuse , mainnet } from 'viem/chains' ;
55
66import { explorerUrls , layerzero } from '@/constants/explorers' ;
7- import { getInfoClient } from '@/graphql/clients' ;
7+ import { getInfoClient , getInfoClientEth , getInfoClientFuse } from '@/graphql/clients' ;
88import {
99 GetUserTransactionsDocument ,
1010 GetUserTransactionsQuery ,
@@ -51,8 +51,14 @@ const ApyToDays = {
5151 thirtyDay : 30 ,
5252} ;
5353
54- const getAnalyticsVaultKey = ( vault ?: VaultType ) : VaultType . USDC | VaultType . FUSE | VaultType . ETH =>
55- vault === VaultType . FUSE ? VaultType . FUSE : vault === VaultType . ETH ? VaultType . ETH : VaultType . USDC ;
54+ const getAnalyticsVaultKey = (
55+ vault ?: VaultType ,
56+ ) : VaultType . USDC | VaultType . FUSE | VaultType . ETH =>
57+ vault === VaultType . FUSE
58+ ? VaultType . FUSE
59+ : vault === VaultType . ETH
60+ ? VaultType . ETH
61+ : VaultType . USDC ;
5662
5763const safeFormatUnits = (
5864 value : string | number | bigint | null | undefined ,
@@ -133,11 +139,20 @@ const filterTransfers = (transfers: BlockscoutTransactions) => {
133139 } ) ;
134140} ;
135141
136- export const userTransactionsQueryOptions = ( safeAddress : string | undefined ) => ( {
137- queryKey : [ 'user-transactions' , safeAddress ?. toLowerCase ( ) ] ,
142+ export const userTransactionsQueryOptions = (
143+ safeAddress : string | undefined ,
144+ vault ?: VaultType ,
145+ ) => ( {
146+ queryKey : [ 'user-transactions' , safeAddress ?. toLowerCase ( ) , vault ] ,
138147 queryFn : async ( ) => {
139148 if ( ! safeAddress ) return undefined ;
140- const { data } = await getInfoClient ( ) . query < GetUserTransactionsQuery > ( {
149+ const client =
150+ vault === VaultType . ETH
151+ ? getInfoClientEth ( )
152+ : vault === VaultType . FUSE
153+ ? getInfoClientFuse ( )
154+ : getInfoClient ( ) ;
155+ const { data } = await client . query < GetUserTransactionsQuery > ( {
141156 query : GetUserTransactionsDocument ,
142157 variables : {
143158 address : safeAddress . toLowerCase ( ) ,
@@ -150,11 +165,11 @@ export const userTransactionsQueryOptions = (safeAddress: string | undefined) =>
150165 staleTime : secondsToMilliseconds ( 30 ) , // Data is fresh for 30 seconds
151166 gcTime : secondsToMilliseconds ( 300 ) , // Keep in cache for 5 minutes
152167 refetchInterval : secondsToMilliseconds ( 30 ) , // Poll every 30 seconds
153- placeholderData : keepPreviousData , // Show stale data while fetching new data
168+ // placeholderData: vault ? undefined : keepPreviousData, // Disable placeholder when vault changes to avoid cross-vault data contamination
154169} ) ;
155170
156- export const useUserTransactions = ( safeAddress : string | undefined ) => {
157- return useQuery ( userTransactionsQueryOptions ( safeAddress ) ) ;
171+ export const useUserTransactions = ( safeAddress : string | undefined , vault ?: VaultType ) => {
172+ return useQuery ( userTransactionsQueryOptions ( safeAddress , vault ) ) ;
158173} ;
159174
160175export const useSendTransactions = ( address : string ) => {
0 commit comments