Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tax report ccy conversion #402

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 23 additions & 18 deletions workers/loc.api/sync/transaction.tax.report/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict'

const { setTimeout } = require('node:timers/promises')

const INTERRUPTER_NAMES = require(
'bfx-report/workers/loc.api/interrupter/interrupter.names'
)
Expand Down Expand Up @@ -460,28 +462,31 @@ class TransactionTaxReport {
const getDataFn = this.rService[this.SYNC_API_METHODS.PUBLIC_TRADES]
.bind(this.rService)

const { res } = await this.getDataFromApi({
getData: (s, args) => getDataFn(args),
args,
callerName: 'TRANSACTION_TAX_REPORT',
eNetErrorAttemptsTimeframeMin: 10,
eNetErrorAttemptsTimeoutMs: 10000,
interrupter
})
for (let i = 0; i < 6; i += 1) {
const { res } = await this.getDataFromApi({
getData: (s, args) => getDataFn(args),
args,
callerName: 'TRANSACTION_TAX_REPORT',
eNetErrorAttemptsTimeframeMin: 10,
eNetErrorAttemptsTimeoutMs: 10000,
interrupter
})

const pubTrades = Array.isArray(res)
? res
: []
if (isTestEnv) {
/*
* Need to reverse pub-trades array for test env
* as mocked test server return data in desc order
*/
return res.reverse()
}
if (Array.isArray(res)) {
return res
}

if (isTestEnv) {
/*
* Need to reverse pub-trades array for test env
* as mocked test server return data in desc order
*/
return pubTrades.reverse()
await setTimeout(10000)
}

return pubTrades
return []
}

async #updateExactUsdValueInColls (trxs) {
Expand Down