Feature gate jsonrpsee related crates and check features powerset for reth-rpc-types (#10141)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Nikolai Golub
2024-08-07 00:15:46 +02:00
committed by GitHub
parent f8104cc93f
commit 2ab17a4dec
5 changed files with 22 additions and 10 deletions

View File

@ -473,4 +473,5 @@ check-features:
--package reth-codecs \
--package reth-primitives-traits \
--package reth-primitives \
--package reth-rpc-types \
--feature-powerset

View File

@ -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 }
@ -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"]

View File

@ -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()
}
}

View File

@ -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;

View File

@ -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},
};