From 4f21a6c1c0549ee3b0ecc72d23cfdabdcf66b2da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Bachst=C3=A4tter?= Date: Mon, 25 Nov 2019 23:10:17 +1100 Subject: [PATCH] Add commits from previous PR (#94) --- src/ducks/wallet.js | 8 +++++++- src/index.js | 1 + src/pages/WalletSelection/WalletSelection.js | 12 ++++++++---- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/ducks/wallet.js b/src/ducks/wallet.js index ef57faf1..711d705e 100644 --- a/src/ducks/wallet.js +++ b/src/ducks/wallet.js @@ -1,3 +1,4 @@ +import { setSigner } from '../helpers/snxJSConnector'; import { getAddress } from '../helpers/formatters'; const UPDATE_WALLET_STATUS = 'WALLET/UPDATE_WALLET_STATUS'; @@ -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, diff --git a/src/index.js b/src/index.js index 06db7636..505a51ea 100644 --- a/src/index.js +++ b/src/index.js @@ -17,6 +17,7 @@ const initialState = { unlocked: false, walletPaginatorIndex: 0, availableWallets: [], + derivationPath: localStorage.getItem('derivationPath'), }, transactions: { currentTransactions: [], diff --git a/src/pages/WalletSelection/WalletSelection.js b/src/pages/WalletSelection/WalletSelection.js index 3313786b..304da9b5 100644 --- a/src/pages/WalletSelection/WalletSelection.js +++ b/src/pages/WalletSelection/WalletSelection.js @@ -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'; @@ -10,7 +10,7 @@ import { updateCurrentPage } from '../../ducks/ui'; import { updateWalletStatus, updateWalletPaginatorIndex, - setDerivationPath, + derivationPathChange, } from '../../ducks/wallet'; import { SimpleInput } from '../../components/Input'; @@ -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); }} >