diff options
author | Dan Finlay <flyswatter@users.noreply.github.com> | 2017-06-28 06:33:32 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-28 06:33:32 +0800 |
commit | b9f220c90d5265d18a0d6f7b196e1429e1f8a791 (patch) | |
tree | 29814a6054e11122a3ae9db83b10bec0256aa5bb /app | |
parent | ed08e736d7e0c8b105d48d584a9d9cee33bfa34f (diff) | |
parent | 4e0ec74bb7cb36e2e0fa035bf653ce0e57b7c2e7 (diff) | |
download | tangerine-wallet-browser-b9f220c90d5265d18a0d6f7b196e1429e1f8a791.tar tangerine-wallet-browser-b9f220c90d5265d18a0d6f7b196e1429e1f8a791.tar.gz tangerine-wallet-browser-b9f220c90d5265d18a0d6f7b196e1429e1f8a791.tar.bz2 tangerine-wallet-browser-b9f220c90d5265d18a0d6f7b196e1429e1f8a791.tar.lz tangerine-wallet-browser-b9f220c90d5265d18a0d6f7b196e1429e1f8a791.tar.xz tangerine-wallet-browser-b9f220c90d5265d18a0d6f7b196e1429e1f8a791.tar.zst tangerine-wallet-browser-b9f220c90d5265d18a0d6f7b196e1429e1f8a791.zip |
Merge pull request #1685 from MetaMask/setFailed
Migration #015 set txs Failed
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/migrations/015.js | 38 | ||||
-rw-r--r-- | app/scripts/migrations/index.js | 1 |
2 files changed, 39 insertions, 0 deletions
diff --git a/app/scripts/migrations/015.js b/app/scripts/migrations/015.js new file mode 100644 index 000000000..4b839580b --- /dev/null +++ b/app/scripts/migrations/015.js @@ -0,0 +1,38 @@ +const version = 15 + +/* + +This migration sets transactions with the 'Gave up submitting tx.' err message +to a 'failed' stated + +*/ + +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.err) return txMeta + else if (txMeta.err.message === 'Gave up submitting tx.') txMeta.status = 'failed' + return txMeta + }) + return newState +} diff --git a/app/scripts/migrations/index.js b/app/scripts/migrations/index.js index fb1ad7863..651ee6a9c 100644 --- a/app/scripts/migrations/index.js +++ b/app/scripts/migrations/index.js @@ -25,4 +25,5 @@ module.exports = [ require('./012'), require('./013'), require('./014'), + require('./015'), ] |