diff options
Merge branch 'master' into i18n-translator-redux
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/background.js | 2 | ||||
-rw-r--r-- | app/scripts/migrations/022.js | 39 | ||||
-rw-r--r-- | app/scripts/migrations/index.js | 1 |
3 files changed, 40 insertions, 2 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js index c8fe1cd63..98de1d278 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -85,7 +85,6 @@ async function loadStateFromPersistence () { // write to disk if (localStore.isSupported) localStore.set(versionedData) - diskStore.putState(versionedData) // return just the data return versionedData.data @@ -123,7 +122,6 @@ function setupController (initState, initLangCode) { debounce(1000), storeTransform(versionifyData), storeTransform(syncDataWithExtension), - asStream(diskStore), (error) => { log.error('pump hit error', error) } 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 +} 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'), ] |