dep bump, add validation

This commit is contained in:
Mikhail Mikheev 2019-07-29 13:34:41 +04:00
parent 7d936b1f80
commit 6e5bdf90e4
5 changed files with 76 additions and 41 deletions

View File

@ -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",

View File

@ -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<*> => (
<>
<Field
name={name}
component={TextField}
type="text"
validate={composeValidators(required, mustBeEthereumAddress)}
validate={composeValidators(
required,
ifElseValidator(isValidEnsName, ensResolverHasAddress, mustBeEthereumAddress),
...validators,
)}
placeholder={placeholder}
text={text}
className={className}
testId={testId}
/>
<Field
name={name}

View File

@ -1,6 +1,6 @@
// @flow
import { type FieldValidator } from 'final-form'
import { getWeb3 } from '~/logic/wallets/getWeb3'
import { getWeb3, getAddressFromENS } from '~/logic/wallets/getWeb3'
export const simpleMemoize = (fn: Function) => {
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)
}

View File

@ -89,7 +89,7 @@ const OwnerForm = ({
<Col xs={8}>
<AddressInput
name="ownerAddress"
// validate={composeValidators(required, mustBeEthereumAddress, ownerDoesntExist)}
validators={[ownerDoesntExist]}
placeholder="Owner address*"
text="Owner address*"
className={classes.addressInput}

View File

@ -1127,7 +1127,7 @@
dependencies:
regenerator-runtime "^0.13.2"
"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.1.5", "@babel/runtime@^7.2.0", "@babel/runtime@^7.3.1", "@babel/runtime@^7.4.0", "@babel/runtime@^7.4.2", "@babel/runtime@^7.4.3", "@babel/runtime@^7.4.5", "@babel/runtime@^7.5.1", "@babel/runtime@^7.5.4":
"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.1.5", "@babel/runtime@^7.2.0", "@babel/runtime@^7.3.1", "@babel/runtime@^7.4.0", "@babel/runtime@^7.4.2", "@babel/runtime@^7.4.3", "@babel/runtime@^7.4.4", "@babel/runtime@^7.4.5", "@babel/runtime@^7.5.1", "@babel/runtime@^7.5.4":
version "7.5.5"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.5.5.tgz#74fba56d35efbeca444091c7850ccd494fd2f132"
integrity sha512-28QvEGyQyNkB0/m2B4FU7IEZGK2NUrcMtT6BZEFALTguLk+AUT6ofsHtPk5QyjAdUkpMJ+/Em+quwz4HOt30AQ==
@ -1489,17 +1489,17 @@
"@types/istanbul-reports" "^1.1.1"
"@types/yargs" "^12.0.9"
"@material-ui/core@4.2.1":
version "4.2.1"
resolved "https://registry.yarnpkg.com/@material-ui/core/-/core-4.2.1.tgz#18255c01d039ff856bfdb2f955fec6c9ae64a464"
integrity sha512-hasPQUFAb9OxKng7UX2+SjUWtVZbnkVJ/jHZWXTivVcU+UzvNIpA9AyRRQvZ8SPV6swP/HD2VzUBzoMEeRR6wg==
"@material-ui/core@4.3.0":
version "4.3.0"
resolved "https://registry.yarnpkg.com/@material-ui/core/-/core-4.3.0.tgz#ce44f7fad736f44b70f6d44d390ba8b848fcfca0"
integrity sha512-KAYvvq8Z/uP4zvdF3Adi53OfjmcnLiIi+KXb0vROkZ+soYkRQcw6X7VoCuQNwL7Sp7Rr1SSFTxgtJ3G+YBSVyA==
dependencies:
"@babel/runtime" "^7.2.0"
"@babel/runtime" "^7.4.4"
"@material-ui/styles" "^4.2.0"
"@material-ui/system" "^4.3.0"
"@material-ui/types" "^4.1.1"
"@material-ui/utils" "^4.1.0"
"@types/react-transition-group" "^2.0.16"
"@types/react-transition-group" "^4.2.0"
clsx "^1.0.2"
convert-css-length "^2.0.1"
deepmerge "^4.0.0"
@ -2157,10 +2157,10 @@
pretty-format "^24.0.0"
redent "^3.0.0"
"@testing-library/react@8.0.6":
version "8.0.6"
resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-8.0.6.tgz#614340646f32027426377dc6e5895a566eeb61b5"
integrity sha512-/4oeS0eatnHvAf9yuxIg1/8pjl1OrtWN7SLpDFEdxFjllIAEL09xXhA88C93vvlN+8enZa+xlXJ8ecohECT6Yg==
"@testing-library/react@8.0.7":
version "8.0.7"
resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-8.0.7.tgz#b5992c9156e926850a0e3a7c882ae1aed83b1c77"
integrity sha512-6XoeWSr3UCdxMswbkW0BmuXYw8a6w+stt+5gg4D4zAcljfhXETQ5o28bjJFwNab4OPg8gBNK8KIVot86L4Q8Vg==
dependencies:
"@babel/runtime" "^7.5.4"
"@testing-library/dom" "^5.5.4"
@ -2274,10 +2274,10 @@
resolved "https://registry.yarnpkg.com/@types/q/-/q-1.5.2.tgz#690a1475b84f2a884fd07cd797c00f5f31356ea8"
integrity sha512-ce5d3q03Ex0sy4R14722Rmt6MT07Ua+k4FwDfdcToYJcMKNtRVQvJ6JCAPdAmAnbRb6CsX6aYb9m96NGod9uTw==
"@types/react-transition-group@^2.0.16":
version "2.9.2"
resolved "https://registry.yarnpkg.com/@types/react-transition-group/-/react-transition-group-2.9.2.tgz#c48cf2a11977c8b4ff539a1c91d259eaa627028d"
integrity sha512-5Fv2DQNO+GpdPZcxp2x/OQG/H19A01WlmpjVD9cKvVFmoVLOZ9LvBgSWG6pSXIU4og5fgbvGPaCV5+VGkWAEHA==
"@types/react-transition-group@^4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@types/react-transition-group/-/react-transition-group-4.2.0.tgz#86ddb509ce3de27341c7cb7797abb99b1c4676bf"
integrity sha512-8KkpFRwqS9U1dtVVw1kt/MmWgLmbd5iK5TgqsaeC7fAm74J4j/HiBiRC8eETvwjGGju48RAwyZ3l5iv1H1x93Q==
dependencies:
"@types/react" "*"
@ -6776,10 +6776,10 @@ eslint-module-utils@^2.4.0:
debug "^2.6.8"
pkg-dir "^2.0.0"
eslint-plugin-flowtype@3.12.1:
version "3.12.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-3.12.1.tgz#b673c716b578c9aa66887feef3bc146f8cbe1c21"
integrity sha512-NZqf5iRgsfHOC31HQdtX2pvzCi0n/j9pB+L7Cf9QtuYxpx0i2wObT+R3rPKhQK4KtEDzGuzPYVf75j4eg+s9ZQ==
eslint-plugin-flowtype@3.12.2:
version "3.12.2"
resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-3.12.2.tgz#f02fb8a4e20993bff860292bdd39b93d511d7326"
integrity sha512-Fky+noPK7WPEAuclGRBsRHNukmSc9h2cUMpht9+tVd30YoJwz3xK7ma1QQ69wIjVTbk2N0sA6QjEo2DlIf9LlA==
dependencies:
lodash "^4.17.11"
@ -6800,10 +6800,10 @@ eslint-plugin-import@2.18.2:
read-pkg-up "^2.0.0"
resolve "^1.11.0"
eslint-plugin-jest@22.13.7:
version "22.13.7"
resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-22.13.7.tgz#08516e7c77dd2a95d41dadd4e2ed9b7b29d18ce6"
integrity sha512-ckgSt9YHwgYd0PgMGtdYei4dfjsPmKnQlNs+Hr238sLKiLXODu38nbumtpDloa6uqUN/NVzHGYG9lV+X7iUv6Q==
eslint-plugin-jest@22.14.0:
version "22.14.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-22.14.0.tgz#f9b09837f665cfe360b55c08866904255294cc16"
integrity sha512-Xtc9ZTtxdYFC7vu0PHxDeQ9lOMQ8gjwMmSQq/ni83TdflgL3eVh/qg3t99I7gcDxpeXfcp+lHu9C0vN3QAhATw==
dependencies:
"@typescript-eslint/experimental-utils" "^1.13.0"
@ -7946,10 +7946,10 @@ flatted@^2.0.0:
resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.1.tgz#69e57caa8f0eacbc281d2e2cb458d46fdb449e08"
integrity sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==
flow-bin@0.103.0:
version "0.103.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.103.0.tgz#7aec510d85e1c1b0f2b912bb988337d70035cb0f"
integrity sha512-Y3yrnE5ICN1Kl/y10BwjA3JSuS+gt4jVPNyUNCZb0RqmkdssMrW8QNNysJYvhgAY/JBJH8Qv7NVUf11MiwfSlA==
flow-bin@0.104.0:
version "0.104.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.104.0.tgz#ef5b3600dfd36abe191a87d19f66e481bad2e235"
integrity sha512-EZXRRmf7m7ET5Lcnwm/I/T8G3d427Bq34vmO3qIlRcPIYloGuVoqRCwjaeezLRDntHkdciagAKbhJ+NTbDjnkw==
flush-write-stream@^1.0.0, flush-write-stream@^1.0.2:
version "1.1.1"
@ -14026,10 +14026,10 @@ react-helmet-async@^1.0.2:
react-fast-compare "2.0.4"
shallowequal "1.1.0"
react-hot-loader@4.12.9:
version "4.12.9"
resolved "https://registry.yarnpkg.com/react-hot-loader/-/react-hot-loader-4.12.9.tgz#cb2a85731ca38366b0e9e28e7fd1dbd7dcacc1ef"
integrity sha512-lWT3JpWUN7nGHSoI9c4MV+42ov79bd8aqwDzhoyKev3owIh+hbEivT6Mb81lCV6tWuqm9trKo2/Th2/YDhFCdw==
react-hot-loader@4.12.10:
version "4.12.10"
resolved "https://registry.yarnpkg.com/react-hot-loader/-/react-hot-loader-4.12.10.tgz#b3457c0f733423c4827c6d2672e50c9f8bedaf6b"
integrity sha512-dX+ZUigxQijWLsKPnxc0khuCt2sYiZ1W59LgSBMOLeGSG3+HkknrTlnJu6BCNdhYxbEQkGvBsr7zXlNWYUIhAQ==
dependencies:
fast-levenshtein "^2.0.6"
global "^4.3.0"