Skip to content

Commit

Permalink
Update HubPoolClient.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaspai committed Feb 13, 2025
1 parent aab61e9 commit 329d44c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/clients/HubPoolClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -776,15 +776,19 @@ export class HubPoolClient extends BaseAbstractClient {
return endBlock > 0 ? endBlock + 1 : 0;
}

getLatestExecutedRootBundleContainingL1Token(block: number, chain: number, l1Token: string): ExecutedRootBundle {
getLatestExecutedRootBundleContainingL1Token(
block: number,
chain: number,
l1Token: string
): ExecutedRootBundle | undefined {
// Search ExecutedRootBundles in descending block order to find the most recent event before the target block.
return sortEventsDescending(this.executedRootBundles).find((executedLeaf: ExecutedRootBundle) => {
return (
executedLeaf.blockNumber <= block &&
executedLeaf.chainId === chain &&
executedLeaf.l1Tokens.some((token) => token.toLowerCase() === l1Token.toLowerCase()
);

Check failure on line 790 in src/clients/HubPoolClient.ts

View workflow job for this annotation

GitHub Actions / Test

')' expected.

Check failure on line 790 in src/clients/HubPoolClient.ts

View workflow job for this annotation

GitHub Actions / Test

')' expected.

Check failure on line 790 in src/clients/HubPoolClient.ts

View workflow job for this annotation

GitHub Actions / Test

')' expected.

Check failure on line 790 in src/clients/HubPoolClient.ts

View workflow job for this annotation

GitHub Actions / Test

')' expected.

Check failure on line 790 in src/clients/HubPoolClient.ts

View workflow job for this annotation

GitHub Actions / Lint

')' expected.

Check failure on line 790 in src/clients/HubPoolClient.ts

View workflow job for this annotation

GitHub Actions / Lint

')' expected.

Check failure on line 790 in src/clients/HubPoolClient.ts

View workflow job for this annotation

GitHub Actions / Lint

')' expected.

Check failure on line 790 in src/clients/HubPoolClient.ts

View workflow job for this annotation

GitHub Actions / Builds

')' expected.

Check failure on line 790 in src/clients/HubPoolClient.ts

View workflow job for this annotation

GitHub Actions / Builds

')' expected.

Check failure on line 790 in src/clients/HubPoolClient.ts

View workflow job for this annotation

GitHub Actions / Builds

')' expected.

Check failure on line 790 in src/clients/HubPoolClient.ts

View workflow job for this annotation

GitHub Actions / Builds

')' expected.

Check failure on line 790 in src/clients/HubPoolClient.ts

View workflow job for this annotation

GitHub Actions / Builds

')' expected.

Check failure on line 790 in src/clients/HubPoolClient.ts

View workflow job for this annotation

GitHub Actions / Builds

')' expected.
}) as ExecutedRootBundle;
});
}

getRunningBalanceBeforeBlockForChain(block: number, chain: number, l1Token: string): TokenRunningBalance {
Expand All @@ -793,7 +797,10 @@ export class HubPoolClient extends BaseAbstractClient {
return this.getRunningBalanceForToken(l1Token, executedRootBundle);
}

public getRunningBalanceForToken(l1Token: string, executedRootBundle: ExecutedRootBundle): TokenRunningBalance {
public getRunningBalanceForToken(
l1Token: string,
executedRootBundle: ExecutedRootBundle | undefined
): TokenRunningBalance {
let runningBalance = toBN(0);
if (executedRootBundle) {
const indexOfL1Token = executedRootBundle.l1Tokens
Expand Down

0 comments on commit 329d44c

Please sign in to comment.