aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/migrations
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2017-02-16 03:29:21 +0800
committerGitHub <noreply@github.com>2017-02-16 03:29:21 +0800
commitcdd4faa917a2f02b531c479eb2f05f39f303d51b (patch)
tree2068fb2a606a2cee15256ee986306768a93c26d9 /app/scripts/migrations
parentec8aa3d1f28e24586031f36151a3b5b5490b3248 (diff)
parent6ef78eb02bf856c85f6acbf3ad8e343ab281f63c (diff)
downloadtangerine-wallet-browser-cdd4faa917a2f02b531c479eb2f05f39f303d51b.tar
tangerine-wallet-browser-cdd4faa917a2f02b531c479eb2f05f39f303d51b.tar.gz
tangerine-wallet-browser-cdd4faa917a2f02b531c479eb2f05f39f303d51b.tar.bz2
tangerine-wallet-browser-cdd4faa917a2f02b531c479eb2f05f39f303d51b.tar.lz
tangerine-wallet-browser-cdd4faa917a2f02b531c479eb2f05f39f303d51b.tar.xz
tangerine-wallet-browser-cdd4faa917a2f02b531c479eb2f05f39f303d51b.tar.zst
tangerine-wallet-browser-cdd4faa917a2f02b531c479eb2f05f39f303d51b.zip
Merge pull request #1117 from MetaMask/disclaimer-clean
Migration Testing
Diffstat (limited to 'app/scripts/migrations')
-rw-r--r--app/scripts/migrations/002.js6
-rw-r--r--app/scripts/migrations/003.js5
-rw-r--r--app/scripts/migrations/004.js17
-rw-r--r--app/scripts/migrations/005.js7
-rw-r--r--app/scripts/migrations/006.js6
-rw-r--r--app/scripts/migrations/007.js6
-rw-r--r--app/scripts/migrations/008.js6
-rw-r--r--app/scripts/migrations/009.js9
-rw-r--r--app/scripts/migrations/010.js4
-rw-r--r--app/scripts/migrations/011.js33
-rw-r--r--app/scripts/migrations/index.js1
11 files changed, 79 insertions, 21 deletions
diff --git a/app/scripts/migrations/002.js b/app/scripts/migrations/002.js
index 476b0a43a..36a870342 100644
--- a/app/scripts/migrations/002.js
+++ b/app/scripts/migrations/002.js
@@ -1,9 +1,13 @@
const version = 2
+const clone = require('clone')
+
+
module.exports = {
version,
- migrate: function (versionedData) {
+ migrate: function (originalVersionedData) {
+ let versionedData = clone(originalVersionedData)
versionedData.meta.version = version
try {
if (versionedData.data.config.provider.type === 'etherscan') {
diff --git a/app/scripts/migrations/003.js b/app/scripts/migrations/003.js
index eceaeaa4b..1893576ad 100644
--- a/app/scripts/migrations/003.js
+++ b/app/scripts/migrations/003.js
@@ -2,10 +2,13 @@ const version = 3
const oldTestRpc = 'https://rawtestrpc.metamask.io/'
const newTestRpc = 'https://testrpc.metamask.io/'
+const clone = require('clone')
+
module.exports = {
version,
- migrate: function (versionedData) {
+ migrate: function (originalVersionedData) {
+ let versionedData = clone(originalVersionedData)
versionedData.meta.version = version
try {
if (versionedData.data.config.provider.rpcTarget === oldTestRpc) {
diff --git a/app/scripts/migrations/004.js b/app/scripts/migrations/004.js
index 0f9850208..405d932f8 100644
--- a/app/scripts/migrations/004.js
+++ b/app/scripts/migrations/004.js
@@ -1,25 +1,28 @@
const version = 4
+const clone = require('clone')
+
module.exports = {
- version,
+ version,
migrate: function (versionedData) {
- versionedData.meta.version = version
+ let safeVersionedData = clone(versionedData)
+ safeVersionedData.meta.version = version
try {
- if (versionedData.data.config.provider.type !== 'rpc') return Promise.resolve(versionedData)
- switch (versionedData.data.config.provider.rpcTarget) {
+ if (safeVersionedData.data.config.provider.type !== 'rpc') return Promise.resolve(safeVersionedData)
+ switch (safeVersionedData.data.config.provider.rpcTarget) {
case 'https://testrpc.metamask.io/':
- versionedData.data.config.provider = {
+ safeVersionedData.data.config.provider = {
type: 'testnet',
}
break
case 'https://rpc.metamask.io/':
- versionedData.data.config.provider = {
+ safeVersionedData.data.config.provider = {
type: 'mainnet',
}
break
}
} catch (_) {}
- return Promise.resolve(versionedData)
+ return Promise.resolve(safeVersionedData)
},
}
diff --git a/app/scripts/migrations/005.js b/app/scripts/migrations/005.js
index 65f62a861..e4b84f460 100644
--- a/app/scripts/migrations/005.js
+++ b/app/scripts/migrations/005.js
@@ -7,11 +7,14 @@ This migration moves state from the flat state trie into KeyringController subst
*/
const extend = require('xtend')
+const clone = require('clone')
+
module.exports = {
- version,
+ version,
- migrate: function (versionedData) {
+ migrate: function (originalVersionedData) {
+ let versionedData = clone(originalVersionedData)
versionedData.meta.version = version
try {
const state = versionedData.data
diff --git a/app/scripts/migrations/006.js b/app/scripts/migrations/006.js
index 950c4deb8..94d1b6ecd 100644
--- a/app/scripts/migrations/006.js
+++ b/app/scripts/migrations/006.js
@@ -7,11 +7,13 @@ This migration moves KeyringController.selectedAddress to PreferencesController.
*/
const extend = require('xtend')
+const clone = require('clone')
module.exports = {
- version,
+ version,
- migrate: function (versionedData) {
+ migrate: function (originalVersionedData) {
+ let versionedData = clone(originalVersionedData)
versionedData.meta.version = version
try {
const state = versionedData.data
diff --git a/app/scripts/migrations/007.js b/app/scripts/migrations/007.js
index 3ae8cdc2d..236e35224 100644
--- a/app/scripts/migrations/007.js
+++ b/app/scripts/migrations/007.js
@@ -7,11 +7,13 @@ This migration breaks out the TransactionManager substate
*/
const extend = require('xtend')
+const clone = require('clone')
module.exports = {
- version,
+ version,
- migrate: function (versionedData) {
+ migrate: function (originalVersionedData) {
+ let versionedData = clone(originalVersionedData)
versionedData.meta.version = version
try {
const state = versionedData.data
diff --git a/app/scripts/migrations/008.js b/app/scripts/migrations/008.js
index 7f6e72ee6..cd5e95d22 100644
--- a/app/scripts/migrations/008.js
+++ b/app/scripts/migrations/008.js
@@ -7,11 +7,13 @@ This migration breaks out the NoticeController substate
*/
const extend = require('xtend')
+const clone = require('clone')
module.exports = {
- version,
+ version,
- migrate: function (versionedData) {
+ migrate: function (originalVersionedData) {
+ let versionedData = clone(originalVersionedData)
versionedData.meta.version = version
try {
const state = versionedData.data
diff --git a/app/scripts/migrations/009.js b/app/scripts/migrations/009.js
index 38e6dcc09..4612fefdc 100644
--- a/app/scripts/migrations/009.js
+++ b/app/scripts/migrations/009.js
@@ -7,11 +7,13 @@ This migration breaks out the CurrencyController substate
*/
const merge = require('deep-extend')
+const clone = require('clone')
module.exports = {
- version,
+ version,
- migrate: function (versionedData) {
+ migrate: function (originalVersionedData) {
+ let versionedData = clone(originalVersionedData)
versionedData.meta.version = version
try {
const state = versionedData.data
@@ -27,12 +29,13 @@ module.exports = {
function transformState (state) {
const newState = merge({}, state, {
CurrencyController: {
- currentCurrency: state.currentFiat || 'USD',
+ currentCurrency: state.currentFiat || state.fiatCurrency || 'USD',
conversionRate: state.conversionRate,
conversionDate: state.conversionDate,
},
})
delete newState.currentFiat
+ delete newState.fiatCurrency
delete newState.conversionRate
delete newState.conversionDate
diff --git a/app/scripts/migrations/010.js b/app/scripts/migrations/010.js
index d41c63fcd..48a841bc1 100644
--- a/app/scripts/migrations/010.js
+++ b/app/scripts/migrations/010.js
@@ -7,11 +7,13 @@ This migration breaks out the CurrencyController substate
*/
const merge = require('deep-extend')
+const clone = require('clone')
module.exports = {
version,
- migrate: function (versionedData) {
+ migrate: function (originalVersionedData) {
+ let versionedData = clone(originalVersionedData)
versionedData.meta.version = version
try {
const state = versionedData.data
diff --git a/app/scripts/migrations/011.js b/app/scripts/migrations/011.js
new file mode 100644
index 000000000..bf283ef98
--- /dev/null
+++ b/app/scripts/migrations/011.js
@@ -0,0 +1,33 @@
+const version = 11
+
+/*
+
+This migration breaks out the CurrencyController substate
+
+*/
+
+const clone = require('clone')
+
+module.exports = {
+ version,
+
+ migrate: function (originalVersionedData) {
+ let 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
+ delete newState.TOSHash
+ delete newState.isDisclaimerConfirmed
+ return newState
+}
diff --git a/app/scripts/migrations/index.js b/app/scripts/migrations/index.js
index 2db8646b0..a3dd48c17 100644
--- a/app/scripts/migrations/index.js
+++ b/app/scripts/migrations/index.js
@@ -21,4 +21,5 @@ module.exports = [
require('./008'),
require('./009'),
require('./010'),
+ require('./011'),
]