From 15cc6e00f3b127ca5a18049f5121f8643788d375 Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Mon, 4 Mar 2019 19:03:07 +0100 Subject: [PATCH 1/6] handle response codes --- src/actions/WalletActions.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/actions/WalletActions.js b/src/actions/WalletActions.js index 063f548e..620d3ace 100644 --- a/src/actions/WalletActions.js +++ b/src/actions/WalletActions.js @@ -86,13 +86,21 @@ export const toggleSidebar = (): WalletAction => ({ export const fetchLocale = (locale: string): ThunkAction => (dispatch: Dispatch): void => { fetch(`./l10n/${locale}.json`) - .then(response => response.json()) + .then(response => { + if (response.ok) { + return response.json(); + } + throw Error(response.statusText); + }) .then(messages => { dispatch({ type: WALLET.SET_LANGUAGE, locale, messages, }); + }) + .catch(error => { + console.log(error); }); }; From 4757c71f45a806b8c9d07a9b648392095b5af5c7 Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Tue, 5 Mar 2019 11:53:33 +0100 Subject: [PATCH 2/6] use console.error instead of console.log --- src/actions/WalletActions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/actions/WalletActions.js b/src/actions/WalletActions.js index 620d3ace..d44914a2 100644 --- a/src/actions/WalletActions.js +++ b/src/actions/WalletActions.js @@ -100,7 +100,7 @@ export const fetchLocale = (locale: string): ThunkAction => (dispatch: Dispatch) }); }) .catch(error => { - console.log(error); + console.error(error); }); }; From ff9f072119e76132c540d9588e5759be1637e2ac Mon Sep 17 00:00:00 2001 From: Vladimir Volek Date: Thu, 14 Mar 2019 13:26:58 +0100 Subject: [PATCH 3/6] test format adjusted --- src/utils/__tests__/cryptoUriParser.js | 18 ------------------ ...{fiatConverter.js => fiatConverter.test.js} | 0 2 files changed, 18 deletions(-) delete mode 100644 src/utils/__tests__/cryptoUriParser.js rename src/utils/__tests__/{fiatConverter.js => fiatConverter.test.js} (100%) diff --git a/src/utils/__tests__/cryptoUriParser.js b/src/utils/__tests__/cryptoUriParser.js deleted file mode 100644 index 1dde9ad6..00000000 --- a/src/utils/__tests__/cryptoUriParser.js +++ /dev/null @@ -1,18 +0,0 @@ -import * as utils from '../cryptoUriParser'; - -describe('crypto uri parser', () => { - it('parseUri', () => { - expect(utils.parseUri('http://www.trezor.io')).toEqual({ address: '//www.trezor.io' }); // TODO: Error in function - expect(utils.parseUri('www.trezor.io')).toEqual({ address: 'www.trezor.io' }); - expect(utils.parseUri('www.trezor.io/TT')).toEqual({ address: 'www.trezor.io/TT' }); - expect(utils.parseUri('www.trezor.io/TT?param1=aha')).toEqual({ - address: 'www.trezor.io/TT', - param1: 'aha', - }); - expect(utils.parseUri('www.trezor.io/TT?param1=aha¶m2=hah')).toEqual({ - address: 'www.trezor.io/TT', - param1: 'aha', - param2: 'hah', - }); - }); -}); diff --git a/src/utils/__tests__/fiatConverter.js b/src/utils/__tests__/fiatConverter.test.js similarity index 100% rename from src/utils/__tests__/fiatConverter.js rename to src/utils/__tests__/fiatConverter.test.js From 1a07af9413f535469d432c9a5c04a25b7bc120a6 Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Thu, 14 Mar 2019 15:51:31 +0100 Subject: [PATCH 4/6] fix fiatRates for tokens on set max btn --- src/actions/ethereum/SendFormValidationActions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/actions/ethereum/SendFormValidationActions.js b/src/actions/ethereum/SendFormValidationActions.js index 6c22a7a1..6a5d1cc5 100644 --- a/src/actions/ethereum/SendFormValidationActions.js +++ b/src/actions/ethereum/SendFormValidationActions.js @@ -134,7 +134,7 @@ export const recalculateTotalAmount = ($state: State): PayloadAction => ( // calculate amount in local currency const { localCurrency } = getState().sendFormEthereum; - const fiatRates = getState().fiat.find(f => f.network === state.networkName); + const fiatRates = getState().fiat.find(f => f.network === state.currency.toLowerCase()); const localAmount = toFiatCurrency(state.amount, localCurrency, fiatRates); if (localAmount) { state.localAmount = localAmount; From 628d424438aa104311e854db503939f11fd0ced3 Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Thu, 14 Mar 2019 16:35:50 +0100 Subject: [PATCH 5/6] fix recalculating local amount for tokens on set max btn --- src/actions/ethereum/SendFormValidationActions.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/actions/ethereum/SendFormValidationActions.js b/src/actions/ethereum/SendFormValidationActions.js index 6a5d1cc5..c3f9a4d0 100644 --- a/src/actions/ethereum/SendFormValidationActions.js +++ b/src/actions/ethereum/SendFormValidationActions.js @@ -131,15 +131,12 @@ export const recalculateTotalAmount = ($state: State): PayloadAction => ( } else { const b = new BigNumber(account.balance).minus(pendingAmount); state.amount = calculateMaxAmount(b, state.gasPrice, state.gasLimit); - - // calculate amount in local currency - const { localCurrency } = getState().sendFormEthereum; - const fiatRates = getState().fiat.find(f => f.network === state.currency.toLowerCase()); - const localAmount = toFiatCurrency(state.amount, localCurrency, fiatRates); - if (localAmount) { - state.localAmount = localAmount; - } } + // calculate amount in local currency + const { localCurrency } = getState().sendFormEthereum; + const fiatRates = getState().fiat.find(f => f.network === state.currency.toLowerCase()); + const localAmount = toFiatCurrency(state.amount, localCurrency, fiatRates); + state.localAmount = localAmount; } state.total = calculateTotal(isToken ? '0' : state.amount, state.gasPrice, state.gasLimit); From 9f2a3f641613ad675004afe102d247d2a43c2013 Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Thu, 14 Mar 2019 17:05:50 +0100 Subject: [PATCH 6/6] remove console.log --- src/views/Wallet/views/WalletSettings/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/views/Wallet/views/WalletSettings/index.js b/src/views/Wallet/views/WalletSettings/index.js index 91ddd07b..56fc65eb 100644 --- a/src/views/Wallet/views/WalletSettings/index.js +++ b/src/views/Wallet/views/WalletSettings/index.js @@ -51,7 +51,6 @@ const buildCurrencyOption = currency => { const WalletSettings = (props: Props) => ( - {console.log(props)}