Skip to content

Commit

Permalink
rename feature
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin committed Sep 29, 2024
1 parent 09ec27e commit af593d2
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 32 deletions.
2 changes: 1 addition & 1 deletion crates/consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ serde = [
"dep:alloy-serde",
"alloy-eips/serde",
]
bincode-compat = ["serde_with"]
serde-bincode-compat = ["serde_with"]
12 changes: 6 additions & 6 deletions crates/consensus/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -822,8 +822,8 @@ mod tests {
}

/// Bincode-compatibl [`Header`] serde implementation.
#[cfg(all(feature = "serde", feature = "bincode-compat"))]
pub(super) mod bincode_compat {
#[cfg(all(feature = "serde", feature = "serde-bincode-compat"))]
pub(super) mod serde_bincode_compat {
use alloc::borrow::Cow;
use alloy_primitives::{Address, BlockNumber, Bloom, Bytes, B256, B64, U256};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
Expand All @@ -833,14 +833,14 @@ pub(super) mod bincode_compat {
///
/// Intended to use with the [`serde_with::serde_as`] macro in the following way:
/// ```rust
/// use alloy_consensus::{bincode_compat, Header};
/// use alloy_consensus::{serde_bincode_compat, Header};
/// use serde::{Deserialize, Serialize};
/// use serde_with::serde_as;
///
/// #[serde_as]
/// #[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
/// struct Data {
/// #[serde_as(as = "bincode_compat::Header")]
/// #[serde_as(as = "serde_bincode_compat::Header")]
/// header: Header,
/// }
/// ```
Expand Down Expand Up @@ -962,14 +962,14 @@ pub(super) mod bincode_compat {
use serde::{Deserialize, Serialize};
use serde_with::serde_as;

use super::super::{bincode_compat, Header};
use super::super::{serde_bincode_compat, Header};

#[test]
fn test_header_bincode_roundtrip() {
#[serde_as]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
struct Data {
#[serde_as(as = "bincode_compat::Header")]
#[serde_as(as = "serde_bincode_compat::Header")]
header: Header,
}

Expand Down
8 changes: 5 additions & 3 deletions crates/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ mod signed;
pub use signed::Signed;

/// Bincode-compatible serde implementations for consensus types.
#[cfg(all(feature = "serde", feature = "bincode-compat"))]
pub mod bincode_compat {
pub use super::{header::bincode_compat::*, transaction::bincode_compat as transaction};
#[cfg(all(feature = "serde", feature = "serde-bincode-compat"))]
pub mod serde_bincode_compat {
pub use super::{
header::serde_bincode_compat::*, transaction::serde_bincode_compat as transaction,
};
}
14 changes: 7 additions & 7 deletions crates/consensus/src/transaction/eip1559.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,9 @@ mod tests {
}
}

/// Bincode-compatible [`TxEip1559`] serde implementation.
#[cfg(all(feature = "serde", feature = "bincode-compat"))]
pub(super) mod bincode_compat {
/// serde-bincode-compatible [`TxEip1559`] serde implementation.
#[cfg(all(feature = "serde", feature = "serde-bincode-compat"))]
pub(super) mod serde_bincode_compat {
use alloc::borrow::Cow;
use alloy_eips::eip2930::AccessList;
use alloy_primitives::{Bytes, ChainId, TxKind, U256};
Expand All @@ -463,14 +463,14 @@ pub(super) mod bincode_compat {
///
/// Intended to use with the [`serde_with::serde_as`] macro in the following way:
/// ```rust
/// use alloy_consensus::{bincode_compat, TxEip1559};
/// use alloy_consensus::{serde_bincode_compat, TxEip1559};
/// use serde::{Deserialize, Serialize};
/// use serde_with::serde_as;
///
/// #[serde_as]
/// #[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
/// struct Data {
/// #[serde_as(as = "bincode_compat::transaction::TxEip1559")]
/// #[serde_as(as = "serde_bincode_compat::transaction::TxEip1559")]
/// transaction: TxEip1559,
/// }
/// ```
Expand Down Expand Up @@ -552,14 +552,14 @@ pub(super) mod bincode_compat {
use serde::{Deserialize, Serialize};
use serde_with::serde_as;

use super::super::{bincode_compat, TxEip1559};
use super::super::{serde_bincode_compat, TxEip1559};

#[test]
fn test_tx_eip1559_bincode_roundtrip() {
#[serde_as]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
struct Data {
#[serde_as(as = "bincode_compat::TxEip1559")]
#[serde_as(as = "serde_bincode_compat::TxEip1559")]
transaction: TxEip1559,
}

Expand Down
12 changes: 6 additions & 6 deletions crates/consensus/src/transaction/eip2930.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ mod tests {
}

/// Bincode-compatible [`TxEip2930`] serde implementation.
#[cfg(all(feature = "serde", feature = "bincode-compat"))]
pub(super) mod bincode_compat {
#[cfg(all(feature = "serde", feature = "serde-bincode-compat"))]
pub(super) mod serde_bincode_compat {
use alloc::borrow::Cow;
use alloy_eips::eip2930::AccessList;
use alloy_primitives::{Bytes, ChainId, TxKind, U256};
Expand All @@ -420,14 +420,14 @@ pub(super) mod bincode_compat {
///
/// Intended to use with the [`serde_with::serde_as`] macro in the following way:
/// ```rust
/// use alloy_consensus::{bincode_compat, TxEip2930};
/// use alloy_consensus::{serde_bincode_compat, TxEip2930};
/// use serde::{Deserialize, Serialize};
/// use serde_with::serde_as;
///
/// #[serde_as]
/// #[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
/// struct Data {
/// #[serde_as(as = "bincode_compat::transaction::TxEip2930")]
/// #[serde_as(as = "serde_bincode_compat::transaction::TxEip2930")]
/// transaction: TxEip2930,
/// }
/// ```
Expand Down Expand Up @@ -505,14 +505,14 @@ pub(super) mod bincode_compat {
use serde::{Deserialize, Serialize};
use serde_with::serde_as;

use super::super::{bincode_compat, TxEip2930};
use super::super::{serde_bincode_compat, TxEip2930};

#[test]
fn test_tx_eip2930_bincode_roundtrip() {
#[serde_as]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
struct Data {
#[serde_as(as = "bincode_compat::TxEip2930")]
#[serde_as(as = "serde_bincode_compat::TxEip2930")]
transaction: TxEip2930,
}

Expand Down
12 changes: 6 additions & 6 deletions crates/consensus/src/transaction/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ mod tests {
}

/// Bincode-compatible [`TxLegacy`] serde implementation.
#[cfg(all(feature = "serde", feature = "bincode-compat"))]
pub(super) mod bincode_compat {
#[cfg(all(feature = "serde", feature = "serde-bincode-compat"))]
pub(super) mod serde_bincode_compat {
use alloc::borrow::Cow;
use alloy_primitives::{Bytes, ChainId, TxKind, U256};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
Expand All @@ -402,14 +402,14 @@ pub(super) mod bincode_compat {
///
/// Intended to use with the [`serde_with::serde_as`] macro in the following way:
/// ```rust
/// use alloy_consensus::{bincode_compat, TxLegacy};
/// use alloy_consensus::{serde_bincode_compat, TxLegacy};
/// use serde::{Deserialize, Serialize};
/// use serde_with::serde_as;
///
/// #[serde_as]
/// #[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
/// struct Data {
/// #[serde_as(as = "bincode_compat::transaction::TxLegacy")]
/// #[serde_as(as = "serde_bincode_compat::transaction::TxLegacy")]
/// header: TxLegacy,
/// }
/// ```
Expand Down Expand Up @@ -484,14 +484,14 @@ pub(super) mod bincode_compat {
use serde::{Deserialize, Serialize};
use serde_with::serde_as;

use super::super::{bincode_compat, TxLegacy};
use super::super::{serde_bincode_compat, TxLegacy};

#[test]
fn test_tx_eip1559_bincode_roundtrip() {
#[serde_as]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
struct Data {
#[serde_as(as = "bincode_compat::TxLegacy")]
#[serde_as(as = "serde_bincode_compat::TxLegacy")]
transaction: TxLegacy,
}

Expand Down
7 changes: 4 additions & 3 deletions crates/consensus/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ mod typed;
pub use typed::TypedTransaction;

/// Bincode-compatible serde implementations for transaction types.
#[cfg(all(feature = "serde", feature = "bincode-compat"))]
pub mod bincode_compat {
#[cfg(all(feature = "serde", feature = "serde-bincode-compat"))]
pub mod serde_bincode_compat {
pub use super::{
eip1559::bincode_compat::*, eip2930::bincode_compat::*, legacy::bincode_compat::*,
eip1559::serde_bincode_compat::*, eip2930::serde_bincode_compat::*,
legacy::serde_bincode_compat::*,
};
}

Expand Down

0 comments on commit af593d2

Please sign in to comment.