66 EnsIndexerIndexingStatusResponseCodes ,
77 type EnsIndexerIndexingStatusResponseError ,
88 type EnsIndexerIndexingStatusResponseOk ,
9+ IndexingMetadataContextStatusCodes ,
910 serializeEnsIndexerIndexingStatusResponse ,
1011 serializeEnsIndexerPublicConfig ,
1112} from "@ensnode/ensnode-sdk" ;
@@ -17,32 +18,33 @@ const app = new Hono();
1718
1819// include ENSIndexer Public Config endpoint
1920app . get ( "/config" , async ( c ) => {
20- const publicConfig = await ensDbClient . getEnsIndexerPublicConfig ( ) ;
21+ const indexingMetadataContext = await ensDbClient . getIndexingMetadataContext ( ) ;
2122
2223 // Invariant: the public config is guaranteed to be available in ENSDb after
2324 // application startup.
24- if ( typeof publicConfig === "undefined" ) {
25+ if ( indexingMetadataContext . statusCode !== IndexingMetadataContextStatusCodes . Initialized ) {
2526 throw new Error ( "Unreachable: ENSIndexer Public Config is not available in ENSDb" ) ;
2627 }
2728
2829 // respond with the serialized public config object
29- return c . json ( serializeEnsIndexerPublicConfig ( publicConfig ) ) ;
30+ return c . json ( serializeEnsIndexerPublicConfig ( indexingMetadataContext . stackInfo . ensIndexer ) ) ;
3031} ) ;
3132
3233app . get ( "/indexing-status" , async ( c ) => {
3334 try {
34- const crossChainSnapshot = await ensDbClient . getIndexingStatusSnapshot ( ) ;
35+ const indexingMetadataContext = await ensDbClient . getIndexingMetadataContext ( ) ;
3536
3637 // Invariant: the Indexing Status Snapshot is expected to be available in
3738 // ENSDb shortly after application startup. There is a possibility that
3839 // the snapshot is not yet available at the time of the request,
3940 // i.e. when ENSDb has not yet been populated with the first snapshot.
4041 // In this case, we treat the snapshot as unavailable and respond with
4142 // an error response.
42- if ( typeof crossChainSnapshot === "undefined" ) {
43+ if ( indexingMetadataContext . statusCode !== IndexingMetadataContextStatusCodes . Initialized ) {
4344 throw new Error ( "ENSDb does not contain an Indexing Status Snapshot" ) ;
4445 }
4546
47+ const crossChainSnapshot = indexingMetadataContext . indexingStatus ;
4648 const projectedAt = getUnixTime ( new Date ( ) ) ;
4749 const realtimeProjection = createRealtimeIndexingStatusProjection (
4850 crossChainSnapshot ,
0 commit comments