From 5a7839eb28aadbf0abda0d0efc5d6434647e8588 Mon Sep 17 00:00:00 2001 From: Theo Date: Thu, 15 Jun 2023 07:20:15 -0700 Subject: [PATCH] Fix function that gets owner of ENS domain by domain name: with new ENS Name Wrapper simple call of function 'owner' from ensRegistry contract returned not owner, but wrapper address. Changed to function ethers.provider.resolveName, that returns real owner address --- services/ENS/ens.ts | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/services/ENS/ens.ts b/services/ENS/ens.ts index ab1864e..c3cf83d 100644 --- a/services/ENS/ens.ts +++ b/services/ENS/ens.ts @@ -1,21 +1,13 @@ -import { BigNumber } from 'ethers' -import { namehash } from 'ethers/lib/utils' - import { ChainId } from '@/types' -import { getEnsRegistry } from '@/contracts' + +import { getProvider } from '@/services' async function getEnsOwner(ensName: string, chainId: ChainId) { try { - const node = namehash(ensName) - const ensContract = getEnsRegistry(chainId) + const { provider } = getProvider(chainId) + const ownerAddress = await provider.resolveName(ensName) - const owner = await ensContract.callStatic.owner(node) - - if (BigNumber.from(owner).isZero()) { - return undefined - } - - return owner + return ownerAddress || undefined } catch (err) { return undefined }