1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00

EIP-1559 - Maintain changed form values and unselect radio buttons when user customizes form value (#11577)

This commit is contained in:
David Walsh 2021-07-22 11:32:59 -05:00 committed by GitHub
parent b259546db8
commit 286fd397f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 3 deletions

View File

@ -81,8 +81,8 @@ export default function AdvancedGasControls({
titleUnit="(GWEI)"
tooltipText={t('editGasMaxPriorityFeeTooltip')}
onChange={(value) => {
setMaxPriorityFee(value);
onManualChange?.();
setMaxPriorityFee(value);
}}
value={maxPriorityFee}
detailText={maxPriorityFeeFiat}
@ -122,8 +122,8 @@ export default function AdvancedGasControls({
titleUnit="(GWEI)"
tooltipText={t('editGasMaxFeeTooltip')}
onChange={(value) => {
setMaxFee(value);
onManualChange?.();
setMaxFee(value);
}}
value={maxFee}
numeric
@ -165,8 +165,8 @@ export default function AdvancedGasControls({
titleText={t('advancedGasPriceTitle')}
titleUnit="(GWEI)"
onChange={(value) => {
setGasPrice(value);
onManualChange?.();
setGasPrice(value);
}}
tooltipText={t('editGasPriceTooltip')}
value={gasPrice}

View File

@ -55,6 +55,7 @@ export default function EditGasDisplay({
setShowAdvancedForm,
warning,
gasErrors,
onManualChange,
}) {
const t = useContext(I18nContext);
@ -199,6 +200,7 @@ export default function EditGasDisplay({
maxPriorityFeeFiat={maxPriorityFeePerGasFiat}
maxFeeFiat={maxFeePerGasFiat}
gasErrors={gasErrors}
onManualChange={onManualChange}
/>
)}
</div>
@ -245,4 +247,5 @@ EditGasDisplay.propTypes = {
warning: PropTypes.string,
transaction: PropTypes.object,
gasErrors: PropTypes.object,
onManualChange: PropTypes.func,
};

View File

@ -74,6 +74,7 @@ export default function EditGasPopover({
estimatedMaximumFiat,
hasGasErrors,
gasErrors,
onManualChange,
} = useGasFeeInputs(defaultEstimateToUse);
/**
@ -216,6 +217,7 @@ export default function EditGasPopover({
mode={mode}
transaction={transaction}
gasErrors={gasErrors}
onManualChange={onManualChange}
{...editGasDisplayProps}
/>
)}

View File

@ -354,5 +354,13 @@ export function useGasFeeInputs(defaultEstimateToUse = 'medium') {
estimatedGasFeeTimeBounds,
gasErrors: errorsAndWarnings,
hasGasErrors: hasBlockingGasErrors,
onManualChange: () => {
setEstimateToUse(null);
// Restore existing values
setGasPrice(gasPriceToUse);
setGasLimit(gasLimit);
setMaxFeePerGas(maxFeePerGasToUse);
setMaxPriorityFeePerGas(maxPriorityFeePerGasToUse);
},
};
}