@lifi/widget
Version:
LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.
38 lines (34 loc) • 947 B
text/typescript
import type { ExtendedChain } from '@lifi/sdk'
import { ChainType, isBatchingSupported } from '@lifi/sdk'
import { useQuery } from '@tanstack/react-query'
import { useWidgetConfig } from '../providers/WidgetProvider/WidgetProvider.js'
import { getQueryKey } from '../utils/queries.js'
export function useIsBatchingSupported(
chain?: ExtendedChain,
address?: string
) {
const { keyPrefix } = useWidgetConfig()
const enabled = Boolean(
chain && chain.chainType === ChainType.EVM && !!address
)
const { data, isLoading } = useQuery({
queryKey: [
getQueryKey('isBatchingSupported', keyPrefix),
chain?.id,
address,
],
queryFn: () => {
return isBatchingSupported({
chainId: chain!.id,
skipReady: true,
})
},
enabled,
staleTime: 3_600_000,
retry: false,
})
return {
isBatchingSupported: data,
isBatchingSupportedLoading: enabled && isLoading,
}
}