mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Hide gasTiming on edit-gas-popover when form is in error (#11792)
* Hide gasTiming on edit-gas-popover when form is in error * Show unknown processing error if maxFeePerGas is too low for network conditions * remove unnecessary change * remove unnecessary function wrapper
This commit is contained in:
parent
738d2722c5
commit
9566cd09c0
@ -61,6 +61,7 @@ export default function EditGasDisplay({
|
|||||||
setDappSuggestedGasFeeAcknowledged,
|
setDappSuggestedGasFeeAcknowledged,
|
||||||
warning,
|
warning,
|
||||||
gasErrors,
|
gasErrors,
|
||||||
|
gasWarnings,
|
||||||
onManualChange,
|
onManualChange,
|
||||||
minimumGasLimit,
|
minimumGasLimit,
|
||||||
balanceError,
|
balanceError,
|
||||||
@ -173,10 +174,13 @@ export default function EditGasDisplay({
|
|||||||
])
|
])
|
||||||
}
|
}
|
||||||
timing={
|
timing={
|
||||||
<GasTiming
|
hasGasErrors === false && (
|
||||||
maxFeePerGas={maxFeePerGas}
|
<GasTiming
|
||||||
maxPriorityFeePerGas={maxPriorityFeePerGas}
|
maxFeePerGas={maxFeePerGas}
|
||||||
/>
|
maxPriorityFeePerGas={maxPriorityFeePerGas}
|
||||||
|
gasWarnings={gasWarnings}
|
||||||
|
/>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{requireDappAcknowledgement && (
|
{requireDappAcknowledgement && (
|
||||||
@ -306,6 +310,7 @@ EditGasDisplay.propTypes = {
|
|||||||
warning: PropTypes.string,
|
warning: PropTypes.string,
|
||||||
transaction: PropTypes.object,
|
transaction: PropTypes.object,
|
||||||
gasErrors: PropTypes.object,
|
gasErrors: PropTypes.object,
|
||||||
|
gasWarnings: PropTypes.object,
|
||||||
onManualChange: PropTypes.func,
|
onManualChange: PropTypes.func,
|
||||||
minimumGasLimit: PropTypes.number,
|
minimumGasLimit: PropTypes.number,
|
||||||
balanceError: PropTypes.bool,
|
balanceError: PropTypes.bool,
|
||||||
|
@ -86,6 +86,7 @@ export default function EditGasPopover({
|
|||||||
estimatedMaximumFiat,
|
estimatedMaximumFiat,
|
||||||
hasGasErrors,
|
hasGasErrors,
|
||||||
gasErrors,
|
gasErrors,
|
||||||
|
gasWarnings,
|
||||||
onManualChange,
|
onManualChange,
|
||||||
balanceError,
|
balanceError,
|
||||||
estimatesUnavailableWarning,
|
estimatesUnavailableWarning,
|
||||||
@ -245,6 +246,7 @@ export default function EditGasPopover({
|
|||||||
mode={mode}
|
mode={mode}
|
||||||
transaction={transaction}
|
transaction={transaction}
|
||||||
gasErrors={gasErrors}
|
gasErrors={gasErrors}
|
||||||
|
gasWarnings={gasWarnings}
|
||||||
onManualChange={onManualChange}
|
onManualChange={onManualChange}
|
||||||
minimumGasLimit={minimumGasLimitDec}
|
minimumGasLimit={minimumGasLimitDec}
|
||||||
balanceError={balanceError}
|
balanceError={balanceError}
|
||||||
|
@ -23,6 +23,7 @@ import {
|
|||||||
import InfoTooltip from '../../ui/info-tooltip/info-tooltip';
|
import InfoTooltip from '../../ui/info-tooltip/info-tooltip';
|
||||||
|
|
||||||
import { getGasFeeTimeEstimate } from '../../../store/actions';
|
import { getGasFeeTimeEstimate } from '../../../store/actions';
|
||||||
|
import { GAS_FORM_ERRORS } from '../../../helpers/constants/gas';
|
||||||
|
|
||||||
// Once we reach this second threshold, we switch to minutes as a unit
|
// Once we reach this second threshold, we switch to minutes as a unit
|
||||||
const SECOND_CUTOFF = 90;
|
const SECOND_CUTOFF = 90;
|
||||||
@ -38,12 +39,14 @@ const toHumanReadableTime = (milliseconds = 1, t) => {
|
|||||||
export default function GasTiming({
|
export default function GasTiming({
|
||||||
maxFeePerGas = 0,
|
maxFeePerGas = 0,
|
||||||
maxPriorityFeePerGas = 0,
|
maxPriorityFeePerGas = 0,
|
||||||
|
gasWarnings,
|
||||||
}) {
|
}) {
|
||||||
const gasEstimateType = useSelector(getGasEstimateType);
|
const gasEstimateType = useSelector(getGasEstimateType);
|
||||||
const gasFeeEstimates = useSelector(getGasFeeEstimates);
|
const gasFeeEstimates = useSelector(getGasFeeEstimates);
|
||||||
const isGasEstimatesLoading = useSelector(getIsGasEstimatesLoading);
|
const isGasEstimatesLoading = useSelector(getIsGasEstimatesLoading);
|
||||||
|
|
||||||
const [customEstimatedTime, setCustomEstimatedTime] = useState(null);
|
const [customEstimatedTime, setCustomEstimatedTime] = useState(null);
|
||||||
|
const t = useContext(I18nContext);
|
||||||
|
|
||||||
// If the user has chosen a value lower than the low gas fee estimate,
|
// If the user has chosen a value lower than the low gas fee estimate,
|
||||||
// We'll need to use the useEffect hook below to make a call to calculate
|
// We'll need to use the useEffect hook below to make a call to calculate
|
||||||
@ -89,7 +92,27 @@ export default function GasTiming({
|
|||||||
previousIsUnknownLow,
|
previousIsUnknownLow,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const t = useContext(I18nContext);
|
const unknownProcessingTimeText = (
|
||||||
|
<>
|
||||||
|
{t('editGasTooLow')}{' '}
|
||||||
|
<InfoTooltip position="top" contentText={t('editGasTooLowTooltip')} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (
|
||||||
|
gasWarnings?.maxPriorityFee === GAS_FORM_ERRORS.MAX_PRIORITY_FEE_TOO_LOW ||
|
||||||
|
gasWarnings?.maxFee === GAS_FORM_ERRORS.MAX_FEE_TOO_LOW
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<Typography
|
||||||
|
variant={TYPOGRAPHY.H7}
|
||||||
|
fontWeight={FONT_WEIGHT.BOLD}
|
||||||
|
className={classNames('gas-timing', 'gas-timing--negative')}
|
||||||
|
>
|
||||||
|
{unknownProcessingTimeText}
|
||||||
|
</Typography>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Don't show anything if we don't have enough information
|
// Don't show anything if we don't have enough information
|
||||||
if (
|
if (
|
||||||
@ -137,15 +160,7 @@ export default function GasTiming({
|
|||||||
customEstimatedTime?.upperTimeBound === 'unknown'
|
customEstimatedTime?.upperTimeBound === 'unknown'
|
||||||
) {
|
) {
|
||||||
fontWeight = FONT_WEIGHT.BOLD;
|
fontWeight = FONT_WEIGHT.BOLD;
|
||||||
text = (
|
text = unknownProcessingTimeText;
|
||||||
<>
|
|
||||||
{t('editGasTooLow')}{' '}
|
|
||||||
<InfoTooltip
|
|
||||||
position="top"
|
|
||||||
contentText={t('editGasTooLowTooltip')}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
text = t('gasTimingNegative', [
|
text = t('gasTimingNegative', [
|
||||||
toHumanReadableTime(Number(customEstimatedTime?.upperTimeBound), t),
|
toHumanReadableTime(Number(customEstimatedTime?.upperTimeBound), t),
|
||||||
@ -174,4 +189,5 @@ export default function GasTiming({
|
|||||||
GasTiming.propTypes = {
|
GasTiming.propTypes = {
|
||||||
maxPriorityFeePerGas: PropTypes.string,
|
maxPriorityFeePerGas: PropTypes.string,
|
||||||
maxFeePerGas: PropTypes.string,
|
maxFeePerGas: PropTypes.string,
|
||||||
|
gasWarnings: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
@ -531,6 +531,7 @@ export function useGasFeeInputs(
|
|||||||
estimatedGasFeeTimeBounds,
|
estimatedGasFeeTimeBounds,
|
||||||
gasErrors: errorsAndWarnings,
|
gasErrors: errorsAndWarnings,
|
||||||
hasGasErrors: hasBlockingGasErrors,
|
hasGasErrors: hasBlockingGasErrors,
|
||||||
|
gasWarnings,
|
||||||
onManualChange: () => {
|
onManualChange: () => {
|
||||||
setInternalEstimateToUse('custom');
|
setInternalEstimateToUse('custom');
|
||||||
handleGasLimitOutOfBoundError();
|
handleGasLimitOutOfBoundError();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user