Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: new evm tx format not integrated #1414

Merged
merged 10 commits into from
May 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix
  • Loading branch information
mmsqe committed Apr 30, 2024
commit 21433076010c86293ffce848ff2cf33aae580188
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 @@
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 @@

// 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 @@

// 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
Loading