From d210b4e7ef60d9c1d6b884ff6ff4d76abae8924e Mon Sep 17 00:00:00 2001 From: Viktor Voronin Date: Fri, 15 Nov 2019 15:14:02 +0300 Subject: [PATCH] DEXW-2351: remove legacy user settings during migration --- src/modules/app/services/DefaultSettings.js | 4 ++++ src/modules/app/services/StorageExporter.js | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/modules/app/services/DefaultSettings.js b/src/modules/app/services/DefaultSettings.js index 364a140765..be42905f07 100644 --- a/src/modules/app/services/DefaultSettings.js +++ b/src/modules/app/services/DefaultSettings.js @@ -193,6 +193,10 @@ return Object.prototype.hasOwnProperty.call(this.commonDefaults, start); } + getDefaultSettings() { + return this.defaults; + } + } return { diff --git a/src/modules/app/services/StorageExporter.js b/src/modules/app/services/StorageExporter.js index 47d78d0047..f70fb4e00a 100644 --- a/src/modules/app/services/StorageExporter.js +++ b/src/modules/app/services/StorageExporter.js @@ -1,12 +1,15 @@ (function () { 'use strict'; + const { pickBy, hasIn } = require('ramda'); + class StorageExporter { static $inject = [ '$log', 'storage', - 'multiAccount' + 'multiAccount', + 'defaultSettings' ]; /** @@ -14,10 +17,11 @@ * @param {app.utils.Storage} storage * @param {app.MultiAccount} multiAccount */ - constructor($log, storage, multiAccount) { + constructor($log, storage, multiAccount, defaultSettings) { this.$log = $log; this.storage = storage; this.multiAccount = multiAccount; + this.defaultSettings = defaultSettings; } /** @@ -49,6 +53,13 @@ } } + const predicate = (value, key) => hasIn(key, this.defaultSettings.create().getDefaultSettings()); + + for (const user of Object.values(storageData.userList)) { + delete user.settings.encryptionRounds; + user.settings = pickBy(predicate)(user.settings); + } + return this.multiAccount.export(privateKeyFrom, publicKeyTo, storageData); }