WIPP
This commit is contained in:
parent
b4d8f3cd4c
commit
340b39d47d
9 changed files with 189 additions and 72 deletions
14
lib/tx.js
14
lib/tx.js
|
|
@ -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}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue