diff --git a/package.json b/package.json index 95d6be2e..09b4ec6a 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "dependencies": { "@gnosis.pm/safe-contracts": "^1.0.0", "@gnosis.pm/util-contracts": "2.0.1", - "@material-ui/core": "4.2.1", + "@material-ui/core": "4.3.0", "@material-ui/icons": "4.2.1", "@testing-library/jest-dom": "^4.0.0", "@welldone-software/why-did-you-render": "3.2.3", @@ -51,7 +51,7 @@ "react-dom": "^16.8.6", "react-final-form": "6.3.0", "react-final-form-listeners": "^1.0.2", - "react-hot-loader": "4.12.9", + "react-hot-loader": "4.12.10", "react-infinite-scroll-component": "^4.5.2", "react-qr-reader": "^2.2.1", "react-redux": "7.1.0", @@ -93,7 +93,7 @@ "@storybook/addon-knobs": "5.1.9", "@storybook/addon-links": "5.1.9", "@storybook/react": "5.1.9", - "@testing-library/react": "8.0.6", + "@testing-library/react": "8.0.7", "autoprefixer": "9.6.1", "babel-core": "^7.0.0-bridge.0", "babel-eslint": "10.0.2", @@ -107,15 +107,15 @@ "detect-port": "^1.2.2", "eslint": "5.16.0", "eslint-config-airbnb": "17.1.1", - "eslint-plugin-flowtype": "3.12.1", + "eslint-plugin-flowtype": "3.12.2", "eslint-plugin-import": "2.18.2", - "eslint-plugin-jest": "22.13.7", + "eslint-plugin-jest": "22.14.0", "eslint-plugin-jsx-a11y": "6.2.3", "eslint-plugin-react": "7.14.3", "ethereumjs-abi": "^0.6.7", "extract-text-webpack-plugin": "^4.0.0-beta.0", "file-loader": "4.1.0", - "flow-bin": "0.103.0", + "flow-bin": "0.104.0", "fs-extra": "8.1.0", "html-loader": "^0.5.5", "html-webpack-plugin": "^3.0.4", diff --git a/src/components/forms/AddressInput/index.jsx b/src/components/forms/AddressInput/index.jsx index 33116a16..fe017123 100644 --- a/src/components/forms/AddressInput/index.jsx +++ b/src/components/forms/AddressInput/index.jsx @@ -2,7 +2,13 @@ import * as React from 'react' import { Field } from 'react-final-form' import TextField from '~/components/forms/TextField' -import { composeValidators, required, mustBeEthereumAddress } from '~/components/forms/validator' +import { + composeValidators, + required, + mustBeEthereumAddress, + ifElseValidator, + ensResolverHasAddress, +} from '~/components/forms/validator' import { getAddressFromENS } from '~/logic/wallets/getWeb3' type Props = { @@ -11,6 +17,8 @@ type Props = { text?: string, placeholder?: string, fieldMutator: Function, + testId?: string, + validators?: Function[], } const isValidEnsName = name => /^([\w-]+\.)+(eth|test)$/.test(name) @@ -26,16 +34,23 @@ const AddressInput = ({ text = 'Recipient*', placeholder = 'Recipient*', fieldMutator, + testId, + validators = [], }: Props): React.Element<*> => ( <> { let lastArg @@ -90,4 +90,24 @@ export const differentFrom = (diffValue: string) => (value: string) => { return undefined } +export const ensResolverHasAddress = async (value: string) => { + let error + + try { + await getAddressFromENS(value) + } catch { + error = 'Couldn\'t resolve the address' + } + + return error +} + export const noErrorsOn = (name: string, errors: Object) => errors[name] === undefined + +export const ifElseValidator = (ifFunc: Function, thenFunc: Function, elseFunc: Function) => (value: string) => { + if (ifFunc(value)) { + return thenFunc(value) + } + + return elseFunc(value) +} diff --git a/src/routes/safe/components/Settings/ManageOwners/AddOwnerModal/screens/OwnerForm/index.jsx b/src/routes/safe/components/Settings/ManageOwners/AddOwnerModal/screens/OwnerForm/index.jsx index 6fa6e191..9361bf91 100644 --- a/src/routes/safe/components/Settings/ManageOwners/AddOwnerModal/screens/OwnerForm/index.jsx +++ b/src/routes/safe/components/Settings/ManageOwners/AddOwnerModal/screens/OwnerForm/index.jsx @@ -89,7 +89,7 @@ const OwnerForm = ({