aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/migrations/031.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts/migrations/031.js')
-rw-r--r--app/scripts/migrations/031.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/app/scripts/migrations/031.js b/app/scripts/migrations/031.js
new file mode 100644
index 000000000..98d182828
--- /dev/null
+++ b/app/scripts/migrations/031.js
@@ -0,0 +1,31 @@
+// next version number
+const version = 31
+const clone = require('clone')
+
+ /*
+ * The purpose of this migration is to properly set the completedOnboarding flag baesd on the state
+ * of the KeyringController.
+ */
+module.exports = {
+ version,
+
+ migrate: async function (originalVersionedData) {
+ const versionedData = clone(originalVersionedData)
+ versionedData.meta.version = version
+ const state = versionedData.data
+ const newState = transformState(state)
+ versionedData.data = newState
+ return versionedData
+ },
+}
+
+ function transformState (state) {
+ const { KeyringController, PreferencesController } = state
+
+ if (KeyringController && PreferencesController) {
+ const { vault } = KeyringController
+ PreferencesController.completedOnboarding = Boolean(vault)
+ }
+
+ return state
+}