cashEnabled bug fixes
This commit is contained in:
parent
54611f6c17
commit
b6568baa5c
3 changed files with 9 additions and 4 deletions
|
|
@ -36,7 +36,7 @@ function generalScoped (crypto, machine, config) {
|
||||||
const keys = R.uniq(R.map(r => r.fieldLocator.code, config))
|
const keys = R.uniq(R.map(r => r.fieldLocator.code, config))
|
||||||
const keyedValues = keys.map(key => scopedValue(key, allScopes(key)))
|
const keyedValues = keys.map(key => scopedValue(key, allScopes(key)))
|
||||||
|
|
||||||
return R.fromPairs(keys, keyedValues)
|
return R.zipObj(keys, keyedValues)
|
||||||
}
|
}
|
||||||
|
|
||||||
function machineScoped (machine, config) {
|
function machineScoped (machine, config) {
|
||||||
|
|
|
||||||
|
|
@ -50,9 +50,10 @@ function buildRates (deviceId, tickers) {
|
||||||
const settings = settingsLoader.settings()
|
const settings = settingsLoader.settings()
|
||||||
const config = configManager.machineScoped(deviceId, settings.config)
|
const config = configManager.machineScoped(deviceId, settings.config)
|
||||||
const cryptoCodes = config.cryptoCurrencies
|
const cryptoCodes = config.cryptoCurrencies
|
||||||
|
const cashOut = config.cashOutEnabled
|
||||||
|
|
||||||
const cashInCommission = new BigNumber(config.cashInCommission).div(100).plus(1)
|
const cashInCommission = new BigNumber(config.cashInCommission).div(100).plus(1)
|
||||||
const cashOutCommission = new BigNumber(config.cashOutCommission).div(100).plus(1)
|
const cashOutCommission = cashOut && new BigNumber(config.cashOutCommission).div(100).plus(1)
|
||||||
|
|
||||||
const rates = {}
|
const rates = {}
|
||||||
|
|
||||||
|
|
@ -62,7 +63,7 @@ function buildRates (deviceId, tickers) {
|
||||||
const rate = rateRec.rates
|
const rate = rateRec.rates
|
||||||
rates[cryptoCode] = {
|
rates[cryptoCode] = {
|
||||||
cashIn: rate.ask.times(cashInCommission),
|
cashIn: rate.ask.times(cashInCommission),
|
||||||
cashOut: rate.bid.div(cashOutCommission)
|
cashOut: cashOut ? rate.bid.div(cashOutCommission) : undefined
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -395,6 +396,7 @@ function executeTrades () {
|
||||||
const config = configManager.machineScoped(deviceId, settings.config)
|
const config = configManager.machineScoped(deviceId, settings.config)
|
||||||
const fiatCode = config.fiatCurrency
|
const fiatCode = config.fiatCurrency
|
||||||
const cryptoCodes = config.cryptoCurrencies
|
const cryptoCodes = config.cryptoCurrencies
|
||||||
|
|
||||||
return cryptoCodes.map(cryptoCode => ({fiatCode, cryptoCode}))
|
return cryptoCodes.map(cryptoCode => ({fiatCode, cryptoCode}))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ const pids = {}
|
||||||
const reboots = {}
|
const reboots = {}
|
||||||
|
|
||||||
function poll (req, res, next) {
|
function poll (req, res, next) {
|
||||||
|
console.log('DEBUG77')
|
||||||
const deviceId = req.deviceId
|
const deviceId = req.deviceId
|
||||||
const deviceTime = req.deviceTime
|
const deviceTime = req.deviceTime
|
||||||
const pid = req.query.pid
|
const pid = req.query.pid
|
||||||
|
|
@ -54,7 +55,7 @@ function poll (req, res, next) {
|
||||||
idVerificationEnabled: config.idVerificationEnabled,
|
idVerificationEnabled: config.idVerificationEnabled,
|
||||||
smsVerificationEnabled: config.smsVerificationEnabled,
|
smsVerificationEnabled: config.smsVerificationEnabled,
|
||||||
cartridges,
|
cartridges,
|
||||||
twoWayMode: !!cartridges,
|
twoWayMode: config.cashOutEnabled,
|
||||||
zeroConfLimit: config.zeroConfLimit,
|
zeroConfLimit: config.zeroConfLimit,
|
||||||
fiatTxLimit: config.cashOutTransactionLimit,
|
fiatTxLimit: config.cashOutTransactionLimit,
|
||||||
reboot,
|
reboot,
|
||||||
|
|
@ -142,11 +143,13 @@ function ca (req, res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function pair (req, res, next) {
|
function pair (req, res, next) {
|
||||||
|
console.log('DEBUG100')
|
||||||
const token = req.query.token
|
const token = req.query.token
|
||||||
const deviceId = req.deviceId
|
const deviceId = req.deviceId
|
||||||
|
|
||||||
return pairing.pair(token, deviceId)
|
return pairing.pair(token, deviceId)
|
||||||
.then(valid => {
|
.then(valid => {
|
||||||
|
console.log('DEBUG102')
|
||||||
if (valid) return res.end()
|
if (valid) return res.end()
|
||||||
throw httpError('Pairing failed')
|
throw httpError('Pairing failed')
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue