diff options
author | frankiebee <frankie.diamond@gmail.com> | 2017-07-13 09:56:50 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2017-07-13 10:03:35 +0800 |
commit | de0cd6e66375f690965f60c58e70900660f565f2 (patch) | |
tree | f4171d31fd891fd184518fe67ebe3f71617c3b46 /app/scripts/migrations/017.js | |
parent | 27cb02bc5868673af794e0ad597fea87b2ddf175 (diff) | |
download | tangerine-wallet-browser-de0cd6e66375f690965f60c58e70900660f565f2.tar tangerine-wallet-browser-de0cd6e66375f690965f60c58e70900660f565f2.tar.gz tangerine-wallet-browser-de0cd6e66375f690965f60c58e70900660f565f2.tar.bz2 tangerine-wallet-browser-de0cd6e66375f690965f60c58e70900660f565f2.tar.lz tangerine-wallet-browser-de0cd6e66375f690965f60c58e70900660f565f2.tar.xz tangerine-wallet-browser-de0cd6e66375f690965f60c58e70900660f565f2.tar.zst tangerine-wallet-browser-de0cd6e66375f690965f60c58e70900660f565f2.zip |
write a migration for resubmit tx's to get put back into a submitted state
Diffstat (limited to 'app/scripts/migrations/017.js')
-rw-r--r-- | app/scripts/migrations/017.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/app/scripts/migrations/017.js b/app/scripts/migrations/017.js new file mode 100644 index 000000000..c9898ead7 --- /dev/null +++ b/app/scripts/migrations/017.js @@ -0,0 +1,40 @@ +const version = 17 + +/* + +This migration sets transactions who were retried and marked as failed to submitted + +*/ + +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 === 'failed') return txMeta + if (txMeta.retryCount > 0) { + txMeta.status = 'submitted' + delete txMeta.err + } + return txMeta + }) + return newState +} |