Skip to content

Commit

Permalink
refactor: use EIP TX_TYPE_ID (paradigmxyz#10471)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkysg authored Aug 23, 2024
1 parent 24495cd commit 0a7ac41
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions crates/primitives/src/receipt.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#[cfg(feature = "reth-codec")]
use crate::compression::{RECEIPT_COMPRESSOR, RECEIPT_DECOMPRESSOR};
use crate::{logs_bloom, Bloom, Bytes, TxType, B256};
use crate::{
logs_bloom, Bloom, Bytes, TxType, B256, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID,
EIP4844_TX_TYPE_ID, EIP7702_TX_TYPE_ID,
};
use alloy_primitives::Log;
use alloy_rlp::{length_of_length, Decodable, Encodable, RlpDecodable, RlpEncodable};
use bytes::{Buf, BufMut};
@@ -329,24 +332,24 @@ impl Decodable for ReceiptWithBloom {
"typed receipt cannot be decoded from an empty slice",
))?;
match receipt_type {
0x01 => {
EIP2930_TX_TYPE_ID => {
buf.advance(1);
Self::decode_receipt(buf, TxType::Eip2930)
}
0x02 => {
EIP1559_TX_TYPE_ID => {
buf.advance(1);
Self::decode_receipt(buf, TxType::Eip1559)
}
0x03 => {
EIP4844_TX_TYPE_ID => {
buf.advance(1);
Self::decode_receipt(buf, TxType::Eip4844)
}
0x04 => {
EIP7702_TX_TYPE_ID => {
buf.advance(1);
Self::decode_receipt(buf, TxType::Eip7702)
}
#[cfg(feature = "optimism")]
0x7E => {
crate::DEPOSIT_TX_TYPE_ID => {
buf.advance(1);
Self::decode_receipt(buf, TxType::Deposit)
}
@@ -469,20 +472,20 @@ impl<'a> ReceiptWithBloomEncoder<'a> {
TxType::Legacy => unreachable!("legacy already handled"),

TxType::Eip2930 => {
out.put_u8(0x01);
out.put_u8(EIP2930_TX_TYPE_ID);
}
TxType::Eip1559 => {
out.put_u8(0x02);
out.put_u8(EIP1559_TX_TYPE_ID);
}
TxType::Eip4844 => {
out.put_u8(0x03);
out.put_u8(EIP4844_TX_TYPE_ID);
}
TxType::Eip7702 => {
out.put_u8(0x04);
out.put_u8(EIP7702_TX_TYPE_ID);
}
#[cfg(feature = "optimism")]
TxType::Deposit => {
out.put_u8(0x7E);
out.put_u8(crate::DEPOSIT_TX_TYPE_ID);
}
}
out.put_slice(payload.as_ref());

0 comments on commit 0a7ac41

Please sign in to comment.