From 21433076010c86293ffce848ff2cf33aae580188 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Tue, 30 Apr 2024 18:22:07 +0800 Subject: [PATCH] fix --- x/cronos/rpc/api.go | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/x/cronos/rpc/api.go b/x/cronos/rpc/api.go index e2b6d68358..2ebda2ef00 100644 --- a/x/cronos/rpc/api.go +++ b/x/cronos/rpc/api.go @@ -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() parsedTx := parsedTxs.GetTxByMsgIndex(msgIndex) // Get the transaction result from the log @@ -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(), "contractAddress": nil, "gasUsed": hexutil.Uint64(parsedTx.GasUsed), @@ -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()), } // 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()) } - - 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)) } - receipts = append(receipts, receipt) - txIndex++ } cumulativeGasUsed += msgCumulativeGasUsed