From d51ddbf8016ea380a7fddee24cd65e208750dea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Tue, 5 Jun 2018 17:55:06 +0200 Subject: [PATCH] fix countervalue for btc --- package.json | 2 +- src/components/CalculateBalance.js | 21 ++++++-------- src/components/CounterValue/index.js | 21 ++++++-------- src/components/DashboardPage/AccountsOrder.js | 14 ++++------ src/components/RequestAmount/index.js | 4 --- .../SettingsPage/sections/Currencies.js | 28 ++++++++++--------- yarn.lock | 6 ++-- 7 files changed, 43 insertions(+), 53 deletions(-) diff --git a/package.json b/package.json index f8f47f78..1de9158d 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@ledgerhq/hw-transport": "^4.12.0", "@ledgerhq/hw-transport-node-hid": "^4.12.0", "@ledgerhq/ledger-core": "1.4.5", - "@ledgerhq/live-common": "2.27.0", + "@ledgerhq/live-common": "2.27.1", "axios": "^0.18.0", "babel-runtime": "^6.26.0", "bcryptjs": "^2.4.3", diff --git a/src/components/CalculateBalance.js b/src/components/CalculateBalance.js index d1824e9b..d688c8fc 100644 --- a/src/components/CalculateBalance.js +++ b/src/components/CalculateBalance.js @@ -51,18 +51,15 @@ const mapStateToProps = (state: State, props: OwnProps) => { originalValues.push(value) const fromExchange = exchangeSettingsForAccountSelector(state, { account }) - const cv = - fromExchange && - counterValueExchange && - CounterValues.calculateWithIntermediarySelector(state, { - value, - date, - from: account.currency, - fromExchange, - intermediary: intermediaryCurrency, - toExchange: counterValueExchange, - to: counterValueCurrency, - }) + const cv = CounterValues.calculateWithIntermediarySelector(state, { + value, + date, + from: account.currency, + fromExchange, + intermediary: intermediaryCurrency, + toExchange: counterValueExchange, + to: counterValueCurrency, + }) if (!cv && cv !== 0) { isAvailable = false return 0 diff --git a/src/components/CounterValue/index.js b/src/components/CounterValue/index.js index 615f017b..b7f63900 100644 --- a/src/components/CounterValue/index.js +++ b/src/components/CounterValue/index.js @@ -39,18 +39,15 @@ const mapStateToProps = (state: State, props: OwnProps) => { const counterValueCurrency = counterValueCurrencySelector(state) const fromExchange = currencySettingsSelector(state, { currency }).exchange const toExchange = counterValueExchangeSelector(state) - const counterValue = - fromExchange && - toExchange && - CounterValues.calculateWithIntermediarySelector(state, { - from: currency, - fromExchange, - intermediary: intermediaryCurrency, - toExchange, - to: counterValueCurrency, - value, - date, - }) + const counterValue = CounterValues.calculateWithIntermediarySelector(state, { + from: currency, + fromExchange, + intermediary: intermediaryCurrency, + toExchange, + to: counterValueCurrency, + value, + date, + }) return { counterValueCurrency, diff --git a/src/components/DashboardPage/AccountsOrder.js b/src/components/DashboardPage/AccountsOrder.js index 131d6ef6..a3c7831a 100644 --- a/src/components/DashboardPage/AccountsOrder.js +++ b/src/components/DashboardPage/AccountsOrder.js @@ -82,14 +82,12 @@ const accountsBtcBalanceSelector = createSelector( accounts.map(account => { const { exchange } = currencySettingsForAccountSelector(state, { account }) return ( - (exchange && - CounterValues.calculateSelector(state, { - from: account.currency, - to: intermediaryCurrency, - exchange, - value: account.balance, - })) || - 0 + CounterValues.calculateSelector(state, { + from: account.currency, + to: intermediaryCurrency, + exchange, + value: account.balance, + }) || 0 ) }), ) diff --git a/src/components/RequestAmount/index.js b/src/components/RequestAmount/index.js index a039e93f..2e5de5d4 100644 --- a/src/components/RequestAmount/index.js +++ b/src/components/RequestAmount/index.js @@ -80,8 +80,6 @@ const mapStateToProps = (state: State, props: OwnProps) => { const fromExchange = currencySettingsSelector(state, { currency }).exchange const toExchange = counterValueExchangeSelector(state) const getCounterValue = value => - fromExchange && - toExchange && CounterValues.calculateWithIntermediarySelector(state, { from: currency, fromExchange, @@ -92,8 +90,6 @@ const mapStateToProps = (state: State, props: OwnProps) => { }) const getReverseCounterValue = value => - fromExchange && - toExchange && CounterValues.reverseWithIntermediarySelector(state, { from: currency, fromExchange, diff --git a/src/components/SettingsPage/sections/Currencies.js b/src/components/SettingsPage/sections/Currencies.js index b44a998b..500641db 100644 --- a/src/components/SettingsPage/sections/Currencies.js +++ b/src/components/SettingsPage/sections/Currencies.js @@ -110,19 +110,21 @@ class TabCurrencies extends PureComponent { } /> - - - + {currency !== intermediaryCurrency ? ( + + + + ) : null} {defaults.confirmationsNb ? (