import React from 'react'; import translate from 'translations'; import { isValidTxHash, isValidETHAddress } from 'libs/validators'; import './TxHashInput.scss'; import { Input } from 'components/ui'; interface Props { hash?: string; onSubmit(hash: string): void; } interface State { hash: string; } export default class TxHashInput extends React.Component { public constructor(props: Props) { super(props); this.state = { hash: props.hash || '' }; } public componentWillReceiveProps(nextProps: Props) { if (this.props.hash !== nextProps.hash && nextProps.hash) { this.setState({ hash: nextProps.hash }); } } public render() { const { hash } = this.state; const validClass = hash ? (isValidTxHash(hash) ? '' : 'invalid') : ''; return (
{isValidETHAddress(hash) && (

You cannot use an address, you must use a transaction hash

)}
); } private handleChange = (ev: React.FormEvent) => { this.setState({ hash: ev.currentTarget.value }); }; private handleSubmit = (ev: React.FormEvent) => { ev.preventDefault(); if (isValidTxHash(this.state.hash)) { this.props.onSubmit(this.state.hash); } }; }