diff options
author | Chi Kei Chan <chikeichan@gmail.com> | 2017-10-21 09:26:18 +0800 |
---|---|---|
committer | Chi Kei Chan <chikeichan@gmail.com> | 2017-10-21 09:26:18 +0800 |
commit | 8f3b762461ada222f82089e686a61183dd167428 (patch) | |
tree | 1efbdbc2f91c7b7468dda469de53e0cccf8e9ac4 /ui/app | |
parent | 5eb3cf43bfab3728dde151bc84439993b1a93184 (diff) | |
download | tangerine-wallet-browser-8f3b762461ada222f82089e686a61183dd167428.tar tangerine-wallet-browser-8f3b762461ada222f82089e686a61183dd167428.tar.gz tangerine-wallet-browser-8f3b762461ada222f82089e686a61183dd167428.tar.bz2 tangerine-wallet-browser-8f3b762461ada222f82089e686a61183dd167428.tar.lz tangerine-wallet-browser-8f3b762461ada222f82089e686a61183dd167428.tar.xz tangerine-wallet-browser-8f3b762461ada222f82089e686a61183dd167428.tar.zst tangerine-wallet-browser-8f3b762461ada222f82089e686a61183dd167428.zip |
Fix Conversions bugs; Fiat value bugs
Diffstat (limited to 'ui/app')
-rw-r--r-- | ui/app/components/pending-tx/confirm-deploy-contract.js | 4 | ||||
-rw-r--r-- | ui/app/components/pending-tx/confirm-send-ether.js | 2 | ||||
-rw-r--r-- | ui/app/components/send/currency-display.js | 12 | ||||
-rw-r--r-- | ui/app/components/token-cell.js | 8 | ||||
-rw-r--r-- | ui/app/send-v2.js | 7 |
5 files changed, 24 insertions, 9 deletions
diff --git a/ui/app/components/pending-tx/confirm-deploy-contract.js b/ui/app/components/pending-tx/confirm-deploy-contract.js index d19cec755..a0ba94045 100644 --- a/ui/app/components/pending-tx/confirm-deploy-contract.js +++ b/ui/app/components/pending-tx/confirm-deploy-contract.js @@ -195,14 +195,16 @@ ConfirmDeployContract.prototype.getGasFee = function () { eth: Number(ETH), } } + ConfirmDeployContract.prototype.renderGasFee = function () { + const { currentCurrency } = this.props const { fiat: fiatGas, eth: ethGas } = this.getGasFee() return ( h('section.flex-row.flex-center.confirm-screen-row', [ h('span.confirm-screen-label.confirm-screen-section-column', [ 'Gas Fee' ]), h('div.confirm-screen-section-column', [ - h('div.confirm-screen-row-info', `${fiatGas} FIAT`), + h('div.confirm-screen-row-info', `${fiatGas} ${currentCurrency.toUpperCase()}`), h( 'div.confirm-screen-row-detail', diff --git a/ui/app/components/pending-tx/confirm-send-ether.js b/ui/app/components/pending-tx/confirm-send-ether.js index 51c36ba42..7162c7122 100644 --- a/ui/app/components/pending-tx/confirm-send-ether.js +++ b/ui/app/components/pending-tx/confirm-send-ether.js @@ -241,7 +241,7 @@ ConfirmSendEther.prototype.render = function () { // `You're sending to Recipient ...${toAddress.slice(toAddress.length - 4)}`, // ]), - h('h3.flex-center.confirm-screen-send-amount', [`$${amountInFIAT}`]), + h('h3.flex-center.confirm-screen-send-amount', [`${amountInFIAT}`]), h('h3.flex-center.confirm-screen-send-amount-currency', [ currentCurrency.toUpperCase() ]), h('div.flex-center.confirm-memo-wrapper', [ h('h3.confirm-screen-send-memo', [ memo ? `"${memo}"` : '' ]), diff --git a/ui/app/components/send/currency-display.js b/ui/app/components/send/currency-display.js index 2c9a2d33b..7180b94d3 100644 --- a/ui/app/components/send/currency-display.js +++ b/ui/app/components/send/currency-display.js @@ -36,6 +36,16 @@ function toHexWei (value) { }) } +CurrencyDisplay.prototype.getAmount = function (value) { + const { selectedToken } = this.props + const { decimals } = selectedToken || {} + const multiplier = Math.pow(10, Number(decimals || 0)) + const sendAmount = '0x' + Number(value * multiplier).toString(16) + return selectedToken + ? sendAmount + : toHexWei(value) +} + CurrencyDisplay.prototype.render = function () { const { className = 'currency-display', @@ -102,7 +112,7 @@ CurrencyDisplay.prototype.render = function () { this.setState({ value: newValue }) } }, - onBlur: event => !readOnly && handleChange(toHexWei(event.target.value.split(' ')[0])), + onBlur: event => !readOnly && handleChange(this.getAmount(event.target.value.split(' ')[0])), onKeyUp: event => { if (!readOnly) { validate(toHexWei(value || initValueToRender)) diff --git a/ui/app/components/token-cell.js b/ui/app/components/token-cell.js index ad431df69..6bb42204e 100644 --- a/ui/app/components/token-cell.js +++ b/ui/app/components/token-cell.js @@ -13,6 +13,7 @@ const TokenMenuDropdown = require('./dropdowns/token-menu-dropdown.js') function mapStateToProps (state) { return { network: state.metamask.network, + currentCurrency: state.metamask.currentCurrency, selectedTokenAddress: state.metamask.selectedTokenAddress, userAddress: selectors.getSelectedAddress(state), tokenExchangeRates: state.metamask.tokenExchangeRates, @@ -63,18 +64,19 @@ TokenCell.prototype.render = function () { ethToUSDRate, hideSidebar, sidebarOpen, + currentCurrency, // userAddress, } = props const pair = `${symbol.toLowerCase()}_eth`; let currentTokenToEthRate; - let currentTokenInUSD; + let currentTokenInFiat; let formattedUSD = '' if (tokenExchangeRates[pair]) { currentTokenToEthRate = tokenExchangeRates[pair].rate; - currentTokenInUSD = conversionUtil(string, { + currentTokenInFiat = conversionUtil(string, { fromNumericBase: 'dec', fromCurrency: symbol, toCurrency: 'USD', @@ -82,7 +84,7 @@ TokenCell.prototype.render = function () { conversionRate: currentTokenToEthRate, ethToUSDRate, }) - formattedUSD = `$${currentTokenInUSD} USD`; + formattedUSD = `${currentTokenInFiat} ${currentCurrency.toUpperCase()}`; } return ( diff --git a/ui/app/send-v2.js b/ui/app/send-v2.js index effa68b4b..5e64daceb 100644 --- a/ui/app/send-v2.js +++ b/ui/app/send-v2.js @@ -296,6 +296,7 @@ SendTransactionScreen.prototype.renderAmountRow = function () { inError: Boolean(errors.amount), primaryCurrency, convertedCurrency, + selectedToken, value: amount, conversionRate: amountConversionRate, handleChange: this.handleAmountChange, @@ -326,14 +327,14 @@ SendTransactionScreen.prototype.renderGasRow = function () { convertedCurrency, onClick: showCustomizeGasModal, }), - + h('div.send-v2__sliders-icon-container', { onClick: showCustomizeGasModal, }, [ h('i.fa.fa-sliders.send-v2__sliders-icon'), ]), - ]), + ]), ]) } @@ -350,7 +351,7 @@ SendTransactionScreen.prototype.renderMemoRow = function () { h(MemoTextArea, { memo, onChange: (event) => updateSendMemo(event.target.value), - }) + }), ]), ]) |