Skip to content

Conversation

@mattsse
Copy link
Member

@mattsse mattsse commented Oct 30, 2025

The transaction conversion logic from TypedTransaction to RpcTransaction was spread across multiple functions with significant code duplication. This change consolidates and simplifies the conversion flow.

TypedTransaction now has a try_into_eth() method that converts to TxEnvelope, returning an error for OP-stack Deposit transactions which aren't part of standard Ethereum transaction types.

The new MaybeImpersonatedTransaction::into_rpc_transaction() method encapsulates the entire conversion logic in one place, making the API more explicit and easier to use. The From trait implementation now simply delegates to this method.

The standalone to_alloy_transaction_with_hash_and_sender function has been removed since its logic is now part of the into_rpc_transaction method. This eliminates ~80 lines of duplicated RpcTransaction construction and makes the code easier to maintain.

this is still a bit verbose because we need to inject fake fake hashes for impersonated txs

Added TypedTransaction::try_into_eth() to convert TypedTransaction to TxEnvelope, returning an error for Deposit transactions that are not part of standard Ethereum.

Added MaybeImpersonatedTransaction::into_rpc_transaction() method that encapsulates the conversion logic, making it more explicit and easier to use. The From<MaybeImpersonatedTransaction> for RpcTransaction trait now delegates to this method.

Removed the standalone to_alloy_transaction_with_hash_and_sender function since its logic is now part of the into_rpc_transaction method.

Updated transaction_build to use the new into_rpc_transaction() method, simplifying the conversion flow and eliminating redundant recovery calls.

Co-Authored-By: Claude <noreply@anthropic.com>
@grandizzy grandizzy added this pull request to the merge queue Oct 31, 2025
Merged via the queue into master with commit 65f96cf Oct 31, 2025
15 checks passed
@grandizzy grandizzy deleted the refactor-transaction-rpc-conversion branch October 31, 2025 02:40
@github-project-automation github-project-automation bot moved this to Done in Foundry Oct 31, 2025
@rplusq rplusq mentioned this pull request Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants