format for latest standard
This commit is contained in:
parent
4108efd9c7
commit
c2af183911
77 changed files with 1697 additions and 1693 deletions
|
|
@ -7,7 +7,7 @@ var db = pgp(psqlUrl)
|
|||
|
||||
db.manyOrNone(`select * from transactions where incoming=false
|
||||
and stage='final_request' and authority='machine'`)
|
||||
.then(rs =>
|
||||
.then(rs =>
|
||||
db.tx(t =>
|
||||
t.batch(rs.map(r => db.none(`insert into cash_in_txs (session_id,
|
||||
device_fingerprint, to_address, crypto_atoms, crypto_code, fiat,
|
||||
|
|
@ -17,10 +17,10 @@ db.manyOrNone(`select * from transactions where incoming=false
|
|||
r.tx_hash, r.error, r.created]))
|
||||
)
|
||||
)
|
||||
)
|
||||
.then(() => db.manyOrNone(`select * from transactions where incoming=true
|
||||
)
|
||||
.then(() => db.manyOrNone(`select * from transactions where incoming=true
|
||||
and stage='initial_request' and authority='pending'`))
|
||||
.then(rs =>
|
||||
.then(rs =>
|
||||
db.tx(t =>
|
||||
t.batch(rs.map(r => db.none(`insert into cash_out_txs (session_id,
|
||||
device_fingerprint, to_address, crypto_atoms, crypto_code, fiat,
|
||||
|
|
@ -30,10 +30,10 @@ db.manyOrNone(`select * from transactions where incoming=false
|
|||
r.tx_hash, r.phone, r.error, r.created]))
|
||||
)
|
||||
)
|
||||
)
|
||||
.then(() => db.manyOrNone(`select * from transactions where incoming=true
|
||||
)
|
||||
.then(() => db.manyOrNone(`select * from transactions where incoming=true
|
||||
and stage='dispense' and authority='authorized'`))
|
||||
.then(rs =>
|
||||
.then(rs =>
|
||||
db.tx(t =>
|
||||
t.batch(rs.map(r =>
|
||||
db.none(`update cash_out_txs set dispensed=true where session_id=$1`, [r.session_id])
|
||||
|
|
@ -41,10 +41,10 @@ db.manyOrNone(`select * from transactions where incoming=false
|
|||
created) values ($1, $2, $3)`, [r.session_id, 'dispensed', r.created]))
|
||||
))
|
||||
)
|
||||
)
|
||||
.then(() => pgp.end())
|
||||
.then(() => console.log('Success.'))
|
||||
.catch(e => {
|
||||
)
|
||||
.then(() => pgp.end())
|
||||
.then(() => console.log('Success.'))
|
||||
.catch(e => {
|
||||
console.log(e)
|
||||
pgp.end()
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ const settingsLoader = require('../lib/settings-loader')
|
|||
const pp = require('../lib/pp')
|
||||
|
||||
settingsLoader.loadLatest()
|
||||
.then(r => {
|
||||
.then(r => {
|
||||
pp('config')(r)
|
||||
process.exit(0)
|
||||
})
|
||||
.catch(e => {
|
||||
})
|
||||
.catch(e => {
|
||||
console.log(e.stack)
|
||||
process.exit(1)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ const psqlUrl = require('../lib/options').postgresql
|
|||
const db = pgp(psqlUrl)
|
||||
|
||||
db.many('select data from user_config', 'exchanges')
|
||||
.then(rows => {
|
||||
.then(rows => {
|
||||
const config = rows.filter(r => r.type === 'exchanges')[0].data
|
||||
const brain = rows.filter(r => r.type === 'unit')[0].data
|
||||
const settings = config.exchanges.settings
|
||||
|
|
@ -42,4 +42,4 @@ db.many('select data from user_config', 'exchanges')
|
|||
console.error('Error: %s', err)
|
||||
process.exit(1)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ const headers = {
|
|||
|
||||
const body = JSON.stringify({tx: tx})
|
||||
got('http://localhost:3000/dispense', {body: body, json: true, headers: headers})
|
||||
.then(res => {
|
||||
.then(res => {
|
||||
console.log(res.body)
|
||||
})
|
||||
.catch(console.log)
|
||||
})
|
||||
.catch(console.log)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ db.init(psqlUrl)
|
|||
notifier.init(db, getBalances, {lowBalanceThreshold: 10})
|
||||
console.log('DEBUG0')
|
||||
notifier.checkStatus()
|
||||
.then(function (alertRec) {
|
||||
.then(function (alertRec) {
|
||||
console.log('DEBUG1')
|
||||
console.log('%j', alertRec)
|
||||
var subject = notifier.alertSubject(alertRec)
|
||||
|
|
@ -24,8 +24,8 @@ notifier.checkStatus()
|
|||
console.log(body)
|
||||
console.log(notifier.alertFingerprint(alertRec))
|
||||
process.exit(0)
|
||||
})
|
||||
.catch(function (err) {
|
||||
})
|
||||
.catch(function (err) {
|
||||
console.log(err.stack)
|
||||
process.exit(1)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ var rec = {
|
|||
|
||||
var db = config.connection
|
||||
config.loadConfig(db)
|
||||
.then(function (config) {
|
||||
.then(function (config) {
|
||||
plugins.configure(config)
|
||||
plugins.sendMessage(rec)
|
||||
.then(function () {
|
||||
|
|
@ -26,4 +26,4 @@ config.loadConfig(db)
|
|||
.catch(function (err) {
|
||||
console.log(err.stack)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ const schemas = ph.loadSchemas()
|
|||
function fetchAccounts () {
|
||||
return db.oneOrNone('select data from user_config where type=$1', ['accounts'])
|
||||
.then(row => {
|
||||
|
||||
// Hard code this for now
|
||||
const accounts = [{
|
||||
code: 'blockcypher',
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ function getField (schema, group, fieldCode) {
|
|||
}
|
||||
|
||||
const fetchMachines = () => machineLoader.getMachines()
|
||||
.then(machineList => machineList.map(r => r.deviceId))
|
||||
.then(machineList => machineList.map(r => r.deviceId))
|
||||
|
||||
function validateCurrentConfig () {
|
||||
return fetchConfig()
|
||||
|
|
|
|||
|
|
@ -114,4 +114,3 @@ function run () {
|
|||
inquirer.prompt(questions)
|
||||
.then(answers => processCryptos(answers.crypto))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,4 +16,3 @@ function run () {
|
|||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -505,13 +505,23 @@ function plugins (settings, deviceId) {
|
|||
: null
|
||||
|
||||
const cassette1Alert = cashOutEnabled && device.cassette1 < config.cashOutCassette1AlertThreshold
|
||||
? {code: 'LOW_CASH_OUT', cassette: 1, machineName, deviceId: device.deviceId,
|
||||
notes: device.cassette1, denomination: denomination1, fiatCode}
|
||||
? {code: 'LOW_CASH_OUT',
|
||||
cassette: 1,
|
||||
machineName,
|
||||
deviceId: device.deviceId,
|
||||
notes: device.cassette1,
|
||||
denomination: denomination1,
|
||||
fiatCode}
|
||||
: null
|
||||
|
||||
const cassette2Alert = cashOutEnabled && device.cassette2 < config.cashOutCassette2AlertThreshold
|
||||
? {code: 'LOW_CASH_OUT', cassette: 2, machineName, deviceId: device.deviceId,
|
||||
notes: device.cassette2, denomination: denomination2, fiatCode}
|
||||
? {code: 'LOW_CASH_OUT',
|
||||
cassette: 2,
|
||||
machineName,
|
||||
deviceId: device.deviceId,
|
||||
notes: device.cassette2,
|
||||
denomination: denomination2,
|
||||
fiatCode}
|
||||
: null
|
||||
|
||||
return _.compact([cashInAlert, cassette1Alert, cassette2Alert])
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ const axios = require('axios')
|
|||
const BN = require('../../../bn')
|
||||
|
||||
function ticker (account, fiatCode, cryptoCode) {
|
||||
|
||||
return axios.get('https://bitpay.com/api/rates/' + cryptoCode + '/' + fiatCode)
|
||||
.then(r => {
|
||||
const data = r.data
|
||||
|
|
|
|||
|
|
@ -52,4 +52,3 @@ function ticker (account, fiatCode, cryptoCode) {
|
|||
module.exports = {
|
||||
ticker
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,4 +35,3 @@ function authorize (account, toAddress, cryptoAtoms, cryptoCode) {
|
|||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ function updateCustomer (req, res, next) {
|
|||
const patch = req.body
|
||||
customers.getById(id)
|
||||
.then(customer => {
|
||||
if (!customer) { throw httpError('Not Found', 404)}
|
||||
if (!customer) { throw httpError('Not Found', 404) }
|
||||
return customers.update(id, patch)
|
||||
})
|
||||
.then(customer => respond(req, res, {customer}))
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ const rawCountries = require('../raw-countries.json')
|
|||
const topCodes = ['US', 'GB', 'CA', 'AU']
|
||||
|
||||
const countries = rawCountries
|
||||
.map(r => ({code: r.cca2, display: r.name.common}))
|
||||
.map(r => ({code: r.cca2, display: r.name.common}))
|
||||
|
||||
const topCountries = topCodes.map(c => countries.find(_.matchesProperty('code', c)))
|
||||
const final = _.uniqBy(_.get('code'), _.concat(topCountries, countries))
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ const fields = [
|
|||
]
|
||||
|
||||
settingsLoader.modifyConfig(fields)
|
||||
.then(() => {
|
||||
.then(() => {
|
||||
console.log('success.')
|
||||
process.exit(0)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@ function dbFetchConfig () {
|
|||
}
|
||||
|
||||
dbFetchConfig()
|
||||
.then(config => {
|
||||
.then(config => {
|
||||
pp(config)
|
||||
process.exit(0)
|
||||
})
|
||||
.catch(e => {
|
||||
})
|
||||
.catch(e => {
|
||||
console.log(e)
|
||||
process.exit(1)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue