@@ -425,6 +425,63 @@ async function main() {
425
425
}
426
426
}
427
427
}
428
+
429
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
430
+ // check contracts in data files are not discovered from factory as well
431
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
432
+ for ( const chain of uniqChains ) {
433
+ const fs = require ( "fs" )
434
+ if ( ! fs . existsSync ( `./data/${ chain } _data.json` ) ) {
435
+ continue
436
+ }
437
+ const data = JSON . parse ( fs . readFileSync ( `./data/${ chain } _data.json` , "utf8" ) )
438
+
439
+ const gql = `
440
+ query Misconfig {
441
+ duplicate_config: contracts(where: {
442
+ factory: true,
443
+ config: true,
444
+ }) {
445
+ id
446
+ }
447
+
448
+ none_config: contracts(where: {
449
+ factory: false,
450
+ config: false,
451
+ }) {
452
+ id
453
+ }
454
+ }
455
+ `
456
+
457
+ // only use the next version of the subgraph
458
+ const subgraphUrl = `https://api.goldsky.com/api/public/project_clu2walwem1qm01w40v3yhw1f/subgraphs/beefy-balances-${ chain } /next/gn`
459
+ const result = await fetch ( subgraphUrl , {
460
+ method : "POST" ,
461
+ headers : { "Content-Type" : "application/json" } ,
462
+ body : JSON . stringify ( { query : gql } ) ,
463
+ } )
464
+
465
+ if ( ! result . ok ) {
466
+ console . error ( `Failed to fetch data from subgraph: ${ result . statusText } ` )
467
+ continue
468
+ }
469
+
470
+ const resultData = ( await result . json ( ) ) as {
471
+ data : {
472
+ duplicate_config : { id : string } [ ]
473
+ none_config : { id : string } [ ]
474
+ }
475
+ }
476
+
477
+ for ( const contract of resultData . data . duplicate_config ) {
478
+ console . error ( `${ chain } : Contract ${ contract . id } is discovered from factory as well` )
479
+ }
480
+
481
+ for ( const contract of resultData . data . none_config ) {
482
+ console . error ( `${ chain } : Contract ${ contract . id } is not discovered from factory` )
483
+ }
484
+ }
428
485
}
429
486
430
487
main ( )
0 commit comments