@@ -1,4 +1,4 @@
1−import React, { useCallback, useEffect, useState } from 'react';
1+import React, { useCallback, useEffect } from 'react';
2import Maybe from 'folktale/maybe';
2import Maybe from 'folktale/maybe';
3import { P, Text, Input, Grid, H5, CheckboxInput } from 'indigo-react';
3import { P, Text, Input, Grid, H5, CheckboxInput } from 'indigo-react';
4import { times } from 'lodash';
4import { times } from 'lodash';
@@ -8,8 +8,11 @@ import Eth from '@ledgerhq/hw-app-eth';
8import * as secp256k1 from 'secp256k1';
8import * as secp256k1 from 'secp256k1';
10import { ForwardButton } from 'components/Buttons';
10import { ForwardButton } from 'components/Buttons';
11−import { InnerLabelDropdown } from 'components/old/Base';
11+import {
12−import { useCheckboxInput, useHdPathInput } from 'components/Inputs';
15+} from 'components/Inputs';
14import { useWallet } from 'store/wallet';
17import { useWallet } from 'store/wallet';
@@ -21,14 +24,15 @@ import {
21} from 'lib/ledger';
24} from 'lib/ledger';
22import { WALLET_TYPES } from 'lib/wallet';
25import { WALLET_TYPES } from 'lib/wallet';
23import useLoginView from 'lib/useLoginView';
26import useLoginView from 'lib/useLoginView';
27+import SelectInput from 'indigo-react/components/SelectInput';
25−const pathOptions = [
29+const PATH_OPTIONS = [
26− { title: 'Ledger Live', value: LEDGER_LIVE_PATH },
30+ { text: 'Ledger Live', value: LEDGER_LIVE_PATH },
27− { title: 'Ledger Legacy', value: LEDGER_LEGACY_PATH },
31+ { text: 'Ledger Legacy', value: LEDGER_LEGACY_PATH },
30−const accountOptions = times(20, i => ({
34+const ACCOUNT_OPTIONS = times(20, i => ({
31− title: `Account #${i + 1}`,
35+ text: `Account #${i + 1}`,
@@ -37,10 +41,21 @@ export default function Ledger({ className }) {
38 const { setWallet, setWalletHdPath } = useWallet();
42 const { setWallet, setWalletHdPath } = useWallet();
40− // ledger has two derivation path _patterns_
44+ // derivation path input
41− const [basePathPattern, setBasePathPattern] = useState(LEDGER_LIVE_PATH);
45+ const [derivationPathInput, { data: basePathPattern }] = useSelectInput({
42− // and then we want to be able to select an index within that path
46+ name: 'derivationpath',
43− const [accountIndex, setAccountIndex] = useState(0);
47+ label: 'Derivation Path',
48+ placeholder: 'Choose path pattern...',
49+ options: PATH_OPTIONS,
53+ const [accountInput, { data: accountIndex }] = useSelectInput({
56+ placeholder: 'Choose account...',
57+ options: ACCOUNT_OPTIONS,
45 // custom toggle
60 // custom toggle
46 const [customPathInput, { data: useCustomPath }] = useCheckboxInput({
61 const [customPathInput, { data: useCustomPath }] = useCheckboxInput({
@@ -90,11 +105,6 @@ export default function Ledger({ className }) {
91 }, [useCustomPath, setHdPath, basePathPattern, accountIndex]);
106 }, [useCustomPath, setHdPath, basePathPattern, accountIndex]);
93− const basePathPatternTitle = pathOptions.find(
94− o => o.value === basePathPattern
96− const accountTitle = accountOptions.find(o => o.value === accountIndex).title;
98 const isHTTPS = document.location.protocol === 'http:';
108 const isHTTPS = document.location.protocol === 'http:';
100 // when not on https, tell user how to get there
110 // when not on https, tell user how to get there
@@ -141,41 +151,33 @@ export default function Ledger({ className }) {
141 <Grid.Item full as={H5}>
151 <Grid.Item full as={H5}>
142 Authenticate With Your Ledger
152 Authenticate With Your Ledger
143 </Grid.Item>
153 </Grid.Item>
144− <Grid.Item full as={Text} className="f6">
154+ <Grid.Item full as={Text} className="f6 mb3">
145 Connect and authenticate to your Ledger, and then open the "Ethereum"
155 Connect and authenticate to your Ledger, and then open the "Ethereum"
146 application. If you're running on older firmware, make sure the "browser
156 application. If you're running on older firmware, make sure the "browser
147 support" option is turned on. To sign transactions, you'll also need to
157 support" option is turned on. To sign transactions, you'll also need to
148 enable the "contract data" option.
158 enable the "contract data" option.
149 </Grid.Item>
159 </Grid.Item>
152− <Grid.Item full as={Input} className="mv3" {...hdPathInput} />
161+ {useCustomPath && <Grid.Item full as={Input} {...hdPathInput} />}
155 {!useCustomPath && (
163 {!useCustomPath && (
157 <Grid.Item
165 <Grid.Item
159− as={InnerLabelDropdown}
167+ as={SelectInput}
160− className="mv4"
168+ className="pr1"
161− title="Derivation path"
169+ {...derivationPathInput}
162− options={pathOptions}
163− handleUpdate={setBasePathPattern}
164− currentSelectionTitle={basePathPatternTitle}
166 <Grid.Item
171 <Grid.Item
168− as={InnerLabelDropdown}
173+ as={SelectInput}
169− className="mt4"
174+ className="pl1"
170− title="Account"
175+ {...accountInput}
171− options={accountOptions}
172− handleUpdate={setAccountIndex}
173− currentSelectionTitle={accountTitle}
178− <Grid.Item full as={CheckboxInput} {...customPathInput} />
180+ <Grid.Item full as={CheckboxInput} className="mv3" {...customPathInput} />
180 <Grid.Item
182 <Grid.Item