1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Using eth balance component to ensure proper rounding.

This commit is contained in:
Dan 2017-08-28 20:20:40 -02:30
parent af6e30b8ba
commit dc72c4cc91
3 changed files with 56 additions and 32 deletions

View File

@ -37,7 +37,17 @@ EthBalanceComponent.prototype.render = function () {
} }
EthBalanceComponent.prototype.renderBalance = function (value) { EthBalanceComponent.prototype.renderBalance = function (value) {
var props = this.props var props = this.props
const { conversionRate, shorten, incoming, currentCurrency } = props const {
conversionRate,
shorten,
incoming,
currentCurrency,
hideTooltip,
styleOveride,
} = props
const { fontSize, color, fontFamily, lineHeight } = styleOveride
if (value === 'None') return value if (value === 'None') return value
if (value === '...') return value if (value === '...') return value
var balanceObj = generateBalanceObject(value, shorten ? 1 : 3) var balanceObj = generateBalanceObject(value, shorten ? 1 : 3)
@ -54,36 +64,41 @@ EthBalanceComponent.prototype.renderBalance = function (value) {
} }
var label = balanceObj.label var label = balanceObj.label
const tooltipProps = hideTooltip ? {} : {
position: 'bottom',
title: `${ethNumber} ${ethSuffix}`,
};
return ( return (
h(Tooltip, { h(hideTooltip ? 'div' : Tooltip,
position: 'bottom', tooltipProps,
title: `${ethNumber} ${ethSuffix}`, h('div.flex-column', [
}, h('div.flex-column', [ h('.flex-row', {
h('.flex-row', {
style: {
alignItems: 'flex-end',
lineHeight: '13px',
fontFamily: 'Montserrat Light',
textRendering: 'geometricPrecision',
},
}, [
h('div', {
style: { style: {
width: '100%', alignItems: 'flex-end',
textAlign: 'right', lineHeight: lineHeight || '13px',
fontFamily: fontFamily || 'Montserrat Light',
textRendering: 'geometricPrecision',
}, },
}, incoming ? `+${balance}` : balance), }, [
h('div', { h('div', {
style: { style: {
color: ' #AEAEAE', width: '100%',
fontSize: '12px', textAlign: 'right',
marginLeft: '5px', fontSize: fontSize || 'inherit',
}, color: color || 'inherit',
}, label), },
]), }, incoming ? `+${balance}` : balance),
h('div', {
style: {
color: color || '#AEAEAE',
fontSize: fontSize || '12px',
marginLeft: '5px',
},
}, label),
]),
showFiat ? h(FiatValue, { value: props.value, conversionRate, currentCurrency }) : null, showFiat ? h(FiatValue, { value: props.value, conversionRate, currentCurrency }) : null,
])) ]))
) )
} }

View File

@ -12,7 +12,7 @@ function Tooltip () {
Tooltip.prototype.render = function () { Tooltip.prototype.render = function () {
const props = this.props const props = this.props
const { position, title, children } = props const { position, title, children, show = true } = props
return h(ReactTooltip, { return h(ReactTooltip, {
position: position || 'left', position: position || 'left',

View File

@ -58,7 +58,6 @@ function SendTransactionScreen () {
amount: '0.0001', // see L544 amount: '0.0001', // see L544
gasPrice: '0x19', gasPrice: '0x19',
gas: '0x7b0d', gas: '0x7b0d',
gasFee: ((parseInt('0x7b0d', 16) * parseInt('0x19', 16)) / 1000000000).toFixed(6),
txData: null, txData: null,
memo: '', memo: '',
}, },
@ -276,7 +275,19 @@ SendTransactionScreen.prototype.render = function () {
lineHeight: '22.4px' lineHeight: '22.4px'
} }
}) })
: h('div', {}, [`${this.state.newTx.gasFee} ETH`]), : h(EthBalance, {
value: this.getTxFeeBn(this.state.newTx.gas.toString(16), this.state.newTx.gasPrice.toString(16)).toString(16),
currentCurrency,
conversionRate,
showFiat: false,
hideTooltip: true,
styleOveride: {
color: '#5d5d5d',
fontSize: '16px',
fontFamily: 'DIN OT',
lineHeight: '22.4px'
}
}),
h('div.send-screen-gas-input-customize', { h('div.send-screen-gas-input-customize', {
onClick: () => this.toggleTooltip.bind(this)(!this.state.tooltipIsOpen), onClick: () => this.toggleTooltip.bind(this)(!this.state.tooltipIsOpen),
}, [ }, [
@ -294,8 +305,6 @@ SendTransactionScreen.prototype.render = function () {
newTx: Object.assign( newTx: Object.assign(
this.state.newTx, this.state.newTx,
{ {
// TODO: determine how prices are rounded on master
gasFee: ((gasPrice / 1000000000) * gasLimit).toFixed(6),
gas: gasLimit, gas: gasLimit,
gasPrice, gasPrice,
} }