diff --git a/common/components/ui/Identicon.jsx b/common/components/ui/Identicon.jsx index 2422bedd..7f9dac56 100644 --- a/common/components/ui/Identicon.jsx +++ b/common/components/ui/Identicon.jsx @@ -1,6 +1,8 @@ +// @flow + import React from 'react'; import { toDataUrl } from 'ethereum-blockies'; -import { isValidAddress } from 'eth/validators'; +import { isValidETHAddress } from 'libs/validators'; type Props = { address: string @@ -8,7 +10,7 @@ type Props = { export default function Identicon(props: Props) { // FIXME breaks on failed checksums - const style = !isValidAddress(props.address) + const style = !isValidETHAddress(props.address) ? {} : { backgroundImage: `url(${toDataUrl(props.address.toLowerCase())})` }; return
; diff --git a/common/containers/Tabs/SendTransaction/components/AddressField.jsx b/common/containers/Tabs/SendTransaction/components/AddressField.jsx index c42ca04f..50aace23 100644 --- a/common/containers/Tabs/SendTransaction/components/AddressField.jsx +++ b/common/containers/Tabs/SendTransaction/components/AddressField.jsx @@ -4,7 +4,7 @@ import { Identicon } from 'components/ui'; import { getEnsAddress } from 'selectors/ens'; import { connect } from 'react-redux'; import type { State } from 'reducers'; -import { isValidENSorEtherAddress, isValidENSAddress } from 'eth/validators'; +import { isValidENSorEtherAddress, isValidENSAddress } from 'libs/validators'; import { resolveEnsName } from 'actions/ens'; type PublicProps = { diff --git a/common/containers/Tabs/SendTransaction/components/DataField.jsx b/common/containers/Tabs/SendTransaction/components/DataField.jsx index 1cc35fc3..371f5b04 100644 --- a/common/containers/Tabs/SendTransaction/components/DataField.jsx +++ b/common/containers/Tabs/SendTransaction/components/DataField.jsx @@ -1,7 +1,7 @@ // @flow import React from 'react'; import translate from 'translations'; -import { isValidHex } from 'eth/validators'; +import { isValidHex } from 'libs/validators'; export default class DataField extends React.Component { props: { diff --git a/common/containers/Tabs/Swap/components/receivingAddress.js b/common/containers/Tabs/Swap/components/receivingAddress.js index c2bc37a8..1932e026 100644 --- a/common/containers/Tabs/Swap/components/receivingAddress.js +++ b/common/containers/Tabs/Swap/components/receivingAddress.js @@ -1,40 +1,32 @@ +// @flow import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { DONATION_ADDRESSES_MAP } from 'config/data'; -import Validator from 'libs/validator'; +import {isValidBTCAddress, isValidETHAddress} from 'libs/validators'; import translate from 'translations'; export default class ReceivingAddress extends Component { - constructor(props) { - super(props); - this.validator = new Validator(); - this.state = { - validAddress: false - }; - } - static propTypes = { destinationKind: PropTypes.string.isRequired, receivingAddressSwap: PropTypes.func.isRequired, receivingAddress: PropTypes.string }; - onChangeReceivingAddress = event => { + onChangeReceivingAddress = (event: SyntheticInputEvent) => { const value = event.target.value; this.props.receivingAddressSwap(value); - let validAddress; - // TODO - find better pattern here once currencies move beyond BTC, ETH, REP - if (this.props.destinationKind === 'BTC') { - validAddress = this.validator.isValidBTCAddress(value); - } else { - validAddress = this.validator.isValidETHAddress(value); - } - this.setState({ validAddress }); }; render() { const { destinationKind, receivingAddress } = this.props; - const { validAddress } = this.state; + let validAddress; + // TODO - find better pattern here once currencies move beyond BTC, ETH, REP + if (this.props.destinationKind === 'BTC') { + validAddress = isValidBTCAddress(receivingAddress); + } else { + validAddress = isValidETHAddress(receivingAddress); + } + return (