diff options
author | Dan <danjm.com@gmail.com> | 2017-09-20 21:56:20 +0800 |
---|---|---|
committer | Chi Kei Chan <chikeichan@gmail.com> | 2017-09-22 07:43:29 +0800 |
commit | 39afbea7aaf17cfee5d7fc11299cb82e657edd7e (patch) | |
tree | 2050ca79891021802a4a13273dc24a7ce170e5ac /ui | |
parent | 4fa79ffc6eccce1c758f719062d2db6abb65489c (diff) | |
download | tangerine-wallet-browser-39afbea7aaf17cfee5d7fc11299cb82e657edd7e.tar tangerine-wallet-browser-39afbea7aaf17cfee5d7fc11299cb82e657edd7e.tar.gz tangerine-wallet-browser-39afbea7aaf17cfee5d7fc11299cb82e657edd7e.tar.bz2 tangerine-wallet-browser-39afbea7aaf17cfee5d7fc11299cb82e657edd7e.tar.lz tangerine-wallet-browser-39afbea7aaf17cfee5d7fc11299cb82e657edd7e.tar.xz tangerine-wallet-browser-39afbea7aaf17cfee5d7fc11299cb82e657edd7e.tar.zst tangerine-wallet-browser-39afbea7aaf17cfee5d7fc11299cb82e657edd7e.zip |
Confirm screen shows amount plus gas in total field
Diffstat (limited to 'ui')
-rw-r--r-- | ui/app/components/pending-tx.js | 25 | ||||
-rw-r--r-- | ui/app/conversion-util.js | 10 |
2 files changed, 29 insertions, 6 deletions
diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js index 18b622925..a8fac4c28 100644 --- a/ui/app/components/pending-tx.js +++ b/ui/app/components/pending-tx.js @@ -14,7 +14,7 @@ const ethUtil = require('ethereumjs-util') const BN = ethUtil.BN const hexToBn = require('../../../app/scripts/lib/hex-to-bn') const util = require('../util') -const { conversionUtil } = require('../conversion-util') +const { conversionUtil, addCurrencies } = require('../conversion-util') const MIN_GAS_PRICE_GWEI_BN = new BN(1) const GWEI_FACTOR = new BN(1e9) @@ -67,7 +67,7 @@ PendingTx.prototype.componentWillMount = function () { this.props.setCurrentCurrencyToUSD() } -PendingTx.prototype.getTotal = function () { +PendingTx.prototype.getAmount = function () { const { conversionRate } = this.props const txMeta = this.gatherTxMeta() const txParams = txMeta.txParams || {} @@ -186,7 +186,16 @@ PendingTx.prototype.getData = function () { const { name, params = [] } = decodedData || {} const { type, value } = params[0] || {} const { USD: gasFeeInUSD, ETH: gasFeeInETH } = this.getGasFee() - const { USD: totalInUSD, ETH: totalInETH } = this.getTotal() + const { USD: amountInUSD, ETH: amountInETH } = this.getAmount() + + const totalInUSD = addCurrencies(gasFeeInUSD, amountInUSD, { + toNumericBase: 'dec', + numberOfDecimals: 2, + }) + const totalInETH = addCurrencies(gasFeeInETH, amountInETH, { + toNumericBase: 'dec', + numberOfDecimals: 6, + }) if (name === 'transfer' && type === 'address') { return { @@ -201,8 +210,8 @@ PendingTx.prototype.getData = function () { memo: txParams.memo || '', gasFeeInUSD, gasFeeInETH, - totalInUSD, - totalInETH, + amountInUSD, + amountInETH, } } else { return { @@ -217,6 +226,8 @@ PendingTx.prototype.getData = function () { memo: txParams.memo || '', gasFeeInUSD, gasFeeInETH, + amountInUSD, + amountInETH, totalInUSD, totalInETH, } @@ -243,6 +254,8 @@ PendingTx.prototype.render = function () { memo, gasFeeInUSD, gasFeeInETH, + amountInUSD, + amountInETH, totalInUSD, totalInETH, } = this.getData() @@ -307,7 +320,7 @@ PendingTx.prototype.render = function () { `You're sending to Recipient ...${toAddress.slice(toAddress.length - 4)}`, ]), - h('h3.flex-center.confirm-screen-send-amount', [`$${totalInUSD}`]), + h('h3.flex-center.confirm-screen-send-amount', [`$${amountInUSD}`]), h('h3.flex-center.confirm-screen-send-amount-currency', [ 'USD' ]), h('div.flex-center.confirm-memo-wrapper', [ h('h3.confirm-screen-send-memo', [ memo ]), diff --git a/ui/app/conversion-util.js b/ui/app/conversion-util.js index 29e5ce668..0ede77487 100644 --- a/ui/app/conversion-util.js +++ b/ui/app/conversion-util.js @@ -114,6 +114,16 @@ const conversionUtil = (value, { value, }); +const addCurrencies = (a, b, { toNumericBase, numberOfDecimals }) => { + const value = (new BigNumber(a)).add(b); + return converter({ + value, + toNumericBase, + numberOfDecimals, + }) +} + module.exports = { conversionUtil, + addCurrencies, }
\ No newline at end of file |