Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip adding history entry for empty txMeta diffs #8379

Merged
merged 1 commit into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/scripts/controllers/transactions/tx-state-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ class TransactionStateManager extends EventEmitter {
const previousState = replayHistory(txMeta.history)
// generate history entry and add to history
const entry = generateHistoryEntry(previousState, currentState, note)
txMeta.history.push(entry)
if (entry.length) {
txMeta.history.push(entry)
}

// commit txMeta to state
const txId = txMeta.id
Expand Down
17 changes: 17 additions & 0 deletions test/unit/app/controllers/transactions/tx-state-manager-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,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 () {
Expand Down