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

fix: make "recursions" debug message #42

Merged
merged 1 commit into from
Nov 15, 2024
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
14 changes: 10 additions & 4 deletions src/rpc/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { Address, GetLogsReturnType, Client, fromHex, Hex } from 'viem';
import {
type Address,
type GetLogsReturnType,
type Client,
fromHex,
type Hex,
} from 'viem';
import type { AbiEvent } from 'abitype';
import { PromisePool } from '@supercharge/promise-pool';
import { getBlock, getBytecode, getLogs } from 'viem/actions';
import { debug } from 'node:util';

interface GetContractDeploymentBlockArgs {
client: Client;
Expand Down Expand Up @@ -169,7 +176,7 @@ export async function getLogsRecursive<
fromBlock,
toBlock,
}: GetLogsArgs<TAbiEvents>): Promise<GetLogsReturnType<undefined, TAbiEvents>> {
console.log('recursions', fromBlock, toBlock);
debug('recursions')(`fetching from block ${fromBlock} to block ${toBlock}`);
if (fromBlock <= toBlock) {
try {
const logs = await getLogs(client, {
Expand Down Expand Up @@ -278,8 +285,7 @@ async function getLogsInBatches<TAbiEvents extends AbiEvent[] | undefined>({
address,
});
});
if (errors.length != 0) {
console.log(errors);
if (errors.length !== 0) {
throw new Error('Error fetching logs');
}
return results.flat() as GetLogsReturnType<undefined, TAbiEvents>;
Expand Down
Loading