mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Skip adding history entry for empty txMeta diffs (#8379)
This commit is contained in:
parent
d908102636
commit
f2f70342e2
@ -202,7 +202,9 @@ class TransactionStateManager extends EventEmitter {
|
|||||||
const previousState = replayHistory(txMeta.history)
|
const previousState = replayHistory(txMeta.history)
|
||||||
// generate history entry and add to history
|
// generate history entry and add to history
|
||||||
const entry = generateHistoryEntry(previousState, currentState, note)
|
const entry = generateHistoryEntry(previousState, currentState, note)
|
||||||
txMeta.history.push(entry)
|
if (entry.length) {
|
||||||
|
txMeta.history.push(entry)
|
||||||
|
}
|
||||||
|
|
||||||
// commit txMeta to state
|
// commit txMeta to state
|
||||||
const txId = txMeta.id
|
const txId = txMeta.id
|
||||||
|
@ -256,6 +256,23 @@ describe('TransactionStateManager', function () {
|
|||||||
assert.deepEqual(result.history[1][0].value, expectedEntry.value, 'two history items (initial + diff) value')
|
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)
|
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 () {
|
describe('#getUnapprovedTxList', function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user