Skip to content

Commit

Permalink
feat: custom hd path for new account
Browse files Browse the repository at this point in the history
  • Loading branch information
gutsyphilip committed May 5, 2022
1 parent b848560 commit 0c18b63
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@ import React, { useState } from 'react';
import { Translate } from 'react-localize-redux';

import { Mixpanel } from '../../../mixpanel/index';
import { getLedgerHDPath } from '../../../utils/ledger';
import FormButton from '../../common/FormButton';
import Container from '../../common/styled/Container.css';
import LedgerIcon from '../../svg/LedgerIcon';
import InstructionsModal from './InstructionsModal';
import LedgerHdPaths from './LedgerHdPaths';

export default ({
onClickConnectLedger
}) => {
const [showInstructions, setShowInstructions] = useState(false);
const [path, setPath] = useState(1);
const [confirmedPath, setConfirmedPath] = useState(null);
const customLedgerHdPath = getLedgerHDPath(confirmedPath);
return (
<Container className='small-centered border ledger-theme'>
<h1><Translate id='setupLedger.header' /></h1>
Expand All @@ -28,7 +33,17 @@ export default ({
<Translate id='setupLedger.twoLink' />
</span>.
</h2>
<FormButton onClick={onClickConnectLedger}>
<LedgerHdPaths
path={path}
onSetPath={(path) => setPath(path)}
onConfirmHdPath={() => {
setConfirmedPath(path);
Mixpanel.track('SR-Ledger Setup set custom HD path');
}}
/>
<FormButton onClick={()=>{
onClickConnectLedger(customLedgerHdPath);
}}>
<Translate id='button.continue' />
</FormButton>
<FormButton
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/routes/SetupLedgerNewAccountWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ export function SetupLedgerNewAccountWrapper() {
const dispatch = useDispatch();
return (
<SetupLedgerNewAccount
onClickConnectLedger={async () => {
onClickConnectLedger={async (path) => {
try {
const ledgerPublicKey = await dispatch(getLedgerPublicKey());
const ledgerPublicKey = await dispatch(getLedgerPublicKey(path));
const implicitAccountId = Buffer.from(ledgerPublicKey.data).toString('hex');
const account = wallet.getAccountBasic(implicitAccountId);
try {
Expand Down

0 comments on commit 0c18b63

Please sign in to comment.