Merge pull request #766 from josepfo/feat/crypto-units-selector
feat: advanced wallet settings
This commit is contained in:
commit
0881d00594
9 changed files with 222 additions and 47 deletions
28
migrations/1623975493095-add-crypto-units-to-config.js
Normal file
28
migrations/1623975493095-add-crypto-units-to-config.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
const { saveConfig, loadLatest } = require('../lib/new-settings-loader')
|
||||
const { getCryptosFromWalletNamespace } = require('../lib/new-config-manager.js')
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
exports.up = function (next) {
|
||||
loadLatest()
|
||||
.then(settings => {
|
||||
const newSettings = {}
|
||||
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())
|
||||
.catch(err => {
|
||||
console.log(err.message)
|
||||
return next(err)
|
||||
})
|
||||
}
|
||||
|
||||
exports.down = function (next) {
|
||||
next()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue