WIP routes
This commit is contained in:
parent
a9ded1ddf2
commit
b6dc94cb12
1 changed files with 20 additions and 16 deletions
|
|
@ -19,13 +19,12 @@ const STALE_BALANCE = 3 * 60 * 1000
|
||||||
const pids = {}
|
const pids = {}
|
||||||
const reboots = {}
|
const reboots = {}
|
||||||
|
|
||||||
function buildRates () {
|
function buildRates (deviceId) {
|
||||||
const cryptoCodes = plugins.getcryptoCodes()
|
const cryptoCodes = plugins.getcryptoCodes()
|
||||||
const config = plugins.getConfig()
|
const config = plugins.getConfig(deviceId)
|
||||||
const settings = config.exchanges.settings
|
|
||||||
|
|
||||||
const cashInCommission = settings.commission
|
const cashInCommission = config.commissions.cashInCommission
|
||||||
const cashOutCommission = settings.fiatCommission || cashInCommission
|
const cashOutCommission = config.commissions.cashOutCommission
|
||||||
|
|
||||||
const rates = {}
|
const rates = {}
|
||||||
cryptoCodes.forEach(cryptoCode => {
|
cryptoCodes.forEach(cryptoCode => {
|
||||||
|
|
@ -68,36 +67,41 @@ function poll (req, res) {
|
||||||
let rates = {}
|
let rates = {}
|
||||||
let balances = {}
|
let balances = {}
|
||||||
|
|
||||||
rates = buildRates()
|
rates = buildRates(deviceId)
|
||||||
balances = buildBalances()
|
balances = buildBalances()
|
||||||
|
|
||||||
const config = plugins.getConfig()
|
const config = plugins.getConfig(deviceId)
|
||||||
const settings = config.exchanges.settings
|
|
||||||
const complianceSettings = settings.compliance
|
|
||||||
|
|
||||||
plugins.pollQueries(deviceId)
|
plugins.pollQueries(deviceId)
|
||||||
.then(results => {
|
.then(results => {
|
||||||
const cartridges = results.cartridges
|
const cartridges = results.cartridges
|
||||||
|
|
||||||
const reboot = reboots[deviceId] === pid
|
const reboot = reboots[deviceId] === pid
|
||||||
|
const langs = config.languages.machineLanguages
|
||||||
|
|
||||||
|
const locale = {
|
||||||
|
currency: config.fiat.fiatCurrency,
|
||||||
|
primaryLocale: langs[0],
|
||||||
|
primaryLocales: langs
|
||||||
|
}
|
||||||
|
|
||||||
const response = {
|
const response = {
|
||||||
err: null,
|
err: null,
|
||||||
locale: config.brain.locale,
|
locale,
|
||||||
txLimit: parseInt(complianceSettings.maximum.limit, 10),
|
txLimit: config.limits.cashInTransactionLimit,
|
||||||
idVerificationEnabled: complianceSettings.idVerificationEnabled,
|
idVerificationEnabled: config.compliance.idVerificationEnabled,
|
||||||
cartridges,
|
cartridges,
|
||||||
twoWayMode: !!cartridges,
|
twoWayMode: !!cartridges,
|
||||||
zeroConfLimit: settings.zeroConfLimit,
|
zeroConfLimit: config.commissions.zeroConfLimit,
|
||||||
fiatTxLimit: settings.fiatTxLimit,
|
fiatTxLimit: config.limits.cashOutTransactionLimit,
|
||||||
reboot,
|
reboot,
|
||||||
rates,
|
rates,
|
||||||
balances,
|
balances,
|
||||||
coins: settings.coins
|
coins: config.cryptos.cryptos
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.idVerificationEnabled) {
|
if (response.idVerificationEnabled) {
|
||||||
response.idVerificationLimit = complianceSettings.idVerificationLimit
|
response.idVerificationLimit = config.compliance.idVerificationLimit
|
||||||
}
|
}
|
||||||
|
|
||||||
res.json(response)
|
res.json(response)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue