diff --git a/apps/desktop-wallet/src/api/queries/transactionQueries.ts b/apps/desktop-wallet/src/api/queries/transactionQueries.ts index b68b9f9c7..89986ef35 100644 --- a/apps/desktop-wallet/src/api/queries/transactionQueries.ts +++ b/apps/desktop-wallet/src/api/queries/transactionQueries.ts @@ -43,18 +43,14 @@ export const addressLatestTransactionQuery = ({ addressHash, networkId, skip }: queryFn: !skip && networkId !== undefined ? async ({ queryKey }) => { - const transactions = await throttledClient.explorer.addresses.getAddressesAddressTransactions(addressHash, { - page: 1, - limit: 1 - }) + const latestTx = await throttledClient.explorer.addresses.getAddressesAddressLatestTransaction(addressHash) - const latestTx = transactions.length > 0 ? transactions[0] : undefined const cachedData = queryClient.getQueryData(queryKey) as AddressLatestTransactionQueryFnData | undefined const cachedLatestTx = cachedData?.latestTx // The following block invalidates queries that need to refetch data if a new transaction hash has been // detected. This way, we don't need to use the latest tx hash in the queryKey of each of those queries. - if (latestTx !== undefined && latestTx.hash !== cachedLatestTx?.hash) { + if (latestTx?.hash && latestTx.hash !== cachedLatestTx?.hash) { queryClient.invalidateQueries({ queryKey: ['address', addressHash, 'balance'] }) queryClient.invalidateQueries({ queryKey: ['wallet', 'transactions', 'latest'] }) }