From 312347199a6c9e108f7f6ca40ea434f6882a7cd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Oliveira?= Date: Thu, 28 Oct 2021 18:04:43 +0100 Subject: [PATCH] fix: replace getAllCryptoCurrencies function --- .../1623975493095-add-crypto-units-to-config.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/migrations/1623975493095-add-crypto-units-to-config.js b/migrations/1623975493095-add-crypto-units-to-config.js index 743850c0..512e14df 100644 --- a/migrations/1623975493095-add-crypto-units-to-config.js +++ b/migrations/1623975493095-add-crypto-units-to-config.js @@ -1,5 +1,5 @@ const { saveConfig, loadLatest } = require('../lib/new-settings-loader') -const { getAllCryptoCurrencies } = require('../lib/new-config-manager.js') +const { getCryptosFromWalletNamespace } = require('../lib/new-config-manager.js') const { utils: coinUtils } = require('lamassu-coins') const _ = require('lodash/fp') @@ -7,14 +7,13 @@ exports.up = function (next) { loadLatest() .then(settings => { const newSettings = {} - const activeCryptos = getAllCryptoCurrencies(settings.config) - if (_.head(activeCryptos)) { - _.map(crypto => { - const defaultUnit = _.head(_.keys(coinUtils.getCryptoCurrency(crypto).units)) - newSettings[`wallets_${crypto}_cryptoUnits`] = defaultUnit - return newSettings - }, activeCryptos) - } + const activeCryptos = getCryptosFromWalletNamespace(settings.config) + if (!activeCryptos.length) return Promise.resolve() + _.map(crypto => { + const defaultUnit = _.head(_.keys(coinUtils.getCryptoCurrency(crypto).units)) + newSettings[`wallets_${crypto}_cryptoUnits`] = defaultUnit + return newSettings + }, activeCryptos) return saveConfig(newSettings) }) .then(() => next())