mirror of
https://github.com/lux-tel/websites.git
synced 2026-10-30 20:31:36 +00:00
19 lines
487 B
TypeScript
19 lines
487 B
TypeScript
import { skipToken, useQuery } from '@tanstack/react-query';
|
|
import { usePublicWeb3Client } from './usePublicWeb3Client';
|
|
|
|
export function useGasPrice() {
|
|
const publicClient = usePublicWeb3Client();
|
|
|
|
const chainId = publicClient?.chain?.id;
|
|
|
|
const { data, ...rest } = useQuery({
|
|
queryKey: ['gasPrice', chainId],
|
|
queryFn: publicClient && chainId !== undefined ? () => publicClient.getGasPrice() : skipToken,
|
|
});
|
|
|
|
return {
|
|
gasPrice: data ?? null,
|
|
...rest,
|
|
};
|
|
}
|