/** * Copyright (c) TonTech. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import { getBlockNumberQueryOptions } from '@ton/appkit/queries'; import type { GetBlockNumberData, GetBlockNumberErrorType, GetBlockNumberQueryConfig } from '@ton/appkit/queries'; import { useAppKit } from '../../settings'; import { useQuery } from '../../../libs/query'; import type { UseQueryReturnType } from '../../../libs/query'; import { useNetwork } from '../hooks/use-network'; export type UseBlockNumberParameters = GetBlockNumberQueryConfig; export type UseBlockNumberReturnType = UseQueryReturnType< selectData, GetBlockNumberErrorType >; /** * Hook to get the current masterchain block number */ export const useBlockNumber = ( parameters: UseBlockNumberParameters = {}, ): UseBlockNumberReturnType => { const appKit = useAppKit(); const walletNetwork = useNetwork(); return useQuery( getBlockNumberQueryOptions(appKit, { ...parameters, network: parameters.network ?? walletNetwork }), ); };