Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 5aceb3e

Browse files
authoredOct 15, 2024
primitives: rm redundant chain_id function for Transaction (paradigmxyz#11751)
1 parent 6fb2710 commit 5aceb3e

File tree

9 files changed

+15
-20
lines changed

9 files changed

+15
-20
lines changed
 

‎Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/primitives/src/alloy_compat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{
55
Transaction, TransactionSigned, TransactionSignedEcRecovered, TransactionSignedNoHash, TxType,
66
};
77
use alloc::{string::ToString, vec::Vec};
8-
use alloy_consensus::{TxEip1559, TxEip2930, TxEip4844, TxLegacy};
8+
use alloy_consensus::{Transaction as _, TxEip1559, TxEip2930, TxEip4844, TxLegacy};
99
use alloy_primitives::{Parity, TxKind};
1010
use alloy_rlp::Error as RlpError;
1111
use alloy_serde::WithOtherFields;

‎crates/primitives/src/transaction/mod.rs

+6-15
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ use crate::BlockHashOrNumber;
44
use alloy_eips::eip7702::SignedAuthorization;
55
use alloy_primitives::{keccak256, Address, ChainId, TxKind, B256, U256};
66

7-
use alloy_consensus::{SignableTransaction, TxEip1559, TxEip2930, TxEip4844, TxEip7702, TxLegacy};
7+
use alloy_consensus::{
8+
SignableTransaction, Transaction as AlloyTransaction, TxEip1559, TxEip2930, TxEip4844,
9+
TxEip7702, TxLegacy,
10+
};
811
use alloy_eips::{
912
eip2718::{Decodable2718, Eip2718Error, Eip2718Result, Encodable2718},
1013
eip2930::AccessList,
@@ -197,19 +200,6 @@ impl Transaction {
197200
}
198201
}
199202

200-
/// Get `chain_id`.
201-
pub const fn chain_id(&self) -> Option<u64> {
202-
match self {
203-
Self::Legacy(TxLegacy { chain_id, .. }) => *chain_id,
204-
Self::Eip2930(TxEip2930 { chain_id, .. }) |
205-
Self::Eip1559(TxEip1559 { chain_id, .. }) |
206-
Self::Eip4844(TxEip4844 { chain_id, .. }) |
207-
Self::Eip7702(TxEip7702 { chain_id, .. }) => Some(*chain_id),
208-
#[cfg(feature = "optimism")]
209-
Self::Deposit(_) => None,
210-
}
211-
}
212-
213203
/// Sets the transaction's chain id to the provided value.
214204
pub fn set_chain_id(&mut self, chain_id: u64) {
215205
match self {
@@ -824,7 +814,7 @@ impl Encodable for Transaction {
824814
}
825815
}
826816

827-
impl alloy_consensus::Transaction for Transaction {
817+
impl AlloyTransaction for Transaction {
828818
fn chain_id(&self) -> Option<ChainId> {
829819
match self {
830820
Self::Legacy(tx) => tx.chain_id(),
@@ -1974,6 +1964,7 @@ mod tests {
19741964
transaction::{signature::Signature, TxEip1559, TxKind, TxLegacy},
19751965
Transaction, TransactionSigned, TransactionSignedEcRecovered, TransactionSignedNoHash,
19761966
};
1967+
use alloy_consensus::Transaction as _;
19771968
use alloy_eips::eip2718::{Decodable2718, Encodable2718};
19781969
use alloy_primitives::{address, b256, bytes, hex, Address, Bytes, Parity, B256, U256};
19791970
use alloy_rlp::{Decodable, Encodable, Error as RlpError};

‎crates/rpc/rpc-types-compat/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ alloy-rpc-types.workspace = true
2424
alloy-rpc-types-eth = { workspace = true, default-features = false, features = ["serde"] }
2525
alloy-serde.workspace = true
2626
alloy-rpc-types-engine.workspace = true
27+
alloy-consensus.workspace = true
2728

2829
[dev-dependencies]
2930
serde_json.workspace = true

‎crates/rpc/rpc-types-compat/src/transaction/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ mod signature;
44
pub use signature::*;
55
use std::fmt;
66

7+
use alloy_consensus::Transaction as _;
78
use alloy_rpc_types::{
89
request::{TransactionInput, TransactionRequest},
910
Transaction, TransactionInfo,

‎crates/rpc/rpc/src/eth/helpers/types.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! L1 `eth` API types.
22
3+
use alloy_consensus::Transaction as _;
34
use alloy_network::{AnyNetwork, Network};
45
use alloy_primitives::{Address, TxKind};
56
use alloy_rpc_types::{Transaction, TransactionInfo};

‎crates/transaction-pool/Cargo.toml

+2-3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ revm.workspace = true
2727
alloy-eips.workspace = true
2828
alloy-primitives.workspace = true
2929
alloy-rlp.workspace = true
30+
alloy-consensus.workspace = true
3031

3132
# async/futures
3233
futures-util.workspace = true
@@ -54,7 +55,6 @@ rand = { workspace = true, optional = true }
5455
paste = { workspace = true, optional = true }
5556
proptest = { workspace = true, optional = true }
5657
proptest-arbitrary-interop = { workspace = true, optional = true }
57-
alloy-consensus = { workspace = true, optional = true }
5858

5959
[dev-dependencies]
6060
reth-primitives = { workspace = true, features = ["arbitrary"] }
@@ -69,12 +69,11 @@ pprof = { workspace = true, features = ["criterion", "flamegraph"] }
6969
assert_matches.workspace = true
7070
tempfile.workspace = true
7171
serde_json.workspace = true
72-
alloy-consensus.workspace = true
7372

7473
[features]
7574
default = ["serde"]
7675
serde = ["dep:serde"]
77-
test-utils = ["rand", "paste", "serde", "alloy-consensus"]
76+
test-utils = ["rand", "paste", "serde"]
7877
arbitrary = ["proptest", "reth-primitives/arbitrary", "proptest-arbitrary-interop"]
7978

8079
[[bench]]

‎crates/transaction-pool/src/traits.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::{
77
validate::ValidPoolTransaction,
88
AllTransactionsEvents,
99
};
10+
use alloy_consensus::Transaction as _;
1011
use alloy_eips::{eip2718::Encodable2718, eip2930::AccessList, eip4844::BlobAndProofV1};
1112
use alloy_primitives::{Address, TxHash, TxKind, B256, U256};
1213
use futures_util::{ready, Stream};

‎testing/testing-utils/src/generators.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Generators for different data structures like block headers, block bodies and ranges of those.
22
3-
use alloy_consensus::TxLegacy;
3+
use alloy_consensus::{Transaction as _, TxLegacy};
44
use alloy_eips::{
55
eip6110::DepositRequest, eip7002::WithdrawalRequest, eip7251::ConsolidationRequest,
66
};

0 commit comments

Comments
 (0)
This repository has been archived.