Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getAvailable returning true for any emoji, also for one character emojis #198

Open
anthony23991 opened this issue Sep 4, 2024 · 0 comments

Comments

@anthony23991
Copy link

anthony23991 commented Sep 4, 2024

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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant