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

Provide EIP 1559 fields in transaction history (#11464)

This commit is contained in:
David Walsh 2021-07-13 08:42:36 -05:00 committed by GitHub
parent 2edd44e1c5
commit 97d9cdff80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 84 additions and 21 deletions

View File

@ -2451,6 +2451,15 @@
"transactionFee": { "transactionFee": {
"message": "Transaction Fee" "message": "Transaction Fee"
}, },
"transactionHistoryBaseFee": {
"message": "Base fee (GWEI)"
},
"transactionHistoryEffectiveGasPrice": {
"message": "Effective gas price"
},
"transactionHistoryPriorityFee": {
"message": "Priority fee (GWEI)"
},
"transactionResubmitted": { "transactionResubmitted": {
"message": "Transaction resubmitted with gas fee increased to $1 at $2" "message": "Transaction resubmitted with gas fee increased to $1 at $2"
}, },

View File

@ -23,6 +23,9 @@ export default class TransactionBreakdown extends PureComponent {
gasPrice: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), gasPrice: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
gasUsed: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), gasUsed: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
totalInHex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), totalInHex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
baseFee: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
priorityFee: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
effectiveGasPrice: PropTypes.number,
}; };
static defaultProps = { static defaultProps = {
@ -42,6 +45,9 @@ export default class TransactionBreakdown extends PureComponent {
totalInHex, totalInHex,
gasUsed, gasUsed,
isTokenApprove, isTokenApprove,
baseFee,
priorityFee,
effectiveGasPrice,
} = this.props; } = this.props;
return ( return (
<div className={classnames('transaction-breakdown', className)}> <div className={classnames('transaction-breakdown', className)}>
@ -85,35 +91,83 @@ export default class TransactionBreakdown extends PureComponent {
/> />
</TransactionBreakdownRow> </TransactionBreakdownRow>
)} )}
<TransactionBreakdownRow title={t('gasPrice')}> {process.env.SHOW_EIP_1559_UI && (
{typeof gasPrice === 'undefined' ? ( <TransactionBreakdownRow title={t('transactionHistoryBaseFee')}>
'?' {typeof baseFee === 'undefined' ? (
) : ( '?'
<CurrencyDisplay ) : (
<CurrencyDisplay
className="transaction-breakdown__value"
data-testid="transaction-breakdown__base-fee"
currency={nativeCurrency}
denomination={GWEI}
value={baseFee}
hideLabel
/>
)}
</TransactionBreakdownRow>
)}
{process.env.SHOW_EIP_1559_UI && (
<TransactionBreakdownRow title={t('transactionHistoryPriorityFee')}>
{typeof priorityFee === 'undefined' ? (
'?'
) : (
<CurrencyDisplay
className="transaction-breakdown__value"
data-testid="transaction-breakdown__priority-fee"
currency={nativeCurrency}
denomination={GWEI}
value={priorityFee}
hideLabel
/>
)}
</TransactionBreakdownRow>
)}
{!process.env.SHOW_EIP_1559_UI && (
<TransactionBreakdownRow title={t('gasPrice')}>
{typeof gasPrice === 'undefined' ? (
'?'
) : (
<CurrencyDisplay
className="transaction-breakdown__value"
data-testid="transaction-breakdown__gas-price"
currency={nativeCurrency}
denomination={GWEI}
value={gasPrice}
hideLabel
/>
)}
</TransactionBreakdownRow>
)}
<TransactionBreakdownRow
title={t('transactionHistoryEffectiveGasPrice')}
>
<UserPreferencedCurrencyDisplay
className="transaction-breakdown__value transaction-breakdown__value--effective-gas-price"
type={PRIMARY}
value={effectiveGasPrice}
/>
{showFiat && (
<UserPreferencedCurrencyDisplay
className="transaction-breakdown__value" className="transaction-breakdown__value"
data-testid="transaction-breakdown__gas-price" type={SECONDARY}
currency={nativeCurrency} value={effectiveGasPrice}
denomination={GWEI}
value={gasPrice}
hideLabel
/> />
)} )}
</TransactionBreakdownRow> </TransactionBreakdownRow>
<TransactionBreakdownRow title={t('total')}> <TransactionBreakdownRow title={t('total')}>
<div> <UserPreferencedCurrencyDisplay
className="transaction-breakdown__value transaction-breakdown__value--eth-total"
type={PRIMARY}
value={totalInHex}
/>
{showFiat && (
<UserPreferencedCurrencyDisplay <UserPreferencedCurrencyDisplay
className="transaction-breakdown__value transaction-breakdown__value--eth-total" className="transaction-breakdown__value"
type={PRIMARY} type={SECONDARY}
value={totalInHex} value={totalInHex}
/> />
{showFiat && ( )}
<UserPreferencedCurrencyDisplay
className="transaction-breakdown__value"
type={SECONDARY}
value={totalInHex}
/>
)}
</div>
</TransactionBreakdownRow> </TransactionBreakdownRow>
</div> </div>
); );