From 00c1a4059c406973fe199761f8f27026888ee719 Mon Sep 17 00:00:00 2001 From: Gustavo Inacio Date: Wed, 18 Dec 2024 19:18:40 +0100 Subject: [PATCH] common: fix return in filter and to_timestamp query Signed-off-by: Gustavo Inacio --- packages/indexer-common/src/allocations/__tests__/tap.test.ts | 4 ++-- packages/indexer-common/src/allocations/tap-collector.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/indexer-common/src/allocations/__tests__/tap.test.ts b/packages/indexer-common/src/allocations/__tests__/tap.test.ts index 64707cdbc..b096a9220 100644 --- a/packages/indexer-common/src/allocations/__tests__/tap.test.ts +++ b/packages/indexer-common/src/allocations/__tests__/tap.test.ts @@ -313,7 +313,7 @@ describe('TAP', () => { redeemedAt: null, } await queryFeeModels.receiptAggregateVouchers.create(rav2) - let ravs = await tapCollector['pendingRAVs']() + const ravs = await tapCollector['pendingRAVs']() await tapCollector['markRavsInTransactionsAsRedeemed'](transactions, ravs) const redeemedRavs = await queryFeeModels.receiptAggregateVouchers.findAll({ where: { @@ -326,7 +326,7 @@ describe('TAP', () => { }) // Expect redeemed rav to be returned here expect(redeemedRavs).toEqual([ - expect.objectContaining({ ...rav2, redeemedAt: nowSecs }), + expect.objectContaining({ ...rav2, redeemedAt: new Date(nowSecs * 1000) }), ]) }) diff --git a/packages/indexer-common/src/allocations/tap-collector.ts b/packages/indexer-common/src/allocations/tap-collector.ts index 486b11a81..40f83c4f3 100644 --- a/packages/indexer-common/src/allocations/tap-collector.ts +++ b/packages/indexer-common/src/allocations/tap-collector.ts @@ -384,7 +384,7 @@ export class TapCollector { // transactions for different senders with the same allocation id .filter((tx) => { // check if exists in the ravsLastNotFinal list - !!ravsLastNotFinal.find( + return !!ravsLastNotFinal.find( (rav) => // rav has the same sender address as tx toAddress(rav.senderAddress) === toAddress(tx.sender.id) && @@ -695,7 +695,7 @@ export class TapCollector { // https://github.com/sequelize/sequelize/issues/7664 (bug been open for 7 years no fix yet or ever) const query = ` UPDATE scalar_tap_ravs - SET redeemed_at = ${timestamp ? timestamp : 'NOW()'} + SET redeemed_at = ${timestamp ? `to_timestamp(${timestamp})` : 'NOW()'} WHERE allocation_id = '${allocationId .toString() .toLowerCase()