From b9b72f13c2f158137b97d65ae79648d03d3cbef7 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 19 Jan 2023 01:41:12 +0000 Subject: [PATCH] isAddress utils replacement --- src/@context/Profile/index.tsx | 4 ++-- src/components/Asset/Edit/_validation.ts | 4 ++-- src/pages/profile/index.tsx | 4 ++-- src/pages/search.tsx | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/@context/Profile/index.tsx b/src/@context/Profile/index.tsx index 64cf4be12..8d63b907e 100644 --- a/src/@context/Profile/index.tsx +++ b/src/@context/Profile/index.tsx @@ -16,9 +16,9 @@ import { getUserSales } from '@utils/aquarius' import axios, { CancelToken } from 'axios' -import web3 from 'web3' import { useMarketMetadata } from '../MarketMetadata' import { getEnsProfile } from '@utils/ens' +import { isAddress } from 'ethers/lib/utils' interface ProfileProviderValue { profile: Profile @@ -64,7 +64,7 @@ function ProfileProvider({ // when accountId is no ETH address // useEffect(() => { - const isEthAddress = web3.utils.isAddress(accountId) + const isEthAddress = isAddress(accountId) setIsEthAddress(isEthAddress) }, [accountId]) diff --git a/src/components/Asset/Edit/_validation.ts b/src/components/Asset/Edit/_validation.ts index bc29ca701..472907f29 100644 --- a/src/components/Asset/Edit/_validation.ts +++ b/src/components/Asset/Edit/_validation.ts @@ -1,6 +1,6 @@ import { FileInfo } from '@oceanprotocol/lib' import * as Yup from 'yup' -import web3 from 'web3' +import { isAddress } from 'ethers/lib/utils' import { testLinks } from '../../../@utils/yup' export const validationSchema = Yup.object().shape({ @@ -41,7 +41,7 @@ export const validationSchema = Yup.object().shape({ 'ValidAddress', 'Must be a valid Ethereum Address.', (value) => { - return web3.utils.isAddress(value) + return isAddress(value) } ), retireAsset: Yup.string() diff --git a/src/pages/profile/index.tsx b/src/pages/profile/index.tsx index 679ef8e19..5a4e52b7c 100644 --- a/src/pages/profile/index.tsx +++ b/src/pages/profile/index.tsx @@ -6,7 +6,7 @@ import ProfileProvider from '@context/Profile' import { getEnsAddress, getEnsName } from '@utils/ens' import { useRouter } from 'next/router' import { useAccount, useEnsName } from 'wagmi' -import { utils } from 'ethers' +import { isAddress } from 'ethers/lib/utils' export default function PageProfile(): ReactElement { const router = useRouter() @@ -32,7 +32,7 @@ export default function PageProfile(): ReactElement { const pathAccount = router.query.account as string // Path has ETH address - if (utils.isAddress(pathAccount)) { + if (isAddress(pathAccount)) { setOwnAccount(pathAccount === address) const finalAccountId = pathAccount || address setFinalAccountId(finalAccountId) diff --git a/src/pages/search.tsx b/src/pages/search.tsx index 14dfe67a5..35c62dd38 100644 --- a/src/pages/search.tsx +++ b/src/pages/search.tsx @@ -4,7 +4,7 @@ import Page from '@shared/Page' import { accountTruncate } from '@utils/web3' import { MAXIMUM_NUMBER_OF_PAGES_WITH_RESULTS } from '@utils/aquarius' import { useRouter } from 'next/router' -import web3 from 'web3' +import { isAddress } from 'ethers/lib/utils' export default function PageSearch(): ReactElement { const router = useRouter() @@ -13,7 +13,7 @@ export default function PageSearch(): ReactElement { const [totalResults, setTotalResults] = useState() const [totalPagesNumber, setTotalPagesNumber] = useState() - const isETHAddress = web3.utils.isAddress(text as string) + const isETHAddress = isAddress(text as string) const searchValue = (isETHAddress ? accountTruncate(text as string) : text) || tags ||