import { useAsyncRetry } from 'react-use' ; import { ChainId , useChainId } from '@masknet/web3-shared-evm' ; import { useRedPacketContract } from './useRedPacketContract' ; export function useAvailability ( version , from , id , redpacketChainId ) { const redPacketContract = useRedPacketContract ( version ) ; const currentChainId = useChainId ( ) ; return useAsyncRetry ( async ( ) => { if ( ! id || redpacketChainId !== currentChainId ) return null ; if ( ! redPacketContract ) return null ; return redPacketContract . methods . check_availability ( id ) . call ( { from , } ) ; } , [ id , from , redpacketChainId , currentChainId , redPacketContract ] ) ; }