on master help sign in
Refactor account options generation for hardware wallets
commit8b8b3ee12b9faaebb9240e32c7c897105a334b96 authorFang <git@fang.io> dateTue 25 Jun 2019, 17:12 (7 years ago) parent74ca391
2 files changed+9−13
src/views/Login/Ledger.js+5−7 src/views/Login/Trezor.js+4−6
src/views/Login/Ledger.js+5−7
@@ -1,5 +1,6 @@
11import * as bip32 from 'bip32';
22import React, { useState } from 'react';
3+import { times } from 'lodash';
34import Maybe from 'folktale/maybe';
45import Transport from '@ledgerhq/hw-transport-u2f';
56import Eth from '@ledgerhq/hw-app-eth';
@@ -67,13 +68,10 @@ export default function Ledger({ loginCompleted }) {
6768 ];
6869 const basePathTitle = pathOptions.find(o => o.value === basePath).title;
6970
70− let accountOptions = [];
71− for (let i = 0; i < 20; i++) {
72− accountOptions.push({
73− title: 'Account #' + (i + 1),
74− value: i,
75− });
76− }
71+ const accountOptions = times(20, i => ({
72+ title: `Account #${i + 1}`,
73+ value: i,
74+ }));
7775 const accountTitle = accountOptions.find(o => o.value === account).title;
7876
7977 const basePathSelection = (
src/views/Login/Trezor.js+4−6
@@ -1,6 +1,7 @@
11import * as bip32 from 'bip32';
22import React, { useState } from 'react';
33import Maybe from 'folktale/maybe';
4+import { times } from 'lodash';
45import TrezorConnect from 'trezor-connect';
56import * as secp256k1 from 'secp256k1';
67
@@ -46,12 +47,9 @@ export default function Trezor({ loginCompleted }) {
4647 };
4748
4849 let accountOptions = [{ title: 'Custom path', value: 'custom' }];
49− for (let i = 0; i < 20; i++) {
50− accountOptions.push({
51− title: 'Account #' + (i + 1),
52− value: i,
53− });
54− }
50+ times(20, i => {
51+ accountOptions.push({ title: `Account #${i + 1}`, value: i });
52+ });
5553 let accountTitle = accountOptions.find(o => o.value === account).title;
5654
5755 const accountSelection = (