|
|
@ -6,8 +6,6 @@ import CurrencyDisplay from '../currency-display' |
|
|
|
import UserPreferencedCurrencyDisplay from '../user-preferenced-currency-display' |
|
|
|
import UserPreferencedCurrencyDisplay from '../user-preferenced-currency-display' |
|
|
|
import HexToDecimal from '../hex-to-decimal' |
|
|
|
import HexToDecimal from '../hex-to-decimal' |
|
|
|
import { GWEI, PRIMARY, SECONDARY } from '../../constants/common' |
|
|
|
import { GWEI, PRIMARY, SECONDARY } from '../../constants/common' |
|
|
|
import { getHexGasTotal } from '../../helpers/confirm-transaction/util' |
|
|
|
|
|
|
|
import { sumHexes } from '../../helpers/transactions.util' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default class TransactionBreakdown extends PureComponent { |
|
|
|
export default class TransactionBreakdown extends PureComponent { |
|
|
|
static contextTypes = { |
|
|
|
static contextTypes = { |
|
|
@ -19,6 +17,11 @@ export default class TransactionBreakdown extends PureComponent { |
|
|
|
className: PropTypes.string, |
|
|
|
className: PropTypes.string, |
|
|
|
nativeCurrency: PropTypes.string.isRequired, |
|
|
|
nativeCurrency: PropTypes.string.isRequired, |
|
|
|
showFiat: PropTypes.bool, |
|
|
|
showFiat: PropTypes.bool, |
|
|
|
|
|
|
|
gas: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), |
|
|
|
|
|
|
|
gasPrice: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), |
|
|
|
|
|
|
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), |
|
|
|
|
|
|
|
gasUsed: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), |
|
|
|
|
|
|
|
totalInHex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static defaultProps = { |
|
|
|
static defaultProps = { |
|
|
@ -28,13 +31,7 @@ export default class TransactionBreakdown extends PureComponent { |
|
|
|
|
|
|
|
|
|
|
|
render () { |
|
|
|
render () { |
|
|
|
const { t } = this.context |
|
|
|
const { t } = this.context |
|
|
|
const { transaction, className, nativeCurrency, showFiat } = this.props |
|
|
|
const { gas, gasPrice, value, className, nativeCurrency, showFiat, totalInHex, gasUsed } = this.props |
|
|
|
const { txParams: { gas, gasPrice, value } = {}, txReceipt: { gasUsed } = {} } = transaction |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const gasLimit = typeof gasUsed === 'string' ? gasUsed : gas |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const hexGasTotal = getHexGasTotal({ gasLimit, gasPrice }) |
|
|
|
|
|
|
|
const totalInHex = sumHexes(hexGasTotal, value) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div className={classnames('transaction-breakdown', className)}> |
|
|
|
<div className={classnames('transaction-breakdown', className)}> |
|
|
@ -52,10 +49,13 @@ export default class TransactionBreakdown extends PureComponent { |
|
|
|
title={`${t('gasLimit')} (${t('units')})`} |
|
|
|
title={`${t('gasLimit')} (${t('units')})`} |
|
|
|
className="transaction-breakdown__row-title" |
|
|
|
className="transaction-breakdown__row-title" |
|
|
|
> |
|
|
|
> |
|
|
|
<HexToDecimal |
|
|
|
{typeof gas !== 'undefined' |
|
|
|
className="transaction-breakdown__value" |
|
|
|
? <HexToDecimal |
|
|
|
value={gas} |
|
|
|
className="transaction-breakdown__value" |
|
|
|
/> |
|
|
|
value={gas} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
: '?' |
|
|
|
|
|
|
|
} |
|
|
|
</TransactionBreakdownRow> |
|
|
|
</TransactionBreakdownRow> |
|
|
|
{ |
|
|
|
{ |
|
|
|
typeof gasUsed === 'string' && ( |
|
|
|
typeof gasUsed === 'string' && ( |
|
|
@ -71,13 +71,16 @@ export default class TransactionBreakdown extends PureComponent { |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
<TransactionBreakdownRow title={t('gasPrice')}> |
|
|
|
<TransactionBreakdownRow title={t('gasPrice')}> |
|
|
|
<CurrencyDisplay |
|
|
|
{typeof gasPrice !== 'undefined' |
|
|
|
className="transaction-breakdown__value" |
|
|
|
? <CurrencyDisplay |
|
|
|
currency={nativeCurrency} |
|
|
|
className="transaction-breakdown__value" |
|
|
|
denomination={GWEI} |
|
|
|
currency={nativeCurrency} |
|
|
|
value={gasPrice} |
|
|
|
denomination={GWEI} |
|
|
|
hideLabel |
|
|
|
value={gasPrice} |
|
|
|
/> |
|
|
|
hideLabel |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
: '?' |
|
|
|
|
|
|
|
} |
|
|
|
</TransactionBreakdownRow> |
|
|
|
</TransactionBreakdownRow> |
|
|
|
<TransactionBreakdownRow title={t('total')}> |
|
|
|
<TransactionBreakdownRow title={t('total')}> |
|
|
|
<div> |
|
|
|
<div> |
|
|
|