|
|
@ -4,16 +4,11 @@ import { useSelector } from 'react-redux'; |
|
|
|
|
|
|
|
|
|
|
|
import { I18nContext } from '../../../contexts/i18n'; |
|
|
|
import { I18nContext } from '../../../contexts/i18n'; |
|
|
|
import FormField from '../../ui/form-field'; |
|
|
|
import FormField from '../../ui/form-field'; |
|
|
|
import { |
|
|
|
import { GAS_ESTIMATE_TYPES } from '../../../../shared/constants/gas'; |
|
|
|
GAS_ESTIMATE_TYPES, |
|
|
|
|
|
|
|
GAS_RECOMMENDATIONS, |
|
|
|
|
|
|
|
} from '../../../../shared/constants/gas'; |
|
|
|
|
|
|
|
import { getGasFormErrorText } from '../../../helpers/constants/gas'; |
|
|
|
import { getGasFormErrorText } from '../../../helpers/constants/gas'; |
|
|
|
import { checkNetworkAndAccountSupports1559 } from '../../../selectors'; |
|
|
|
import { checkNetworkAndAccountSupports1559 } from '../../../selectors'; |
|
|
|
|
|
|
|
|
|
|
|
export default function AdvancedGasControls({ |
|
|
|
export default function AdvancedGasControls({ |
|
|
|
estimateToUse, |
|
|
|
|
|
|
|
gasFeeEstimates, |
|
|
|
|
|
|
|
gasEstimateType, |
|
|
|
gasEstimateType, |
|
|
|
maxPriorityFee, |
|
|
|
maxPriorityFee, |
|
|
|
maxFee, |
|
|
|
maxFee, |
|
|
@ -34,28 +29,6 @@ export default function AdvancedGasControls({ |
|
|
|
checkNetworkAndAccountSupports1559, |
|
|
|
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 = |
|
|
|
const showFeeMarketFields = |
|
|
|
networkAndAccountSupport1559 && |
|
|
|
networkAndAccountSupport1559 && |
|
|
|
(gasEstimateType === GAS_ESTIMATE_TYPES.FEE_MARKET || |
|
|
|
(gasEstimateType === GAS_ESTIMATE_TYPES.FEE_MARKET || |
|
|
@ -142,23 +115,6 @@ export default function AdvancedGasControls({ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
AdvancedGasControls.propTypes = { |
|
|
|
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)), |
|
|
|
gasEstimateType: PropTypes.oneOf(Object.values(GAS_ESTIMATE_TYPES)), |
|
|
|
setMaxPriorityFee: PropTypes.func, |
|
|
|
setMaxPriorityFee: PropTypes.func, |
|
|
|
setMaxFee: PropTypes.func, |
|
|
|
setMaxFee: PropTypes.func, |
|
|
|