Skip to content

[Feature] Add specializations for Signed types for OpTransaction<TxEnv> #207

@mattsse

Description

@mattsse

Describe the feature you would like

rn we only support going from the envelope to the OpTransaction<TxEnv>

impl FromTxWithEncoded<OpTxEnvelope> for TxEnv {
fn from_encoded_tx(tx: &OpTxEnvelope, caller: Address, _encoded: Bytes) -> Self {
Self::from_recovered_tx(tx, caller)
}
}

impl FromTxWithEncoded<OpTxEnvelope> for OpTransaction<TxEnv> {
fn from_encoded_tx(tx: &OpTxEnvelope, caller: Address, encoded: Bytes) -> Self {
let base = TxEnv::from_recovered_tx(tx, caller);
let deposit = if let OpTxEnvelope::Deposit(tx) = tx {
DepositTransactionParts {
source_hash: tx.source_hash,
mint: Some(tx.mint),
is_system_transaction: tx.is_system_transaction,
}
} else {
Default::default()
};
Self { base, enveloped_tx: Some(encoded), deposit }
}
}

while for just TxEnv we also support:

evm/crates/evm/src/tx.rs

Lines 255 to 261 in f3e5d1d

impl FromTxWithEncoded<TxEip4844> for TxEnv {
fn from_encoded_tx(tx: &TxEip4844, sender: Address, _encoded: Bytes) -> Self {
Self::from_recovered_tx(tx, sender)
}
}
impl FromRecoveredTx<TxEip7702> for TxEnv {

ideally we have the same

this means effectively inlining this per tx implementation:

impl FromTxWithEncoded<OpTxEnvelope> for OpTransaction<TxEnv> {
fn from_encoded_tx(tx: &OpTxEnvelope, caller: Address, encoded: Bytes) -> Self {
let base = TxEnv::from_recovered_tx(tx, caller);
let deposit = if let OpTxEnvelope::Deposit(tx) = tx {
DepositTransactionParts {
source_hash: tx.source_hash,
mint: Some(tx.mint),
is_system_transaction: tx.is_system_transaction,
}
} else {
Default::default()
};
Self { base, enveloped_tx: Some(encoded), deposit }

and then updating this impl for envelope like:

impl<Eip4844: AsRef<TxEip4844>> FromTxWithEncoded<EthereumTxEnvelope<Eip4844>> for TxEnv {

Additional context

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions