@@ -11,40 +11,31 @@ const queries = {
11
11
* - {address}
12
12
*/
13
13
get : ( opts : {
14
- chainId ? : number ;
14
+ chainId : number ;
15
15
contractAddress ?: string ;
16
16
contractName ?: string ;
17
- deployment ?: Sablier . Deployment ;
18
- release ?: Sablier . Release ;
17
+ deployments ?: Sablier . Deployment [ ] ;
18
+ protocol ?: Sablier . Protocol ;
19
19
} ) : Sablier . Contract | undefined => {
20
- const { contractAddress , contractName , deployment , release , chainId } = opts ;
20
+ const { chainId , deployments , contractAddress , contractName , protocol } = opts ;
21
21
22
22
if ( contractAddress && contractName ) {
23
- throw new Error ( "Cannot specify both contractAddress and contractNam as query options" ) ;
23
+ throw new Error ( "Cannot specify both contractAddress and contractName as query options" ) ;
24
24
}
25
25
26
26
if ( contractName ) {
27
- if ( deployment ) {
28
- return _ . find ( deployment . contracts , { name : contractName } ) ;
29
- }
30
-
31
- if ( release ) {
32
- if ( ! chainId ) {
33
- throw new Error ( "Cannot specify release without chainId" ) ;
34
- }
35
- const dep = _ . find ( release . deployments , { chainId } ) ;
36
- return dep && _ . find ( dep . contracts , { name : contractName } ) ;
27
+ if ( ! deployments ) {
28
+ throw new Error ( "Cannot specify contractName without deployments" ) ;
37
29
}
30
+ const dep = _ . find ( deployments , { chainId } ) ;
31
+ return dep && _ . find ( dep . contracts , { name : contractName } ) ;
38
32
}
39
33
40
34
if ( contractAddress ) {
41
- if ( ! release ) {
42
- throw new Error ( "Cannot specify contractAddress without release" ) ;
43
- }
44
- if ( ! chainId ) {
45
- throw new Error ( "Cannot specify contractAddress without chainId" ) ;
35
+ if ( ! protocol ) {
36
+ throw new Error ( "Cannot specify contractAddress without protocol" ) ;
46
37
}
47
- return _ . get ( catalog , [ release . protocol , chainId , contractAddress ] ) ;
38
+ return _ . get ( catalog , [ protocol , chainId , contractAddress ] ) ;
48
39
}
49
40
50
41
return undefined ;
0 commit comments