1import * as bip39 from 'bip39'
2import Maybe from 'folktale/maybe'
3import React from 'react'
4import { Button } from '../components/Base'
5import { Input, MnemonicInput, InnerLabel, InputCaption } from '../components/Base'
6import { Row, Col, H1 } from '../components/Base'
8import { ROUTE_NAMES } from '../lib/router'
9import { DEFAULT_HD_PATH, walletFromMnemonic } from '../lib/wallet'
12class Mnemonic extends React.Component {
19 hdpath: DEFAULT_HD_PATH,
22 this.handleMnemonicInput = this.handleMnemonicInput.bind(this)
23 this.handleHdPathInput = this.handleHdPathInput.bind(this)
27 const { mnemonic, hdpath } = this.state
28 this.attemptWalletDerivation(mnemonic, hdpath)
31 exampleMnemonic: bip39.generateMnemonic(),
35 handleMnemonicInput(mnemonic) {
36 this.setState((state, _) => {
37 const hdpath = state.hdpath
38 this.attemptWalletDerivation(
40 hdpath === '' ? DEFAULT_HD_PATH : hdpath
48 handleHdPathInput(hdpath) {
49 this.setState((state, _) => {
50 const mnemonic = state.mnemonic
51 this.attemptWalletDerivation(
53 hdpath === '' ? DEFAULT_HD_PATH : hdpath
61 attemptWalletDerivation(mnemonic, hdpath) {
62 const { setWallet, setAuthMnemonic, setWalletHdPath } = this.props
63 const wallet = walletFromMnemonic(mnemonic, hdpath)
65 setAuthMnemonic(Maybe.Just(mnemonic))
66 setWalletHdPath(hdpath)
70 const { pushRoute, popRoute, wallet } = this.props
80 <H1 className={'mb-4'}>{ 'Enter Your Mnemonic' }</H1>
82 { "Please enter your BIP39 mnemonic here." }
88 prop-format='innerLabel'
91 placeholder={ `e.g. ${exampleMnemonic}` }
92 onChange={ this.handleMnemonicInput }
96 <InnerLabel>{'Mnemonic'}</InnerLabel>
101 {`If you'd like to use a custom derivation path, you may enter it below.`}
105 className='pt-8 text-mono'
107 prop-format='innerLabel'
111 onChange={ this.handleHdPathInput }>
112 <InnerLabel>{'HD Path'}</InnerLabel>
117 disabled={ Maybe.Nothing.hasInstance(wallet) }
120 pushRoute(ROUTE_NAMES.SHIPS)
134export default Mnemonic
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