From f91bd3a08dae076f5af3ffd622d267c8ee6bbe2d Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Wed, 29 Apr 2020 16:17:52 -0300 Subject: [PATCH] Backport "Snapshot txMeta without cloning history (#8363)" (#8458) Backport #8363 to v7.7.9. Note that this uses `clone` instead of `cloneDeep`, because `clone` hadn't yet been replaced by `cloneDeep` on `master`. Backporting that change as well would have been very disruptive, so I've updated this to use `clone` instead to minimize conflicts. It is functionally equivalent. Co-authored-by: Whymarrh Whitby --- CHANGELOG.md | 1 + .../transactions/lib/tx-state-history-helper.js | 15 +++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88de7b535edb..ad4f1102c57b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - [#8449](https://github.com/MetaMask/metamask-extension/pull/8449): Skip adding history entry for empty txMeta diffs - [#8447](https://github.com/MetaMask/metamask-extension/pull/8447): Delete Dai/Sai migration notification - [#8460](https://github.com/MetaMask/metamask-extension/pull/8460): Update deposit copy for Wyre +- [#8458](https://github.com/MetaMask/metamask-extension/pull/8458): Snapshot txMeta without cloning history ## 7.7.8 Wed Mar 11 2020 - [#8176](https://github.com/MetaMask/metamask-extension/pull/8176): Handle and set gas estimation when max mode is clicked diff --git a/app/scripts/controllers/transactions/lib/tx-state-history-helper.js b/app/scripts/controllers/transactions/lib/tx-state-history-helper.js index 76fc5c35b394..20e64696b28c 100644 --- a/app/scripts/controllers/transactions/lib/tx-state-history-helper.js +++ b/app/scripts/controllers/transactions/lib/tx-state-history-helper.js @@ -57,13 +57,12 @@ function replayHistory (_shortHistory) { } /** - @param txMeta {Object} - @returns {object} a clone object of the txMeta with out history -*/ + * Snapshot {@code txMeta} + * @param {Object} txMeta - the tx metadata object + * @returns {Object} a deep clone without history + */ function snapshotFromTxMeta (txMeta) { - // create txMeta snapshot for history - const snapshot = clone(txMeta) - // dont include previous history in this snapshot - delete snapshot.history - return snapshot + const shallow = { ...txMeta } + delete shallow.history + return clone(shallow) }