aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/migrations
diff options
context:
space:
mode:
authorfrankiebee <frankie.diamond@gmail.com>2017-05-23 13:55:20 +0800
committerfrankiebee <frankie.diamond@gmail.com>2017-05-23 13:55:20 +0800
commite08c1541e5a91d7958b15753982d22066c1a0a7d (patch)
tree9d6d6591536e67f90eea078d695463831a0ab572 /app/scripts/migrations
parent13a41f3129299844c908965a25996ec5cd190eb1 (diff)
downloadtangerine-wallet-browser-e08c1541e5a91d7958b15753982d22066c1a0a7d.tar
tangerine-wallet-browser-e08c1541e5a91d7958b15753982d22066c1a0a7d.tar.gz
tangerine-wallet-browser-e08c1541e5a91d7958b15753982d22066c1a0a7d.tar.bz2
tangerine-wallet-browser-e08c1541e5a91d7958b15753982d22066c1a0a7d.tar.lz
tangerine-wallet-browser-e08c1541e5a91d7958b15753982d22066c1a0a7d.tar.xz
tangerine-wallet-browser-e08c1541e5a91d7958b15753982d22066c1a0a7d.tar.zst
tangerine-wallet-browser-e08c1541e5a91d7958b15753982d22066c1a0a7d.zip
Add a migration for the network controller
Diffstat (limited to 'app/scripts/migrations')
-rw-r--r--app/scripts/migrations/014.js34
-rw-r--r--app/scripts/migrations/index.js1
2 files changed, 35 insertions, 0 deletions
diff --git a/app/scripts/migrations/014.js b/app/scripts/migrations/014.js
new file mode 100644
index 000000000..0fe92125b
--- /dev/null
+++ b/app/scripts/migrations/014.js
@@ -0,0 +1,34 @@
+const version = 14
+
+/*
+
+This migration removes provider from config and moves it too NetworkController.
+
+*/
+
+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
+ newState.NetworkController = {}
+ newState.NetworkController.provider = newState.config.provider
+ delete newState.config.provider
+ return newState
+}
diff --git a/app/scripts/migrations/index.js b/app/scripts/migrations/index.js
index 3a95cf88e..fb1ad7863 100644
--- a/app/scripts/migrations/index.js
+++ b/app/scripts/migrations/index.js
@@ -24,4 +24,5 @@ module.exports = [
require('./011'),
require('./012'),
require('./013'),
+ require('./014'),
]