@@ -21,6 +21,16 @@ export type GetSpokeClientParams = {
21
21
hubPoolClient : across . clients . HubPoolClient ;
22
22
} ;
23
23
24
+ function getAddress ( contractName : string , chainId : number ) : string {
25
+ const address = getDeployedAddress ( contractName , chainId ) ;
26
+ if ( ! address ) {
27
+ throw new Error (
28
+ `Address for contract ${ contractName } on ${ chainId } not found ` ,
29
+ ) ;
30
+ }
31
+ return address ;
32
+ }
33
+
24
34
/**
25
35
* Resolves a spoke pool client with the given parameters
26
36
* @param params Parameters to resolve a spoke client.
@@ -32,7 +42,7 @@ export function getSpokeClient(
32
42
params : GetSpokeClientParams ,
33
43
) : across . clients . SpokePoolClient {
34
44
const { provider, logger, maxBlockLookBack, chainId, hubPoolClient } = params ;
35
- const address = getDeployedAddress ( "SpokePool" , chainId ) ;
45
+ const address = getAddress ( "SpokePool" , chainId ) ;
36
46
const deployedBlockNumber = getDeployedBlockNumber ( "SpokePool" , chainId ) ;
37
47
38
48
const toBlock = params . toBlock ;
@@ -85,7 +95,7 @@ export function getConfigStoreClient(
85
95
params : GetConfigStoreClientParams ,
86
96
) : across . clients . AcrossConfigStoreClient {
87
97
const { provider, logger, maxBlockLookBack, chainId } = params ;
88
- const address = getDeployedAddress ( "AcrossConfigStore" , chainId ) ;
98
+ const address = getAddress ( "AcrossConfigStore" , chainId ) ;
89
99
const deployedBlockNumber = getDeployedBlockNumber (
90
100
"AcrossConfigStore" ,
91
101
chainId ,
@@ -131,7 +141,7 @@ export function getHubPoolClient(
131
141
) : across . clients . HubPoolClient {
132
142
const { provider, logger, maxBlockLookBack, chainId, configStoreClient } =
133
143
params ;
134
- const address = getDeployedAddress ( "HubPool" , chainId ) ;
144
+ const address = getAddress ( "HubPool" , chainId ) ;
135
145
const deployedBlockNumber = getDeployedBlockNumber ( "HubPool" , chainId ) ;
136
146
137
147
const hubPoolContract = new Contract ( address , HubPoolFactory . abi , provider ) ;
0 commit comments