mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
tx controller - tx state history various small fixes
This commit is contained in:
parent
fec0f2ca5e
commit
1af797b1b3
@ -1,6 +1,5 @@
|
|||||||
const EventEmitter = require('events')
|
const EventEmitter = require('events')
|
||||||
const extend = require('xtend')
|
const extend = require('xtend')
|
||||||
const clone = require('clone')
|
|
||||||
const ObservableStore = require('obs-store')
|
const ObservableStore = require('obs-store')
|
||||||
const ethUtil = require('ethereumjs-util')
|
const ethUtil = require('ethereumjs-util')
|
||||||
const EthQuery = require('ethjs-query')
|
const EthQuery = require('ethjs-query')
|
||||||
|
@ -15,7 +15,7 @@ function migrateFromSnapshotsToDiffs(longHistory) {
|
|||||||
// convert non-initial history entries into diffs
|
// convert non-initial history entries into diffs
|
||||||
.map((entry, index) => {
|
.map((entry, index) => {
|
||||||
if (index === 0) return entry
|
if (index === 0) return entry
|
||||||
return generateHistoryEntry(longHistory[index-1], entry)
|
return generateHistoryEntry(longHistory[index - 1], entry)
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ function transformState (state) {
|
|||||||
const transactions = newState.TransactionController.transactions
|
const transactions = newState.TransactionController.transactions
|
||||||
newState.TransactionController.transactions = transactions.map((txMeta) => {
|
newState.TransactionController.transactions = transactions.map((txMeta) => {
|
||||||
// no history: initialize
|
// no history: initialize
|
||||||
if (!txMeta.history || tx.history.length === 0) {
|
if (!txMeta.history || txMeta.history.length === 0) {
|
||||||
const snapshot = txStateHistoryHelper.snapshotFromTxMeta(txMeta)
|
const snapshot = txStateHistoryHelper.snapshotFromTxMeta(txMeta)
|
||||||
txMeta.history = [snapshot]
|
txMeta.history = [snapshot]
|
||||||
return txMeta
|
return txMeta
|
||||||
|
@ -3,7 +3,7 @@ const txStateHistoryHelper = require('../../app/scripts/lib/tx-state-history-hel
|
|||||||
const testVault = require('../data/v17-long-history.json')
|
const testVault = require('../data/v17-long-history.json')
|
||||||
|
|
||||||
|
|
||||||
describe('history-differ', function () {
|
describe('tx-state-history-helper', function () {
|
||||||
it('migrates history to diffs and can recover original values', function () {
|
it('migrates history to diffs and can recover original values', function () {
|
||||||
testVault.data.TransactionController.transactions.forEach((tx, index) => {
|
testVault.data.TransactionController.transactions.forEach((tx, index) => {
|
||||||
const newHistory = txStateHistoryHelper.migrateFromSnapshotsToDiffs(tx.history)
|
const newHistory = txStateHistoryHelper.migrateFromSnapshotsToDiffs(tx.history)
|
||||||
|
Loading…
Reference in New Issue
Block a user