@@ -1231,19 +1231,19 @@ export class EthImpl implements Eth {
1231
1231
this . logger . trace (
1232
1232
`${ requestIdPrefix } getTransactionByBlockHashAndIndex(hash=${ blockHash } , index=${ transactionIndex } )` ,
1233
1233
) ;
1234
-
1235
- try {
1236
- return await this . getTransactionByBlockHashOrBlockNumAndIndex (
1237
- { title : 'blockHash' , value : blockHash } ,
1238
- transactionIndex ,
1234
+ return this . mirrorNodeClient
1235
+ . getContractResults (
1236
+ { blockHash : blockHash , transactionIndex : Number ( transactionIndex ) } ,
1237
+ undefined ,
1239
1238
requestIdPrefix ,
1240
- ) ;
1241
- } catch ( error ) {
1242
- throw this . common . genericErrorHandler (
1243
- error ,
1244
- `${ requestIdPrefix } Failed to retrieve contract result for blockHash ${ blockHash } and index=${ transactionIndex } ` ,
1245
- ) ;
1246
- }
1239
+ )
1240
+ . then ( ( contractResults ) => formatContractResult ( contractResults [ 0 ] ?? null ) )
1241
+ . catch ( ( error : any ) => {
1242
+ throw this . common . genericErrorHandler (
1243
+ error ,
1244
+ `${ requestIdPrefix } Failed to retrieve contract result for blockHash ${ blockHash } and index=${ transactionIndex } ` ,
1245
+ ) ;
1246
+ } ) ;
1247
1247
}
1248
1248
1249
1249
/**
@@ -1261,19 +1261,19 @@ export class EthImpl implements Eth {
1261
1261
`${ requestIdPrefix } getTransactionByBlockNumberAndIndex(blockNum=${ blockNumOrTag } , index=${ transactionIndex } )` ,
1262
1262
) ;
1263
1263
const blockNum = await this . translateBlockTag ( blockNumOrTag , requestIdPrefix ) ;
1264
-
1265
- try {
1266
- return await this . getTransactionByBlockHashOrBlockNumAndIndex (
1267
- { title : 'blockNumber' , value : blockNum } ,
1268
- transactionIndex ,
1264
+ return this . mirrorNodeClient
1265
+ . getContractResults (
1266
+ { blockNumber : blockNum , transactionIndex : Number ( transactionIndex ) } ,
1267
+ undefined ,
1269
1268
requestIdPrefix ,
1270
- ) ;
1271
- } catch ( error ) {
1272
- throw this . common . genericErrorHandler (
1273
- error ,
1274
- `${ requestIdPrefix } Failed to retrieve contract result for blockNum ${ blockNum } and index=${ transactionIndex } ` ,
1275
- ) ;
1276
- }
1269
+ )
1270
+ . then ( ( contractResults ) => formatContractResult ( contractResults [ 0 ] ?? null ) )
1271
+ . catch ( ( e : any ) => {
1272
+ throw this . common . genericErrorHandler (
1273
+ e ,
1274
+ `${ requestIdPrefix } Failed to retrieve contract result for blockNum ${ blockNum } and index=${ transactionIndex } ` ,
1275
+ ) ;
1276
+ } ) ;
1277
1277
}
1278
1278
1279
1279
/**
@@ -1500,40 +1500,6 @@ export class EthImpl implements Eth {
1500
1500
}
1501
1501
}
1502
1502
1503
- /**
1504
- * Gets transactions by block hash or block number and index with resolved EVM addresses
1505
- * @param blockParam
1506
- * @param transactionIndex
1507
- * @param requestIdPrefix
1508
- * @returns Promise<Transaction | null>
1509
- */
1510
- private async getTransactionByBlockHashOrBlockNumAndIndex (
1511
- blockParam : {
1512
- title : 'blockHash' | 'blockNumber' ;
1513
- value : string | number ;
1514
- } ,
1515
- transactionIndex : string ,
1516
- requestIdPrefix ?: string ,
1517
- ) : Promise < Transaction | null > {
1518
- const contractResults = await this . mirrorNodeClient . getContractResults (
1519
- {
1520
- [ blockParam . title ] : blockParam . value ,
1521
- transactionIndex : Number ( transactionIndex ) ,
1522
- } ,
1523
- undefined ,
1524
- requestIdPrefix ,
1525
- ) ;
1526
-
1527
- if ( ! contractResults [ 0 ] ) return null ;
1528
-
1529
- const resolvedToAddress = await this . resolveEvmAddress ( contractResults [ 0 ] . to , requestIdPrefix ) ;
1530
- const resolvedFromAddress = await this . resolveEvmAddress ( contractResults [ 0 ] . from , requestIdPrefix , [
1531
- constants . TYPE_ACCOUNT ,
1532
- ] ) ;
1533
-
1534
- return formatContractResult ( { ...contractResults [ 0 ] , from : resolvedFromAddress , to : resolvedToAddress } ) ;
1535
- }
1536
-
1537
1503
// according to EIP-1898 (https://eips.ethereum.org/EIPS/eip-1898) block param can either be a string (blockNumber or Block Tag) or an object (blockHash or blockNumber)
1538
1504
private async extractBlockNumberOrTag (
1539
1505
blockParam : string | object | null ,
@@ -2038,18 +2004,8 @@ export class EthImpl implements Eth {
2038
2004
throw predefined . MAX_BLOCK_SIZE ( blockResponse . count ) ;
2039
2005
}
2040
2006
2041
- // prepare transactionArray
2042
- let transactionArray : any [ ] = [ ] ;
2043
- for ( const contractResult of contractResults ) {
2044
- contractResult . from = await this . resolveEvmAddress ( contractResult . from , requestIdPrefix , [
2045
- constants . TYPE_ACCOUNT ,
2046
- ] ) ;
2047
- contractResult . to = await this . resolveEvmAddress ( contractResult . to , requestIdPrefix ) ;
2048
-
2049
- transactionArray . push ( showDetails ? formatContractResult ( contractResult ) : contractResult . hash ) ;
2050
- }
2051
-
2052
2007
const blockHash = toHash32 ( blockResponse . hash ) ;
2008
+ const transactionArray = contractResults . map ( ( cr ) => ( showDetails ? formatContractResult ( cr ) : cr . hash ) ) ;
2053
2009
// Gating feature in case of unexpected behavior with other apps.
2054
2010
if ( this . shouldPopulateSyntheticContractResults ) {
2055
2011
this . filterAndPopulateSyntheticContractResults ( showDetails , logs , transactionArray , requestIdPrefix ) ;
0 commit comments