1import * as bip32 from 'bip32'
2import React from 'react'
3import Maybe from 'folktale/maybe'
4import { Button } from '../components/Base'
5import { Row, Col, H1, P } from '../components/Base'
6import { Form, InnerLabel, Input } from '../components/Base'
7import TrezorConnect from 'trezor-connect'
8import * as secp256k1 from 'secp256k1'
10import { TREZOR_BASE_PATH } from '../lib/trezor'
11import { ROUTE_NAMES } from '../lib/router'
13class Trezor extends React.Component {
19 hdpath: TREZOR_BASE_PATH
22 this.handleHdPathInput = this.handleHdPathInput.bind(this)
23 this.pollDevice = this.pollDevice.bind(this)
26 handleHdPathInput(hdpath) {
27 this.setState({ hdpath })
31 const { setWallet, setWalletHdPath } = this.props
32 const { hdpath } = this.state
34 TrezorConnect.getPublicKey({ path: hdpath })
36 if (info.success === true) {
37 const payload = info.payload
38 const publicKey = Buffer.from(payload.publicKey, 'hex')
39 const chainCode = Buffer.from(payload.chainCode, 'hex')
40 const pub = secp256k1.publicKeyConvert(publicKey, true)
41 const hd = bip32.fromPublicKey(pub, chainCode)
42 setWallet(Maybe.Just(hd))
43 setWalletHdPath(hdpath)
45 setWallet(Maybe.Nothing())
51 const { pushRoute, popRoute, wallet } = this.props
52 const { hdpath } = this.state
56 <Col className={'measure-md'}>
57 <H1>{ 'Authenticate With Your Trezor' }</H1>
60 { `Connect and authenticate to your Trezor. If you'd like
61 to use a custom derivation path, you may enter it below.`
69 prop-format='innerLabel'
73 onChange={ this.handleHdPathInput }>
74 <InnerLabel>{'HD Path'}</InnerLabel>
80 onClick={ this.pollDevice }>
87 disabled={ Maybe.Nothing.hasInstance(wallet) }
91 pushRoute(ROUTE_NAMES.SHIPS)
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