mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
EIP-1559 v2 - small fixes (#13392)
This commit is contained in:
parent
fcd5f89e2f
commit
a0e97f4681
@ -54,7 +54,7 @@ const CancelSpeedupPopover = () => {
|
|||||||
const gasUsedLessThanMedium =
|
const gasUsedLessThanMedium =
|
||||||
gasFeeEstimates &&
|
gasFeeEstimates &&
|
||||||
gasEstimateGreaterThanGasUsedPlusTenPercent(
|
gasEstimateGreaterThanGasUsedPlusTenPercent(
|
||||||
transaction,
|
transaction.txParams,
|
||||||
gasFeeEstimates,
|
gasFeeEstimates,
|
||||||
PRIORITY_LEVELS.MEDIUM,
|
PRIORITY_LEVELS.MEDIUM,
|
||||||
);
|
);
|
||||||
|
@ -125,6 +125,7 @@ const EditGasItem = ({ priorityLevel }) => {
|
|||||||
backgroundColor={
|
backgroundColor={
|
||||||
priorityLevel === estimateUsed ? '#f2f3f4' : '#fff'
|
priorityLevel === estimateUsed ? '#f2f3f4' : '#fff'
|
||||||
}
|
}
|
||||||
|
estimateUsed={priorityLevel}
|
||||||
/>
|
/>
|
||||||
<UserPreferencedCurrencyDisplay
|
<UserPreferencedCurrencyDisplay
|
||||||
key="editGasSubTextFeeAmount"
|
key="editGasSubTextFeeAmount"
|
||||||
|
@ -106,7 +106,7 @@ export const useGasItemFeeDetails = (priorityLevel) => {
|
|||||||
priorityLevel === PRIORITY_LEVELS.HIGH)
|
priorityLevel === PRIORITY_LEVELS.HIGH)
|
||||||
) {
|
) {
|
||||||
const estimateGreater = !gasEstimateGreaterThanGasUsedPlusTenPercent(
|
const estimateGreater = !gasEstimateGreaterThanGasUsedPlusTenPercent(
|
||||||
transaction,
|
transaction.previousGas || transaction.txParams,
|
||||||
gasFeeEstimates,
|
gasFeeEstimates,
|
||||||
priorityLevel,
|
priorityLevel,
|
||||||
);
|
);
|
||||||
|
@ -39,7 +39,7 @@ const GasDetailsItem = ({ userAcknowledgedGasMissing = false }) => {
|
|||||||
detailTitleColor={COLORS.BLACK}
|
detailTitleColor={COLORS.BLACK}
|
||||||
detailText={
|
detailText={
|
||||||
<div className="gas-details-item__currency-container">
|
<div className="gas-details-item__currency-container">
|
||||||
<LoadingHeartBeat />
|
<LoadingHeartBeat estimateUsed={estimateUsed} />
|
||||||
<UserPreferencedCurrencyDisplay
|
<UserPreferencedCurrencyDisplay
|
||||||
type={SECONDARY}
|
type={SECONDARY}
|
||||||
value={hexMinimumTransactionFee}
|
value={hexMinimumTransactionFee}
|
||||||
@ -49,7 +49,7 @@ const GasDetailsItem = ({ userAcknowledgedGasMissing = false }) => {
|
|||||||
}
|
}
|
||||||
detailTotal={
|
detailTotal={
|
||||||
<div className="gas-details-item__currency-container">
|
<div className="gas-details-item__currency-container">
|
||||||
<LoadingHeartBeat />
|
<LoadingHeartBeat estimateUsed={estimateUsed} />
|
||||||
<UserPreferencedCurrencyDisplay
|
<UserPreferencedCurrencyDisplay
|
||||||
type={PRIMARY}
|
type={PRIMARY}
|
||||||
value={hexMinimumTransactionFee}
|
value={hexMinimumTransactionFee}
|
||||||
@ -66,7 +66,7 @@ const GasDetailsItem = ({ userAcknowledgedGasMissing = false }) => {
|
|||||||
'gas-details-item__gas-fee-warning': estimateUsed === 'high',
|
'gas-details-item__gas-fee-warning': estimateUsed === 'high',
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<LoadingHeartBeat />
|
<LoadingHeartBeat estimateUsed={estimateUsed} />
|
||||||
<Box marginRight={1}>
|
<Box marginRight={1}>
|
||||||
<strong>
|
<strong>
|
||||||
{estimateUsed === 'high' && '⚠ '}
|
{estimateUsed === 'high' && '⚠ '}
|
||||||
@ -77,7 +77,7 @@ const GasDetailsItem = ({ userAcknowledgedGasMissing = false }) => {
|
|||||||
key="editGasSubTextFeeValue"
|
key="editGasSubTextFeeValue"
|
||||||
className="gas-details-item__currency-container"
|
className="gas-details-item__currency-container"
|
||||||
>
|
>
|
||||||
<LoadingHeartBeat />
|
<LoadingHeartBeat estimateUsed={estimateUsed} />
|
||||||
<UserPreferencedCurrencyDisplay
|
<UserPreferencedCurrencyDisplay
|
||||||
key="editGasSubTextFeeAmount"
|
key="editGasSubTextFeeAmount"
|
||||||
type={PRIMARY}
|
type={PRIMARY}
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
&__message {
|
&__message {
|
||||||
color: var(--Blue-600);
|
color: var(--Blue-600);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__actions {
|
&__actions {
|
||||||
|
@ -3,17 +3,24 @@ import classNames from 'classnames';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
import { isVolatileGasEstimate } from '../../../helpers/utils/gas';
|
||||||
import { getGasLoadingAnimationIsShowing } from '../../../ducks/app/app';
|
import { getGasLoadingAnimationIsShowing } from '../../../ducks/app/app';
|
||||||
import { useShouldAnimateGasEstimations } from '../../../hooks/useShouldAnimateGasEstimations';
|
import { useShouldAnimateGasEstimations } from '../../../hooks/useShouldAnimateGasEstimations';
|
||||||
|
|
||||||
const BASE_CLASS = 'loading-heartbeat';
|
const BASE_CLASS = 'loading-heartbeat';
|
||||||
const LOADING_CLASS = `${BASE_CLASS}--active`;
|
const LOADING_CLASS = `${BASE_CLASS}--active`;
|
||||||
|
|
||||||
export default function LoadingHeartBeat({ backgroundColor = '#fff' }) {
|
export default function LoadingHeartBeat({
|
||||||
|
estimateUsed,
|
||||||
|
backgroundColor = '#fff',
|
||||||
|
}) {
|
||||||
useShouldAnimateGasEstimations();
|
useShouldAnimateGasEstimations();
|
||||||
const active = useSelector(getGasLoadingAnimationIsShowing);
|
const active = useSelector(getGasLoadingAnimationIsShowing);
|
||||||
|
|
||||||
if (process.env.IN_TEST) {
|
if (
|
||||||
|
process.env.IN_TEST ||
|
||||||
|
(estimateUsed && !isVolatileGasEstimate(estimateUsed))
|
||||||
|
) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,4 +40,5 @@ export default function LoadingHeartBeat({ backgroundColor = '#fff' }) {
|
|||||||
|
|
||||||
LoadingHeartBeat.propTypes = {
|
LoadingHeartBeat.propTypes = {
|
||||||
backgroundColor: PropTypes.string,
|
backgroundColor: PropTypes.string,
|
||||||
|
estimateUsed: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
import { addHexPrefix } from 'ethereumjs-util';
|
import { addHexPrefix } from 'ethereumjs-util';
|
||||||
|
|
||||||
|
import { GAS_RECOMMENDATIONS } from '../../../shared/constants/gas';
|
||||||
import { multiplyCurrencies } from '../../../shared/modules/conversion.utils';
|
import { multiplyCurrencies } from '../../../shared/modules/conversion.utils';
|
||||||
import { bnGreaterThan } from './util';
|
import { bnGreaterThan } from './util';
|
||||||
import { hexWEIToDecGWEI } from './conversions.util';
|
import { hexWEIToDecGWEI } from './conversions.util';
|
||||||
|
|
||||||
export const gasEstimateGreaterThanGasUsedPlusTenPercent = (
|
export const gasEstimateGreaterThanGasUsedPlusTenPercent = (
|
||||||
transaction,
|
gasUsed,
|
||||||
gasFeeEstimates,
|
gasFeeEstimates,
|
||||||
estimate,
|
estimate,
|
||||||
) => {
|
) => {
|
||||||
let { maxFeePerGas: maxFeePerGasInTransaction } = transaction.txParams;
|
let { maxFeePerGas: maxFeePerGasInTransaction } = gasUsed;
|
||||||
maxFeePerGasInTransaction = new BigNumber(
|
maxFeePerGasInTransaction = new BigNumber(
|
||||||
hexWEIToDecGWEI(addTenPercentAndRound(maxFeePerGasInTransaction)),
|
hexWEIToDecGWEI(addTenPercentAndRound(maxFeePerGasInTransaction)),
|
||||||
);
|
);
|
||||||
@ -53,3 +54,11 @@ export function addTenPercent(hexStringValue, conversionOptions = {}) {
|
|||||||
export function addTenPercentAndRound(hexStringValue) {
|
export function addTenPercentAndRound(hexStringValue) {
|
||||||
return addTenPercent(hexStringValue, { numberOfDecimals: 0 });
|
return addTenPercent(hexStringValue, { numberOfDecimals: 0 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isVolatileGasEstimate(estimate) {
|
||||||
|
return [
|
||||||
|
GAS_RECOMMENDATIONS.HIGH,
|
||||||
|
GAS_RECOMMENDATIONS.MEDIUM,
|
||||||
|
GAS_RECOMMENDATIONS.LOW,
|
||||||
|
].includes(estimate);
|
||||||
|
}
|
||||||
|
@ -10,10 +10,8 @@ describe('Gas utils', () => {
|
|||||||
const compareGas = (estimateValues) => {
|
const compareGas = (estimateValues) => {
|
||||||
return gasEstimateGreaterThanGasUsedPlusTenPercent(
|
return gasEstimateGreaterThanGasUsedPlusTenPercent(
|
||||||
{
|
{
|
||||||
txParams: {
|
maxFeePerGas: '0x59682f10',
|
||||||
maxFeePerGas: '0x59682f10',
|
maxPriorityFeePerGas: '0x59682f00',
|
||||||
maxPriorityFeePerGas: '0x59682f00',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
medium: estimateValues,
|
medium: estimateValues,
|
||||||
|
@ -365,7 +365,7 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
<div className="confirm-page-container-content__total-value">
|
<div className="confirm-page-container-content__total-value">
|
||||||
<LoadingHeartBeat />
|
<LoadingHeartBeat estimateUsed={this.props.txData?.userFeeLevel} />
|
||||||
<UserPreferencedCurrencyDisplay
|
<UserPreferencedCurrencyDisplay
|
||||||
type={PRIMARY}
|
type={PRIMARY}
|
||||||
key="total-detail-value"
|
key="total-detail-value"
|
||||||
@ -387,7 +387,7 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
<div className="confirm-page-container-content__total-value">
|
<div className="confirm-page-container-content__total-value">
|
||||||
<LoadingHeartBeat />
|
<LoadingHeartBeat estimateUsed={this.props.txData?.userFeeLevel} />
|
||||||
<UserPreferencedCurrencyDisplay
|
<UserPreferencedCurrencyDisplay
|
||||||
type={SECONDARY}
|
type={SECONDARY}
|
||||||
key="total-detail-text"
|
key="total-detail-text"
|
||||||
@ -608,7 +608,9 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
subTitle={t('transactionDetailGasTotalSubtitle')}
|
subTitle={t('transactionDetailGasTotalSubtitle')}
|
||||||
subText={
|
subText={
|
||||||
<div className="confirm-page-container-content__total-amount">
|
<div className="confirm-page-container-content__total-amount">
|
||||||
<LoadingHeartBeat />
|
<LoadingHeartBeat
|
||||||
|
estimateUsed={this.props.txData?.userFeeLevel}
|
||||||
|
/>
|
||||||
<strong key="editGasSubTextAmountLabel">
|
<strong key="editGasSubTextAmountLabel">
|
||||||
{t('editGasSubTextAmountLabel')}
|
{t('editGasSubTextAmountLabel')}
|
||||||
</strong>{' '}
|
</strong>{' '}
|
||||||
|
Loading…
Reference in New Issue
Block a user