aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/token-cell.js
diff options
context:
space:
mode:
authorDan J Miller <danjm.com@gmail.com>2017-10-27 13:55:34 +0800
committerDaniel Tsui <szehungdanieltsui@gmail.com>2017-10-27 13:55:34 +0800
commit3d53716f4366212ed7a51b49ce747584b13fd1ce (patch)
tree25b5449b236ba7502dd0d481e27e65c40a7cafe8 /ui/app/components/token-cell.js
parent0ed1add110ec630ed358aa44af030623bab1ad92 (diff)
downloadtangerine-wallet-browser-3d53716f4366212ed7a51b49ce747584b13fd1ce.tar
tangerine-wallet-browser-3d53716f4366212ed7a51b49ce747584b13fd1ce.tar.gz
tangerine-wallet-browser-3d53716f4366212ed7a51b49ce747584b13fd1ce.tar.bz2
tangerine-wallet-browser-3d53716f4366212ed7a51b49ce747584b13fd1ce.tar.lz
tangerine-wallet-browser-3d53716f4366212ed7a51b49ce747584b13fd1ce.tar.xz
tangerine-wallet-browser-3d53716f4366212ed7a51b49ce747584b13fd1ce.tar.zst
tangerine-wallet-browser-3d53716f4366212ed7a51b49ce747584b13fd1ce.zip
Correct rendering of conversions when conversion rate is a token. (#2498)
Diffstat (limited to 'ui/app/components/token-cell.js')
-rw-r--r--ui/app/components/token-cell.js28
1 files changed, 16 insertions, 12 deletions
diff --git a/ui/app/components/token-cell.js b/ui/app/components/token-cell.js
index 6bb42204e..f55e23f9e 100644
--- a/ui/app/components/token-cell.js
+++ b/ui/app/components/token-cell.js
@@ -6,7 +6,7 @@ const Identicon = require('./identicon')
const prefixForNetwork = require('../../lib/etherscan-prefix-for-network')
const selectors = require('../selectors')
const actions = require('../actions')
-const { conversionUtil } = require('../conversion-util')
+const { conversionUtil, multiplyCurrencies } = require('../conversion-util')
const TokenMenuDropdown = require('./dropdowns/token-menu-dropdown.js')
@@ -17,7 +17,7 @@ function mapStateToProps (state) {
selectedTokenAddress: state.metamask.selectedTokenAddress,
userAddress: selectors.getSelectedAddress(state),
tokenExchangeRates: state.metamask.tokenExchangeRates,
- ethToUSDRate: state.metamask.conversionRate,
+ conversionRate: state.metamask.conversionRate,
sidebarOpen: state.appState.sidebarOpen,
}
}
@@ -61,7 +61,7 @@ TokenCell.prototype.render = function () {
setSelectedToken,
selectedTokenAddress,
tokenExchangeRates,
- ethToUSDRate,
+ conversionRate,
hideSidebar,
sidebarOpen,
currentCurrency,
@@ -70,22 +70,26 @@ TokenCell.prototype.render = function () {
const pair = `${symbol.toLowerCase()}_eth`;
- let currentTokenToEthRate;
+ let currentTokenToFiatRate;
let currentTokenInFiat;
- let formattedUSD = ''
+ let formattedFiat = ''
if (tokenExchangeRates[pair]) {
- currentTokenToEthRate = tokenExchangeRates[pair].rate;
+ currentTokenToFiatRate = multiplyCurrencies(
+ tokenExchangeRates[pair].rate,
+ conversionRate
+ )
currentTokenInFiat = conversionUtil(string, {
fromNumericBase: 'dec',
fromCurrency: symbol,
- toCurrency: 'USD',
+ toCurrency: currentCurrency.toUpperCase(),
numberOfDecimals: 2,
- conversionRate: currentTokenToEthRate,
- ethToUSDRate,
+ conversionRate: currentTokenToFiatRate,
})
- formattedUSD = `${currentTokenInFiat} ${currentCurrency.toUpperCase()}`;
+ formattedFiat = `${currentTokenInFiat} ${currentCurrency.toUpperCase()}`;
}
+
+ const showFiat = Boolean(currentTokenInFiat) && currentCurrency.toUpperCase() !== symbol
return (
h('div.token-list-item', {
@@ -108,9 +112,9 @@ TokenCell.prototype.render = function () {
h('h.token-list-item__balance-wrapper', null, [
h('h3.token-list-item__token-balance', `${string || 0} ${symbol}`),
- h('div.token-list-item__fiat-amount', {
+ showFiat && h('div.token-list-item__fiat-amount', {
style: {},
- }, formattedUSD),
+ }, formattedFiat),
]),
h('i.fa.fa-ellipsis-h.fa-lg.token-list-item__ellipsis.cursor-pointer', {