Skip to content

Commit 24f8e1e

Browse files
authored
Reorg the transaction module (#54)
* Reorg the transaction module - split the transaction module to legacy/eip2930/eip1559 modules - add to_message method for LegacyTransaction/EIP2930Transaction/EIP1559Transaction - adjust some imports * apply review suggestions
1 parent 8cacae5 commit 24f8e1e

File tree

9 files changed

+955
-899
lines changed

9 files changed

+955
-899
lines changed

src/block.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
use crate::{
2-
util::ordered_trie_root, EnvelopedDecodable, EnvelopedEncodable, Header, PartialHeader,
3-
TransactionAny, TransactionV0, TransactionV1, TransactionV2,
4-
};
51
use alloc::vec::Vec;
2+
63
use ethereum_types::H256;
7-
use rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream};
4+
use rlp::{DecoderError, Rlp, RlpStream};
85
use sha3::{Digest, Keccak256};
96

7+
use crate::{
8+
enveloped::{EnvelopedDecodable, EnvelopedEncodable},
9+
header::{Header, PartialHeader},
10+
transaction::{TransactionAny, TransactionV0, TransactionV1, TransactionV2},
11+
util::ordered_trie_root,
12+
};
13+
1014
#[derive(Clone, Debug, PartialEq, Eq)]
1115
#[cfg_attr(
1216
feature = "with-codec",
@@ -19,7 +23,7 @@ pub struct Block<T> {
1923
pub ommers: Vec<Header>,
2024
}
2125

22-
impl<T: EnvelopedEncodable> Encodable for Block<T> {
26+
impl<T: EnvelopedEncodable> rlp::Encodable for Block<T> {
2327
fn rlp_append(&self, s: &mut RlpStream) {
2428
s.begin_list(3);
2529
s.append(&self.header);
@@ -34,7 +38,7 @@ impl<T: EnvelopedEncodable> Encodable for Block<T> {
3438
}
3539
}
3640

37-
impl<T: EnvelopedDecodable> Decodable for Block<T> {
41+
impl<T: EnvelopedDecodable> rlp::Decodable for Block<T> {
3842
fn decode(rlp: &Rlp) -> Result<Self, DecoderError> {
3943
Ok(Self {
4044
header: rlp.val_at(0)?,

src/lib.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ pub mod util;
1414
// Alias for `Vec<u8>`. This type alias is necessary for rlp-derive to work correctly.
1515
type Bytes = alloc::vec::Vec<u8>;
1616

17-
pub use account::Account;
18-
pub use block::*;
19-
pub use enveloped::*;
20-
pub use header::{Header, PartialHeader};
21-
pub use log::Log;
22-
pub use receipt::*;
23-
pub use transaction::*;
17+
pub use crate::account::Account;
18+
pub use crate::block::*;
19+
pub use crate::enveloped::*;
20+
pub use crate::header::{Header, PartialHeader};
21+
pub use crate::log::Log;
22+
pub use crate::receipt::*;
23+
pub use crate::transaction::*;

src/log.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
use crate::Bytes;
21
use alloc::vec::Vec;
2+
33
use ethereum_types::{H160, H256};
44

5+
use crate::Bytes;
6+
57
#[derive(Clone, Debug, PartialEq, Eq)]
68
#[derive(rlp::RlpEncodable, rlp::RlpDecodable)]
79
#[cfg_attr(

src/receipt.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
use crate::{EnvelopedDecodable, EnvelopedDecoderError, EnvelopedEncodable, Log};
21
use alloc::vec::Vec;
2+
33
use bytes::BytesMut;
44
use ethereum_types::{Bloom, H256, U256};
55
use rlp::{Decodable, DecoderError, Rlp};
66

7+
use crate::{
8+
enveloped::{EnvelopedDecodable, EnvelopedDecoderError, EnvelopedEncodable},
9+
log::Log,
10+
};
11+
712
#[derive(Clone, Debug, PartialEq, Eq)]
813
#[derive(rlp::RlpEncodable, rlp::RlpDecodable)]
914
#[cfg_attr(

0 commit comments

Comments
 (0)