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 { 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.manifest({
35 email: 'bridge-trezor@urbit.org',
36 appUrl: 'https://github.com/urbit/bridge'
38 TrezorConnect.getPublicKey({ path: hdpath })
40 if (info.success === true) {
41 const payload = info.payload
42 const publicKey = Buffer.from(payload.publicKey, 'hex')
43 const chainCode = Buffer.from(payload.chainCode, 'hex')
44 const pub = secp256k1.publicKeyConvert(publicKey, true)
45 const hd = bip32.fromPublicKey(pub, chainCode)
46 setWallet(Maybe.Just(hd))
47 setWalletHdPath(hdpath)
49 setWallet(Maybe.Nothing())
55 const { pushRoute, popRoute, wallet } = this.props
56 const { hdpath } = this.state
60 <Col className={'measure-md'}>
61 <H1>{ 'Authenticate With Your Trezor' }</H1>
64 { `Connect and authenticate to your Trezor. If you'd like
65 to use a custom derivation path, you may enter it below.`
70 className='pt-8 text-mono'
72 prop-format='innerLabel'
76 onChange={ this.handleHdPathInput }>
77 <InnerLabel>{'HD Path'}</InnerLabel>
83 onClick={ this.pollDevice }>
90 disabled={ Maybe.Nothing.hasInstance(wallet) }
94 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