Skip to content

Commit

Permalink
fix: wallet button stale ENS addies (#8536)
Browse files Browse the repository at this point in the history
fix: walletbutton stale ENS addies
  • Loading branch information
gomesalexandre authored Jan 13, 2025
1 parent b57d4b4 commit b25b002
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/components/Layout/Header/NavBar/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -92,7 +92,10 @@ const WalletButton: FC<WalletButtonProps> = ({
const [walletLabel, setWalletLabel] = useState('')
const [shouldShorten, setShouldShorten] = useState(true)
const bgColor = useColorModeValue('gray.200', 'gray.800')
const [ensName, setEnsName] = useState<string | null>('')

const { data: ensName } = useEnsName({
address: walletInfo?.meta?.address ? getAddress(walletInfo.meta.address) : undefined,
})

const maybeRdns = useAppSelector(selectWalletRdns)

Expand All @@ -102,13 +105,6 @@ const WalletButton: FC<WalletButtonProps> = ({
[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)
Expand Down

0 comments on commit b25b002

Please sign in to comment.