1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

avoid mutation of state in signTransaction action (#17772)

Co-authored-by: ryanml <ryanlanese@gmail.com>
This commit is contained in:
Brad Decker 2023-02-23 12:16:55 -06:00 committed by PeterYinusa
parent 2a6bcff4e2
commit 591fe1a0a6

View File

@ -1,7 +1,7 @@
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit'; import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
import { addHexPrefix } from 'ethereumjs-util'; import { addHexPrefix } from 'ethereumjs-util';
import { debounce } from 'lodash'; import { cloneDeep, debounce } from 'lodash';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { import {
decimalToHex, decimalToHex,
@ -2270,7 +2270,7 @@ export function signTransaction() {
// merge in the modified txParams. Once the transaction has been modified // merge in the modified txParams. Once the transaction has been modified
// we can send that to the background to update the transaction in state. // we can send that to the background to update the transaction in state.
const unapprovedTxs = getUnapprovedTxs(state); const unapprovedTxs = getUnapprovedTxs(state);
const unapprovedTx = unapprovedTxs[draftTransaction.id]; const unapprovedTx = cloneDeep(unapprovedTxs[draftTransaction.id]);
// We only update the tx params that can be changed via the edit flow UX // We only update the tx params that can be changed via the edit flow UX
const eip1559OnlyTxParamsToUpdate = { const eip1559OnlyTxParamsToUpdate = {
data: txParams.data, data: txParams.data,