Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Apr 30, 2024
1 parent 56ba615 commit 2143307
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions x/cronos/rpc/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,7 @@ func (api *CronosAPI) GetTransactionReceiptsByBlock(blockNrOrHash rpctypes.Block
return nil, fmt.Errorf("invalid tx type: %T", msg)
}

txData, err := evmtypes.UnpackTxData(ethMsg.Data)
if err != nil {
api.logger.Error("failed to unpack tx data", "error", err.Error())
return nil, err
}

txData := ethMsg.AsTransaction()

Check warning on line 162 in x/cronos/rpc/api.go

View check run for this annotation

Codecov / codecov/patch

x/cronos/rpc/api.go#L162

Added line #L162 was not covered by tests
parsedTx := parsedTxs.GetTxByMsgIndex(msgIndex)

// Get the transaction result from the log
Expand Down Expand Up @@ -197,7 +192,7 @@ func (api *CronosAPI) GetTransactionReceiptsByBlock(blockNrOrHash rpctypes.Block

// Implementation fields: These fields are added by geth when processing a transaction.
// They are stored in the chain database.
"transactionHash": ethMsg.Hash,
"transactionHash": txData.Hash(),

Check warning on line 195 in x/cronos/rpc/api.go

View check run for this annotation

Codecov / codecov/patch

x/cronos/rpc/api.go#L195

Added line #L195 was not covered by tests
"contractAddress": nil,
"gasUsed": hexutil.Uint64(parsedTx.GasUsed),

Expand All @@ -209,21 +204,18 @@ func (api *CronosAPI) GetTransactionReceiptsByBlock(blockNrOrHash rpctypes.Block

// sender and receiver (contract or EOA) addreses
"from": from,
"to": txData.GetTo(),
"type": hexutil.Uint(ethMsg.AsTransaction().Type()),
"to": txData.To(),
"type": hexutil.Uint(txData.Type()),

Check warning on line 208 in x/cronos/rpc/api.go

View check run for this annotation

Codecov / codecov/patch

x/cronos/rpc/api.go#L207-L208

Added lines #L207 - L208 were not covered by tests
}

// If the to is empty, assume it is a contract creation
if txData.GetTo() == nil {
receipt["contractAddress"] = crypto.CreateAddress(from, txData.GetNonce())
if txData.To() == nil {
receipt["contractAddress"] = crypto.CreateAddress(from, txData.Nonce())

Check warning on line 213 in x/cronos/rpc/api.go

View check run for this annotation

Codecov / codecov/patch

x/cronos/rpc/api.go#L212-L213

Added lines #L212 - L213 were not covered by tests
}

if dynamicTx, ok := txData.(*evmtypes.DynamicFeeTx); ok {
receipt["effectiveGasPrice"] = hexutil.Big(*dynamicTx.EffectiveGasPrice(baseFee))
if txData.Type() == ethtypes.DynamicFeeTxType {
receipt["effectiveGasPrice"] = hexutil.Big(*ethMsg.GetEffectiveGasPrice(baseFee))

Check warning on line 216 in x/cronos/rpc/api.go

View check run for this annotation

Codecov / codecov/patch

x/cronos/rpc/api.go#L215-L216

Added lines #L215 - L216 were not covered by tests
}

receipts = append(receipts, receipt)

txIndex++
}
cumulativeGasUsed += msgCumulativeGasUsed
Expand Down

0 comments on commit 2143307

Please sign in to comment.