Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Commit

Permalink
Add commits from previous PR (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xjocke committed Nov 25, 2019
1 parent a9a0a40 commit 4f21a6c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/ducks/wallet.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { setSigner } from '../helpers/snxJSConnector';
import { getAddress } from '../helpers/formatters';

const UPDATE_WALLET_STATUS = 'WALLET/UPDATE_WALLET_STATUS';
Expand Down Expand Up @@ -27,12 +28,17 @@ export default (state, action) => {
};

// Actions
export const setDerivationPath = (path, dispatch) => {
const setDerivationPath = (path, dispatch) => {
return dispatch({
type: SET_DERIVATION_PATH,
payload: path,
});
};
export const derivationPathChange = (signerOptions, derivationPath, dispatch) => {
setSigner(signerOptions);
localStorage.setItem('derivationPath', derivationPath);
return setDerivationPath(derivationPath, dispatch);
};
export const updateWalletStatus = (walletStatus, dispatch) => {
return dispatch({
type: UPDATE_WALLET_STATUS,
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const initialState = {
unlocked: false,
walletPaginatorIndex: 0,
availableWallets: [],
derivationPath: localStorage.getItem('derivationPath'),
},
transactions: {
currentTransactions: [],
Expand Down
12 changes: 8 additions & 4 deletions src/pages/WalletSelection/WalletSelection.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useContext, useState, useEffect } from 'react';
import styled, { keyframes } from 'styled-components';
import snxJSConnector, { setSigner } from '../../helpers/snxJSConnector';
import snxJSConnector from '../../helpers/snxJSConnector';
import { withTranslation, useTranslation, Trans } from 'react-i18next';

import { bigNumberFormatter, formatCurrency } from '../../helpers/formatters';
Expand All @@ -10,7 +10,7 @@ import { updateCurrentPage } from '../../ducks/ui';
import {
updateWalletStatus,
updateWalletPaginatorIndex,
setDerivationPath,
derivationPathChange,
} from '../../ducks/wallet';

import { SimpleInput } from '../../components/Input';
Expand Down Expand Up @@ -185,8 +185,12 @@ const WalletConnection = ({ t }) => {
value={selectedDerivationPath}
onChange={option => {
if (option.value === derivationPath) return;
setSigner({ type: 'Ledger', networkId, derivationPath: option.value });
setDerivationPath(option.value, dispatch);
const signerOptions = {
type: 'Ledger',
networkId,
derivationPath: option.value,
};
derivationPathChange(signerOptions, option.value, dispatch);
}}
></SimpleSelect>
</SelectWrapper>
Expand Down

0 comments on commit 4f21a6c

Please sign in to comment.