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 } = COINS
const CRYPTO = [BTC, ETH]
const FIAT = ['USD']
const AMOUNT_PRECISION = 4
const REQUIRED_CONFIG_FIELDS = ['clientKey', 'clientSecret', 'userId', 'walletId']
const loadConfig = (account) => {
const mapper = {
@ -20,10 +21,4 @@ const loadConfig = (account) => {
}
const loadOptions = ({ walletId }) => ({ walletId })
const isConfigValid = options => {
const requiredOptions = ['clientKey', 'clientSecret', 'userId', 'walletId']
const givenOptions = _.pick(requiredOptions, options)
return _.isEqual(_.keys(givenOptions), requiredOptions)
}
module.exports = { loadOptions, loadConfig, isConfigValid, CRYPTO, FIAT, ORDER_TYPE, AMOUNT_PRECISION }
module.exports = { loadOptions, loadConfig, REQUIRED_CONFIG_FIELDS, CRYPTO, FIAT, ORDER_TYPE, AMOUNT_PRECISION }