@@ -12,6 +12,7 @@ import { IdentitiesService } from "../identities/identities.service";
1212import { ApiConfigService } from "../../common/api-config/api.config.service" ;
1313import { ConcurrencyUtils } from "src/utils/concurrency.utils" ;
1414import { ApiUtils } from "@multiversx/sdk-nestjs-http" ;
15+ import { GatewayService } from "../../common/gateway/gateway.service" ;
1516
1617@Injectable ( )
1718export class BlockService {
@@ -24,6 +25,7 @@ export class BlockService {
2425 @Inject ( forwardRef ( ( ) => IdentitiesService ) )
2526 private readonly identitiesService : IdentitiesService ,
2627 private readonly apiConfigService : ApiConfigService ,
28+ private readonly gatewayService : GatewayService ,
2729 ) { }
2830
2931 async getBlocksCount ( filter : BlockFilter ) : Promise < number > {
@@ -115,7 +117,8 @@ export class BlockService {
115117 const isChainAndromedaEnabled = this . apiConfigService . isChainAndromedaEnabled ( )
116118 && result . epoch >= this . apiConfigService . getChainAndromedaActivationEpoch ( ) ;
117119
118- const isSupernovaEnabled = result . epoch >= await this . getSupernovaEnableEpoch ( ) ;
120+ const supernovaEnableEpoch = await this . getSupernovaEnableEpoch ( ) ;
121+ const isSupernovaEnabled = supernovaEnableEpoch !== - 1 && result . epoch >= supernovaEnableEpoch ;
119122 if ( isSupernovaEnabled ) {
120123 const executionResults = await this . indexerService . getExecutionResults ( hash ) ;
121124 if ( executionResults ) {
@@ -172,7 +175,15 @@ export class BlockService {
172175 }
173176
174177 async getSupernovaEnableEpoch ( ) : Promise < number > {
175- // TODO: fetch it from proxy /network/enable-epochs -> erd_supernova_enable_epoch
176- return await Promise . resolve ( 2 ) ;
178+ const enableEpochs = await this . getNetworkEnableEpochs ( ) ;
179+ return enableEpochs [ "erd_supernova_enable_epoch" ] ?? - 1 ;
180+ }
181+
182+ async getNetworkEnableEpochs ( ) : Promise < Record < string , number > > {
183+ return await this . cachingService . getOrSet (
184+ CacheInfo . NetworkEnableEpochs . key ,
185+ async ( ) => this . gatewayService . getNetworkEnableEpochs ( ) ,
186+ CacheInfo . NetworkEnableEpochs . ttl ,
187+ )
177188 }
178189}
0 commit comments