diff --git a/lib/config-migration.js b/lib/config-migration.js index defac75d..2cffa11e 100644 --- a/lib/config-migration.js +++ b/lib/config-migration.js @@ -5,6 +5,7 @@ const { scopedValue } = require('./admin/config-manager') const GLOBAL = 'global' const ALL_CRYPTOS = _.values(COINS).sort() +const ALL_CRYPTOS_STRING = 'ALL_COINS' const ALL_MACHINES = 'ALL_MACHINES' const GLOBAL_SCOPE = { @@ -66,7 +67,7 @@ function getConfigFields (codes, config) { } function migrateCommissions (config) { - const areArraysEquals = (arr1, arr2) => _.isEmpty(_.xor(arr1, arr2)) + const areArraysEquals = (arr1, arr2) => Array.isArray(arr1) && Array.isArray(arr2) && _.isEmpty(_.xor(arr1, arr2)) const getMachine = _.get('scope.machine') const getCrypto = _.get('scope.crypto') const flattenCoins = _.compose(_.flatten, _.map(getCrypto)) @@ -116,7 +117,7 @@ function migrateCommissions (config) { commissions_overrides: allCommissionsOverrides.map(s => ({ ..._.fromPairs(s.values.map(f => [codes[f.code], f.value])), machine: s.scope.machine === GLOBAL ? ALL_MACHINES : s.scope.machine, - cryptoCurrencies: s.scope.crypto, + cryptoCurrencies: areArraysEquals(s.scope.crypto, ALL_CRYPTOS) ? [ALL_CRYPTOS_STRING] : s.scope.crypto, id: uuid.v4() })) }) diff --git a/lib/new-settings-loader.js b/lib/new-settings-loader.js index ab435c18..916c6c5b 100644 --- a/lib/new-settings-loader.js +++ b/lib/new-settings-loader.js @@ -42,7 +42,6 @@ function loadAccounts (schemaVersion) { const configSql = 'insert into user_config (type, data, valid, schema_version) values ($1, $2, $3, $4)' function saveConfig (config) { - console.log(config) return loadLatestConfigOrNone() .then(currentConfig => { const newConfig = _.assign(currentConfig, config)