mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-10-22 11:22:43 +02:00
Fix setting of gasPrice when on non-eip 1559 networks (#15628)
* Fix setting of gasPrice when on non-eip 1559 networks * Fix unit tests * Fix logic * Update ui/ducks/send/send.test.js Co-authored-by: Mark Stacey <markjstacey@gmail.com> Co-authored-by: Mark Stacey <markjstacey@gmail.com>
This commit is contained in:
parent
34eeea26f3
commit
ce35a204b2
@ -381,6 +381,7 @@ export const draftTransactionInitialState = {
|
||||
gasTotal: '0x0',
|
||||
maxFeePerGas: '0x0',
|
||||
maxPriorityFeePerGas: '0x0',
|
||||
wasManuallyEdited: false,
|
||||
},
|
||||
history: [],
|
||||
id: null,
|
||||
@ -1057,19 +1058,15 @@ const slice = createSlice({
|
||||
draftTransaction.transactionType =
|
||||
TRANSACTION_ENVELOPE_TYPES.FEE_MARKET;
|
||||
} else {
|
||||
// Until we remove the old UI we don't want to automatically update
|
||||
// gasPrice if the user has already manually changed the field value.
|
||||
// When receiving a new estimate the isAutomaticUpdate property will be
|
||||
// on the payload (and set to true). If isAutomaticUpdate is true,
|
||||
// then we check if the previous estimate was '0x0' or if the previous
|
||||
// gasPrice equals the previous gasEstimate. if either of those cases
|
||||
// are true then we update the gasPrice otherwise we skip it because
|
||||
// it indicates the user has ejected from the estimates by modifying
|
||||
// the field.
|
||||
if (action.payload.manuallyEdited) {
|
||||
draftTransaction.gas.wasManuallyEdited = true;
|
||||
}
|
||||
|
||||
// Update the gas price if it has not been manually edited,
|
||||
// or if this current action is a manual edit.
|
||||
if (
|
||||
action.payload.isAutomaticUpdate !== true ||
|
||||
state.gasPriceEstimate === '0x0' ||
|
||||
draftTransaction.gas.gasPrice === state.gasPriceEstimate
|
||||
!draftTransaction.gas.wasManuallyEdited ||
|
||||
action.payload.manuallyEdited
|
||||
) {
|
||||
draftTransaction.gas.gasPrice = addHexPrefix(
|
||||
action.payload.gasPrice,
|
||||
@ -1821,6 +1818,7 @@ export function updateGasPrice(gasPrice) {
|
||||
actions.updateGasFees({
|
||||
gasPrice,
|
||||
transactionType: TRANSACTION_ENVELOPE_TYPES.LEGACY,
|
||||
manuallyEdited: true,
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
@ -1410,6 +1410,7 @@ describe('Send Slice', () => {
|
||||
type: 'send/updateGasFees',
|
||||
payload: {
|
||||
gasPrice: '0x0',
|
||||
manuallyEdited: true,
|
||||
transactionType: TRANSACTION_ENVELOPE_TYPES.LEGACY,
|
||||
},
|
||||
},
|
||||
@ -2453,6 +2454,7 @@ describe('Send Slice', () => {
|
||||
gasLimit: GAS_LIMITS.SIMPLE,
|
||||
gasPrice: '0x3b9aca00',
|
||||
gasTotal: '0x0',
|
||||
wasManuallyEdited: false,
|
||||
maxFeePerGas: '0x0',
|
||||
maxPriorityFeePerGas: '0x0',
|
||||
},
|
||||
@ -2597,6 +2599,7 @@ describe('Send Slice', () => {
|
||||
gasLimit: GAS_LIMITS.BASE_TOKEN_ESTIMATE,
|
||||
gasPrice: '0x3b9aca00',
|
||||
gasTotal: '0x0',
|
||||
wasManuallyEdited: false,
|
||||
maxFeePerGas: '0x0',
|
||||
maxPriorityFeePerGas: '0x0',
|
||||
},
|
||||
@ -2786,6 +2789,7 @@ describe('Send Slice', () => {
|
||||
error: null,
|
||||
gasLimit: '0x186a0',
|
||||
gasPrice: '0x3b9aca00',
|
||||
wasManuallyEdited: false,
|
||||
gasTotal: '0x0',
|
||||
maxFeePerGas: '0x0',
|
||||
maxPriorityFeePerGas: '0x0',
|
||||
|
Loading…
Reference in New Issue
Block a user