v12.0.0 - initial commit
This commit is contained in:
commit
e2c49ea43c
1145 changed files with 97211 additions and 0 deletions
36
packages/server/migrations/1732874039534-market-currency.js
Normal file
36
packages/server/migrations/1732874039534-market-currency.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
const _ = require('lodash/fp')
|
||||
const { loadAccounts, saveAccounts } = require('./settings')
|
||||
const { ACCOUNT_LIST } = require('../lib/new-admin/config/accounts')
|
||||
const { ALL } = require('../lib/plugins/common/ccxt')
|
||||
|
||||
exports.up = function (next) {
|
||||
return loadAccounts()
|
||||
.then(accounts => {
|
||||
const allExchanges = _.map(it => it.code)(
|
||||
_.filter(it => it.class === 'exchange', ACCOUNT_LIST),
|
||||
)
|
||||
const configuredExchanges = _.intersection(allExchanges, _.keys(accounts))
|
||||
|
||||
const newAccounts = _.reduce(
|
||||
(acc, value) => {
|
||||
if (!_.isNil(accounts[value].currencyMarket)) return acc
|
||||
if (_.includes('EUR', ALL[value].FIAT))
|
||||
return { ...acc, [value]: { currencyMarket: 'EUR' } }
|
||||
return {
|
||||
...acc,
|
||||
[value]: { currencyMarket: ALL[value].DEFAULT_FIAT_CURRENCY },
|
||||
}
|
||||
},
|
||||
{},
|
||||
configuredExchanges,
|
||||
)
|
||||
|
||||
return saveAccounts(newAccounts)
|
||||
})
|
||||
.then(next)
|
||||
.catch(next)
|
||||
}
|
||||
|
||||
module.exports.down = function (next) {
|
||||
next()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue