Skip to content

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

@anthony23991

Description

@anthony23991

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions