diff options
Diffstat (limited to 'app/scripts/migrations')
-rw-r--r-- | app/scripts/migrations/031.js | 31 | ||||
-rw-r--r-- | app/scripts/migrations/index.js | 1 |
2 files changed, 32 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 +} diff --git a/app/scripts/migrations/index.js b/app/scripts/migrations/index.js index 99cca94b8..eb1b51685 100644 --- a/app/scripts/migrations/index.js +++ b/app/scripts/migrations/index.js @@ -41,4 +41,5 @@ module.exports = [ require('./028'), require('./029'), require('./030'), + require('./031'), ] |