@@ -11,6 +11,8 @@ import { NodeService } from "../nodes/node.service";
1111import { IdentitiesService } from "../identities/identities.service" ;
1212import { ApiConfigService } from "../../common/api-config/api.config.service" ;
1313import { ConcurrencyUtils } from "src/utils/concurrency.utils" ;
14+ import { ApiUtils } from "@multiversx/sdk-nestjs-http" ;
15+ import { GatewayService } from "../../common/gateway/gateway.service" ;
1416
1517@Injectable ( )
1618export class BlockService {
@@ -23,6 +25,7 @@ export class BlockService {
2325 @Inject ( forwardRef ( ( ) => IdentitiesService ) )
2426 private readonly identitiesService : IdentitiesService ,
2527 private readonly apiConfigService : ApiConfigService ,
28+ private readonly gatewayService : GatewayService ,
2629 ) { }
2730
2831 async getBlocksCount ( filter : BlockFilter ) : Promise < number > {
@@ -109,11 +112,20 @@ export class BlockService {
109112 }
110113
111114 async getBlock ( hash : string ) : Promise < BlockDetailed > {
112- const result = await this . indexerService . getBlock ( hash ) as any ;
115+ let result = await this . indexerService . getBlock ( hash ) as any ;
113116
114117 const isChainAndromedaEnabled = this . apiConfigService . isChainAndromedaEnabled ( )
115118 && result . epoch >= this . apiConfigService . getChainAndromedaActivationEpoch ( ) ;
116119
120+ const supernovaEnableEpoch = await this . getSupernovaEnableEpoch ( ) ;
121+ const isSupernovaEnabled = supernovaEnableEpoch !== - 1 && result . epoch >= supernovaEnableEpoch ;
122+ if ( isSupernovaEnabled ) {
123+ const executionResults = await this . indexerService . getExecutionResults ( hash ) ;
124+ if ( executionResults ) {
125+ result = ApiUtils . mergeObjects ( result , executionResults ) ;
126+ }
127+ }
128+
117129 if ( result . round > 0 ) {
118130 const publicKeys = await this . blsService . getPublicKeys ( result . shardId , result . epoch ) ;
119131 if ( result . proposerBlsKey ) {
@@ -122,7 +134,7 @@ export class BlockService {
122134 result . proposer = publicKeys [ result . proposer ] ;
123135 }
124136 if ( ! isChainAndromedaEnabled ) {
125- result . validators = result . validators . map ( ( validator : number ) => publicKeys [ validator ] ) ;
137+ result . validators = result . validators ? .map ( ( validator : number ) => publicKeys [ validator ] ) ;
126138 } else {
127139 result . validators = publicKeys ;
128140 }
@@ -161,4 +173,17 @@ export class BlockService {
161173 }
162174 return blocks [ 0 ] ;
163175 }
176+
177+ async getSupernovaEnableEpoch ( ) : Promise < number > {
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 ( ) => await this . gatewayService . getNetworkEnableEpochs ( ) ,
186+ CacheInfo . NetworkEnableEpochs . ttl ,
187+ ) ;
188+ }
164189}
0 commit comments