diff --git a/src/integration/blockchain/icp/icp-wallet.ts b/src/integration/blockchain/icp/icp-wallet.ts index 81e3e12651..3802572edd 100644 --- a/src/integration/blockchain/icp/icp-wallet.ts +++ b/src/integration/blockchain/icp/icp-wallet.ts @@ -41,6 +41,6 @@ export class InternetComputerWallet { } getAgent(host: string): HttpAgent { - return HttpAgent.createSync({ identity: this.identity, host }); + return HttpAgent.createSync({ identity: this.identity, host, shouldSyncTime: true }); } } diff --git a/src/subdomains/core/history/services/history.service.ts b/src/subdomains/core/history/services/history.service.ts index df3e21667b..d5f8b0e082 100644 --- a/src/subdomains/core/history/services/history.service.ts +++ b/src/subdomains/core/history/services/history.service.ts @@ -129,7 +129,13 @@ export class HistoryService { query.limit, query.offset, ) - : await this.transactionService.getTransactionsForUsers([user.id], query.from, query.to, query.limit); + : await this.transactionService.getTransactionsForUsers( + [user.id], + query.from, + query.to, + query.limit, + query.offset, + ); const all = query.buy == null && query.sell == null && query.staking == null && query.ref == null && query.lm == null; diff --git a/src/subdomains/core/liquidity-management/adapters/actions/base/ccxt-exchange.adapter.ts b/src/subdomains/core/liquidity-management/adapters/actions/base/ccxt-exchange.adapter.ts index 5c07b697a2..593b09a121 100644 --- a/src/subdomains/core/liquidity-management/adapters/actions/base/ccxt-exchange.adapter.ts +++ b/src/subdomains/core/liquidity-management/adapters/actions/base/ccxt-exchange.adapter.ts @@ -298,13 +298,18 @@ export abstract class CcxtExchangeAdapter extends LiquidityActionAdapter { const token = asset ?? targetAsset.dexName; const withdrawal = await this.exchangeService.getWithdraw(correlationId, token); - if (!withdrawal?.txid) { - this.logger.verbose( - `No withdrawal id for id ${correlationId} and asset ${token} at ${this.exchangeService.name} found`, - ); + if (!withdrawal) { + this.logger.verbose(`No withdrawal for id ${correlationId} and asset ${token} at ${this.exchangeService.name}`); + return false; + } + + if (withdrawal.status === 'failed') { + throw new OrderFailedException(`Withdrawal ${correlationId} has failed`); + } + + if (!withdrawal.txid) { + this.logger.verbose(`No txid yet for withdrawal ${correlationId} at ${this.exchangeService.name}`); return false; - } else if (withdrawal.status === 'failed') { - throw new OrderFailedException(`Withdrawal TX ${withdrawal.txid} has failed`); } order.outputAmount = withdrawal.amount; @@ -409,13 +414,20 @@ export abstract class CcxtExchangeAdapter extends LiquidityActionAdapter { const { target } = this.parseTransferParams(paramMap); const withdrawal = await this.exchangeService.getWithdraw(correlationId, targetAsset.dexName); - if (!withdrawal?.txid) { + if (!withdrawal) { this.logger.verbose( - `No withdrawal id for id ${correlationId} and asset ${targetAsset.dexName} at ${this.exchangeService.name} found`, + `No withdrawal for id ${correlationId} and asset ${targetAsset.dexName} at ${this.exchangeService.name}`, ); return false; - } else if (withdrawal.status === 'failed') { - throw new OrderFailedException(`Withdrawal TX ${withdrawal.txid} has failed`); + } + + if (withdrawal.status === 'failed') { + throw new OrderFailedException(`Withdrawal ${correlationId} has failed`); + } + + if (!withdrawal.txid) { + this.logger.verbose(`No txid yet for withdrawal ${correlationId} at ${this.exchangeService.name}`); + return false; } order.outputAmount = withdrawal.amount; diff --git a/src/subdomains/supporting/payment/services/transaction.service.ts b/src/subdomains/supporting/payment/services/transaction.service.ts index 917f2237f1..a76b1ef746 100644 --- a/src/subdomains/supporting/payment/services/transaction.service.ts +++ b/src/subdomains/supporting/payment/services/transaction.service.ts @@ -182,6 +182,7 @@ export class TransactionService { return this.repo.find({ where: { userData: { id: userDataId }, type: Not(IsNull()), created: Between(from, to) }, relations: { + userData: { country: true }, buyCrypto: { buy: true, cryptoRoute: true, @@ -206,6 +207,7 @@ export class TransactionService { from = new Date(0), to = new Date(), limit?: number, + offset?: number, ): Promise { return Util.doInBatchesWithLimit( userIds, @@ -213,6 +215,7 @@ export class TransactionService { this.repo.find({ where: { user: { id: In(batch) }, type: Not(IsNull()), created: Between(from, to) }, relations: { + userData: { country: true }, buyCrypto: { buy: true, cryptoRoute: true, @@ -224,7 +227,9 @@ export class TransactionService { buyFiat: { sell: true, cryptoInput: true, bankTx: true, fiatOutput: true }, refReward: true, }, + order: { created: 'DESC' }, take: remaining, + skip: offset, }), 100, limit,