1import Maybe from 'folktale/maybe'
2import React from 'react'
3import * as keythereum from 'keythereum'
4import { Button } from '../components/Base'
5import { Input, InnerLabel, InputCaption } from '../components/Base'
6import { Row, Col, H1, Form } from '../components/Base'
8import { ROUTE_NAMES } from '../lib/router'
9import { EthereumWallet } from '../lib/wallet'
10import UploadButton from '../components/UploadButton'
12class Keystore extends React.Component {
22 this.handleKeystoreInput = this.handleKeystoreInput.bind(this)
23 this.handlePasswordInput = this.handlePasswordInput.bind(this)
24 this.constructWallet = this.constructWallet.bind(this)
27 handleKeystoreInput(keystore) {
28 this.setState({ keystore })
31 handlePasswordInput(password) {
32 this.setState({ password })
36 const { setWallet } = this.props
37 const { keystore, password } = this.state
40 const json = JSON.parse(keystore)
41 const privateKey = keythereum.recover(password, json)
42 const wallet = new EthereumWallet(privateKey)
43 setWallet(Maybe.Just(wallet))
45 setWallet(Maybe.Nothing())
49 handleKeystoreUpload = (event) => {
50 const file = event.files.item(0)
51 const reader = new FileReader()
53 reader.readAsText(file)
55 console.log(reader.readyState)
57 // const loop = arg =>
58 // arg.readyState === 2
62 // const keystore = loop(reader)
63 // this.setState({ keystore })
67 const { pushRoute, popRoute, wallet } = this.props
68 const { keystore, password } = this.state
74 prop-format='innerLabel'
77 onChange={ this.handleKeystoreInput }
81 <InnerLabel>{'Keystore File'}</InnerLabel>
86 <Col className={'measure-md'}>
87 <H1 className={'mb-4'}>{ 'Enter Your Keystore File' }</H1>
90 { `Please paste in your Ethereum keystore file. If your keystore
91 file is encrypted with a password, you'll also need to enter
96 className={ `btn btn-primary table mt-4` }
97 onChange={ this.handleKeystoreUpload }
99 { 'Upload Keystore file' }
103 className='pt-8 mt-8'
105 prop-format='innerLabel'
108 onChange={ this.handlePasswordInput }
112 <InnerLabel>{'Password'}</InnerLabel>
117 prop-size={ 'wide lg' }
118 disabled={ keystore === '' }
119 onClick={ this.constructWallet }
126 prop-size={ 'wide lg' }
127 disabled={ Maybe.Nothing.hasInstance(wallet) }
130 pushRoute(ROUTE_NAMES.SHIPS)
146export default Keystore
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list