From 5a61a6d57af62bd4dea8f1563a9edde6a03e439b Mon Sep 17 00:00:00 2001 From: Frankie Date: Mon, 26 Mar 2018 14:24:12 -0700 Subject: migration for adding submittedTime to the txMeta (#3727) * test for migration 022 * write migration 022 adding submittedTime to txMetas whove been submitted --- app/scripts/migrations/022.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 app/scripts/migrations/022.js (limited to 'app/scripts') diff --git a/app/scripts/migrations/022.js b/app/scripts/migrations/022.js new file mode 100644 index 000000000..c3c0d53ef --- /dev/null +++ b/app/scripts/migrations/022.js @@ -0,0 +1,39 @@ + +const version = 22 + +/* + +This migration adds submittedTime to the txMeta if it is not their + +*/ + +const clone = require('clone') + +module.exports = { + version, + + migrate: function (originalVersionedData) { + const versionedData = clone(originalVersionedData) + versionedData.meta.version = version + try { + const state = versionedData.data + const newState = transformState(state) + versionedData.data = newState + } catch (err) { + console.warn(`MetaMask Migration #${version}` + err.stack) + } + return Promise.resolve(versionedData) + }, +} + +function transformState (state) { + const newState = state + const transactions = newState.TransactionController.transactions + + newState.TransactionController.transactions = transactions.map((txMeta) => { + if (txMeta.status !== 'submitted' || txMeta.submittedTime) return txMeta + txMeta.submittedTime = (new Date()).getTime() + return txMeta + }) + return newState +} -- cgit v1.2.3 From e196b6dcb7c9a0df059491b7f0d75b50d54c1b66 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 26 Mar 2018 15:25:26 -0700 Subject: Fix bug where full localStorage would crash on start --- app/scripts/background.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'app/scripts') diff --git a/app/scripts/background.js b/app/scripts/background.js index 8bd7766ad..7bbaa89d6 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -84,7 +84,6 @@ async function loadStateFromPersistence () { // write to disk if (localStore.isSupported) localStore.set(versionedData) - diskStore.putState(versionedData) // return just the data return versionedData.data @@ -121,7 +120,6 @@ function setupController (initState) { debounce(1000), storeTransform(versionifyData), storeTransform(syncDataWithExtension), - asStream(diskStore), (error) => { log.error('pump hit error', error) } -- cgit v1.2.3 From 0a2616a37fad6573b3543c39ca4f5c557198ad0c Mon Sep 17 00:00:00 2001 From: frankiebee Date: Mon, 26 Mar 2018 18:12:16 -0700 Subject: include migration 22 --- app/scripts/migrations/index.js | 1 + 1 file changed, 1 insertion(+) (limited to 'app/scripts') diff --git a/app/scripts/migrations/index.js b/app/scripts/migrations/index.js index a0cf5f4d4..b49a40c65 100644 --- a/app/scripts/migrations/index.js +++ b/app/scripts/migrations/index.js @@ -32,4 +32,5 @@ module.exports = [ require('./019'), require('./020'), require('./021'), + require('./022'), ] -- cgit v1.2.3