fix undefined crypto scope
This commit is contained in:
parent
c2af183911
commit
3b35743bb5
2 changed files with 10 additions and 7 deletions
|
|
@ -55,10 +55,6 @@ function satisfiesRequire (config, cryptos, machineList, field, anyFields, allFi
|
|||
|
||||
const isValid = isRequired ? !isBlank : true
|
||||
|
||||
if (!isValid) {
|
||||
pp('DEBUG103')({fieldCode, isBlank, isRequired})
|
||||
}
|
||||
|
||||
return isValid
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -197,6 +197,8 @@ function cryptoCodeDefaults (schema, cryptoCode) {
|
|||
const hasCryptoSpecificDefault = r => r.cryptoScope === 'specific' && !_.isNil(r.default)
|
||||
const cryptoSpecificFields = _.filter(hasCryptoSpecificDefault, schemaEntries)
|
||||
|
||||
pp('DEBUG202')({scope, cryptoCode})
|
||||
|
||||
return _.map(r => {
|
||||
const defaultValue = cryptoDefaultOverride(cryptoCode, r.code, r.default)
|
||||
|
||||
|
|
@ -204,14 +206,19 @@ function cryptoCodeDefaults (schema, cryptoCode) {
|
|||
}, cryptoSpecificFields)
|
||||
}
|
||||
|
||||
const uniqCompact = _.flow(_.compact, _.uniq)
|
||||
|
||||
const pp = require('./pp')
|
||||
function addCryptoDefaults (oldConfig, newFields) {
|
||||
const cryptoCodeEntries = _.filter(v => v.fieldLocator.code === 'cryptoCurrencies', newFields)
|
||||
const cryptoCodes = _.map(_.get('fieldValue.value'), cryptoCodeEntries)
|
||||
const uniqueCryptoCodes = _.uniq(_.flatten(cryptoCodes))
|
||||
const cryptoCodes = _.flatMap(_.get('fieldValue.value'), cryptoCodeEntries)
|
||||
const uniqueCryptoCodes = uniqCompact(cryptoCodes)
|
||||
|
||||
const mapDefaults = cryptoCode => cryptoCodeDefaults(schema, cryptoCode)
|
||||
const defaults = _.flatten(_.map(mapDefaults, uniqueCryptoCodes))
|
||||
const defaults = _.flatMap(mapDefaults, uniqueCryptoCodes)
|
||||
|
||||
pp('DEBUG201')({cryptoCodeEntries, cryptoCodes, uniqueCryptoCodes})
|
||||
pp('DEBUG200')(defaults)
|
||||
return mergeValues(defaults, oldConfig)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue