From 01cc7d869ab7f2bc3d742539723b18b22273162a Mon Sep 17 00:00:00 2001 From: gomes <17035424+gomesalexandre@users.noreply.github.com> Date: Fri, 10 Jan 2025 16:28:21 +0400 Subject: [PATCH] fix: walletbutton stale ENS addies --- src/components/Layout/Header/NavBar/UserMenu.tsx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/components/Layout/Header/NavBar/UserMenu.tsx b/src/components/Layout/Header/NavBar/UserMenu.tsx index 89966538096..9f36a55c5f6 100644 --- a/src/components/Layout/Header/NavBar/UserMenu.tsx +++ b/src/components/Layout/Header/NavBar/UserMenu.tsx @@ -13,13 +13,13 @@ import { MenuList, useColorModeValue, } from '@chakra-ui/react' -import { viemEthMainnetClient } from '@shapeshiftoss/contracts' import type { FC } from 'react' import { memo, useCallback, useEffect, useMemo, useState } from 'react' import { FaWallet } from 'react-icons/fa' import { useTranslate } from 'react-polyglot' import { MemoryRouter } from 'react-router-dom' -import type { Address } from 'viem' +import { getAddress } from 'viem' +import { useEnsName } from 'wagmi' import { WalletConnectedRoutes } from 'components/Layout/Header/NavBar/hooks/useMenuRoutes' import { WalletConnectedMenu } from 'components/Layout/Header/NavBar/WalletConnectedMenu' import { WalletImage } from 'components/Layout/Header/NavBar/WalletImage' @@ -92,7 +92,10 @@ const WalletButton: FC = ({ const [walletLabel, setWalletLabel] = useState('') const [shouldShorten, setShouldShorten] = useState(true) const bgColor = useColorModeValue('gray.200', 'gray.800') - const [ensName, setEnsName] = useState('') + + const { data: ensName } = useEnsName({ + address: walletInfo?.meta?.address ? getAddress(walletInfo.meta.address) : undefined, + }) const maybeRdns = useAppSelector(selectWalletRdns) @@ -102,13 +105,6 @@ const WalletButton: FC = ({ [mipdProviders, maybeRdns], ) - useEffect(() => { - if (!walletInfo?.meta?.address) return - viemEthMainnetClient - .getEnsName({ address: walletInfo.meta.address as Address }) - .then(setEnsName) - }, [walletInfo?.meta?.address]) - useEffect(() => { setWalletLabel('') setShouldShorten(true)