diff options
author | Whymarrh Whitby <whymarrh.whitby@gmail.com> | 2018-04-19 11:33:51 +0800 |
---|---|---|
committer | Whymarrh Whitby <whymarrh.whitby@gmail.com> | 2018-05-17 23:27:39 +0800 |
commit | 2d13fac476cfbb7b0140611dca00fa95ee8d91ab (patch) | |
tree | 1a34c0f7bbb1963ac3848f2366d1af4fe9dfadc0 /app/scripts/migrations/026.js | |
parent | 50af02e74bf8967232b97a43db4f3befb6939566 (diff) | |
download | tangerine-wallet-browser-2d13fac476cfbb7b0140611dca00fa95ee8d91ab.tar tangerine-wallet-browser-2d13fac476cfbb7b0140611dca00fa95ee8d91ab.tar.gz tangerine-wallet-browser-2d13fac476cfbb7b0140611dca00fa95ee8d91ab.tar.bz2 tangerine-wallet-browser-2d13fac476cfbb7b0140611dca00fa95ee8d91ab.tar.lz tangerine-wallet-browser-2d13fac476cfbb7b0140611dca00fa95ee8d91ab.tar.xz tangerine-wallet-browser-2d13fac476cfbb7b0140611dca00fa95ee8d91ab.tar.zst tangerine-wallet-browser-2d13fac476cfbb7b0140611dca00fa95ee8d91ab.zip |
Add migration to move identities from KeyringController
Diffstat (limited to 'app/scripts/migrations/026.js')
-rw-r--r-- | app/scripts/migrations/026.js | 40 |
1 files changed, 40 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 +} |