fix no-exchange issue

This commit is contained in:
Josh Harvey 2017-05-10 23:05:19 +03:00
parent a60a4f8793
commit f23d17b357
7 changed files with 29 additions and 17 deletions

View file

@ -1,5 +1,6 @@
#!/usr/bin/env node
const assert = require('assert')
const _ = require('lodash/fp')
// const db = require('../lib/db')
@ -7,6 +8,10 @@ const settingsLoader = require('../lib/settings-loader')
const schema = require('../lamassu-schema.json')
const newFields = []
const DEFAULT_CRYPTO = _.first(_.find(['code', 'cryptoCurrencies'], schema.fields).default)
assert(DEFAULT_CRYPTO)
Promise.resolve()
.then(() => {
schema.groups.forEach(group => {
@ -14,12 +19,16 @@ Promise.resolve()
const field = schema.fields.find(r => r.code === fieldCode)
if (!field) throw new Error('No such field: ' + fieldCode)
if (_.isNil(field.default)) return
if (group.cryptoScope === 'specific' || group.machineScope === 'specific') return
if (group.machineScope === 'specific') return
const crypto = group.cryptoScope === 'specific'
? DEFAULT_CRYPTO
: 'global'
return newFields.push({
fieldLocator: {
fieldScope: {
crypto: 'global',
crypto,
machine: 'global'
},
code: fieldCode,