1
1
import { providers , Signer } from 'ethers'
2
2
import graphChain from './chain'
3
3
4
- // Contract addresses
5
- import * as DEPLOYED_CONTRACTS from '@graphprotocol/contracts/addresses.json'
6
-
7
4
// Contract ABIs
8
5
import { Curation } from '@graphprotocol/contracts/dist/types/Curation'
9
6
import { DisputeManager } from '@graphprotocol/contracts/dist/types/DisputeManager'
@@ -45,7 +42,6 @@ import { L1GraphTokenGateway__factory } from '@graphprotocol/contracts/dist/type
45
42
import { BridgeEscrow__factory } from '@graphprotocol/contracts/dist/types/factories/BridgeEscrow__factory'
46
43
import { L2GraphToken__factory } from '@graphprotocol/contracts/dist/types/factories/L2GraphToken__factory'
47
44
import { L2GraphTokenGateway__factory } from '@graphprotocol/contracts/dist/types/factories/L2GraphTokenGateway__factory'
48
- import { readFileSync } from 'fs'
49
45
50
46
export const GraphChain = graphChain
51
47
@@ -72,16 +68,14 @@ export interface NetworkContracts {
72
68
l2GraphTokenGateway ?: L2GraphTokenGateway
73
69
}
74
70
71
+ export type AddressBook = { [ key : string ] : { [ key : string ] : { address : string } } }
72
+
75
73
export const connectContracts = async (
76
74
providerOrSigner : providers . Provider | Signer ,
77
75
chainId : number ,
78
- addressBook ?: string ,
76
+ addressBook : AddressBook ,
79
77
) : Promise < NetworkContracts > => {
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 } ` ]
78
+ const deployedContracts = addressBook [ `${ chainId } ` ]
85
79
if ( ! deployedContracts ) {
86
80
throw new Error ( `chainId: '${ chainId } ' has no deployed contracts` )
87
81
}
0 commit comments