@@ -232,7 +232,7 @@ export class Agent {
232
232
async ( { network, operator } : NetworkAndOperator ) => {
233
233
try {
234
234
await operator . ensureGlobalIndexingRule ( )
235
- await this . ensureNetworkSubgraphIsIndexing ( network )
235
+ await this . ensureAllSubgraphsIndexing ( network )
236
236
await network . register ( )
237
237
} catch ( err ) {
238
238
this . logger . critical (
@@ -1265,38 +1265,56 @@ export class Agent {
1265
1265
)
1266
1266
}
1267
1267
1268
- // TODO: This could be a initialization check inside Network.create() once/if the Indexer Service
1269
- // uses Network instances.
1270
- async ensureNetworkSubgraphIsIndexing ( network : Network ) {
1268
+ // TODO: After indexer-service deprecation: Move to be an initialization check inside Network.create()
1269
+ async ensureSubgraphIndexing ( deployment : string , networkIdentifier : string ) {
1270
+ try {
1271
+ // TODO: Check both the local deployment and the external subgraph endpoint
1272
+ // Make sure the subgraph is being indexed
1273
+ await this . graphNode . ensure (
1274
+ `indexer-agent/${ deployment . slice ( - 10 ) } ` ,
1275
+ new SubgraphDeploymentID ( deployment ) ,
1276
+ )
1277
+
1278
+ // Validate if the Network Subgraph belongs to the current provider's network.
1279
+ // This check must be performed after we ensure the Network Subgraph is being indexed.
1280
+ await validateProviderNetworkIdentifier (
1281
+ networkIdentifier ,
1282
+ deployment ,
1283
+ this . graphNode ,
1284
+ this . logger ,
1285
+ )
1286
+ } catch ( e ) {
1287
+ this . logger . warn (
1288
+ 'Failed to deploy and validate Network Subgraph on index-nodes. Will use external subgraph endpoint instead' ,
1289
+ e ,
1290
+ )
1291
+ }
1292
+ }
1293
+ async ensureAllSubgraphsIndexing ( network : Network ) {
1294
+ // Network subgraph
1271
1295
if (
1272
1296
network . specification . subgraphs . networkSubgraph . deployment !== undefined
1273
1297
) {
1274
- try {
1275
- // TODO: Check both the local deployment and the external subgraph endpoint
1276
- // Make sure the network subgraph is being indexed
1277
- await this . graphNode . ensure (
1278
- `indexer-agent/${ network . specification . subgraphs . networkSubgraph . deployment . slice (
1279
- - 10 ,
1280
- ) } `,
1281
- new SubgraphDeploymentID (
1282
- network . specification . subgraphs . networkSubgraph . deployment ,
1283
- ) ,
1284
- )
1285
-
1286
- // Validate if the Network Subgraph belongs to the current provider's network.
1287
- // This check must be performed after we ensure the Network Subgraph is being indexed.
1288
- await validateProviderNetworkIdentifier (
1289
- network . specification . networkIdentifier ,
1290
- network . specification . subgraphs . networkSubgraph . deployment ,
1291
- this . graphNode ,
1292
- this . logger ,
1293
- )
1294
- } catch ( e ) {
1295
- this . logger . warn (
1296
- 'Failed to deploy and validate Network Subgraph on index-nodes. Will use external subgraph endpoint instead' ,
1297
- e ,
1298
- )
1299
- }
1298
+ await this . ensureSubgraphIndexing (
1299
+ network . specification . subgraphs . networkSubgraph . deployment ,
1300
+ network . specification . networkIdentifier ,
1301
+ )
1302
+ }
1303
+ // Epoch subgraph
1304
+ if (
1305
+ network . specification . subgraphs . epochSubgraph . deployment !== undefined
1306
+ ) {
1307
+ await this . ensureSubgraphIndexing (
1308
+ network . specification . subgraphs . epochSubgraph . deployment ,
1309
+ network . specification . networkIdentifier ,
1310
+ )
1311
+ }
1312
+ // TAP subgraph
1313
+ if ( network . specification . subgraphs . tapSubgraph ?. deployment !== undefined ) {
1314
+ await this . ensureSubgraphIndexing (
1315
+ network . specification . subgraphs . tapSubgraph . deployment ,
1316
+ network . specification . networkIdentifier ,
1317
+ )
1300
1318
}
1301
1319
}
1302
1320
}
0 commit comments