import { useQuery, skipToken, UseBaseQueryOptions } from "@tanstack/react-query" import { useAuthApiClient } from "./useAuthApiClient" import { QUERY_KEYS } from "./constants" import { ONE_MINUTE_MS } from "../utils/time" import type { GetAccountByMezoIdOrAddressResponse } from "../api" export function useGetAccountByAddress( address?: string, queryOptions: Omit< UseBaseQueryOptions, "queryKey" | "queryFn" > = {}, ) { const authApiClient = useAuthApiClient() return useQuery({ queryKey: [QUERY_KEYS.ACCOUNT, address], queryFn: address ? () => authApiClient.getAccountByMezoIdOrAddress(address) : skipToken, staleTime: ONE_MINUTE_MS, retry: 1, ...queryOptions, }) }