|
|
|
@ -4,16 +4,11 @@ import { useSelector } from 'react-redux'; |
|
|
|
|
|
|
|
|
|
import { I18nContext } from '../../../contexts/i18n'; |
|
|
|
|
import FormField from '../../ui/form-field'; |
|
|
|
|
import { |
|
|
|
|
GAS_ESTIMATE_TYPES, |
|
|
|
|
GAS_RECOMMENDATIONS, |
|
|
|
|
} from '../../../../shared/constants/gas'; |
|
|
|
|
import { GAS_ESTIMATE_TYPES } from '../../../../shared/constants/gas'; |
|
|
|
|
import { getGasFormErrorText } from '../../../helpers/constants/gas'; |
|
|
|
|
import { checkNetworkAndAccountSupports1559 } from '../../../selectors'; |
|
|
|
|
|
|
|
|
|
export default function AdvancedGasControls({ |
|
|
|
|
estimateToUse, |
|
|
|
|
gasFeeEstimates, |
|
|
|
|
gasEstimateType, |
|
|
|
|
maxPriorityFee, |
|
|
|
|
maxFee, |
|
|
|
@ -34,28 +29,6 @@ export default function AdvancedGasControls({ |
|
|
|
|
checkNetworkAndAccountSupports1559, |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
const suggestedValues = {}; |
|
|
|
|
|
|
|
|
|
if (networkAndAccountSupport1559) { |
|
|
|
|
suggestedValues.maxFeePerGas = |
|
|
|
|
gasFeeEstimates?.[estimateToUse]?.suggestedMaxFeePerGas || |
|
|
|
|
gasFeeEstimates?.gasPrice; |
|
|
|
|
suggestedValues.maxPriorityFeePerGas = |
|
|
|
|
gasFeeEstimates?.[estimateToUse]?.suggestedMaxPriorityFeePerGas || |
|
|
|
|
suggestedValues.maxFeePerGas; |
|
|
|
|
} else { |
|
|
|
|
switch (gasEstimateType) { |
|
|
|
|
case GAS_ESTIMATE_TYPES.LEGACY: |
|
|
|
|
suggestedValues.gasPrice = gasFeeEstimates?.[estimateToUse]; |
|
|
|
|
break; |
|
|
|
|
case GAS_ESTIMATE_TYPES.ETH_GASPRICE: |
|
|
|
|
suggestedValues.gasPrice = gasFeeEstimates?.gasPrice; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const showFeeMarketFields = |
|
|
|
|
networkAndAccountSupport1559 && |
|
|
|
|
(gasEstimateType === GAS_ESTIMATE_TYPES.FEE_MARKET || |
|
|
|
@ -142,23 +115,6 @@ export default function AdvancedGasControls({ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
AdvancedGasControls.propTypes = { |
|
|
|
|
estimateToUse: PropTypes.oneOf(Object.values(GAS_RECOMMENDATIONS)), |
|
|
|
|
gasFeeEstimates: PropTypes.oneOf([ |
|
|
|
|
PropTypes.shape({ |
|
|
|
|
gasPrice: PropTypes.string, |
|
|
|
|
}), |
|
|
|
|
PropTypes.shape({ |
|
|
|
|
low: PropTypes.string, |
|
|
|
|
medium: PropTypes.string, |
|
|
|
|
high: PropTypes.string, |
|
|
|
|
}), |
|
|
|
|
PropTypes.shape({ |
|
|
|
|
low: PropTypes.object, |
|
|
|
|
medium: PropTypes.object, |
|
|
|
|
high: PropTypes.object, |
|
|
|
|
estimatedBaseFee: PropTypes.string, |
|
|
|
|
}), |
|
|
|
|
]), |
|
|
|
|
gasEstimateType: PropTypes.oneOf(Object.values(GAS_ESTIMATE_TYPES)), |
|
|
|
|
setMaxPriorityFee: PropTypes.func, |
|
|
|
|
setMaxFee: PropTypes.func, |
|
|
|
|