mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix Conversions bugs; Fiat value bugs
This commit is contained in:
parent
5eb3cf43bf
commit
8f3b762461
@ -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',
|
||||
|
@ -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}"` : '' ]),
|
||||
|
@ -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))
|
||||
|
@ -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 (
|
||||
|
@ -296,6 +296,7 @@ SendTransactionScreen.prototype.renderAmountRow = function () {
|
||||
inError: Boolean(errors.amount),
|
||||
primaryCurrency,
|
||||
convertedCurrency,
|
||||
selectedToken,
|
||||
value: amount,
|
||||
conversionRate: amountConversionRate,
|
||||
handleChange: this.handleAmountChange,
|
||||
@ -350,7 +351,7 @@ SendTransactionScreen.prototype.renderMemoRow = function () {
|
||||
h(MemoTextArea, {
|
||||
memo,
|
||||
onChange: (event) => updateSendMemo(event.target.value),
|
||||
})
|
||||
}),
|
||||
]),
|
||||
|
||||
])
|
||||
|
Loading…
Reference in New Issue
Block a user