Skip to content

Commit

Permalink
lint + test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
timolegros authored and ilijabojanovic committed Oct 1, 2024
1 parent de8896f commit 2dcc9ea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,37 +43,36 @@ export async function getLogs({
endingBlockNum: number;
}): Promise<{ logs: Log[]; lastBlockNum: number }> {
let startBlock = startingBlockNum;
let endBlock = endingBlockNum;
const provider = getProvider(rpc);

if (startBlock > endBlock) {
if (startBlock > endingBlockNum) {
logger.error(
'Starting block number is greater than the latest/current block number!',
undefined,
{
startBlock,
endBlock,
endingBlockNum,
},
);
return { logs: [], lastBlockNum: endBlock };
return { logs: [], lastBlockNum: endingBlockNum };
}

if (contractAddresses.length === 0) {
logger.error(`No contracts given`);
return { logs: [], lastBlockNum: endBlock };
return { logs: [], lastBlockNum: endingBlockNum };
}

// limit the number of blocks to fetch to avoid rate limiting on some public EVM nodes like Celo
// maxBlockRange = -1 indicates there is no block range limit
if (maxBlockRange !== -1 && endBlock - startBlock > maxBlockRange) {
startBlock = endBlock - maxBlockRange;
if (maxBlockRange !== -1 && endingBlockNum - startBlock > maxBlockRange) {
startBlock = endingBlockNum - maxBlockRange;
logger.error(
'Block span too large. The number of fetch blocked is reduced to 500.',
undefined,
{
contractAddresses,
startBlock,
endBlock,
endingBlockNum,
},
);
}
Expand All @@ -92,7 +91,7 @@ export async function getLogs({
}> = await provider.send('eth_getLogs', [
{
fromBlock: decimalToHex(startBlock),
toBlock: decimalToHex(endBlock),
toBlock: decimalToHex(endingBlockNum),
address: contractAddresses,
},
]);
Expand All @@ -104,7 +103,7 @@ export async function getLogs({
logIndex: parseInt(log.logIndex, 16),
}));

return { logs: formattedLogs, lastBlockNum: endBlock };
return { logs: formattedLogs, lastBlockNum: endingBlockNum };
}

export async function parseLogs(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const namespaceDeployedLog = {
topics: [
'0x8870ba2202802ce285ce6bead5ac915b6dc2d35c8a9d6f96fa56de9de12829d5',
],
// eslint-disable-next-line max-len
data: '0x0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000000000000000000000000000000000000000000000000001363657465737431373237373734373236393138000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
blockHash:
'0x5aa2154c16dca3b09a11a8a6f06154b2263c1185f3ef7edb99e8f5099d95083b',
Expand Down Expand Up @@ -267,9 +268,12 @@ describe('EVM Chain Events Log Processing Tests', () => {
(e) => e.eventSource.kind === 'DeployedNamespace',
);
expect(deployedNamespaceEvent).toBeTruthy();
expect(deployedNamespaceEvent!.rawLog.address).to.equal(
namespaceFactoryAddress,
);
expect(
equalEvmAddresses(
deployedNamespaceEvent!.rawLog.address,
namespaceFactoryAddress,
),
).toBeTruthy();
const communityStakeBuyEvent = result.events.find(
(e) => e.eventSource.kind === 'Trade',
);
Expand Down

0 comments on commit 2dcc9ea

Please sign in to comment.