1
1
import immutable from 'immutable' ;
2
2
import { GRAPH_CLI_SHARED_HEADERS } from '../constants' ;
3
+ import debugFactory from '../debug' ;
3
4
import fetch from '../fetch' ;
4
5
import ABI from '../protocols/ethereum/abi' ;
5
6
import { withSpinner } from './spinner' ;
6
7
8
+ const logger = debugFactory ( 'graph-cli:abi-helpers' ) ;
9
+
7
10
export const loadAbiFromEtherscan = async (
8
11
ABICtor : typeof ABI ,
9
12
network : string ,
@@ -51,7 +54,9 @@ export const fetchDeployContractTransactionFromEtherscan = async (
51
54
5 ,
52
55
) ;
53
56
if ( json . status === '1' ) {
54
- return json . result [ 0 ] . txHash ;
57
+ const hash = json . result [ 0 ] . txHash ;
58
+ logger ( 'Successfully fetchDeployContractTransactionFromEtherscan. txHash: %s' , hash ) ;
59
+ return hash ;
55
60
}
56
61
57
62
throw new Error ( `Failed to fetch deploy contract transaction` ) ;
@@ -70,6 +75,7 @@ export const fetchContractCreationHashWithRetry = async (
70
75
return json ;
71
76
}
72
77
} catch ( error ) {
78
+ logger ( 'Failed to fetchContractCreationHashWithRetry: %O' , error ) ;
73
79
/* empty */
74
80
}
75
81
}
@@ -100,6 +106,7 @@ export const fetchTransactionByHashFromRPC = async (
100
106
json = await result . json ( ) ;
101
107
return json ;
102
108
} catch ( error ) {
109
+ logger ( 'Failed to fetchTransactionByHashFromRPC: %O' , error ) ;
103
110
throw new Error ( 'Failed to fetch contract creation transaction' ) ;
104
111
}
105
112
} ;
@@ -111,8 +118,11 @@ export const getStartBlockForContract = async (
111
118
try {
112
119
const transactionHash = await fetchDeployContractTransactionFromEtherscan ( network , address ) ;
113
120
const txn = await fetchTransactionByHashFromRPC ( network , transactionHash ) ;
114
- return parseInt ( txn . result . blockNumber , 16 ) ;
121
+ const blockNumber = parseInt ( txn . result . blockNumber , 16 ) ;
122
+ logger ( 'Successfully getStartBlockForContract. blockNumber: %s' , blockNumber ) ;
123
+ return blockNumber ;
115
124
} catch ( error ) {
125
+ logger ( 'Failed to fetch getStartBlockForContract: %O' , error ) ;
116
126
throw new Error ( error ?. message ) ;
117
127
}
118
128
} ;
@@ -139,8 +149,10 @@ export const loadAbiFromBlockScout = async (
139
149
// a `result` field. The `status` is '0' in case of errors and '1' in
140
150
// case of success
141
151
if ( json . status === '1' ) {
152
+ logger ( 'Successfully loadAbiFromBlockScout. address: %s' , address ) ;
142
153
return new ABICtor ( 'Contract' , undefined , immutable . fromJS ( JSON . parse ( json . result ) ) ) ;
143
154
}
155
+ logger ( 'Failed to loadAbiFromBlockScout. address: %s' , address ) ;
144
156
throw new Error ( 'ABI not found, try loading it from a local file' ) ;
145
157
} ,
146
158
) ;
@@ -285,6 +297,8 @@ const getPublicRPCEndpoint = (network: string) => {
285
297
return 'https://mainnet.era.zksync.io' ;
286
298
case 'zksync-era-testnet' :
287
299
return 'https://testnet.era.zksync.dev' ;
300
+ case 'zksync-era-sepolia' :
301
+ return 'https://sepolia.era.zksync.dev' ;
288
302
case 'sepolia' :
289
303
return 'https://rpc.ankr.com/eth_sepolia' ;
290
304
case 'scroll-sepolia' :
0 commit comments