Merge pull request #1320 from chaotixkilla/fix-remove-coin-specific-unit-fields

Remove coin-specific cryptounits from config
This commit is contained in:
Rafael Taranto 2022-08-01 09:55:06 +01:00 committed by GitHub
commit 1d0f3cd27c
4 changed files with 37 additions and 13 deletions

View file

@ -112,6 +112,17 @@ function saveConfig (config) {
})
}
function removeFromConfig (fields) {
return Promise.all([loadLatestConfigOrNone(), getOperatorId('middleware')])
.then(([currentConfig, operatorId]) => {
const newConfig = _.omit(fields, currentConfig)
return db.tx(t => {
return t.none(configSql, ['config', { config: newConfig }, true, NEW_SETTINGS_LOADER_SCHEMA_VERSION])
.then(() => t.none('NOTIFY $1:name, $2', ['reload', JSON.stringify({ schema: asyncLocalStorage.getStore().get('schema'), operatorId })]))
}).catch(console.error)
})
}
function migrationSaveConfig (config) {
return loadLatestConfigOrNone()
.then(currentConfig => {
@ -221,5 +232,6 @@ module.exports = {
loadLatestConfig,
loadLatestConfigOrNone,
load,
migrate
migrate,
removeFromConfig
}