fix: pre release screen fixes
This commit is contained in:
parent
1bcc87757b
commit
5dd8501a17
98 changed files with 1569 additions and 1149 deletions
|
|
@ -28,7 +28,7 @@ function post (machineTx, pi) {
|
|||
.then(([{ config }, blacklistItems]) => {
|
||||
// TODO new-admin: addressReuse doesnt exist
|
||||
// const rejectAddressReuseActive = configManager.unscoped(config).rejectAddressReuseActive
|
||||
const rejectAddressReuseActive = true
|
||||
const rejectAddressReuseActive = false
|
||||
|
||||
if (_.some(it => it.created_by_operator === true)(blacklistItems)) {
|
||||
blacklisted = true
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ function mapCoin (rates, deviceId, settings, cryptoCode) {
|
|||
|
||||
const cashInFee = showCommissions ? commissions.cashIn / 100 : null
|
||||
const cashOutFee = showCommissions ? commissions.cashOut / 100 : null
|
||||
const cashInFixedFee = showCommissions ? commissions.fixedFee : null
|
||||
const cashInRate = showCommissions ? _.invoke('cashIn.toNumber', buildedRates) : null
|
||||
const cashOutRate = showCommissions ? _.invoke('cashOut.toNumber', buildedRates) : null
|
||||
|
||||
|
|
@ -77,6 +78,7 @@ function mapMachine (rates, settings, machineRow) {
|
|||
|
||||
// TODO new-admin: this is relaying info with backwards compatible triggers
|
||||
// need to get in touch with coinatmradar before updating this
|
||||
// TODO all directions and max between them instead of min
|
||||
const cashLimit = showLimitsAndVerification ? (
|
||||
!!compatTriggers.block
|
||||
? compatTriggers.block
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
const _ = require('lodash/fp')
|
||||
|
||||
function getBackwardsCompatibleTriggers (triggers) {
|
||||
const filtered = _.filter(_.matches({ triggerType: 'volume', cashDirection: 'both' }))(triggers)
|
||||
const filtered = _.filter(_.matches({ triggerType: 'amount', cashDirection: 'both' }))(triggers)
|
||||
const grouped = _.groupBy(_.prop('requirement'))(filtered)
|
||||
return _.mapValues(_.compose(_.get('threshold'), _.minBy('threshold')))(grouped)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -456,7 +456,7 @@ function getCustomerById (id) {
|
|||
row_number() over (partition by c.id order by t.created desc) as rn,
|
||||
count(0) over (partition by c.id) as total_txs,
|
||||
sum(t.fiat) over (partition by c.id) as total_spent
|
||||
from customers c inner join (
|
||||
from customers c left outer join (
|
||||
select 'cashIn' as tx_class, id, fiat, fiat_code, created, customer_id
|
||||
from cash_in_txs where send_confirmed = true union
|
||||
select 'cashOut' as tx_class, id, fiat, fiat_code, created, customer_id
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const pgp = Pgp({
|
|||
if (e.cn) logger.error('Database not reachable.')
|
||||
if (e.query) {
|
||||
logger.error(e.query)
|
||||
logger.error(e.params)
|
||||
e.params && logger.error(e.params)
|
||||
}
|
||||
logger.error(err)
|
||||
}
|
||||
|
|
@ -21,11 +21,12 @@ const db = pgp(psqlUrl)
|
|||
|
||||
eventBus.subscribe('log', args => {
|
||||
const { level, message, meta } = args
|
||||
const msgToSave = message ? message : _.get('message', meta)
|
||||
|
||||
const sql = `insert into server_logs
|
||||
(id, device_id, message, log_level, meta) values ($1, $2, $3, $4, $5) returning *`
|
||||
|
||||
db.one(sql, [uuid.v4(), '', message, level, meta])
|
||||
db.one(sql, [uuid.v4(), '', msgToSave, level, meta])
|
||||
.then(_.mapKeys(_.camelCase))
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
const _ = require('lodash/fp')
|
||||
const axios = require('axios')
|
||||
|
||||
const logger = require('./logger')
|
||||
const db = require('./db')
|
||||
const pairing = require('./pairing')
|
||||
const configManager = require('./new-config-manager')
|
||||
|
|
@ -15,8 +16,10 @@ function getMachines () {
|
|||
cashbox: r.cashbox,
|
||||
cassette1: r.cassette1,
|
||||
cassette2: r.cassette2,
|
||||
pairedAt: new Date(r.created).valueOf(),
|
||||
lastPing: new Date(r.last_online).valueOf(),
|
||||
version: r.version,
|
||||
model: r.model,
|
||||
pairedAt: new Date(r.created),
|
||||
lastPing: new Date(r.last_online),
|
||||
name: r.name,
|
||||
// TODO: we shall start using this JSON field at some point
|
||||
// location: r.location,
|
||||
|
|
@ -36,19 +39,12 @@ function getMachineNames (config) {
|
|||
const addName = r => {
|
||||
const cashOutConfig = configManager.getCashOut(r.deviceId, config)
|
||||
|
||||
const cashOut = cashOutConfig.active
|
||||
const cashOut = !!cashOutConfig.active
|
||||
|
||||
// TODO new-admin: these two fields were not ever working
|
||||
const machineModel = ''
|
||||
const machineLocation = ''
|
||||
|
||||
// TODO: obtain next fields from somewhere
|
||||
const printer = null
|
||||
const pingTime = null
|
||||
// TODO new-admin actually load status based on ping.
|
||||
const statuses = [{label: 'Unknown detailed status', type: 'warning'}]
|
||||
const softwareVersion = ''
|
||||
|
||||
return _.assign(r, {cashOut, machineModel, machineLocation, printer, pingTime, statuses, softwareVersion})
|
||||
return _.assign(r, {cashOut, statuses})
|
||||
}
|
||||
|
||||
return _.map(addName, machines)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
const _ = require('lodash/fp')
|
||||
const { COINS, ALL_CRYPTOS } = require('./coins')
|
||||
|
||||
const { BTC, BCH, DASH, ETH, LTC, ZEC } = COINS
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ const configManager = require('../new-config-manager')
|
|||
const wallet = require('../wallet')
|
||||
const ticker = require('../ticker')
|
||||
const coinUtils = require('../coin-utils')
|
||||
const logger = require('../logger')
|
||||
|
||||
function allScopes (cryptoScopes, machineScopes) {
|
||||
const scopes = []
|
||||
|
|
@ -68,6 +69,9 @@ function getSingleCoinFunding (settings, fiatCode, cryptoCode) {
|
|||
})
|
||||
}
|
||||
|
||||
// Promise.allSettled not running on current version of node
|
||||
const reflect = p => p.then(value => ({value, status: "fulfilled" }), error => ({error: error.toString(), status: "rejected" }))
|
||||
|
||||
function getFunding () {
|
||||
return settingsLoader.loadLatest().then(settings => {
|
||||
const cryptoCodes = configManager.getAllCryptoCurrencies(settings.config)
|
||||
|
|
@ -77,9 +81,10 @@ function getFunding () {
|
|||
const cryptoDisplays = _.filter(pareCoins, cryptoCurrencies)
|
||||
|
||||
const promises = cryptoDisplays.map(it => getSingleCoinFunding(settings, fiatCode, it.cryptoCode))
|
||||
return Promise.all(promises)
|
||||
return Promise.all(promises.map(reflect))
|
||||
.then((response) => {
|
||||
return _.toArray(_.merge(response, cryptoDisplays))
|
||||
const mapped = response.map(it => _.merge({ errorMsg: it.error }, it.value))
|
||||
return _.toArray(_.merge(mapped, cryptoDisplays))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ const serverLogs = require('../server-logs')
|
|||
const pairing = require('../pairing')
|
||||
const { accounts: accountsConfig, coins, countries, currencies, languages } = require('../config')
|
||||
|
||||
// TODO why does server logs messages can be null?
|
||||
const typeDefs = gql`
|
||||
scalar JSON
|
||||
scalar JSONObject
|
||||
|
|
@ -54,6 +53,10 @@ const typeDefs = gql`
|
|||
name: String!
|
||||
deviceId: ID!
|
||||
paired: Boolean!
|
||||
lastPing: Date
|
||||
pairedAt: Date
|
||||
version: String
|
||||
model: String
|
||||
cashbox: Int
|
||||
cassette1: Int
|
||||
cassette2: Int
|
||||
|
|
@ -123,21 +126,22 @@ const typeDefs = gql`
|
|||
|
||||
type CoinFunds {
|
||||
cryptoCode: String!
|
||||
fundingAddress: String!
|
||||
fundingAddressUrl: String!
|
||||
confirmedBalance: String!
|
||||
pending: String!
|
||||
fiatConfirmedBalance: String!
|
||||
fiatPending: String!
|
||||
fiatCode: String!
|
||||
display: String!
|
||||
unitScale: String!
|
||||
errorMsg: String
|
||||
fundingAddress: String
|
||||
fundingAddressUrl: String
|
||||
confirmedBalance: String
|
||||
pending: String
|
||||
fiatConfirmedBalance: String
|
||||
fiatPending: String
|
||||
fiatCode: String
|
||||
display: String
|
||||
unitScale: String
|
||||
}
|
||||
|
||||
type ProcessStatus {
|
||||
name: String!
|
||||
state: String!
|
||||
uptime: Date!
|
||||
uptime: Int!
|
||||
}
|
||||
|
||||
type Transaction {
|
||||
|
|
@ -156,6 +160,7 @@ const typeDefs = gql`
|
|||
created: Date
|
||||
send: Boolean
|
||||
sendConfirmed: Boolean
|
||||
dispense: Boolean
|
||||
timedout: Boolean
|
||||
sendTime: Date
|
||||
errorCode: String
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@ const xmlrpc = require('xmlrpc')
|
|||
const logger = require('../logger')
|
||||
const { promisify } = require('util')
|
||||
|
||||
// TODO new-admin: add the following to supervisor config
|
||||
// [inet_http_server]
|
||||
// port = 127.0.0.1:9001
|
||||
|
||||
function getAllProcessInfo () {
|
||||
const convertStates = (state) => {
|
||||
// From http://supervisord.org/subprocess.html#process-states
|
||||
|
|
@ -45,7 +49,7 @@ function getAllProcessInfo () {
|
|||
{
|
||||
name: process.name,
|
||||
state: convertStates(process.statename),
|
||||
uptime: (process.statename === 'RUNNING') ? new Date(process.now) - new Date(process.start) : 0
|
||||
uptime: (process.statename === 'RUNNING') ? process.now - process.start : 0
|
||||
}
|
||||
))
|
||||
})
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ const FileAsync = require('lowdb/adapters/FileAsync')
|
|||
const adapter = new FileAsync('db.json')
|
||||
let db = null
|
||||
|
||||
// TODO new-admin save to actual db, like the old settings
|
||||
low(adapter).then(it => {
|
||||
db = it
|
||||
})
|
||||
|
|
@ -54,6 +55,7 @@ function loadLatest () {
|
|||
})
|
||||
}
|
||||
|
||||
// TODO new-admin: grab correct version
|
||||
function load (versionId) {
|
||||
return new Promise((resolve) => {
|
||||
if (!db) {
|
||||
|
|
|
|||
|
|
@ -185,7 +185,6 @@ function plugins (settings, deviceId) {
|
|||
const commissions = configManager.getCommissions(cryptoCode, deviceId, settings.config)
|
||||
const minimumTx = BN(commissions.minimumTx)
|
||||
const cashInFee = BN(commissions.fixedFee)
|
||||
logger.info('FEE', cashInFee)
|
||||
const cashInCommission = BN(commissions.cashIn)
|
||||
const cashOutCommission = _.isNumber(commissions.cashOut) ? BN(commissions.cashOut) : null
|
||||
const cryptoRec = coinUtils.getCryptoCurrency(cryptoCode)
|
||||
|
|
@ -201,7 +200,7 @@ function plugins (settings, deviceId) {
|
|||
}
|
||||
}
|
||||
|
||||
function pollQueries (serialNumber, deviceTime, deviceRec) {
|
||||
function pollQueries (serialNumber, deviceTime, deviceRec, machineVersion, machineModel) {
|
||||
const localeConfig = configManager.getLocale(deviceId, settings.config)
|
||||
|
||||
const fiatCode = localeConfig.fiatCurrency
|
||||
|
|
@ -210,7 +209,7 @@ function plugins (settings, deviceId) {
|
|||
const tickerPromises = cryptoCodes.map(c => ticker.getRates(settings, fiatCode, c))
|
||||
const balancePromises = cryptoCodes.map(c => fiatBalance(fiatCode, c))
|
||||
const testnetPromises = cryptoCodes.map(c => wallet.cryptoNetwork(settings, c))
|
||||
const pingPromise = recordPing(deviceTime)
|
||||
const pingPromise = recordPing(deviceTime, machineVersion, machineModel)
|
||||
const currentConfigVersionPromise = fetchCurrentConfigVersion()
|
||||
|
||||
const promises = [
|
||||
|
|
@ -244,8 +243,10 @@ function plugins (settings, deviceId) {
|
|||
return wallet.sendCoins(settings, tx.toAddress, tx.cryptoAtoms, tx.cryptoCode)
|
||||
}
|
||||
|
||||
function recordPing (deviceTime) {
|
||||
function recordPing (deviceTime, version, model) {
|
||||
const devices = {
|
||||
version,
|
||||
model,
|
||||
last_online: deviceTime
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ const logger = require('./logger')
|
|||
const configManager = require('./new-config-manager')
|
||||
const complianceTriggers = require('./compliance-triggers')
|
||||
const pairing = require('./pairing')
|
||||
// TODO new-admin: remove old settings loader from here.
|
||||
const newSettingsLoader = require('./new-settings-loader')
|
||||
const plugins = require('./plugins')
|
||||
const helpers = require('./route-helpers')
|
||||
|
|
@ -51,6 +50,8 @@ function checkHasLightning (settings) {
|
|||
|
||||
function poll (req, res, next) {
|
||||
const machineVersion = req.query.version
|
||||
// TODO new-admin: pass this field from the machines
|
||||
const machineModel = req.query.model
|
||||
const deviceId = req.deviceId
|
||||
const deviceTime = req.deviceTime
|
||||
const serialNumber = req.query.sn
|
||||
|
|
@ -64,13 +65,12 @@ function poll (req, res, next) {
|
|||
const compatTriggers = complianceTriggers.getBackwardsCompatibleTriggers(triggers)
|
||||
|
||||
const operatorInfo = configManager.getOperatorInfo(settings.config)
|
||||
const terms = configManager.getTermsConditions(settings.config)
|
||||
const cashOutConfig = configManager.getCashOut(deviceId, settings.config)
|
||||
const receipt = configManager.getReceipt(settings.config)
|
||||
|
||||
pids[deviceId] = { pid, ts: Date.now() }
|
||||
|
||||
return pi.pollQueries(serialNumber, deviceTime, req.query)
|
||||
return pi.pollQueries(serialNumber, deviceTime, req.query, machineVersion, machineModel)
|
||||
.then(results => {
|
||||
const cassettes = results.cassettes
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ function poll (req, res, next) {
|
|||
sanctionsVerificationThreshold: compatTriggers.sancations,
|
||||
frontCameraVerificationActive: !!compatTriggers.facephoto,
|
||||
frontCameraVerificationThreshold: compatTriggers.facephoto,
|
||||
receiptPrintingActive: receipt.active,
|
||||
receiptPrintingActive: receipt.active === "on",
|
||||
cassettes,
|
||||
twoWayMode: cashOutConfig.active,
|
||||
zeroConfLimit: cashOutConfig.zeroConfLimit,
|
||||
|
|
@ -389,7 +389,7 @@ const localApp = express()
|
|||
app.use(compression({ threshold: 500 }))
|
||||
app.use(helmet({ noCache: true }))
|
||||
app.use(bodyParser.json({ limit: '2mb' }))
|
||||
app.use(morgan('dev', { skip, stream: logger.stream }))
|
||||
app.use(morgan(':method :url :status :response-time ms - :res[content-length]', { stream: logger.stream }))
|
||||
|
||||
// These two have their own authorization
|
||||
app.post('/pair', populateDeviceId, pair)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ function _getRates (settings, fiatCode, cryptoCode) {
|
|||
const config = settings.config
|
||||
const plugin = configManager.getWalletSettings(cryptoCode, config).ticker
|
||||
|
||||
logger.info(plugin)
|
||||
const account = settings.accounts[plugin]
|
||||
const ticker = ph.load(ph.TICKER, plugin)
|
||||
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ function mergeStatusMode (a, b) {
|
|||
}
|
||||
|
||||
function getWalletStatus (settings, tx) {
|
||||
const fudgeFactorEnabled = configManager.unscoped(settings.config).fudgeFactorActive
|
||||
const fudgeFactorEnabled = configManager.getWalletSettings(tx.cryptoCode, settings.config).fudgeFactorActive
|
||||
const fudgeFactor = fudgeFactorEnabled ? 100 : 0
|
||||
|
||||
const walletStatusPromise = fetchWallet(settings, tx.cryptoCode)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue