[rpc] fix transaction receipt fetch bug (#3327)

pull/3336/head
Ganesha Upadhyaya 4 years ago committed by GitHub
parent 81691b692e
commit a0f2af1f43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      rpc/transaction.go
  2. 4
      rpc/v1/types.go
  3. 4
      rpc/v2/types.go

@ -591,6 +591,10 @@ func (s *PublicTransactionService) GetTransactionReceipt(
if stx == nil {
return nil, nil
}
// if there both normal and staking transactions, add to index
if block, _ := s.hmy.GetBlock(ctx, blockHash); block != nil {
index = index + uint64(block.Transactions().Len())
}
}
receipts, err := s.hmy.GetReceipts(ctx, blockHash)
if err != nil {

@ -301,11 +301,11 @@ func NewReceipt(
) (interface{}, error) {
plainTx, ok := tx.(*types.Transaction)
if ok {
return NewTxReceipt(plainTx, blockHash, blockIndex, blockNumber, receipt)
return NewTxReceipt(plainTx, blockHash, blockNumber, blockIndex, receipt)
}
stakingTx, ok := tx.(*staking.StakingTransaction)
if ok {
return NewStakingTxReceipt(stakingTx, blockHash, blockIndex, blockNumber, receipt)
return NewStakingTxReceipt(stakingTx, blockHash, blockNumber, blockIndex, receipt)
}
return nil, fmt.Errorf("unknown transaction type for RPC receipt")
}

@ -299,11 +299,11 @@ func NewReceipt(
) (interface{}, error) {
plainTx, ok := tx.(*types.Transaction)
if ok {
return NewTxReceipt(plainTx, blockHash, blockIndex, blockNumber, receipt)
return NewTxReceipt(plainTx, blockHash, blockNumber, blockIndex, receipt)
}
stakingTx, ok := tx.(*staking.StakingTransaction)
if ok {
return NewStakingTxReceipt(stakingTx, blockHash, blockIndex, blockNumber, receipt)
return NewStakingTxReceipt(stakingTx, blockHash, blockNumber, blockIndex, receipt)
}
return nil, fmt.Errorf("unknown transaction type for RPC receipt")
}

Loading…
Cancel
Save