@@ -134,9 +134,9 @@ export class Network {
134
134
deployment :
135
135
networkSubgraphDeploymentId !== undefined
136
136
? {
137
- graphNode,
138
- deployment : networkSubgraphDeploymentId ,
139
- }
137
+ graphNode,
138
+ deployment : networkSubgraphDeploymentId ,
139
+ }
140
140
: undefined ,
141
141
subgraphFreshnessChecker : networkSubgraphFreshnessChecker ,
142
142
} )
@@ -160,9 +160,9 @@ export class Network {
160
160
deployment :
161
161
tapSubgraphDeploymentId !== undefined
162
162
? {
163
- graphNode,
164
- deployment : tapSubgraphDeploymentId ,
165
- }
163
+ graphNode,
164
+ deployment : tapSubgraphDeploymentId ,
165
+ }
166
166
: undefined ,
167
167
endpoint : specification . subgraphs . tapSubgraph ! . url ,
168
168
subgraphFreshnessChecker : tapSubgraphFreshnessChecker ,
@@ -191,7 +191,8 @@ export class Network {
191
191
wallet ,
192
192
specification . networkIdentifier ,
193
193
logger ,
194
- specification . addressBook ,
194
+ specification . horizonAddressBook ,
195
+ specification . subgraphServiceAddressBook ,
195
196
)
196
197
197
198
// * -----------------------------------------------------------------------
@@ -215,9 +216,9 @@ export class Network {
215
216
deployment :
216
217
epochSubgraphDeploymentId !== undefined
217
218
? {
218
- graphNode,
219
- deployment : epochSubgraphDeploymentId ,
220
- }
219
+ graphNode,
220
+ deployment : epochSubgraphDeploymentId ,
221
+ }
221
222
: undefined ,
222
223
endpoint : specification . subgraphs . epochSubgraph . url ,
223
224
subgraphFreshnessChecker : epochSubgraphFreshnessChecker ,
@@ -556,7 +557,8 @@ async function connectToProtocolContracts(
556
557
wallet : HDNodeWallet ,
557
558
networkIdentifier : string ,
558
559
logger : Logger ,
559
- addressBook ?: string ,
560
+ horizonAddressBook ?: string ,
561
+ subgraphServiceAddressBook ?: string
560
562
) : Promise < GraphHorizonContracts & SubgraphServiceContracts > {
561
563
const numericNetworkId = parseInt ( networkIdentifier . split ( ':' ) [ 1 ] )
562
564
@@ -567,15 +569,17 @@ async function connectToProtocolContracts(
567
569
568
570
logger . info ( `Connect to contracts` , {
569
571
network : networkIdentifier ,
572
+ horizonAddressBook,
573
+ subgraphServiceAddressBook,
570
574
} )
571
575
572
576
let contracts : GraphHorizonContracts & SubgraphServiceContracts
573
577
try {
574
- const horizonContracts = connectGraphHorizon ( numericNetworkId , wallet , addressBook )
578
+ const horizonContracts = connectGraphHorizon ( numericNetworkId , wallet , horizonAddressBook )
575
579
const subgraphServiceContracts = connectSubgraphService (
576
580
numericNetworkId ,
577
581
wallet ,
578
- addressBook ,
582
+ subgraphServiceAddressBook ,
579
583
)
580
584
contracts = {
581
585
...horizonContracts ,
@@ -587,15 +591,50 @@ async function connectToProtocolContracts(
587
591
logger . error ( errorMessage , { error, networkIdentifier, numericNetworkId } )
588
592
throw new Error ( `${ errorMessage } Error: ${ error } ` )
589
593
}
590
- logger . info ( `Successfully connected to contracts` , {
591
- curation : contracts . L2Curation . target ,
592
- disputeManager : contracts . DisputeManager . target ,
594
+
595
+
596
+ // Ensure we are connected to all required contracts
597
+ const requiredContracts = [
598
+ 'EpochManager' ,
599
+ 'RewardsManager' ,
600
+ 'HorizonStaking' ,
601
+ 'GraphTallyCollector' ,
602
+ 'PaymentsEscrow' ,
603
+ 'SubgraphService' ,
604
+ ]
605
+
606
+ // Before horizon we need the LegacyServiceRegistry contract as well
607
+ const isHorizon = await contracts . HorizonStaking . getMaxThawingPeriod ( )
608
+ . then ( ( maxThawingPeriod ) => maxThawingPeriod > 0 )
609
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
610
+ . catch ( ( _ ) => false )
611
+ if ( ! isHorizon ) {
612
+ requiredContracts . push ( 'LegacyServiceRegistry' )
613
+ }
614
+
615
+ const missingContracts = requiredContracts . filter (
616
+ ( contract ) => ! ( contract in contracts ) ,
617
+ )
618
+ if ( missingContracts . length > 0 ) {
619
+ logger . fatal ( `Missing required contracts` , {
620
+ err : indexerError ( IndexerErrorCode . IE075 ) ,
621
+ missingContracts : missingContracts ,
622
+ } )
623
+ process . exit ( 1 )
624
+ }
625
+
626
+
627
+ // Only list contracts that are used by the indexer
628
+ logger . info ( `Successfully connected to Horizon contracts` , {
593
629
epochManager : contracts . EpochManager . target ,
594
- gns : contracts . L2GNS . target ,
595
630
rewardsManager : contracts . RewardsManager . target ,
596
- serviceRegistry : contracts . LegacyServiceRegistry . target ,
597
631
staking : contracts . HorizonStaking . target ,
598
- token : contracts . GraphToken . target ,
632
+ graphTallyCollector : contracts . GraphTallyCollector . target ,
633
+ graphPaymentsEscrow : contracts . PaymentsEscrow . target ,
634
+ } )
635
+ logger . info ( `Successfully connected to Subgraph Service contracts` , {
636
+ ...( isHorizon ? { } : { legacyServiceRegistry : contracts . LegacyServiceRegistry . target } ) ,
637
+ subgraphService : contracts . SubgraphService . target ,
599
638
} )
600
639
return contracts
601
640
}
0 commit comments