feat: relay trade uuid to krakens api

This commit is contained in:
José Oliveira 2021-04-19 21:00:56 +01:00 committed by Josh Harvey
parent bec80ec498
commit 8606d0cc94
6 changed files with 25 additions and 17 deletions

View file

@ -516,12 +516,16 @@ function plugins (settings, deviceId) {
const tradeEntry = expand(_tradeEntry)
const execute = tradeEntry.type === 'buy' ? exchange.buy : exchange.sell
return execute(settings, tradeEntry.cryptoAtoms, tradeEntry.fiatCode, tradeEntry.cryptoCode)
.then(() => recordTrade(tradeEntry))
.catch(err => {
return recordTrade(tradeEntry, err)
.then(() => {
throw err
return recordTrade(tradeEntry)
.then(newEntry => {
return execute(settings, tradeEntry.cryptoAtoms, tradeEntry.fiatCode, tradeEntry.cryptoCode, newEntry.id)
.catch(err => {
const data = mergeTradeEntryAndError(tradeEntry, err)
const sql = pgp.helpers.update(data, ['error'], 'trades') + ` WHERE id = ${newEntry.id}`
return db.none(sql)
.then(() => {
throw err
})
})
})
}
@ -577,7 +581,6 @@ function plugins (settings, deviceId) {
return t.oneOrNone(sql)
.then(newTrade => recordTradeAndTx(newTrade.id, _tradeEntry, t))
})
}
function sendMessage (rec) {
const notifications = configManager.getGlobalNotifications(settings.config)