diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b38bd54f5d0..e06195956681 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ## 7.7.9 Tue Apr 28 2020 - [#8446](https://github.com/MetaMask/metamask-extension/pull/8446): Fix popup not opening +- [#8449](https://github.com/MetaMask/metamask-extension/pull/8449): Skip adding history entry for empty txMeta diffs ## 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/tx-state-manager.js b/app/scripts/controllers/transactions/tx-state-manager.js index cf254352fddd..e2bbe8e39ed6 100644 --- a/app/scripts/controllers/transactions/tx-state-manager.js +++ b/app/scripts/controllers/transactions/tx-state-manager.js @@ -195,7 +195,9 @@ class TransactionStateManager extends EventEmitter { const previousState = txStateHistoryHelper.replayHistory(txMeta.history) // generate history entry and add to history const entry = txStateHistoryHelper.generateHistoryEntry(previousState, currentState, note) - txMeta.history.push(entry) + if (entry.length) { + txMeta.history.push(entry) + } // commit txMeta to state const txId = txMeta.id diff --git a/test/unit/app/controllers/transactions/tx-state-manager-test.js b/test/unit/app/controllers/transactions/tx-state-manager-test.js index 02d6199e9fa8..bdd1c9cb72c3 100644 --- a/test/unit/app/controllers/transactions/tx-state-manager-test.js +++ b/test/unit/app/controllers/transactions/tx-state-manager-test.js @@ -252,6 +252,23 @@ describe('TransactionStateManager', function () { assert.deepEqual(result.history[1][0].value, expectedEntry.value, 'two history items (initial + diff) value') assert.ok(result.history[1][0].timestamp >= before && result.history[1][0].timestamp <= after) }) + + it('does NOT add empty history items', function () { + const txMeta = { + id: '1', + status: 'unapproved', + metamaskNetworkId: currentNetworkId, + txParams: { + gasPrice: '0x01', + }, + } + + txStateManager.addTx(txMeta) + txStateManager.updateTx(txMeta) + + const { history } = txStateManager.getTx('1') + assert.equal(history.length, 1, 'two history items (initial + diff)') + }) }) describe('#getUnapprovedTxList', function () {