diff options
author | Alexander Tseung <alextsg@gmail.com> | 2018-07-15 04:47:07 +0800 |
---|---|---|
committer | Alexander Tseung <alextsg@gmail.com> | 2018-07-18 04:38:14 +0800 |
commit | d19c42fcaeea933793ed459ab5248b42811a0498 (patch) | |
tree | 345394ef9704fa0afd0d713e4d9ef052bcc943fc /ui/app/helpers/confirm-transaction/util.js | |
parent | e9a8c24cc4d26e33380a33e87e80952918339ad7 (diff) | |
download | tangerine-wallet-browser-d19c42fcaeea933793ed459ab5248b42811a0498.tar tangerine-wallet-browser-d19c42fcaeea933793ed459ab5248b42811a0498.tar.gz tangerine-wallet-browser-d19c42fcaeea933793ed459ab5248b42811a0498.tar.bz2 tangerine-wallet-browser-d19c42fcaeea933793ed459ab5248b42811a0498.tar.lz tangerine-wallet-browser-d19c42fcaeea933793ed459ab5248b42811a0498.tar.xz tangerine-wallet-browser-d19c42fcaeea933793ed459ab5248b42811a0498.tar.zst tangerine-wallet-browser-d19c42fcaeea933793ed459ab5248b42811a0498.zip |
Add fallback when no function found, fix network colors, add fiat values for tokens with contract exchange rates
Diffstat (limited to 'ui/app/helpers/confirm-transaction/util.js')
-rw-r--r-- | ui/app/helpers/confirm-transaction/util.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/ui/app/helpers/confirm-transaction/util.js b/ui/app/helpers/confirm-transaction/util.js index ad247a348..1373d28df 100644 --- a/ui/app/helpers/confirm-transaction/util.js +++ b/ui/app/helpers/confirm-transaction/util.js @@ -114,3 +114,20 @@ export function formatCurrency (value, currencyCode) { ? currencyFormatter.format(Number(value), { code: upperCaseCurrencyCode }) : value } + +export function convertTokenToFiat ({ + value, + toCurrency, + conversionRate, + contractExchangeRate, +}) { + const totalExchangeRate = conversionRate * contractExchangeRate + + return conversionUtil(value, { + fromNumericBase: 'dec', + toNumericBase: 'dec', + toCurrency, + numberOfDecimals: 2, + conversionRate: totalExchangeRate, + }) +} |