fix: market currency migration

This commit is contained in:
Sérgio Salgado 2022-10-07 02:02:11 +01:00 committed by Rafael
parent 7f168859d8
commit 47c548c956
11 changed files with 25 additions and 22 deletions

View file

@ -5,16 +5,15 @@ const { ALL } = require('../lib/plugins/common/ccxt')
exports.up = function (next) {
return loadLatest()
.then(({ config, accounts }) => {
.then(({ accounts }) => {
const allExchanges = _.map(it => it.code)(_.filter(it => it.class === 'exchange', ACCOUNT_LIST))
const configuredExchanges = _.intersection(allExchanges, _.keys(accounts))
const localeCurrency = config.locale_fiatCurrency
const newAccounts = _.reduce(
(acc, value) => {
if (!_.isNil(accounts[value].currencyMarket)) return acc
if (_.includes(localeCurrency, ALL[value].FIAT)) return { ...acc, [value]: { currencyMarket: localeCurrency } }
return { ...acc, [value]: { currencyMarket: _.head(ALL[value].FIAT) } }
if (_.includes('EUR', ALL[value].FIAT)) return { ...acc, [value]: { currencyMarket: 'EUR' } }
return { ...acc, [value]: { currencyMarket: ALL[value].DEFAULT_FIAT_CURRENCY } }
},
{},
configuredExchanges