@@ -3,11 +3,11 @@ import React from 'react'
3import Maybe from 'folktale/maybe'
3import Maybe from 'folktale/maybe'
4import { Button } from '../components/Base'
4import { Button } from '../components/Base'
5import { Row, Col, H1, P } from '../components/Base'
5import { Row, Col, H1, P } from '../components/Base'
6−import { InnerLabel, Input } from '../components/Base'
6+import { InnerLabel, Input, InnerLabelDropdown } from '../components/Base'
7import TrezorConnect from 'trezor-connect'
7import TrezorConnect from 'trezor-connect'
8import * as secp256k1 from 'secp256k1'
8import * as secp256k1 from 'secp256k1'
10−import { TREZOR_BASE_PATH } from '../lib/trezor'
10+import { TREZOR_PATH } from '../lib/trezor'
11import { ROUTE_NAMES } from '../lib/router'
11import { ROUTE_NAMES } from '../lib/router'
13class Trezor extends React.Component {
13class Trezor extends React.Component {
@@ -16,13 +16,23 @@ class Trezor extends React.Component {
16 super(props)
16 super(props)
18 this.state = {
18 this.state = {
19− hdpath: TREZOR_BASE_PATH
19+ hdpath: TREZOR_PATH.replace(/x/g, 0),
23+ this.handleAccountSelection = this.handleAccountSelection.bind(this)
22 this.handleHdPathInput = this.handleHdPathInput.bind(this)
24 this.handleHdPathInput = this.handleHdPathInput.bind(this)
23 this.pollDevice = this.pollDevice.bind(this)
25 this.pollDevice = this.pollDevice.bind(this)
28+ handleAccountSelection(account) {
29+ let hdpath = this.state.hdpath;
30+ if (account !== 'custom') {
31+ hdpath = TREZOR_PATH.replace(/x/g, account);
33+ this.setState({ account, hdpath });
26 handleHdPathInput(hdpath) {
36 handleHdPathInput(hdpath) {
27 this.setState({ hdpath })
37 this.setState({ hdpath })
@@ -53,7 +63,57 @@ class Trezor extends React.Component {
54 render() {
64 render() {
55 const { pushRoute, popRoute, wallet } = this.props
65 const { pushRoute, popRoute, wallet } = this.props
56− const { hdpath } = this.state
66+ const { hdpath, account } = this.state
67+ const { handleAccountSelection } = this;
68+ console.log('hdpath', hdpath)
70+ let accountOptions = [{
71+ title: 'Custom path',
74+ for (let i = 0; i < 20; i++) {
75+ accountOptions.push({
76+ title: 'Account #' + (i+1),
81+ let accountTitle = '';
82+ for (let i in accountOptions) {
83+ let option = accountOptions[i];
84+ if (option.value === account) {
85+ accountTitle = option.title;
90+ const accountSelection = (
94+ prop-format='innerLabel'
95+ options={accountOptions}
96+ handleUpdate={handleAccountSelection}
98+ currentSelectionTitle={accountTitle}
101+ </InnerLabelDropdown>
104+ const pathSelection = (account !== 'custom') ? null :
107+ className='mt-8 pt-8 text-mono'
109+ prop-format='innerLabel'
113+ onChange={ this.handleHdPathInput }>
114+ <InnerLabel>{'HD Path'}</InnerLabel>
@@ -66,16 +126,8 @@ class Trezor extends React.Component {
69− <Input
129+ { accountSelection }
70− className='pt-8 text-mono'
130+ { pathSelection }
72− prop-format='innerLabel'
76− onChange={ this.handleHdPathInput }>
77− <InnerLabel>{'HD Path'}</InnerLabel>
81 className={'mt-8'}
133 className={'mt-8'}