fix no-exchange issue
This commit is contained in:
parent
a60a4f8793
commit
f23d17b357
7 changed files with 29 additions and 17 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -211,7 +211,8 @@
|
|||
"displayBottom": "Exchange",
|
||||
"fieldType": "account",
|
||||
"fieldClass": "exchange",
|
||||
"fieldValidation": []
|
||||
"fieldValidation": [],
|
||||
"default": "no-exchange"
|
||||
},
|
||||
{
|
||||
"code": "fiatCurrency",
|
||||
|
|
|
|||
|
|
@ -98,9 +98,9 @@ function fetchConfigGroup (code) {
|
|||
|
||||
return {
|
||||
schema: groupSchema,
|
||||
values: values,
|
||||
values,
|
||||
selectedCryptos: getCryptos(config, machineList),
|
||||
data: data
|
||||
data
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ function postProcess (txVector, pi) {
|
|||
return pi.buildAvailableCassettes(newTx.id)
|
||||
.then(cassettes => {
|
||||
const bills = billMath.makeChange(cassettes.cassettes, newTx.fiat)
|
||||
console.log('DEBUG130: %j', cassettes.cassettes)
|
||||
|
||||
if (!bills) throw httpError('Out of bills', INSUFFICIENT_FUNDS_CODE)
|
||||
return bills
|
||||
})
|
||||
|
|
|
|||
|
|
@ -29,8 +29,6 @@ function getMachineNames (config) {
|
|||
.then(([machines, config]) => {
|
||||
const addName = r => {
|
||||
const name = configManager.machineScoped(r.deviceId, config).machineName
|
||||
console.log('DEBUG200: %j', [name, r])
|
||||
console.log('DEBUG201: %j', configManager.machineScoped(r.deviceId, config))
|
||||
return _.set('name', name, r)
|
||||
}
|
||||
|
||||
|
|
@ -54,5 +52,3 @@ function setMachine (rec) {
|
|||
default: throw new Error('No such action: ' + rec.action)
|
||||
}
|
||||
}
|
||||
|
||||
console.log('DEBUG101')
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ function pullToken (token) {
|
|||
function configureNewDevice (deviceId, machineName, machineModel) {
|
||||
const scope = {crypto: 'global', machine: deviceId}
|
||||
const newFields = [
|
||||
settingsLoader.configAddField(scope, 'cashOutEnabled', false),
|
||||
settingsLoader.configAddField(scope, 'machineName', machineName),
|
||||
settingsLoader.configAddField(scope, 'machineModel', machineModel)
|
||||
settingsLoader.configAddField(scope, 'cashOutEnabled', 'onOff', null, false),
|
||||
settingsLoader.configAddField(scope, 'machineName', 'string', null, machineName),
|
||||
settingsLoader.configAddField(scope, 'machineModel', 'string', null, machineModel)
|
||||
]
|
||||
|
||||
return settingsLoader.modifyConfig(newFields)
|
||||
|
|
@ -26,7 +26,11 @@ function configureNewDevice (deviceId, machineName, machineModel) {
|
|||
|
||||
function removeDeviceConfig (deviceId) {
|
||||
const scope = {crypto: 'global', machine: deviceId}
|
||||
const newFields = [settingsLoader.configDeleteField(scope, 'cashOutEnabled', false)]
|
||||
const newFields = [
|
||||
settingsLoader.configDeleteField(scope, 'cashOutEnabled'),
|
||||
settingsLoader.configDeleteField(scope, 'machineName'),
|
||||
settingsLoader.configDeleteField(scope, 'machineModel')
|
||||
]
|
||||
|
||||
return settingsLoader.modifyConfig(newFields)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,16 +139,18 @@ function save (config) {
|
|||
.catch(() => db.none(sql, ['config', {config}, false]))
|
||||
}
|
||||
|
||||
function configAddField (scope, fieldCode, value) {
|
||||
function configAddField (scope, fieldCode, fieldType, fieldClass, value) {
|
||||
return {
|
||||
fieldLocator: {
|
||||
fieldScope: {
|
||||
crypto: scope.crypto,
|
||||
machine: scope.machine
|
||||
},
|
||||
code: fieldCode
|
||||
code: fieldCode,
|
||||
fieldType,
|
||||
fieldClass
|
||||
},
|
||||
fieldValue: {value}
|
||||
fieldValue: {fieldType, value}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue