Browse Source

fix countervalue for btc

master
Gaëtan Renaudeau 7 years ago
parent
commit
d51ddbf801
  1. 2
      package.json
  2. 21
      src/components/CalculateBalance.js
  3. 21
      src/components/CounterValue/index.js
  4. 14
      src/components/DashboardPage/AccountsOrder.js
  5. 4
      src/components/RequestAmount/index.js
  6. 28
      src/components/SettingsPage/sections/Currencies.js
  7. 6
      yarn.lock

2
package.json

@ -42,7 +42,7 @@
"@ledgerhq/hw-transport": "^4.12.0", "@ledgerhq/hw-transport": "^4.12.0",
"@ledgerhq/hw-transport-node-hid": "^4.12.0", "@ledgerhq/hw-transport-node-hid": "^4.12.0",
"@ledgerhq/ledger-core": "1.4.5", "@ledgerhq/ledger-core": "1.4.5",
"@ledgerhq/live-common": "2.27.0", "@ledgerhq/live-common": "2.27.1",
"axios": "^0.18.0", "axios": "^0.18.0",
"babel-runtime": "^6.26.0", "babel-runtime": "^6.26.0",
"bcryptjs": "^2.4.3", "bcryptjs": "^2.4.3",

21
src/components/CalculateBalance.js

@ -51,18 +51,15 @@ const mapStateToProps = (state: State, props: OwnProps) => {
originalValues.push(value) originalValues.push(value)
const fromExchange = exchangeSettingsForAccountSelector(state, { account }) const fromExchange = exchangeSettingsForAccountSelector(state, { account })
const cv = const cv = CounterValues.calculateWithIntermediarySelector(state, {
fromExchange && value,
counterValueExchange && date,
CounterValues.calculateWithIntermediarySelector(state, { from: account.currency,
value, fromExchange,
date, intermediary: intermediaryCurrency,
from: account.currency, toExchange: counterValueExchange,
fromExchange, to: counterValueCurrency,
intermediary: intermediaryCurrency, })
toExchange: counterValueExchange,
to: counterValueCurrency,
})
if (!cv && cv !== 0) { if (!cv && cv !== 0) {
isAvailable = false isAvailable = false
return 0 return 0

21
src/components/CounterValue/index.js

@ -39,18 +39,15 @@ const mapStateToProps = (state: State, props: OwnProps) => {
const counterValueCurrency = counterValueCurrencySelector(state) const counterValueCurrency = counterValueCurrencySelector(state)
const fromExchange = currencySettingsSelector(state, { currency }).exchange const fromExchange = currencySettingsSelector(state, { currency }).exchange
const toExchange = counterValueExchangeSelector(state) const toExchange = counterValueExchangeSelector(state)
const counterValue = const counterValue = CounterValues.calculateWithIntermediarySelector(state, {
fromExchange && from: currency,
toExchange && fromExchange,
CounterValues.calculateWithIntermediarySelector(state, { intermediary: intermediaryCurrency,
from: currency, toExchange,
fromExchange, to: counterValueCurrency,
intermediary: intermediaryCurrency, value,
toExchange, date,
to: counterValueCurrency, })
value,
date,
})
return { return {
counterValueCurrency, counterValueCurrency,

14
src/components/DashboardPage/AccountsOrder.js

@ -82,14 +82,12 @@ const accountsBtcBalanceSelector = createSelector(
accounts.map(account => { accounts.map(account => {
const { exchange } = currencySettingsForAccountSelector(state, { account }) const { exchange } = currencySettingsForAccountSelector(state, { account })
return ( return (
(exchange && CounterValues.calculateSelector(state, {
CounterValues.calculateSelector(state, { from: account.currency,
from: account.currency, to: intermediaryCurrency,
to: intermediaryCurrency, exchange,
exchange, value: account.balance,
value: account.balance, }) || 0
})) ||
0
) )
}), }),
) )

4
src/components/RequestAmount/index.js

@ -80,8 +80,6 @@ const mapStateToProps = (state: State, props: OwnProps) => {
const fromExchange = currencySettingsSelector(state, { currency }).exchange const fromExchange = currencySettingsSelector(state, { currency }).exchange
const toExchange = counterValueExchangeSelector(state) const toExchange = counterValueExchangeSelector(state)
const getCounterValue = value => const getCounterValue = value =>
fromExchange &&
toExchange &&
CounterValues.calculateWithIntermediarySelector(state, { CounterValues.calculateWithIntermediarySelector(state, {
from: currency, from: currency,
fromExchange, fromExchange,
@ -92,8 +90,6 @@ const mapStateToProps = (state: State, props: OwnProps) => {
}) })
const getReverseCounterValue = value => const getReverseCounterValue = value =>
fromExchange &&
toExchange &&
CounterValues.reverseWithIntermediarySelector(state, { CounterValues.reverseWithIntermediarySelector(state, {
from: currency, from: currency,
fromExchange, fromExchange,

28
src/components/SettingsPage/sections/Currencies.js

@ -110,19 +110,21 @@ class TabCurrencies extends PureComponent<Props, State> {
} }
/> />
<Body> <Body>
<Row {currency !== intermediaryCurrency ? (
title={`Exchange (${currency.ticker}${intermediaryCurrency.ticker})`} <Row
desc="The exchange to use" title={`Exchange (${currency.ticker}${intermediaryCurrency.ticker})`}
> desc="The exchange to use"
<ExchangeSelect >
small <ExchangeSelect
from={currency} small
to={intermediaryCurrency} from={currency}
exchangeId={exchange} to={intermediaryCurrency}
onChange={this.handleChangeExchange} exchangeId={exchange}
minWidth={200} onChange={this.handleChangeExchange}
/> minWidth={200}
</Row> />
</Row>
) : null}
{defaults.confirmationsNb ? ( {defaults.confirmationsNb ? (
<Row <Row
title={t('settings:currencies.confirmationsNb')} title={t('settings:currencies.confirmationsNb')}

6
yarn.lock

@ -1495,9 +1495,9 @@
npm "^5.7.1" npm "^5.7.1"
prebuild-install "^2.2.2" prebuild-install "^2.2.2"
"@ledgerhq/live-common@2.27.0": "@ledgerhq/live-common@2.27.1":
version "2.27.0" version "2.27.1"
resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-2.27.0.tgz#342478f7b85607a11f20803e2f2862394b6f2bbe" resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-2.27.1.tgz#3ea96eb80b3e2676529c805c76e6b20ce14b95f0"
dependencies: dependencies:
axios "^0.18.0" axios "^0.18.0"
invariant "^2.2.2" invariant "^2.2.2"

Loading…
Cancel
Save