'use client' import type { Config, EstimateFeesPerGasErrorType, ResolvedRegister, } from '@wagmi/core' import type { Compute, ConfigParameter } from '@wagmi/core/internal' import { type EstimateFeesPerGasData, type EstimateFeesPerGasOptions, estimateFeesPerGasQueryOptions, } from '@wagmi/core/query' import type { FeeValuesType } from 'viem' import { type UseQueryReturnType, useQuery } from '../utils/query.js' import { useChainId } from './useChainId.js' import { useConfig } from './useConfig.js' export type UseEstimateFeesPerGasParameters< type extends FeeValuesType = FeeValuesType, config extends Config = Config, selectData = EstimateFeesPerGasData, > = Compute< EstimateFeesPerGasOptions & ConfigParameter > export type UseEstimateFeesPerGasReturnType< type extends FeeValuesType = FeeValuesType, selectData = EstimateFeesPerGasData, > = UseQueryReturnType /** https://wagmi.sh/react/api/hooks/useEstimateFeesPerGas */ export function useEstimateFeesPerGas< config extends Config = ResolvedRegister['config'], type extends FeeValuesType = 'eip1559', selectData = EstimateFeesPerGasData, >( parameters: UseEstimateFeesPerGasParameters = {}, ): UseEstimateFeesPerGasReturnType { const config = useConfig(parameters) const chainId = useChainId({ config }) const options = estimateFeesPerGasQueryOptions(config, { ...parameters, chainId: parameters.chainId ?? chainId, }) return useQuery(options) }