Skip to content

Commit 2143307

Browse files
committed
fix
1 parent 56ba615 commit 2143307

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

x/cronos/rpc/api.go

+8-16
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,7 @@ func (api *CronosAPI) GetTransactionReceiptsByBlock(blockNrOrHash rpctypes.Block
159159
return nil, fmt.Errorf("invalid tx type: %T", msg)
160160
}
161161

162-
txData, err := evmtypes.UnpackTxData(ethMsg.Data)
163-
if err != nil {
164-
api.logger.Error("failed to unpack tx data", "error", err.Error())
165-
return nil, err
166-
}
167-
162+
txData := ethMsg.AsTransaction()
168163
parsedTx := parsedTxs.GetTxByMsgIndex(msgIndex)
169164

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

198193
// Implementation fields: These fields are added by geth when processing a transaction.
199194
// They are stored in the chain database.
200-
"transactionHash": ethMsg.Hash,
195+
"transactionHash": txData.Hash(),
201196
"contractAddress": nil,
202197
"gasUsed": hexutil.Uint64(parsedTx.GasUsed),
203198

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

210205
// sender and receiver (contract or EOA) addreses
211206
"from": from,
212-
"to": txData.GetTo(),
213-
"type": hexutil.Uint(ethMsg.AsTransaction().Type()),
207+
"to": txData.To(),
208+
"type": hexutil.Uint(txData.Type()),
214209
}
215210

216211
// If the to is empty, assume it is a contract creation
217-
if txData.GetTo() == nil {
218-
receipt["contractAddress"] = crypto.CreateAddress(from, txData.GetNonce())
212+
if txData.To() == nil {
213+
receipt["contractAddress"] = crypto.CreateAddress(from, txData.Nonce())
219214
}
220-
221-
if dynamicTx, ok := txData.(*evmtypes.DynamicFeeTx); ok {
222-
receipt["effectiveGasPrice"] = hexutil.Big(*dynamicTx.EffectiveGasPrice(baseFee))
215+
if txData.Type() == ethtypes.DynamicFeeTxType {
216+
receipt["effectiveGasPrice"] = hexutil.Big(*ethMsg.GetEffectiveGasPrice(baseFee))
223217
}
224-
225218
receipts = append(receipts, receipt)
226-
227219
txIndex++
228220
}
229221
cumulativeGasUsed += msgCumulativeGasUsed

0 commit comments

Comments
 (0)