diff options
author | kumavis <kumavis@users.noreply.github.com> | 2018-04-06 23:32:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-06 23:32:21 +0800 |
commit | 90bcf9f7d27d2a5240840a1eeb28dede9bfad7a3 (patch) | |
tree | 33c8a0cbe3fccfd6d27c3ea06bd242c05bdeb293 /app/scripts/migrations/018.js | |
parent | 77486a23654a7709091f99bc7ef76d894a46113a (diff) | |
parent | d4e30040a2186a1320a44f86849506729b2dafad (diff) | |
download | tangerine-wallet-browser-90bcf9f7d27d2a5240840a1eeb28dede9bfad7a3.tar tangerine-wallet-browser-90bcf9f7d27d2a5240840a1eeb28dede9bfad7a3.tar.gz tangerine-wallet-browser-90bcf9f7d27d2a5240840a1eeb28dede9bfad7a3.tar.bz2 tangerine-wallet-browser-90bcf9f7d27d2a5240840a1eeb28dede9bfad7a3.tar.lz tangerine-wallet-browser-90bcf9f7d27d2a5240840a1eeb28dede9bfad7a3.tar.xz tangerine-wallet-browser-90bcf9f7d27d2a5240840a1eeb28dede9bfad7a3.tar.zst tangerine-wallet-browser-90bcf9f7d27d2a5240840a1eeb28dede9bfad7a3.zip |
Merge pull request #3907 from MetaMask/fix-all-migrations
migrations - back fixes
Diffstat (limited to 'app/scripts/migrations/018.js')
-rw-r--r-- | app/scripts/migrations/018.js | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/app/scripts/migrations/018.js b/app/scripts/migrations/018.js index d27fe3f46..bea1fe3da 100644 --- a/app/scripts/migrations/018.js +++ b/app/scripts/migrations/018.js @@ -29,24 +29,27 @@ module.exports = { function transformState (state) { const newState = state - const transactions = newState.TransactionController.transactions - newState.TransactionController.transactions = transactions.map((txMeta) => { - // no history: initialize - if (!txMeta.history || txMeta.history.length === 0) { - const snapshot = txStateHistoryHelper.snapshotFromTxMeta(txMeta) - txMeta.history = [snapshot] + const { TransactionController } = newState + if (TransactionController && TransactionController.transactions) { + const transactions = newState.TransactionController.transactions + newState.TransactionController.transactions = transactions.map((txMeta) => { + // no history: initialize + if (!txMeta.history || txMeta.history.length === 0) { + const snapshot = txStateHistoryHelper.snapshotFromTxMeta(txMeta) + txMeta.history = [snapshot] + return txMeta + } + // has history: migrate + const newHistory = ( + txStateHistoryHelper.migrateFromSnapshotsToDiffs(txMeta.history) + // remove empty diffs + .filter((entry) => { + return !Array.isArray(entry) || entry.length > 0 + }) + ) + txMeta.history = newHistory return txMeta - } - // has history: migrate - const newHistory = ( - txStateHistoryHelper.migrateFromSnapshotsToDiffs(txMeta.history) - // remove empty diffs - .filter((entry) => { - return !Array.isArray(entry) || entry.length > 0 - }) - ) - txMeta.history = newHistory - return txMeta - }) + }) + } return newState } |