Skip to content

Commit

Permalink
fix: update across contracts (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
melisaguevara authored Oct 10, 2024
1 parent c45eba7 commit 114ac3e
Show file tree
Hide file tree
Showing 3 changed files with 404 additions and 147 deletions.
4 changes: 2 additions & 2 deletions packages/indexer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"author": "",
"license": "ISC",
"dependencies": {
"@across-protocol/constants": "^3.1.13",
"@across-protocol/contracts": "^3.0.8",
"@across-protocol/constants": "^3.1.16",
"@across-protocol/contracts": "^3.0.11",
"@across-protocol/sdk": "^3.2.2",
"@types/lodash": "^4.17.7",
"bullmq": "^5.12.12",
Expand Down
16 changes: 13 additions & 3 deletions packages/indexer/src/utils/contractUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ export type GetSpokeClientParams = {
hubPoolClient: across.clients.HubPoolClient;
};

function getAddress(contractName: string, chainId: number): string {
const address = getDeployedAddress(contractName, chainId);
if (!address) {
throw new Error(
`Address for contract ${contractName} on ${chainId} not found `,
);
}
return address;
}

/**
* Resolves a spoke pool client with the given parameters
* @param params Parameters to resolve a spoke client.
Expand All @@ -32,7 +42,7 @@ export function getSpokeClient(
params: GetSpokeClientParams,
): across.clients.SpokePoolClient {
const { provider, logger, maxBlockLookBack, chainId, hubPoolClient } = params;
const address = getDeployedAddress("SpokePool", chainId);
const address = getAddress("SpokePool", chainId);
const deployedBlockNumber = getDeployedBlockNumber("SpokePool", chainId);

const toBlock = params.toBlock;
Expand Down Expand Up @@ -85,7 +95,7 @@ export function getConfigStoreClient(
params: GetConfigStoreClientParams,
): across.clients.AcrossConfigStoreClient {
const { provider, logger, maxBlockLookBack, chainId } = params;
const address = getDeployedAddress("AcrossConfigStore", chainId);
const address = getAddress("AcrossConfigStore", chainId);
const deployedBlockNumber = getDeployedBlockNumber(
"AcrossConfigStore",
chainId,
Expand Down Expand Up @@ -131,7 +141,7 @@ export function getHubPoolClient(
): across.clients.HubPoolClient {
const { provider, logger, maxBlockLookBack, chainId, configStoreClient } =
params;
const address = getDeployedAddress("HubPool", chainId);
const address = getAddress("HubPool", chainId);
const deployedBlockNumber = getDeployedBlockNumber("HubPool", chainId);

const hubPoolContract = new Contract(address, HubPoolFactory.abi, provider);
Expand Down
Loading

0 comments on commit 114ac3e

Please sign in to comment.