Update validator to check that addresses start with 0x

This commit is contained in:
Mikhail Mikheev 2019-11-18 11:17:31 +04:00
parent 8688c2bc93
commit a51915d971
1 changed files with 3 additions and 2 deletions

View File

@ -60,10 +60,11 @@ export const maxValue = (max: number | string) => (value: string) => {
export const ok = () => undefined
export const mustBeEthereumAddress = simpleMemoize((address: Field) => {
export const mustBeEthereumAddress = simpleMemoize((address: string) => {
const startsWith0x = address.startsWith('0x')
const isAddress: boolean = getWeb3().utils.isAddress(address)
return isAddress ? undefined : 'Address should be a valid Ethereum address or ENS name'
return startsWith0x && isAddress ? undefined : 'Address should be a valid Ethereum address or ENS name'
})
export const mustBeEthereumContractAddress = simpleMemoize(async (address: string) => {