Skip to content

Commit

Permalink
fix: update ledgerHDPath props
Browse files Browse the repository at this point in the history
  • Loading branch information
gutsyphilip committed May 11, 2022
1 parent ace21ea commit 0c9dc1e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
19 changes: 8 additions & 11 deletions packages/frontend/src/components/accounts/ledger/SetupLedger.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ import {
import { showCustomAlert } from '../../../redux/actions/status';
import { selectAccountSlice } from '../../../redux/slices/account';
import { createNewAccount } from '../../../redux/slices/account/createAccountThunks';
import { actions as ledgerActions } from '../../../redux/slices/ledger';
import { actions as ledgerActions, LEDGER_HD_PATH_PREFIX } from '../../../redux/slices/ledger';
import { actions as linkdropActions } from '../../../redux/slices/linkdrop';
import { selectStatusMainLoader } from '../../../redux/slices/status';
import { getLedgerHDPath } from '../../../utils/ledger';
import { setLedgerHdPath } from '../../../utils/localStorage';
import parseFundingOptions from '../../../utils/parseFundingOptions';
import { setKeyMeta, ENABLE_IDENTITY_VERIFIED_ACCOUNT } from '../../../utils/wallet';
Expand All @@ -45,9 +44,8 @@ const SetupLedger = (props) => {
const [isNewAccount, setIsNewAccount] = useState(null);
// TODO: Custom recaptcha hook
const [recaptchaToken, setRecaptchaToken] = useState(null);
const [path, setPath] = useState(1);
const [confirmedPath, setConfirmedPath] = useState(null);
const customLedgerHdPath = getLedgerHDPath(confirmedPath);
const [confirmedPath, setConfirmedPath] = useState(1);
const ledgerHdPath = `${LEDGER_HD_PATH_PREFIX}${confirmedPath}'`;

const recaptchaRef = useRef(null);
const fundingOptions = parseFundingOptions(props.location.search);
Expand Down Expand Up @@ -83,13 +81,13 @@ const SetupLedger = (props) => {

try {
debugLog(DISABLE_CREATE_ACCOUNT, fundingOptions);
publicKey = await dispatch(getLedgerPublicKey(customLedgerHdPath));
publicKey = await dispatch(getLedgerPublicKey(ledgerHdPath));
await setKeyMeta(publicKey, { type: 'ledger' });
Mixpanel.track('SR-Ledger Set key meta');

// Set custom path to localstorage
if (customLedgerHdPath) {
setLedgerHdPath({ accountId, path: customLedgerHdPath });
if (ledgerHdPath) {
setLedgerHdPath({ accountId, path: ledgerHdPath });
}

// COIN-OP VERIFY ACCOUNT
Expand Down Expand Up @@ -188,9 +186,8 @@ const SetupLedger = (props) => {
&nbsp;<Translate id='setupLedger.two' /> <span className='link underline' onClick={openShowInstructions}><Translate id='setupLedger.twoLink' /></span>.
</h2>
<LedgerHdPaths
path={path}
onSetPath={(path) => setPath(path)}
onConfirmHdPath={() => {
confirmedPath={confirmedPath}
setConfirmedPath={(path) => {
setConfirmedPath(path);
Mixpanel.track('SR-Ledger Setup set custom HD path');
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react';
import { Translate } from 'react-localize-redux';

import { Mixpanel } from '../../../mixpanel/index';
import { getLedgerHDPath } from '../../../utils/ledger';
import { LEDGER_HD_PATH_PREFIX } from '../../../redux/slices/ledger';
import FormButton from '../../common/FormButton';
import Container from '../../common/styled/Container.css';
import LedgerIcon from '../../svg/LedgerIcon';
Expand All @@ -13,9 +13,8 @@ export default ({
onClickConnectLedger
}) => {
const [showInstructions, setShowInstructions] = useState(false);
const [path, setPath] = useState(1);
const [confirmedPath, setConfirmedPath] = useState(null);
const customLedgerHdPath = getLedgerHDPath(confirmedPath);
const [confirmedPath, setConfirmedPath] = useState(1);
const ledgerHdPath = `${LEDGER_HD_PATH_PREFIX}${confirmedPath}'`;
return (
<Container className='small-centered border ledger-theme'>
<h1><Translate id='setupLedger.header' /></h1>
Expand All @@ -34,15 +33,14 @@ export default ({
</span>.
</h2>
<LedgerHdPaths
path={path}
onSetPath={(path) => setPath(path)}
onConfirmHdPath={() => {
confirmedPath={confirmedPath}
setConfirmedPath={(path) => {
setConfirmedPath(path);
Mixpanel.track('SR-Ledger Setup set custom HD path');
}}
/>
<FormButton onClick={()=>{
onClickConnectLedger(customLedgerHdPath);
onClickConnectLedger(ledgerHdPath);
}}>
<Translate id='button.continue' />
</FormButton>
Expand Down

0 comments on commit 0c9dc1e

Please sign in to comment.