@@ -1,4 +1,4 @@
1−import React, { useCallback, useEffect, useState } from 'react';
1+import React, { useCallback, useEffect } from 'react';
22import Maybe from 'folktale/maybe';
33import { P, Text, Input, Grid, H5, CheckboxInput } from 'indigo-react';
44import { times } from 'lodash';
@@ -8,8 +8,11 @@ import Eth from '@ledgerhq/hw-app-eth';
88import * as secp256k1 from 'secp256k1';
99
1010import { ForwardButton } from 'components/Buttons';
11−import { InnerLabelDropdown } from 'components/old/Base';
12−import { useCheckboxInput, useHdPathInput } from 'components/Inputs';
11+import {
12+ useCheckboxInput,
13+ useHdPathInput,
14+ useSelectInput,
15+} from 'components/Inputs';
1316
1417import { useWallet } from 'store/wallet';
1518
@@ -21,14 +24,15 @@ import {
2124} from 'lib/ledger';
2225import { WALLET_TYPES } from 'lib/wallet';
2326import useLoginView from 'lib/useLoginView';
27+import SelectInput from 'indigo-react/components/SelectInput';
2428
25−const pathOptions = [
26− { title: 'Ledger Live', value: LEDGER_LIVE_PATH },
27− { title: 'Ledger Legacy', value: LEDGER_LEGACY_PATH },
29+const PATH_OPTIONS = [
30+ { text: 'Ledger Live', value: LEDGER_LIVE_PATH },
31+ { text: 'Ledger Legacy', value: LEDGER_LEGACY_PATH },
2832];
2933
30−const accountOptions = times(20, i => ({
31− title: `Account #${i + 1}`,
34+const ACCOUNT_OPTIONS = times(20, i => ({
35+ text: `Account #${i + 1}`,
3236 value: i,
3337}));
3438
@@ -37,10 +41,21 @@ export default function Ledger({ className }) {
3741
3842 const { setWallet, setWalletHdPath } = useWallet();
3943
40− // ledger has two derivation path _patterns_
41− const [basePathPattern, setBasePathPattern] = useState(LEDGER_LIVE_PATH);
42− // and then we want to be able to select an index within that path
43− const [accountIndex, setAccountIndex] = useState(0);
44+ // derivation path input
45+ const [derivationPathInput, { data: basePathPattern }] = useSelectInput({
46+ name: 'derivationpath',
47+ label: 'Derivation Path',
48+ placeholder: 'Choose path pattern...',
49+ options: PATH_OPTIONS,
50+ });
51+
52+ // account input
53+ const [accountInput, { data: accountIndex }] = useSelectInput({
54+ name: 'account',
55+ label: 'Account',
56+ placeholder: 'Choose account...',
57+ options: ACCOUNT_OPTIONS,
58+ });
4459
4560 // custom toggle
4661 const [customPathInput, { data: useCustomPath }] = useCheckboxInput({
@@ -90,11 +105,6 @@ export default function Ledger({ className }) {
90105 }
91106 }, [useCustomPath, setHdPath, basePathPattern, accountIndex]);
92107
93− const basePathPatternTitle = pathOptions.find(
94− o => o.value === basePathPattern
95− ).title;
96− const accountTitle = accountOptions.find(o => o.value === accountIndex).title;
97−
98108 const isHTTPS = document.location.protocol === 'http:';
99109
100110 // when not on https, tell user how to get there
@@ -141,41 +151,33 @@ export default function Ledger({ className }) {
141151 <Grid.Item full as={H5}>
142152 Authenticate With Your Ledger
143153 </Grid.Item>
144− <Grid.Item full as={Text} className="f6">
154+ <Grid.Item full as={Text} className="f6 mb3">
145155 Connect and authenticate to your Ledger, and then open the "Ethereum"
146156 application. If you're running on older firmware, make sure the "browser
147157 support" option is turned on. To sign transactions, you'll also need to
148158 enable the "contract data" option.
149159 </Grid.Item>
150160
151− {useCustomPath && (
152− <Grid.Item full as={Input} className="mv3" {...hdPathInput} />
153− )}
161+ {useCustomPath && <Grid.Item full as={Input} {...hdPathInput} />}
154162
155163 {!useCustomPath && (
156164 <>
157165 <Grid.Item
158− full
159− as={InnerLabelDropdown}
160− className="mv4"
161− title="Derivation path"
162− options={pathOptions}
163− handleUpdate={setBasePathPattern}
164− currentSelectionTitle={basePathPatternTitle}
166+ half={1}
167+ as={SelectInput}
168+ className="pr1"
169+ {...derivationPathInput}
165170 />
166171 <Grid.Item
167− full
168− as={InnerLabelDropdown}
169− className="mt4"
170− title="Account"
171− options={accountOptions}
172− handleUpdate={setAccountIndex}
173− currentSelectionTitle={accountTitle}
172+ half={2}
173+ as={SelectInput}
174+ className="pl1"
175+ {...accountInput}
174176 />
175177 </>
176178 )}
177179
178− <Grid.Item full as={CheckboxInput} {...customPathInput} />
180+ <Grid.Item full as={CheckboxInput} className="mv3" {...customPathInput} />
179181
180182 <Grid.Item
181183 full