aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfrankiebee <frankie.diamond@gmail.com>2017-06-28 05:59:37 +0800
committerfrankiebee <frankie.diamond@gmail.com>2017-06-28 06:09:07 +0800
commit4e0ec74bb7cb36e2e0fa035bf653ce0e57b7c2e7 (patch)
tree8b340c2c25847c2849202cbdd4fcc37f13c229f4
parent48f7cff8c0e765e85532c860c5f3061ca1d6deb7 (diff)
downloadtangerine-wallet-browser-4e0ec74bb7cb36e2e0fa035bf653ce0e57b7c2e7.tar
tangerine-wallet-browser-4e0ec74bb7cb36e2e0fa035bf653ce0e57b7c2e7.tar.gz
tangerine-wallet-browser-4e0ec74bb7cb36e2e0fa035bf653ce0e57b7c2e7.tar.bz2
tangerine-wallet-browser-4e0ec74bb7cb36e2e0fa035bf653ce0e57b7c2e7.tar.lz
tangerine-wallet-browser-4e0ec74bb7cb36e2e0fa035bf653ce0e57b7c2e7.tar.xz
tangerine-wallet-browser-4e0ec74bb7cb36e2e0fa035bf653ce0e57b7c2e7.tar.zst
tangerine-wallet-browser-4e0ec74bb7cb36e2e0fa035bf653ce0e57b7c2e7.zip
Create a migration for setting tx's with the message 'Gave up submitting tx.' as failed
-rw-r--r--app/scripts/migrations/015.js38
-rw-r--r--app/scripts/migrations/index.js1
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'),
]