aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts')
-rw-r--r--app/scripts/migrations/026.js40
-rw-r--r--app/scripts/migrations/index.js1
2 files changed, 41 insertions, 0 deletions
diff --git a/app/scripts/migrations/026.js b/app/scripts/migrations/026.js
new file mode 100644
index 000000000..ef0ed0542
--- /dev/null
+++ b/app/scripts/migrations/026.js
@@ -0,0 +1,40 @@
+const version = 26
+
+/*
+
+This migration moves the identities stored in the KeyringController
+ into the PreferencesController
+
+*/
+
+const clone = require('clone')
+
+module.exports = {
+ version,
+ migrate (originalVersionedData) {
+ const versionedData = clone(originalVersionedData)
+ versionedData.meta.version = version
+ try {
+ const state = versionedData.data
+ versionedData.data = transformState(state)
+ } catch (err) {
+ console.warn(`MetaMask Migration #${version}` + err.stack)
+ return Promise.reject(err)
+ }
+ return Promise.resolve(versionedData)
+ },
+}
+
+function transformState (state) {
+ if (!state.KeyringController || !state.PreferencesController) {
+ return
+ }
+
+ if (!state.KeyringController.walletNicknames) {
+ return state
+ }
+
+ state.PreferencesController.identities = state.KeyringController.walletNicknames
+ delete state.KeyringController.walletNicknames
+ return state
+}
diff --git a/app/scripts/migrations/index.js b/app/scripts/migrations/index.js
index 6c4a51b32..04d90bfff 100644
--- a/app/scripts/migrations/index.js
+++ b/app/scripts/migrations/index.js
@@ -36,4 +36,5 @@ module.exports = [
require('./023'),
require('./024'),
require('./025'),
+ require('./026'),
]