Skip to content

Commit

Permalink
Feature gate jsonrpsee related crates and check features powerset f…
Browse files Browse the repository at this point in the history
…or `reth-rpc-types` (paradigmxyz#10141)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
  • Loading branch information
2 people authored and martinezjorge committed Aug 7, 2024
1 parent 5a8d981 commit 088b044
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -473,4 +473,5 @@ check-features:
--package reth-codecs \
--package reth-primitives-traits \
--package reth-primitives \
--package reth-rpc-types \
--feature-powerset
13 changes: 10 additions & 3 deletions crates/rpc/rpc-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ workspace = true

# ethereum
alloy-primitives = { workspace = true, features = ["rand", "rlp", "serde"] }
alloy-rpc-types = { workspace = true, features = ["jsonrpsee-types"] }
alloy-rpc-types.workspace = true
alloy-rpc-types-admin.workspace = true
alloy-rpc-types-anvil.workspace = true
alloy-rpc-types-beacon.workspace = true
alloy-rpc-types-beacon = { workspace = true, optional = true }
alloy-rpc-types-mev.workspace = true
alloy-rpc-types-trace.workspace = true
alloy-rpc-types-txpool.workspace = true
alloy-serde.workspace = true
alloy-rpc-types-engine = { workspace = true, features = ["jsonrpsee-types"] }
alloy-rpc-types-engine = { workspace = true, features = ["jsonrpsee-types"], optional = true }

# misc
jsonrpsee-types = { workspace = true, optional = true }
Expand All @@ -39,4 +39,11 @@ serde_json.workspace = true

[features]
default = ["jsonrpsee-types"]
jsonrpsee-types = [
"dep:jsonrpsee-types",
"dep:alloy-rpc-types-beacon",
"dep:alloy-rpc-types-engine",
"alloy-rpc-types/jsonrpsee-types",
"alloy-rpc-types-engine/jsonrpsee-types"
]
arbitrary = ["alloy-primitives/arbitrary", "alloy-rpc-types/arbitrary"]
10 changes: 5 additions & 5 deletions crates/rpc/rpc-types/src/eth/error.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//! Implementation specific Errors for the `eth_` namespace.

use jsonrpsee_types::ErrorObject;

/// A trait to convert an error to an RPC error.
#[cfg(feature = "jsonrpsee-types")]
pub trait ToRpcError: std::error::Error + Send + Sync + 'static {
/// Converts the error to a JSON-RPC error object.
fn to_rpc_error(&self) -> ErrorObject<'static>;
fn to_rpc_error(&self) -> jsonrpsee_types::ErrorObject<'static>;
}

impl ToRpcError for ErrorObject<'static> {
fn to_rpc_error(&self) -> ErrorObject<'static> {
#[cfg(feature = "jsonrpsee-types")]
impl ToRpcError for jsonrpsee_types::ErrorObject<'static> {
fn to_rpc_error(&self) -> jsonrpsee_types::ErrorObject<'static> {
self.clone()
}
}
1 change: 1 addition & 0 deletions crates/rpc/rpc-types/src/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ pub(crate) mod error;
pub mod transaction;

// re-export
#[cfg(feature = "jsonrpsee-types")]
pub use alloy_rpc_types_engine as engine;
7 changes: 5 additions & 2 deletions crates/rpc/rpc-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,20 @@ pub use alloy_rpc_types_anvil as anvil;
pub use alloy_rpc_types_mev as mev;

// re-export beacon
#[cfg(feature = "jsonrpsee-types")]
pub use alloy_rpc_types_beacon as beacon;

// re-export txpool
pub use alloy_rpc_types_txpool as txpool;

// Ethereum specific rpc types related to typed transaction requests and the engine API.
#[cfg(feature = "jsonrpsee-types")]
pub use eth::error::ToRpcError;
pub use eth::transaction::{self, TransactionRequest, TypedTransactionRequest};
#[cfg(feature = "jsonrpsee-types")]
pub use eth::{
engine,
engine::{
ExecutionPayload, ExecutionPayloadV1, ExecutionPayloadV2, ExecutionPayloadV3, PayloadError,
},
error::ToRpcError,
transaction::{self, TransactionRequest, TypedTransactionRequest},
};

0 comments on commit 088b044

Please sign in to comment.