@@ -39,6 +39,16 @@ export class BlockService {
3939 async getBlocks ( filter : BlockFilter , queryPagination : QueryPagination , withProposerIdentity ?: boolean ) : Promise < Block [ ] > {
4040 const result = await this . indexerService . getBlocks ( filter , queryPagination ) ;
4141
42+ const executionResultsMap = await this . fetchExecutionResultsForBlocks ( result as any [ ] ) ;
43+ if ( executionResultsMap . size > 0 ) {
44+ for ( const item of result as any [ ] ) {
45+ const executionResult = executionResultsMap . get ( item . hash ) ;
46+ if ( executionResult ) {
47+ ApiUtils . mergeObjects ( item , executionResult ) ;
48+ }
49+ }
50+ }
51+
4252 const blocks = await Promise . all ( result . map ( async ( item ) => {
4353 const blockRaw = await this . computeProposerAndValidators ( item ) ;
4454
@@ -58,6 +68,41 @@ export class BlockService {
5868 return blocks ;
5969 }
6070
71+ private async fetchExecutionResultsForBlocks ( items : any [ ] ) : Promise < Map < string , any > > {
72+ const map = new Map < string , any > ( ) ;
73+ if ( ! items || items . length === 0 ) {
74+ return map ;
75+ }
76+
77+ const supernovaEnableEpoch = await this . getSupernovaEnableEpoch ( ) ;
78+ if ( supernovaEnableEpoch === - 1 ) {
79+ return map ;
80+ }
81+
82+ const eligible = items . filter ( ( r : any ) => ( r ?. epoch ?? - 1 ) >= supernovaEnableEpoch ) ;
83+ if ( eligible . length === 0 ) {
84+ return map ;
85+ }
86+
87+ const hashes = eligible . map ( ( r : any ) => r . hash ) . filter ( Boolean ) ;
88+ if ( hashes . length === 0 ) {
89+ return map ;
90+ }
91+
92+ try {
93+ const executionResults = await this . indexerService . getExecutionResultsForHashes ( hashes ) ;
94+ for ( const er of executionResults as any [ ] ) {
95+ if ( er ?. hash ) {
96+ map . set ( er . hash , er ) ;
97+ }
98+ }
99+ } catch {
100+ return map ;
101+ }
102+
103+ return map ;
104+ }
105+
61106 private async applyProposerIdentity ( blocks : Block [ ] ) : Promise < void > {
62107 const proposerBlses = blocks . map ( x => x . proposer ) ;
63108
@@ -176,7 +221,7 @@ export class BlockService {
176221
177222 async getSupernovaEnableEpoch ( ) : Promise < number > {
178223 const enableEpochs = await this . getNetworkEnableEpochs ( ) ;
179- return enableEpochs [ "erd_supernova_enable_epoch" ] ?? - 1 ;
224+ return enableEpochs ?. [ "erd_supernova_enable_epoch" ] ?? - 1 ;
180225 }
181226
182227 async getNetworkEnableEpochs ( ) : Promise < Record < string , number > > {
0 commit comments