Refactor mustBeEthereumContractAddress validator

This commit is contained in:
Germán Martínez 2019-09-18 23:21:38 +02:00
parent 1f8ed4eb3b
commit af99c70299
2 changed files with 2 additions and 5 deletions

View File

@ -7,7 +7,6 @@ import {
composeValidators,
required,
mustBeEthereumAddress,
mustBeEthereumContractAddress,
} from '~/components/forms/validator'
import { getAddressFromENS } from '~/logic/wallets/getWeb3'
@ -20,7 +19,6 @@ type Props = {
testId?: string,
validators?: Function[],
inputAdornment?: React.Element,
mustBeContract?: boolean,
}
const isValidEnsName = (name) => /^([\w-]+\.)+(eth|test|xyz|luxe)$/.test(name)
@ -37,7 +35,6 @@ const AddressInput = ({
testId,
inputAdornment,
validators = [],
mustBeContract,
}: Props): React.Element<*> => (
<>
<Field
@ -47,7 +44,6 @@ const AddressInput = ({
validate={composeValidators(
required,
mustBeEthereumAddress,
mustBeContract && mustBeEthereumContractAddress,
...validators,
)}
inputAdornment={inputAdornment}

View File

@ -20,6 +20,7 @@ import {
composeValidators,
mustBeFloat,
maxValue,
mustBeEthereumContractAddress,
} from '~/components/forms/validator'
import SafeInfo from '~/routes/safe/components/Balances/SendModal/SafeInfo'
import ArrowDown from '../assets/arrow-down.svg'
@ -103,7 +104,7 @@ const SendCustomTx = ({
text="Recipient*"
className={classes.addressInput}
fieldMutator={mutators.setRecipient}
mustBeContract
validators={[mustBeEthereumContractAddress]}
/>
</Col>
</Row>