Skip to content

Commit eb602fc

Browse files
committed
Made addressBook object an optional input to connectContracts()
- Default to the file at '@graphprotocol/contracts/addresses.json'
1 parent 7bf1ab8 commit eb602fc

File tree

1 file changed

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

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { providers, Signer } from 'ethers'
22
import graphChain from './chain'
33

4+
// Contract addresses
5+
import * as DEPLOYED_CONTRACTS from '@graphprotocol/contracts/addresses.json'
6+
47
// Contract ABIs
58
import { Curation } from '@graphprotocol/contracts/dist/types/Curation'
69
import { DisputeManager } from '@graphprotocol/contracts/dist/types/DisputeManager'
@@ -73,9 +76,10 @@ export type AddressBook = { [key: string]: { [key: string]: { address: string }
7376
export const connectContracts = async (
7477
providerOrSigner: providers.Provider | Signer,
7578
chainId: number,
76-
addressBook: AddressBook,
79+
addressBook: AddressBook | undefined,
7780
): Promise<NetworkContracts> => {
78-
const deployedContracts = addressBook[`${chainId}`]
81+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
82+
const deployedContracts = addressBook ? addressBook[`${chainId}`] : (DEPLOYED_CONTRACTS as any)[`${chainId}`]
7983
if (!deployedContracts) {
8084
throw new Error(`chainId: '${chainId}' has no deployed contracts`)
8185
}

0 commit comments

Comments
 (0)