Skip to content

Commit

Permalink
fix: ens network (DimensionDev#4411)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouhanseng authored Sep 21, 2021
1 parent bb022ed commit fa1c330
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useStylesExtends } from '@masknet/shared'
import { getMaskColor, makeStyles } from '@masknet/theme'
import { formatEthereumAddress, resolveAddressLinkOnExplorer, useChainId } from '@masknet/web3-shared'
import { formatEthereumAddress, resolveAddressLinkOnExplorer, useChainId, ChainId } from '@masknet/web3-shared'
import { Box, Link, Typography } from '@material-ui/core'
import InfoOutlinedIcon from '@material-ui/icons/InfoOutlined'
import { useState, useEffect } from 'react'
Expand Down Expand Up @@ -79,7 +79,7 @@ export function EnhancedProfilePage(props: EnhancedProfilePageProps) {
<Typography color="textPrimary" component="span">
Current display of {type}:{' '}
<Link
href={resolveAddressLinkOnExplorer(chainId, address)}
href={resolveAddressLinkOnExplorer(ChainId.Mainnet, address)}
target="_blank"
rel="noopener noreferrer">
{type === 'address' ? formatEthereumAddress(address, 4) : name}
Expand Down
3 changes: 2 additions & 1 deletion packages/web3-shared/src/hooks/useResolveENS.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { useAsyncRetry } from 'react-use'
import { useChainId } from '.'
import { ChainId } from '..'
import { useWeb3 } from './useWeb3'

export function useResolveENS(name: string) {
const web3 = useWeb3()
const web3 = useWeb3(true, ChainId.Mainnet)
const chainId = useChainId()

return useAsyncRetry(async () => {
Expand Down
8 changes: 4 additions & 4 deletions packages/web3-shared/src/hooks/useWeb3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import { first } from 'lodash-es'
import { useSubscription } from 'use-subscription'
import { useWeb3Context } from '../context'
import { useChainId } from '.'
import { useRPCConstants } from '..'
import { useRPCConstants, ChainId } from '..'

function useWeb3Instance() {
const _ = useWeb3Context()
const provider = useSubscription(_.provider)
return useMemo(() => new Web3(provider), [provider])
}

export function useWeb3(readonly = false) {
export function useWeb3(readonly = false, chainId?: ChainId) {
const web3 = useWeb3Instance()
const chainId = useChainId()
const { RPC } = useRPCConstants(chainId)
const currentChainId = useChainId()
const { RPC } = useRPCConstants(chainId ?? currentChainId)

return useMemo(() => {
const providerURL = first(RPC)
Expand Down

0 comments on commit fa1c330

Please sign in to comment.