This commit is contained in:
Josh Harvey 2017-03-15 22:54:40 +02:00
parent b4d8f3cd4c
commit 340b39d47d
9 changed files with 189 additions and 72 deletions

View file

@ -1,10 +1,18 @@
const _ = require('lodash/fp')
const BN = require('./bn')
const CashInTx = require('./cash-in-tx')
const CashOutTx = require('./cash-out-tx')
function post (tx, pi) {
if (tx.direction === 'cashIn') return CashInTx.post(tx, pi)
if (tx.direction === 'cashOut') throw new Error('not implemented')
const mtx = massage(tx)
if (mtx.direction === 'cashIn') return CashInTx.post(mtx, pi)
if (mtx.direction === 'cashOut') return CashOutTx.post(mtx, pi)
return Promise.reject(new Error('No such tx direction: %s', tx.direction))
return Promise.reject(new Error('No such tx direction: ' + mtx.direction))
}
function massage (tx) {
return _.assign(tx, {cryptoAtoms: BN(tx.cryptoAtoms), fiat: BN(tx.fiat)})
}
module.exports = {post}