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, BCH, DASH, ETH, LTC, ZEC } = COINS
const CRYPTO = [BTC, ETH, LTC, DASH, ZEC, BCH]
const FIAT = ['USD', 'EUR']
const AMOUNT_PRECISION = 6
const REQUIRED_CONFIG_FIELDS = ['apiKey', 'privateKey']
const loadConfig = (account) => {
const mapper = {
@ -19,10 +20,4 @@ const loadConfig = (account) => {
const loadOptions = () => ({ expiretm: '+60' })
const isConfigValid = options => {
const requiredOptions = ['apiKey', 'privateKey']
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 }