File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
packages/cli/src/commands Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @graphprotocol/graph-cli ' : minor
3+ ---
4+
5+ Network validation for subgraph contract addresses
Original file line number Diff line number Diff line change @@ -268,6 +268,32 @@ export default class DeployCommand extends Command {
268268 const dataSourcesAndTemplates = await DataSourcesExtractor . fromFilePath ( manifest ) ;
269269
270270 protocol = Protocol . fromDataSources ( dataSourcesAndTemplates ) ;
271+ for ( const ds of dataSourcesAndTemplates . dataSources ) {
272+ const address = ds . source . address ;
273+ if ( ! address ) continue ;
274+
275+ try {
276+ await client . request (
277+ 'eth_getTransactionCount' ,
278+ [ address , 'latest' ] ,
279+ ( requestError , jsonRpcError , res ) => {
280+ if ( jsonRpcError ) {
281+ const message = jsonRpcError ?. message ;
282+ deployDebugger ( 'message: %O' , message ) ;
283+ } else if ( requestError ) {
284+ deployDebugger ( 'HTTP requestError: %O' , requestError ) ;
285+ } else if ( res === '0x0' ) {
286+ print . warning (
287+ `Warning: Contract ${ address } does not appear to exist on network ${ ds . network } . ` +
288+ `Subgraph may index no events.` ,
289+ ) ;
290+ }
291+ } ,
292+ ) ;
293+ } catch ( e ) {
294+ print . warning ( `Could not check contract ${ address } : ${ e } ` ) ;
295+ }
296+ }
271297 } catch ( e ) {
272298 this . error ( e , { exit : 1 } ) ;
273299 }
You can’t perform that action at this time.
0 commit comments