From 7ab017521922a78ce4c4ad6c6a06cb9620862433 Mon Sep 17 00:00:00 2001 From: Michal Zielenkiewicz Date: Thu, 3 Oct 2024 11:48:56 +0200 Subject: [PATCH] Increase before param to avoid exclusive filtering in Nexus --- src/app/hooks/useListBeforeDate.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/app/hooks/useListBeforeDate.ts b/src/app/hooks/useListBeforeDate.ts index 068cd7e6f0..0e3c561377 100644 --- a/src/app/hooks/useListBeforeDate.ts +++ b/src/app/hooks/useListBeforeDate.ts @@ -3,6 +3,15 @@ import { Layer, useGetRuntimeStatus, useGetStatus } from '../../oasis-nexus/api' import { AppError, AppErrors } from 'types/errors' import { SearchScope } from 'types/searchScope' +function addOneSecond(timestamp: string | undefined) { + if (!timestamp) { + return undefined + } + const date = new Date(timestamp) + date.setSeconds(date.getSeconds() + 1) + return date.toISOString() +} + const useListBeforeDate = ( latestBlockTime: string | undefined, offset: number, @@ -10,8 +19,10 @@ const useListBeforeDate = ( ) => { const [beforeDate, setBeforeDate] = useState(undefined) const setBeforeDateFromCollection = (newDate: string | undefined) => { - if (offset === 0 && beforeDate !== newDate) { - setBeforeDate(newDate) + const adjustedDate = addOneSecond(newDate) + // workaround around "before" filter exclusive maximum transaction time. + if (offset === 0 && beforeDate !== adjustedDate) { + setBeforeDate(adjustedDate) } }