chore: re-add feature missing from merge
This commit is contained in:
parent
956b5bfca6
commit
abbcda793b
8 changed files with 67 additions and 20 deletions
|
|
@ -20,7 +20,8 @@ const stripDefaultDbFuncs = dbCtx => {
|
|||
manyOrNone: dbCtx.$manyOrNone,
|
||||
tx: dbCtx.$tx,
|
||||
task: dbCtx.$task,
|
||||
batch: dbCtx.batch
|
||||
batch: dbCtx.batch,
|
||||
multi: dbCtx.$multi
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -67,6 +68,7 @@ const pgp = Pgp({
|
|||
obj.$one = (query, variables) => obj.__taskEx(t => t.one(query, variables))
|
||||
obj.$none = (query, variables) => obj.__taskEx(t => t.none(query, variables))
|
||||
obj.$any = (query, variables) => obj.__taskEx(t => t.any(query, variables))
|
||||
obj.$multi = (query, variables) => obj.__taskEx(t => t.multi(query, variables))
|
||||
// when opts is not defined "cb" occupies the "opts" spot of the arguments
|
||||
obj.$tx = (opts, cb) => typeof opts === 'function' ? _tx(obj, {}, opts) : _tx(obj, opts, cb)
|
||||
obj.$task = (opts, cb) => typeof opts === 'function' ? _task(obj, {}, opts) : _task(obj, opts, cb)
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ const resolvers = {
|
|||
Query: {
|
||||
transactions: (...[, { from, until, limit, offset, deviceId, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status }]) =>
|
||||
transactions.batch(from, until, limit, offset, deviceId, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status),
|
||||
transactionsCsv: (...[, { from, until, limit, offset, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status, timezone }]) =>
|
||||
transactions.batch(from, until, limit, offset, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status)
|
||||
transactionsCsv: (...[, { from, until, limit, offset, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status, timezone, simplified }]) =>
|
||||
transactions.batch(from, until, limit, offset, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status, simplified)
|
||||
.then(data => parseAsync(logDateFormat(timezone, data, ['created', 'sendTime']), { fields: txLogFields })),
|
||||
transactionCsv: (...[, { id, txClass, timezone }]) =>
|
||||
transactions.getTx(id, txClass).then(data =>
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ const typeDef = gql`
|
|||
|
||||
type Query {
|
||||
transactions(from: Date, until: Date, limit: Int, offset: Int, deviceId: ID, txClass: String, machineName: String, customerName: String, fiatCode: String, cryptoCode: String, toAddress: String, status: String): [Transaction] @auth
|
||||
transactionsCsv(from: Date, until: Date, limit: Int, offset: Int, txClass: String, machineName: String, customerName: String, fiatCode: String, cryptoCode: String, toAddress: String, status: String, timezone: String): String @auth
|
||||
transactionsCsv(from: Date, until: Date, limit: Int, offset: Int, txClass: String, machineName: String, customerName: String, fiatCode: String, cryptoCode: String, toAddress: String, status: String, timezone: String, simplified: Boolean): String @auth
|
||||
transactionCsv(id: ID, txClass: String, timezone: String): String @auth
|
||||
txAssociatedDataCsv(id: ID, txClass: String, timezone: String): String @auth
|
||||
transactionFilters: [Filter] @auth
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@ function batch (
|
|||
fiatCode = null,
|
||||
cryptoCode = null,
|
||||
toAddress = null,
|
||||
status = null
|
||||
status = null,
|
||||
simplified = false
|
||||
) {
|
||||
const packager = _.flow(_.flatten, _.orderBy(_.property('created'), ['desc']), _.map(camelize), addNames)
|
||||
|
||||
|
|
@ -99,6 +100,55 @@ function batch (
|
|||
db.any(cashOutSql, [REDEEMABLE_AGE, from, until, limit, offset, id, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status])
|
||||
])
|
||||
.then(packager)
|
||||
.then(res => {
|
||||
if (simplified) return simplifiedBatch(res)
|
||||
else return res
|
||||
})
|
||||
}
|
||||
|
||||
function simplifiedBatch (data) {
|
||||
const fields = ['txClass', 'id', 'created', 'machineName',
|
||||
'cryptoCode', 'fiat', 'fiatCode', 'phone', 'toAddress',
|
||||
'txHash', 'dispense', 'error', 'status', 'fiatProfit', 'cryptoAmount']
|
||||
|
||||
const addSimplifiedFields = _.map(it => ({
|
||||
...it,
|
||||
status: getStatus(it),
|
||||
fiatProfit: getProfit(it).toString(),
|
||||
cryptoAmount: getCryptoAmount(it)
|
||||
}))
|
||||
|
||||
return _.compose(_.map(_.pick(fields)), addSimplifiedFields)(data)
|
||||
}
|
||||
|
||||
const getCryptoAmount = it => coinUtils.toUnit(BN(it.cryptoAtoms), it.cryptoCode).toString()
|
||||
|
||||
const getProfit = it => {
|
||||
const getCommissionFee = it => BN(it.commissionPercentage).mul(BN(it.fiat))
|
||||
if (!it.cashInFee) return getCommissionFee(it)
|
||||
return getCommissionFee(it).add(BN(it.cashInFee))
|
||||
}
|
||||
|
||||
const getCashOutStatus = it => {
|
||||
if (it.hasError) return 'Error'
|
||||
if (it.dispense) return 'Success'
|
||||
if (it.expired) return 'Expired'
|
||||
return 'Pending'
|
||||
}
|
||||
|
||||
const getCashInStatus = it => {
|
||||
if (it.operatorCompleted) return 'Cancelled'
|
||||
if (it.hasError) return 'Error'
|
||||
if (it.sendConfirmed) return 'Sent'
|
||||
if (it.expired) return 'Expired'
|
||||
return 'Pending'
|
||||
}
|
||||
|
||||
const getStatus = it => {
|
||||
if (it.txClass === 'cashOut') {
|
||||
return getCashOutStatus(it)
|
||||
}
|
||||
return getCashInStatus(it)
|
||||
}
|
||||
|
||||
function getCustomerTransactionsBatch (ids) {
|
||||
|
|
|
|||
16
new-lamassu-admin/package-lock.json
generated
16
new-lamassu-admin/package-lock.json
generated
|
|
@ -17157,7 +17157,7 @@
|
|||
"version": "git+https://github.com/lamassu/lamassu-coins.git#f80395e4bab0fccc860de166c97e981ca3ae66a6",
|
||||
"from": "git+https://github.com/lamassu/lamassu-coins.git",
|
||||
"requires": {
|
||||
"bech32": "^1.1.3",
|
||||
"bech32": "2.0.0",
|
||||
"bignumber.js": "^9.0.0",
|
||||
"bitcoinjs-lib": "4.0.3",
|
||||
"bs58check": "^2.0.2",
|
||||
|
|
@ -17165,6 +17165,13 @@
|
|||
"crypto-js": "^3.1.9-1",
|
||||
"ethereumjs-icap": "^0.3.1",
|
||||
"lodash": "^4.17.10"
|
||||
},
|
||||
"dependencies": {
|
||||
"bech32": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/bech32/-/bech32-2.0.0.tgz",
|
||||
"integrity": "sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"language-subtag-registry": {
|
||||
|
|
@ -18301,13 +18308,6 @@
|
|||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"nan": {
|
||||
"version": "2.14.2",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.2.tgz",
|
||||
"integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"nano-css": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/nano-css/-/nano-css-5.3.0.tgz",
|
||||
|
|
|
|||
|
|
@ -3,10 +3,9 @@ import { makeStyles } from '@material-ui/core/styles'
|
|||
import BigNumber from 'bignumber.js'
|
||||
import React from 'react'
|
||||
|
||||
import MachineActions from 'src/components/machineActions/MachineActions'
|
||||
|
||||
// import { Status } from 'src/components/Status'
|
||||
// import { ReactComponent as LinkIcon } from 'src/styling/icons/button/link/zodiac.svg'
|
||||
import MachineActions from 'src/components/machineActions/MachineActions'
|
||||
import { modelPrettifier } from 'src/utils/machine'
|
||||
import { formatDate } from 'src/utils/timezones'
|
||||
|
||||
|
|
|
|||
|
|
@ -8,12 +8,8 @@ import { ReactComponent as BitcoinCashLogo } from 'src/styling/logos/icon-bitcoi
|
|||
import { ReactComponent as DashLogo } from 'src/styling/logos/icon-dash-colour.svg'
|
||||
import { ReactComponent as EthereumLogo } from 'src/styling/logos/icon-ethereum-colour.svg'
|
||||
import { ReactComponent as LitecoinLogo } from 'src/styling/logos/icon-litecoin-colour.svg'
|
||||
<<<<<<< HEAD
|
||||
import { ReactComponent as TetherLogo } from 'src/styling/logos/icon-tether-colour.svg'
|
||||
import { ReactComponent as ZCashLogo } from 'src/styling/logos/icon-zcash-colour.svg'
|
||||
=======
|
||||
import { ReactComponent as ZcashLogo } from 'src/styling/logos/icon-zcash-colour.svg'
|
||||
>>>>>>> 8daa184b (chore: order coins alphabetically, bch logo green)
|
||||
|
||||
const styles = {
|
||||
logo: {
|
||||
|
|
|
|||
2
package-lock.json
generated
2
package-lock.json
generated
|
|
@ -14372,7 +14372,7 @@
|
|||
"version": "git+https://github.com/lamassu/lamassu-coins.git#de843fb210ad8adfa29a0441796125fcb0ab3b67",
|
||||
"from": "git+https://github.com/lamassu/lamassu-coins.git",
|
||||
"requires": {
|
||||
"bech32": "^1.1.3",
|
||||
"bech32": "2.0.0",
|
||||
"bignumber.js": "^9.0.0",
|
||||
"bitcoinjs-lib": "4.0.3",
|
||||
"bs58check": "^2.0.2",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue