Skip to content

Commit

Permalink
improve: remove hardcoding
Browse files Browse the repository at this point in the history
Signed-off-by: james-a-morris <[email protected]>
  • Loading branch information
james-a-morris committed Oct 21, 2024
1 parent b2386ba commit 929778c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/indexer/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export async function Main(config: parseEnv.Config, logger: winston.Logger) {
hubClientFactory: hubPoolClientFactory,
spokePoolClientFactory,
configStoreClientFactory,
hubChainId,
});

const hubPoolIndexerDataHandler = new HubPoolIndexerDataHandler(
Expand Down
12 changes: 7 additions & 5 deletions packages/indexer/src/services/BundleBuilderService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { CHAIN_IDs } from "@across-protocol/constants";
import { caching, clients, typechain, utils } from "@across-protocol/sdk";
import { entities } from "@repo/indexer-database";
import assert from "assert";
Expand Down Expand Up @@ -39,6 +38,7 @@ type BundleBuilderConfig = {
hubClientFactory: HubPoolClientFactory;
configStoreClientFactory: ConfigStoreClientFactory;
spokePoolClientFactory: SpokePoolClientFactory;
hubChainId: number;
};

export class BundleBuilderService extends BaseIndexer {
Expand Down Expand Up @@ -117,7 +117,7 @@ export class BundleBuilderService extends BaseIndexer {
lastExecutedBundle: entities.ProposedRootBundle,
) {
const currentMainnetBlock = await this.config.providerFactory
.getProviderForChainId(CHAIN_IDs.MAINNET)
.getProviderForChainId(this.config.hubChainId)
.getBlockNumber();
const lastExecutedMainnetBlock =
lastExecutedBundle.bundleEvaluationBlockNumbers[0]!;
Expand All @@ -134,7 +134,7 @@ export class BundleBuilderService extends BaseIndexer {
executedBundle: entities.Bundle,
): Promise<void> {
// Resolve a hub client and config store client
const hubClient = this.config.hubClientFactory.get(CHAIN_IDs.MAINNET);
const hubClient = this.config.hubClientFactory.get(this.config.hubChainId);
const configStoreClient = hubClient.configStoreClient;
void (await configStoreClient.update());
void (await hubClient.update());
Expand Down Expand Up @@ -224,7 +224,7 @@ export class BundleBuilderService extends BaseIndexer {
): Promise<void> {
// Resolve a latest config store client and update it
const configStoreClient = this.config.configStoreClientFactory.get(
CHAIN_IDs.MAINNET,
this.config.hubChainId,
);
void (await configStoreClient.update());
// Resolve the latest proposal
Expand Down Expand Up @@ -356,7 +356,9 @@ export class BundleBuilderService extends BaseIndexer {
}
const historicalProposedBundle = historicalProposal.proposal;
// Instantiate the Hub & ConfigStore Client from genesis
const hubPoolClient = this.config.hubClientFactory.get(CHAIN_IDs.MAINNET);
const hubPoolClient = this.config.hubClientFactory.get(
this.config.hubChainId,
);
const configStoreClient = hubPoolClient.configStoreClient;
// Resolve lookback range for the spoke clients
const lookbackRange = getBlockRangeBetweenBundles(
Expand Down

0 comments on commit 929778c

Please sign in to comment.