Skip to content

Commit 711b1ba

Browse files
committed
feat(contracts): optionally override address book
1 parent 4e67da2 commit 711b1ba

File tree

1 file changed

+7
-2
lines changed
  • packages/common-ts/src/contracts

1 file changed

+7
-2
lines changed

packages/common-ts/src/contracts/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { L1GraphTokenGateway__factory } from '@graphprotocol/contracts/dist/type
4545
import { BridgeEscrow__factory } from '@graphprotocol/contracts/dist/types/factories/BridgeEscrow__factory'
4646
import { L2GraphToken__factory } from '@graphprotocol/contracts/dist/types/factories/L2GraphToken__factory'
4747
import { L2GraphTokenGateway__factory } from '@graphprotocol/contracts/dist/types/factories/L2GraphTokenGateway__factory'
48+
import { readFileSync } from 'fs'
4849

4950
export const GraphChain = graphChain
5051

@@ -74,9 +75,13 @@ export interface NetworkContracts {
7475
export const connectContracts = async (
7576
providerOrSigner: providers.Provider | Signer,
7677
chainId: number,
78+
addressBook?: string,
7779
): Promise<NetworkContracts> => {
78-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
79-
const deployedContracts = (DEPLOYED_CONTRACTS as any)[`${chainId}`]
80+
const deployedContracts = addressBook
81+
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
82+
JSON.parse(readFileSync(addressBook).toString())[`${chainId}`]
83+
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
84+
(DEPLOYED_CONTRACTS as any)[`${chainId}`]
8085
if (!deployedContracts) {
8186
throw new Error(`chainId: '${chainId}' has no deployed contracts`)
8287
}

0 commit comments

Comments
 (0)