Merge pull request #1142 from josepfo/fix/kraken-trade-error
fix: trade promises chain errors
This commit is contained in:
commit
a6d0d608c7
2 changed files with 6 additions and 3 deletions
|
|
@ -617,7 +617,10 @@ function plugins (settings, deviceId) {
|
||||||
const sql = pgp.helpers.insert(tradeEntry, null, 'trades') + 'RETURNING *'
|
const sql = pgp.helpers.insert(tradeEntry, null, 'trades') + 'RETURNING *'
|
||||||
return db.tx(t => {
|
return db.tx(t => {
|
||||||
return t.oneOrNone(sql)
|
return t.oneOrNone(sql)
|
||||||
.then(newTrade => recordTradeAndTx(newTrade.id, _tradeEntry, t))
|
.then(newTrade => {
|
||||||
|
return recordTradeAndTx(newTrade.id, _tradeEntry, t)
|
||||||
|
.then(() => newTrade)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
const { toUnit } = require('@lamassu/coins')
|
const { utils: coinUtils } = require('@lamassu/coins')
|
||||||
const _ = require('lodash/fp')
|
const _ = require('lodash/fp')
|
||||||
const ccxt = require('ccxt')
|
const ccxt = require('ccxt')
|
||||||
|
|
||||||
|
|
@ -19,7 +19,7 @@ function trade (side, account, tradeEntry, exchangeName) {
|
||||||
|
|
||||||
const symbol = buildMarket(fiatCode, cryptoCode, exchangeName)
|
const symbol = buildMarket(fiatCode, cryptoCode, exchangeName)
|
||||||
const precision = _.defaultTo(DEFAULT_AMOUNT_PRECISION, AMOUNT_PRECISION)
|
const precision = _.defaultTo(DEFAULT_AMOUNT_PRECISION, AMOUNT_PRECISION)
|
||||||
const amount = toUnit(cryptoAtoms, cryptoCode).toFixed(precision)
|
const amount = coinUtils.toUnit(cryptoAtoms, cryptoCode).toFixed(precision)
|
||||||
const accountOptions = _.isFunction(loadOptions) ? loadOptions(account) : {}
|
const accountOptions = _.isFunction(loadOptions) ? loadOptions(account) : {}
|
||||||
const withCustomKey = USER_REF ? { [USER_REF]: tradeId } : {}
|
const withCustomKey = USER_REF ? { [USER_REF]: tradeId } : {}
|
||||||
const options = _.assign(accountOptions, withCustomKey)
|
const options = _.assign(accountOptions, withCustomKey)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue