Skip to content

Commit

Permalink
fix: restrict @davatar usage to avoid 3p fetches (#2649)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzmp committed Oct 20, 2021
1 parent 5e8d725 commit 9cacd57
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/components/Identicon/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Davatar from '@davatar/react'
import Davatar, { Image } from '@davatar/react'
import { useMemo } from 'react'
import styled from 'styled-components/macro'

import { useActiveWeb3React } from '../../hooks/web3'
Expand All @@ -13,10 +14,19 @@ const StyledIdenticonContainer = styled.div`
export default function Identicon() {
const { account, library } = useActiveWeb3React()

// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/30451
// restrict usage of Davatar until it stops sending 3p requests
// see https://github.com/metaphor-xyz/davatar-helpers/issues/18
const supportsENS = useMemo(() => {
return ([1, 3, 4, 5] as Array<number | undefined>).includes(library?.network.chainId)
}, [library])

return (
<StyledIdenticonContainer>
{account && library?.provider && <Davatar address={account} size={16} provider={library.provider} />}
{account && supportsENS ? (
<Davatar address={account} size={16} provider={library} />
) : (
<Image address={account} size={16} />
)}
</StyledIdenticonContainer>
)
}

2 comments on commit 9cacd57

@vercel
Copy link

@vercel vercel bot commented on 9cacd57 Oct 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

@vercel
Copy link

@vercel vercel bot commented on 9cacd57 Oct 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

widgets – ./

widgets-uniswap.vercel.app
widgets-three-delta.vercel.app
widgets-git-main-uniswap.vercel.app

Please sign in to comment.