mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
isAddress utils replacement
This commit is contained in:
parent
00c145ad99
commit
b9b72f13c2
@ -16,9 +16,9 @@ import {
|
|||||||
getUserSales
|
getUserSales
|
||||||
} from '@utils/aquarius'
|
} from '@utils/aquarius'
|
||||||
import axios, { CancelToken } from 'axios'
|
import axios, { CancelToken } from 'axios'
|
||||||
import web3 from 'web3'
|
|
||||||
import { useMarketMetadata } from '../MarketMetadata'
|
import { useMarketMetadata } from '../MarketMetadata'
|
||||||
import { getEnsProfile } from '@utils/ens'
|
import { getEnsProfile } from '@utils/ens'
|
||||||
|
import { isAddress } from 'ethers/lib/utils'
|
||||||
|
|
||||||
interface ProfileProviderValue {
|
interface ProfileProviderValue {
|
||||||
profile: Profile
|
profile: Profile
|
||||||
@ -64,7 +64,7 @@ function ProfileProvider({
|
|||||||
// when accountId is no ETH address
|
// when accountId is no ETH address
|
||||||
//
|
//
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const isEthAddress = web3.utils.isAddress(accountId)
|
const isEthAddress = isAddress(accountId)
|
||||||
setIsEthAddress(isEthAddress)
|
setIsEthAddress(isEthAddress)
|
||||||
}, [accountId])
|
}, [accountId])
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { FileInfo } from '@oceanprotocol/lib'
|
import { FileInfo } from '@oceanprotocol/lib'
|
||||||
import * as Yup from 'yup'
|
import * as Yup from 'yup'
|
||||||
import web3 from 'web3'
|
import { isAddress } from 'ethers/lib/utils'
|
||||||
import { testLinks } from '../../../@utils/yup'
|
import { testLinks } from '../../../@utils/yup'
|
||||||
|
|
||||||
export const validationSchema = Yup.object().shape({
|
export const validationSchema = Yup.object().shape({
|
||||||
@ -41,7 +41,7 @@ export const validationSchema = Yup.object().shape({
|
|||||||
'ValidAddress',
|
'ValidAddress',
|
||||||
'Must be a valid Ethereum Address.',
|
'Must be a valid Ethereum Address.',
|
||||||
(value) => {
|
(value) => {
|
||||||
return web3.utils.isAddress(value)
|
return isAddress(value)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
retireAsset: Yup.string()
|
retireAsset: Yup.string()
|
||||||
|
@ -6,7 +6,7 @@ import ProfileProvider from '@context/Profile'
|
|||||||
import { getEnsAddress, getEnsName } from '@utils/ens'
|
import { getEnsAddress, getEnsName } from '@utils/ens'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { useAccount, useEnsName } from 'wagmi'
|
import { useAccount, useEnsName } from 'wagmi'
|
||||||
import { utils } from 'ethers'
|
import { isAddress } from 'ethers/lib/utils'
|
||||||
|
|
||||||
export default function PageProfile(): ReactElement {
|
export default function PageProfile(): ReactElement {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@ -32,7 +32,7 @@ export default function PageProfile(): ReactElement {
|
|||||||
const pathAccount = router.query.account as string
|
const pathAccount = router.query.account as string
|
||||||
|
|
||||||
// Path has ETH address
|
// Path has ETH address
|
||||||
if (utils.isAddress(pathAccount)) {
|
if (isAddress(pathAccount)) {
|
||||||
setOwnAccount(pathAccount === address)
|
setOwnAccount(pathAccount === address)
|
||||||
const finalAccountId = pathAccount || address
|
const finalAccountId = pathAccount || address
|
||||||
setFinalAccountId(finalAccountId)
|
setFinalAccountId(finalAccountId)
|
||||||
|
@ -4,7 +4,7 @@ import Page from '@shared/Page'
|
|||||||
import { accountTruncate } from '@utils/web3'
|
import { accountTruncate } from '@utils/web3'
|
||||||
import { MAXIMUM_NUMBER_OF_PAGES_WITH_RESULTS } from '@utils/aquarius'
|
import { MAXIMUM_NUMBER_OF_PAGES_WITH_RESULTS } from '@utils/aquarius'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import web3 from 'web3'
|
import { isAddress } from 'ethers/lib/utils'
|
||||||
|
|
||||||
export default function PageSearch(): ReactElement {
|
export default function PageSearch(): ReactElement {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@ -13,7 +13,7 @@ export default function PageSearch(): ReactElement {
|
|||||||
const [totalResults, setTotalResults] = useState<number>()
|
const [totalResults, setTotalResults] = useState<number>()
|
||||||
const [totalPagesNumber, setTotalPagesNumber] = useState<number>()
|
const [totalPagesNumber, setTotalPagesNumber] = useState<number>()
|
||||||
|
|
||||||
const isETHAddress = web3.utils.isAddress(text as string)
|
const isETHAddress = isAddress(text as string)
|
||||||
const searchValue =
|
const searchValue =
|
||||||
(isETHAddress ? accountTruncate(text as string) : text) ||
|
(isETHAddress ? accountTruncate(text as string) : text) ||
|
||||||
tags ||
|
tags ||
|
||||||
|
Loading…
x
Reference in New Issue
Block a user