fix: verify config field existance and content

This commit is contained in:
José Oliveira 2021-05-13 16:13:27 +01:00 committed by Josh Harvey
parent a8085f3f1d
commit 0c0ca09b4e
5 changed files with 15 additions and 25 deletions

View file

@ -8,6 +8,7 @@ const { BTC, ETH, LTC, BCH } = COINS
const CRYPTO = [BTC, ETH, LTC, BCH]
const FIAT = ['USD', 'EUR']
const AMOUNT_PRECISION = 8
const REQUIRED_CONFIG_FIELDS = ['key', 'secret', 'clientId']
const loadConfig = (account) => {
const mapper = {
@ -18,10 +19,4 @@ const loadConfig = (account) => {
return { ...mapped, timeout: 3000 }
}
const isConfigValid = options => {
const requiredOptions = ['key', 'secret', 'clientId']
const givenOptions = _.pick(requiredOptions, options)
return _.isEqual(_.keys(givenOptions), requiredOptions)
}
module.exports = { loadConfig, isConfigValid, CRYPTO, FIAT, ORDER_TYPE, AMOUNT_PRECISION }
module.exports = { loadConfig, REQUIRED_CONFIG_FIELDS, CRYPTO, FIAT, ORDER_TYPE, AMOUNT_PRECISION }