diff options
author | Frankie <frankie.diamond@gmail.com> | 2018-03-27 05:24:12 +0800 |
---|---|---|
committer | kumavis <kumavis@users.noreply.github.com> | 2018-03-27 05:24:12 +0800 |
commit | 5a61a6d57af62bd4dea8f1563a9edde6a03e439b (patch) | |
tree | 1cc6f2545964fd7ce5efe41a565603ee5b1cd7d4 /app/scripts | |
parent | a6af5fad96f0848030394669c65363e8a0303ac0 (diff) | |
download | tangerine-wallet-browser-5a61a6d57af62bd4dea8f1563a9edde6a03e439b.tar tangerine-wallet-browser-5a61a6d57af62bd4dea8f1563a9edde6a03e439b.tar.gz tangerine-wallet-browser-5a61a6d57af62bd4dea8f1563a9edde6a03e439b.tar.bz2 tangerine-wallet-browser-5a61a6d57af62bd4dea8f1563a9edde6a03e439b.tar.lz tangerine-wallet-browser-5a61a6d57af62bd4dea8f1563a9edde6a03e439b.tar.xz tangerine-wallet-browser-5a61a6d57af62bd4dea8f1563a9edde6a03e439b.tar.zst tangerine-wallet-browser-5a61a6d57af62bd4dea8f1563a9edde6a03e439b.zip |
migration for adding submittedTime to the txMeta (#3727)
* test for migration 022
* write migration 022 adding submittedTime to txMetas whove been submitted
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/migrations/022.js | 39 |
1 files changed, 39 insertions, 0 deletions
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 +} |