File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -1024,7 +1024,7 @@ export class EthImpl implements Eth {
10241024 removed : false ,
10251025 topics : log . topics ,
10261026 transactionHash : EthImpl . toHash32 ( receiptResponse . hash ) ,
1027- transactionIndex : EthImpl . numberTo0x ( receiptResponse . transaction_index )
1027+ transactionIndex : EthImpl . nullableNumberTo0x ( receiptResponse . transaction_index )
10281028 } ) ;
10291029 } ) ;
10301030
@@ -1039,7 +1039,7 @@ export class EthImpl implements Eth {
10391039 logs : logs ,
10401040 logsBloom : receiptResponse . bloom === EthImpl . emptyHex ? EthImpl . emptyBloom : receiptResponse . bloom ,
10411041 transactionHash : EthImpl . toHash32 ( receiptResponse . hash ) ,
1042- transactionIndex : EthImpl . numberTo0x ( receiptResponse . transaction_index ) ,
1042+ transactionIndex : EthImpl . nullableNumberTo0x ( receiptResponse . transaction_index ) ,
10431043 effectiveGasPrice : EthImpl . nanOrNumberTo0x ( Number . parseInt ( effectiveGas ) * 10_000_000_000 ) ,
10441044 root : receiptResponse . root ,
10451045 status : receiptResponse . status ,
@@ -1068,7 +1068,7 @@ export class EthImpl implements Eth {
10681068 }
10691069
10701070 static nullableNumberTo0x ( input : number | BigNumber ) : string | null {
1071- return input === null ? null : EthImpl . numberTo0x ( input ) ;
1071+ return input == null ? null : EthImpl . numberTo0x ( input ) ;
10721072 }
10731073
10741074 static nanOrNumberTo0x ( input : number | BigNumber ) : string {
Original file line number Diff line number Diff line change @@ -2519,6 +2519,24 @@ describe('Eth', async function () {
25192519 if ( receipt == null ) return ;
25202520 expect ( receipt . gasUsed ) . to . eq ( "0x0" ) ;
25212521 } ) ;
2522+
2523+ it ( 'handles missing transaction index' , async function ( ) {
2524+ // mirror node request mocks
2525+ mock . onGet ( `contracts/results/${ defaultTxHash } ` ) . reply ( 200 , {
2526+ ...defaultDetailedContractResultByHash , ...{
2527+ transaction_index : undefined
2528+ }
2529+ } ) ;
2530+ mock . onGet ( `contracts/${ defaultDetailedContractResultByHash . created_contract_ids [ 0 ] } ` ) . reply ( 200 , {
2531+ evm_address : contractEvmAddress
2532+ } ) ;
2533+ const receipt = await ethImpl . getTransactionReceipt ( defaultTxHash ) ;
2534+
2535+ expect ( receipt ) . to . exist ;
2536+
2537+ expect ( receipt . logs [ 0 ] . transactionIndex ) . to . eq ( null ) ;
2538+ expect ( receipt . transactionIndex ) . to . eq ( null ) ;
2539+ } ) ;
25222540 } ) ;
25232541
25242542 describe ( 'eth_getTransactionByHash' , async function ( ) {
You can’t perform that action at this time.
0 commit comments