diff options
author | Dan Finlay <dan@danfinlay.com> | 2017-11-29 08:56:45 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2017-11-29 08:56:45 +0800 |
commit | ab35a76a240dc0139761678028aa8c187345ab49 (patch) | |
tree | df1c8611183c01da92a46cb6a57a09fea8d59e0a /app/scripts | |
parent | 80dedcc01c28f8d3d113e5b9a4ac83e1b1124440 (diff) | |
download | tangerine-wallet-browser-ab35a76a240dc0139761678028aa8c187345ab49.tar tangerine-wallet-browser-ab35a76a240dc0139761678028aa8c187345ab49.tar.gz tangerine-wallet-browser-ab35a76a240dc0139761678028aa8c187345ab49.tar.bz2 tangerine-wallet-browser-ab35a76a240dc0139761678028aa8c187345ab49.tar.lz tangerine-wallet-browser-ab35a76a240dc0139761678028aa8c187345ab49.tar.xz tangerine-wallet-browser-ab35a76a240dc0139761678028aa8c187345ab49.tar.zst tangerine-wallet-browser-ab35a76a240dc0139761678028aa8c187345ab49.zip |
Migrate old data to include firstVersion info
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/migrations/020.js | 40 | ||||
-rw-r--r-- | app/scripts/migrations/index.js | 1 |
2 files changed, 41 insertions, 0 deletions
diff --git a/app/scripts/migrations/020.js b/app/scripts/migrations/020.js new file mode 100644 index 000000000..59b9be7b3 --- /dev/null +++ b/app/scripts/migrations/020.js @@ -0,0 +1,40 @@ +const version = 20 + +/* + +This migration sets transactions as failed +whos nonce is too high + +*/ + +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 + if ('metamask' in newState && + !('firstTimeInfo' in newState.metamask)) { + newState.metamask.firstTimeInfo = { + version: '3.12.0', + date: Date.now(), + } + } + return newState +} + diff --git a/app/scripts/migrations/index.js b/app/scripts/migrations/index.js index e9cbd7b98..9d0631042 100644 --- a/app/scripts/migrations/index.js +++ b/app/scripts/migrations/index.js @@ -30,4 +30,5 @@ module.exports = [ require('./017'), require('./018'), require('./019'), + require('./020'), ] |