diff --git a/src/actions/WalletActions.js b/src/actions/WalletActions.js index ddbb9003..ff72e87b 100644 --- a/src/actions/WalletActions.js +++ b/src/actions/WalletActions.js @@ -93,13 +93,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.error(error); }); }; diff --git a/src/actions/ethereum/SendFormValidationActions.js b/src/actions/ethereum/SendFormValidationActions.js index 6c22a7a1..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.networkName); - 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); 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 diff --git a/src/views/Wallet/views/WalletSettings/index.js b/src/views/Wallet/views/WalletSettings/index.js index cb42d4e2..1c3e8276 100644 --- a/src/views/Wallet/views/WalletSettings/index.js +++ b/src/views/Wallet/views/WalletSettings/index.js @@ -65,7 +65,6 @@ const buildCurrencyOption = currency => { const WalletSettings = (props: Props) => ( - {console.log(props)}