@ -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 }
< / T y p o g r a p h y >
) ;
}
// 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 ,
} ;
} ;