fix: verify config field existance and content
This commit is contained in:
parent
a8085f3f1d
commit
0c0ca09b4e
5 changed files with 15 additions and 25 deletions
|
|
@ -1,7 +1,7 @@
|
|||
const _ = require('lodash/fp')
|
||||
const ccxt = require('ccxt')
|
||||
|
||||
const { toUnit } = require('../../coin-utils')
|
||||
const { toUnit, isConfigValid } = require('../../coin-utils')
|
||||
const { buildMarket, ALL } = require('../common/ccxt')
|
||||
const { ORDER_TYPES } = require('./consts')
|
||||
|
||||
|
|
@ -13,8 +13,8 @@ function trade (side, account, cryptoAtoms, fiatCode, cryptoCode, exchangeName)
|
|||
const exchangeConfig = ALL[exchangeName]
|
||||
if (!exchangeConfig) throw Error('Exchange configuration not found')
|
||||
|
||||
const { loadOptions, loadConfig = _.noop, isConfigValid, ORDER_TYPE, AMOUNT_PRECISION } = exchangeConfig
|
||||
if (_.isFunction(isConfigValid) && !isConfigValid(account)) throw Error('Invalid config')
|
||||
const { loadOptions, loadConfig = _.noop, REQUIRED_CONFIG_FIELDS, ORDER_TYPE, AMOUNT_PRECISION } = exchangeConfig
|
||||
if (!isConfigValid(account, REQUIRED_CONFIG_FIELDS)) throw Error('Invalid config')
|
||||
|
||||
const symbol = buildMarket(fiatCode, cryptoCode, exchangeName)
|
||||
const precision = _.defaultTo(DEFAULT_AMOUNT_PRECISION, AMOUNT_PRECISION)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue