Skip to content

Commit

Permalink
sync primitives
Browse files Browse the repository at this point in the history
  • Loading branch information
mask-pp committed Nov 20, 2024
1 parent a3a22b8 commit 0dc832f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ optimism = [
"reth-codecs?/optimism",
"revm-primitives/optimism",
]
taiko = ["reth-chainspec/taiko", "revm-primitives/taiko"]
alloy-compat = [
"dep:alloy-rpc-types",
"dep:alloy-serde",
Expand Down
24 changes: 23 additions & 1 deletion crates/primitives/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use alloy_eips::{
eip2930::AccessList,
};
use alloy_primitives::{Bytes, TxHash};
use alloy_rlp::{Decodable, Encodable, Error as RlpError, Header};
use alloy_rlp::{encode_list, list_length, Decodable, Encodable, Error as RlpError, Header};
use core::mem;
use derive_more::{AsRef, Deref};
use once_cell::sync::Lazy;
Expand Down Expand Up @@ -1453,6 +1453,28 @@ impl<'a> arbitrary::Arbitrary<'a> for TransactionSigned {
}
}

/// List of signed transactions reference.
#[derive(Debug)]
pub struct TransactionSignedList<'a>(pub &'a [TransactionSigned]);

impl Encodable for TransactionSignedList<'_> {
/// This encodes the transaction _with_ the signature, and an rlp header.
///
/// For legacy transactions, it encodes the transaction data:
/// `rlp(tx-data)`
///
/// For EIP-2718 typed transactions, it encodes the transaction type followed by the rlp of the
/// transaction:
/// `rlp(tx-type || rlp(tx-data))`
fn encode(&self, out: &mut dyn bytes::BufMut) {
encode_list(self.0, out)
}

fn length(&self) -> usize {
list_length(self.0)
}
}

/// Signed transaction with recovered signer.
#[derive(Debug, Clone, PartialEq, Hash, Eq, AsRef, Deref)]
pub struct TransactionSignedEcRecovered {
Expand Down

0 comments on commit 0dc832f

Please sign in to comment.