Skip to content

Commit

Permalink
Merge branch 'main' into rf/book/frames-to-batches
Browse files Browse the repository at this point in the history
  • Loading branch information
refcell authored Nov 15, 2024
2 parents be513b5 + 0d872ba commit 0ef733a
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion crates/consensus/src/transaction/envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use alloy_eips::{
eip7702::SignedAuthorization,
};
use alloy_primitives::{Address, Bytes, TxKind, B256, U256};
use alloy_rlp::{Decodable, Encodable};
use alloy_rlp::{BufMut, Decodable, Encodable};
use derive_more::Display;

use crate::TxDeposit;
Expand Down Expand Up @@ -79,6 +79,36 @@ impl TryFrom<u8> for OpTxType {
}
}

impl PartialEq<u8> for OpTxType {
fn eq(&self, other: &u8) -> bool {
(*self as u8) == *other
}
}

impl PartialEq<OpTxType> for u8 {
fn eq(&self, other: &OpTxType) -> bool {
*self == *other as Self
}
}

impl Encodable for OpTxType {
fn encode(&self, out: &mut dyn BufMut) {
(*self as u8).encode(out);
}

fn length(&self) -> usize {
1
}
}

impl Decodable for OpTxType {
fn decode(buf: &mut &[u8]) -> alloy_rlp::Result<Self> {
let ty = u8::decode(buf)?;

Self::try_from(ty).map_err(|_| alloy_rlp::Error::Custom("invalid transaction type"))
}
}

/// The Ethereum [EIP-2718] Transaction Envelope, modified for OP Stack chains.
///
/// # Note:
Expand Down

0 comments on commit 0ef733a

Please sign in to comment.