refactor: move config validator from coin utils to ccxt common

This commit is contained in:
José Oliveira 2021-05-13 22:46:47 +01:00 committed by Josh Harvey
parent 0c0ca09b4e
commit 047b5752b7
3 changed files with 9 additions and 9 deletions

View file

@ -67,7 +67,7 @@ const CRYPTO_CURRENCIES = [
}
]
module.exports = { buildUrl, cryptoDir, blockchainDir, configPath, cryptoCurrencies, getCryptoCurrency, toUnit, isConfigValid }
module.exports = { buildUrl, cryptoDir, blockchainDir, configPath, cryptoCurrencies, getCryptoCurrency, toUnit }
function getCryptoCurrency (cryptoCode) {
const cryptoCurrency = _.find(['cryptoCode', cryptoCode], CRYPTO_CURRENCIES)
@ -109,8 +109,3 @@ function toUnit (cryptoAtoms, cryptoCode) {
const unitScale = cryptoRec.unitScale
return cryptoAtoms.shift(-unitScale)
}
function isConfigValid (config, fields) {
const values = _.map(it => _.get(it)(config))(fields)
return _.every(it => it || it === 0)(values)
}

View file

@ -34,4 +34,9 @@ function verifyFiatSupport (fiatCode, serviceName) {
return fiat === 'ALL_CURRENCIES' ? true : _.includes(fiatCode, fiat)
}
module.exports = { buildMarket, ALL, verifyFiatSupport }
function isConfigValid (config, fields) {
const values = _.map(it => _.get(it)(config))(fields)
return _.every(it => it || it === 0)(values)
}
module.exports = { buildMarket, ALL, verifyFiatSupport, isConfigValid }

View file

@ -1,8 +1,8 @@
const _ = require('lodash/fp')
const ccxt = require('ccxt')
const { toUnit, isConfigValid } = require('../../coin-utils')
const { buildMarket, ALL } = require('../common/ccxt')
const { toUnit } = require('../../coin-utils')
const { buildMarket, ALL, isConfigValid } = require('../common/ccxt')
const { ORDER_TYPES } = require('./consts')
const DEFAULT_PRICE_PRECISION = 2