-
Notifications
You must be signed in to change notification settings - Fork 68
Open
Description
When calling the getAvailable function in my hook:
import { getAvailable } from '@ensdomains/ensjs/public'
import useEnsClient from '@hooks/ensJs/client'
import { useMountedAccount } from '@justaname.id/react'
import { useQuery } from '@tanstack/react-query'
export const buildIsEnsAvailableKey = (
ens: string,
chainId: number | undefined,
) => ['IS_ENS_AVAILABLE_KEY', ens, chainId]
export const getIsEnsAvailable = async (ens: string, ensClient: any) =>
await getAvailable(ensClient, { name: ens })
export const useIsEnsAvailable = (ens: string) => {
const { chainId } = useMountedAccount()
const ensClient = useEnsClient()
const query = useQuery({
queryKey: buildIsEnsAvailableKey(ens, chainId),
queryFn: () => getIsEnsAvailable(ens, ensClient),
enabled: ens.length > 4,
})
return {
isEnsAvailableLoading: query.isLoading,
isAvailable: query.data,
}
}
When trying to check if 😠️.eth is available, its returning true.
Im using the ^4.0.0 version of ensJs
This is how the ensClient is created:
import { http } from 'viem'
import { mainnet, sepolia } from 'viem/chains'
import { createEnsPublicClient } from '@ensdomains/ensjs'
import { useMountedAccount } from '@hooks';
const useEnsClient = () => {
const { chainId } = useMountedAccount();
const chain = chainId === 1 ? mainnet : sepolia;
const ensClient = createEnsPublicClient({
chain,
transport: http(),
});
return ensClient;
};
export default useEnsClient;
edulennert
Metadata
Metadata
Assignees
Labels
No labels