diff --git a/packages/data-flow/src/eventsFetcher.ts b/packages/data-flow/src/eventsFetcher.ts index dcbeddd..b061c52 100644 --- a/packages/data-flow/src/eventsFetcher.ts +++ b/packages/data-flow/src/eventsFetcher.ts @@ -12,7 +12,7 @@ export class EventsFetcher implements IEventsFetcher { logIndex: number, limit: number = 100, ): Promise { - return await this.indexerClient.getEventsByBlockNumberAndLogIndex( + return await this.indexerClient.getEventsAfterBlockNumberAndLogIndex( chainId, blockNumber, logIndex, diff --git a/packages/data-flow/test/unit/eventsFetcher.spec.ts b/packages/data-flow/test/unit/eventsFetcher.spec.ts index b7ad643..df7620e 100644 --- a/packages/data-flow/test/unit/eventsFetcher.spec.ts +++ b/packages/data-flow/test/unit/eventsFetcher.spec.ts @@ -10,7 +10,7 @@ describe("EventsFetcher", () => { beforeEach(() => { indexerClientMock = { - getEventsByBlockNumberAndLogIndex: vi.fn(), + getEventsAfterBlockNumberAndLogIndex: vi.fn(), }; eventsFetcher = new EventsFetcher(indexerClientMock); @@ -46,15 +46,15 @@ describe("EventsFetcher", () => { const logIndex = 0; const limit = 100; - indexerClientMock.getEventsByBlockNumberAndLogIndex.mockResolvedValue(mockEvents); + indexerClientMock.getEventsAfterBlockNumberAndLogIndex.mockResolvedValue(mockEvents); - const result = await eventsFetcher.fetcEventsByBlockNumberAndLogIndex( + const result = await eventsFetcher.fetchEventsByBlockNumberAndLogIndex( chainId, blockNumber, logIndex, ); - expect(indexerClientMock.getEventsByBlockNumberAndLogIndex).toHaveBeenCalledWith( + expect(indexerClientMock.getEventsAfterBlockNumberAndLogIndex).toHaveBeenCalledWith( chainId, blockNumber, logIndex, @@ -68,12 +68,12 @@ describe("EventsFetcher", () => { const blockNumber = 1000; const logIndex = 0; - indexerClientMock.getEventsByBlockNumberAndLogIndex.mockRejectedValue( + indexerClientMock.getEventsAfterBlockNumberAndLogIndex.mockRejectedValue( new Error("Network error"), ); await expect( - eventsFetcher.fetcEventsByBlockNumberAndLogIndex(chainId, blockNumber, logIndex), + eventsFetcher.fetchEventsByBlockNumberAndLogIndex(chainId, blockNumber, logIndex), ).rejects.toThrow("Network error"); }); }); diff --git a/packages/indexer-client/test/unit/envioIndexerClient.spec.ts b/packages/indexer-client/test/unit/envioIndexerClient.spec.ts index 7bdb0d3..97e28ce 100644 --- a/packages/indexer-client/test/unit/envioIndexerClient.spec.ts +++ b/packages/indexer-client/test/unit/envioIndexerClient.spec.ts @@ -40,7 +40,7 @@ describe("EnvioIndexerClient", () => { }); }); - describe("getEventsByBlockNumberAndLogIndex", () => { + describe("getEventsAfterBlockNumberAndLogIndex", () => { const mockEvents: AnyProtocolEvent[] = [ { chain_id: 1, @@ -65,7 +65,7 @@ describe("EnvioIndexerClient", () => { }; graphqlClient.rawRequest.mockResolvedValue(mockedResponse); - const result = await envioIndexerClient.getEventsByBlockNumberAndLogIndex( + const result = await envioIndexerClient.getEventsAfterBlockNumberAndLogIndex( 1, 12345, 0, @@ -84,7 +84,7 @@ describe("EnvioIndexerClient", () => { }; graphqlClient.rawRequest.mockResolvedValue(mockedResponse); - await envioIndexerClient.getEventsByBlockNumberAndLogIndex(1, 12345, 0); + await envioIndexerClient.getEventsAfterBlockNumberAndLogIndex(1, 12345, 0); expect(graphqlClient.rawRequest).toHaveBeenCalledWith( expect.stringContaining("limit: 100"), ); @@ -100,7 +100,7 @@ describe("EnvioIndexerClient", () => { }; graphqlClient.rawRequest.mockResolvedValue(mockedResponse); - await envioIndexerClient.getEventsByBlockNumberAndLogIndex(1, 12345, 0, 50); + await envioIndexerClient.getEventsAfterBlockNumberAndLogIndex(1, 12345, 0, 50); expect(graphqlClient.rawRequest).toHaveBeenCalledWith( expect.stringContaining("limit: 50"), ); @@ -117,7 +117,7 @@ describe("EnvioIndexerClient", () => { graphqlClient.rawRequest.mockResolvedValue(mockedResponse); await expect( - envioIndexerClient.getEventsByBlockNumberAndLogIndex(1, 12345, 0), + envioIndexerClient.getEventsAfterBlockNumberAndLogIndex(1, 12345, 0), ).rejects.toThrow(InvalidIndexerResponse); }); @@ -126,7 +126,7 @@ describe("EnvioIndexerClient", () => { graphqlClient.rawRequest.mockRejectedValue(error); await expect( - envioIndexerClient.getEventsByBlockNumberAndLogIndex(1, 12345, 0), + envioIndexerClient.getEventsAfterBlockNumberAndLogIndex(1, 12345, 0), ).rejects.toThrow(IndexerClientError); }); @@ -140,7 +140,7 @@ describe("EnvioIndexerClient", () => { }; graphqlClient.rawRequest.mockResolvedValue(mockedResponse); - await envioIndexerClient.getEventsByBlockNumberAndLogIndex(1, 12345, 0); + await envioIndexerClient.getEventsAfterBlockNumberAndLogIndex(1, 12345, 0); expect(graphqlClient.rawRequest).toHaveBeenCalledWith( expect.stringContaining("chain_id: { _eq: 1 }"), ); @@ -162,7 +162,11 @@ describe("EnvioIndexerClient", () => { }; graphqlClient.rawRequest.mockResolvedValue(mockedResponse); - const result = await envioIndexerClient.getEventsByBlockNumberAndLogIndex(1, 12345, 0); + const result = await envioIndexerClient.getEventsAfterBlockNumberAndLogIndex( + 1, + 12345, + 0, + ); expect(result).toEqual([]); }); });