This commit is contained in:
Josh Harvey 2016-05-06 14:11:57 +03:00
parent f91992e20d
commit 11b5958c60
4 changed files with 77 additions and 19 deletions

View file

@ -735,15 +735,28 @@ exports.fetchPhoneTx = function fetchPhoneTx (phone) {
.then(txs => {
const authorizedTxs = txs.filter(tx => tx.authorized)
if (authorizedTxs.length > 0) {
return R.reduce((acc, val) => {
const maxTx = R.reduce((acc, val) => {
!acc || val.cryptoAtoms.gt(acc.cryptoAtoms) ? val : acc
}, null, authorizedTxs)
return {tx: maxTx}
}
if (txs.length > 0) {
// pending txs
}
// no txs for this number
if (txs.length > 0) return {pending: true}
return {}
})
}
exports.fetchTx = function fetchTx (session, status) {
return db.fetchTx(session)
.then(txRecs => {
const deposits = txRecs.filter(t => t.stage === 'deposit')
const deposit = R.last(deposits)
const status = deposit ? deposit.authority : 'notSeen'
const tx = txRecs.find(t => t.stage === 'initial_request')
if (!tx) return null
return R.assoc('status', status, tx)
})
}
exports.fetchTx = function fetchTx (session, status) {