aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.circleci/config.yml17
-rw-r--r--app/scripts/migrations/022.js39
-rw-r--r--test/unit/migrations/022-test.js32
3 files changed, 71 insertions, 17 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml
index bcc9a299f..c14909783 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -6,9 +6,6 @@ workflows:
jobs:
- prep-deps-npm
- prep-deps-firefox
- - build:
- requires:
- - prep-deps-npm
- prep-scss:
requires:
- prep-deps-npm
@@ -203,17 +200,3 @@ jobs:
- run:
name: test:integration:mascara
command: npm run test:mascara
-
- build:
- docker:
- - image: circleci/node:8-browsers
- steps:
- - checkout
- - restore_cache:
- key: dependency-cache-{{ checksum "package-lock.json" }}
- - run:
- name: build:dist
- command: npm run dist
- - run:
- name: build:debug
- command: find dist/ -type f -exec md5sum {} \; | sort -k 2
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
+}
diff --git a/test/unit/migrations/022-test.js b/test/unit/migrations/022-test.js
new file mode 100644
index 000000000..1333d929d
--- /dev/null
+++ b/test/unit/migrations/022-test.js
@@ -0,0 +1,32 @@
+const assert = require('assert')
+const migration22 = require('../../../app/scripts/migrations/022')
+const properTime = (new Date()).getTime()
+const storage = {
+ "meta": {},
+ "data": {
+ "TransactionController": {
+ "transactions": [
+ { "status": "submitted" },
+ { "status": "submitted", "submittedTime": properTime },
+ {"status": "confirmed"},
+ ]
+ },
+ },
+}
+
+describe('storage is migrated successfully where transactions that are submitted have submittedTimes', () => {
+ it('should add submittedTime key on the txMeta if appropriate', (done) => {
+ migration22.migrate(storage)
+ .then((migratedData) => {
+ const [txMeta1, txMeta2, txMeta3] = migratedData.data.TransactionController.transactions
+ assert.equal(migratedData.meta.version, 22)
+ // should have written a submitted time
+ assert(txMeta1.submittedTime)
+ // should not have written a submitted time because it already has one
+ assert.equal(txMeta2.submittedTime, properTime)
+ // should not have written a submitted time
+ assert(!txMeta3.submittedTime)
+ done()
+ }).catch(done)
+ })
+})