Commit 0349c453 authored by tom's avatar tom

fix ts

parent 8e09b62a
...@@ -39,6 +39,10 @@ export default function useAddressQuery({ hash, addressQuery }: Params): Address ...@@ -39,6 +39,10 @@ export default function useAddressQuery({ hash, addressQuery }: Params): Address
const rpcQuery = useQuery<RpcResponseType, unknown, AddressCounters | null>({ const rpcQuery = useQuery<RpcResponseType, unknown, AddressCounters | null>({
queryKey: [ 'RPC', 'address_counters', { hash } ], queryKey: [ 'RPC', 'address_counters', { hash } ],
queryFn: async() => { queryFn: async() => {
if (!publicClient) {
throw new Error('No public RPC client');
}
const txCount = publicClient.getTransactionCount({ address: hash as `0x${ string }` }).catch(() => null); const txCount = publicClient.getTransactionCount({ address: hash as `0x${ string }` }).catch(() => null);
return Promise.all([ return Promise.all([
...@@ -60,7 +64,7 @@ export default function useAddressQuery({ hash, addressQuery }: Params): Address ...@@ -60,7 +64,7 @@ export default function useAddressQuery({ hash, addressQuery }: Params): Address
refetchOnMount: false, refetchOnMount: false,
}); });
const isRpcQuery = Boolean((addressQuery.isDegradedData || apiQuery.isError) && rpcQuery.data); const isRpcQuery = Boolean((addressQuery.isDegradedData || apiQuery.isError) && rpcQuery.data && publicClient);
const query = isRpcQuery ? rpcQuery as UseQueryResult<AddressCounters, ResourceError<{ status: number }>> : apiQuery; const query = isRpcQuery ? rpcQuery as UseQueryResult<AddressCounters, ResourceError<{ status: number }>> : apiQuery;
return { return {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment