import Maybe from 'folktale/maybe' import React from 'react' import { Button } from '../components/Base' import { RequiredInput, InnerLabel, InputCaption } from '../components/Base' import { Row, Col, H1 } from '../components/Base' import { ROUTE_NAMES } from '../lib/router' import { EthereumWallet } from '../lib/wallet' const secre = /[0-9A-Fa-f]{64}/g class PrivateKey extends React.Component { constructor(props) { super(props) this.state = { privateKey: '', } this.handlePrivateKeyInput = this.handlePrivateKeyInput.bind(this) } handlePrivateKeyInput(privateKey) { this.setState({ privateKey }) this.constructWallet(privateKey) } constructWallet(privateKey) { const { setWallet } = this.props if (secre.test(privateKey) === true) { const sec = Buffer.from(privateKey, 'hex') const wallet = new EthereumWallet(sec) setWallet(Maybe.Just(wallet)) } else { setWallet(Maybe.Nothing()) } } render() { const { pushRoute, popRoute, wallet } = this.props const { privateKey } = this.state return (

{ 'Enter Your Private Key' }

{ `Please enter your raw Ethereum private key here.` } {'Private Key'}
) } } export default PrivateKey