Feat: migration rename non blockcypher to none

This commit is contained in:
csrapr 2021-04-15 18:56:31 +01:00 committed by Josh Harvey
parent 8f648cca8e
commit cd3f8aea51
2 changed files with 30 additions and 1 deletions

View file

@ -104,6 +104,13 @@ const getGlobalNotifications = config => getNotifications(null, null, config)
const getTriggers = _.get('triggers')
const split = _.curry(_.split)
const splitGetFirst = _.compose(_.head, split('_'))
const getCryptosFromWalletNamespace = config => {
return _.uniq(_.map(splitGetFirst, _.keys(fromNamespace('wallets', config))))
}
module.exports = {
getWalletSettings,
getOperatorInfo,
@ -118,5 +125,6 @@ module.exports = {
getTermsConditions,
getAllCryptoCurrencies,
getTriggers,
getCashOut
getCashOut,
getCryptosFromWalletNamespace
}

View file

@ -0,0 +1,21 @@
const _ = require('lodash/fp')
const settingsLoader = require('../lib/new-settings-loader')
const configManager = require('../lib/new-config-manager')
exports.up = async function (next) {
const { config } = await settingsLoader.loadLatest()
const cryptoCodes = configManager.getCryptosFromWalletNamespace(config)
_.forEach(cryptoCode => {
const key = `wallets_${cryptoCode}_zeroConf`
const zeroConfSetting = _.get(key, config)
if (cryptoCode === 'BTC' && zeroConfSetting === 'blockcypher') return
if (!_.isNil(zeroConfSetting) && zeroConfSetting !== 'none') {
config[key] = 'none'
}
}, cryptoCodes)
return settingsLoader.saveConfig(config).then(() => next()).catch(err => next(err))
}
exports.down = function (next) {
next()
}