Skip to content

Commit 3831837

Browse files
authored
feat: Implement FromTxWithEncoded and FromRecoveredTx from OpTxEnvelope for TxEnv (#94)
1 parent 5373743 commit 3831837

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

crates/evm/src/tx.rs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,13 @@ mod op {
356356
use op_revm::{transaction::deposit::DepositTransactionParts, OpTransaction};
357357
use revm::context::TxEnv;
358358

359-
impl FromTxWithEncoded<OpTxEnvelope> for OpTransaction<TxEnv> {
360-
fn from_encoded_tx(tx: &OpTxEnvelope, caller: Address, encoded: Bytes) -> Self {
361-
let base = match tx {
362-
OpTxEnvelope::Legacy(tx) => TxEnv::from_recovered_tx(tx.tx(), caller),
363-
OpTxEnvelope::Eip1559(tx) => TxEnv::from_recovered_tx(tx.tx(), caller),
364-
OpTxEnvelope::Eip2930(tx) => TxEnv::from_recovered_tx(tx.tx(), caller),
365-
OpTxEnvelope::Eip7702(tx) => TxEnv::from_recovered_tx(tx.tx(), caller),
359+
impl FromRecoveredTx<OpTxEnvelope> for TxEnv {
360+
fn from_recovered_tx(tx: &OpTxEnvelope, caller: Address) -> Self {
361+
match tx {
362+
OpTxEnvelope::Legacy(tx) => Self::from_recovered_tx(tx.tx(), caller),
363+
OpTxEnvelope::Eip1559(tx) => Self::from_recovered_tx(tx.tx(), caller),
364+
OpTxEnvelope::Eip2930(tx) => Self::from_recovered_tx(tx.tx(), caller),
365+
OpTxEnvelope::Eip7702(tx) => Self::from_recovered_tx(tx.tx(), caller),
366366
OpTxEnvelope::Deposit(tx) => {
367367
let TxDeposit {
368368
to,
@@ -374,7 +374,7 @@ mod op {
374374
mint: _,
375375
is_system_transaction: _,
376376
} = tx.inner();
377-
TxEnv {
377+
Self {
378378
tx_type: tx.ty(),
379379
caller,
380380
gas_limit: *gas_limit,
@@ -384,7 +384,19 @@ mod op {
384384
..Default::default()
385385
}
386386
}
387-
};
387+
}
388+
}
389+
}
390+
391+
impl FromTxWithEncoded<OpTxEnvelope> for TxEnv {
392+
fn from_encoded_tx(tx: &OpTxEnvelope, caller: Address, _encoded: Bytes) -> Self {
393+
Self::from_recovered_tx(tx, caller)
394+
}
395+
}
396+
397+
impl FromTxWithEncoded<OpTxEnvelope> for OpTransaction<TxEnv> {
398+
fn from_encoded_tx(tx: &OpTxEnvelope, caller: Address, encoded: Bytes) -> Self {
399+
let base = TxEnv::from_recovered_tx(tx, caller);
388400

389401
let deposit = if let OpTxEnvelope::Deposit(tx) = tx {
390402
DepositTransactionParts {

0 commit comments

Comments
 (0)