diff --git a/crates/rpc/rpc-types/Cargo.toml b/crates/rpc/rpc-types/Cargo.toml index 8947d325b217..da1b8cda3282 100644 --- a/crates/rpc/rpc-types/Cargo.toml +++ b/crates/rpc/rpc-types/Cargo.toml @@ -22,7 +22,10 @@ thiserror.workspace = true itertools = "0.10" serde = { workspace = true, features = ["derive"] } serde_json.workspace = true -jsonrpsee-types.workspace = true +jsonrpsee-types = { workspace = true, optional = true } + +[features] +default = ["jsonrpsee-types"] [dev-dependencies] # misc diff --git a/crates/rpc/rpc-types/src/eth/block.rs b/crates/rpc/rpc-types/src/eth/block.rs index a246baf20a7d..5b07b300878f 100644 --- a/crates/rpc/rpc-types/src/eth/block.rs +++ b/crates/rpc/rpc-types/src/eth/block.rs @@ -379,7 +379,6 @@ pub struct BlockOverrides { #[cfg(test)] mod tests { use super::*; - use jsonrpsee_types::SubscriptionResponse; #[test] fn test_full_conversion() { @@ -391,7 +390,9 @@ mod tests { } #[test] - fn serde_header() { + #[cfg(feature = "jsonrpsee-types")] + fn serde_json_header() { + use jsonrpsee_types::SubscriptionResponse; let resp = r#"{"jsonrpc":"2.0","method":"eth_subscribe","params":{"subscription":"0x7eef37ff35d471f8825b1c8f67a5d3c0","result":{"hash":"0x7a7ada12e140961a32395059597764416499f4178daf1917193fad7bd2cc6386","parentHash":"0xdedbd831f496e705e7f2ec3c8dcb79051040a360bf1455dbd7eb8ea6ad03b751","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","miner":"0x0000000000000000000000000000000000000000","stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000","transactionsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","number":"0x8","gasUsed":"0x0","gasLimit":"0x1c9c380","extraData":"0x","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","timestamp":"0x642aa48f","difficulty":"0x0","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000"}}}"#; let _header: SubscriptionResponse<'_, Header> = serde_json::from_str(resp).unwrap(); diff --git a/crates/rpc/rpc-types/src/eth/engine/forkchoice.rs b/crates/rpc/rpc-types/src/eth/engine/forkchoice.rs index ea215df5c167..f1c2ca4a79c7 100644 --- a/crates/rpc/rpc-types/src/eth/engine/forkchoice.rs +++ b/crates/rpc/rpc-types/src/eth/engine/forkchoice.rs @@ -50,6 +50,7 @@ pub enum ForkchoiceUpdateError { UnknownFinalBlock, } +#[cfg(feature = "jsonrpsee-types")] impl From for jsonrpsee_types::error::ErrorObject<'static> { fn from(value: ForkchoiceUpdateError) -> Self { match value { diff --git a/crates/rpc/rpc-types/src/eth/filter.rs b/crates/rpc/rpc-types/src/eth/filter.rs index 29ca1f4124d7..bfe92fbe0703 100644 --- a/crates/rpc/rpc-types/src/eth/filter.rs +++ b/crates/rpc/rpc-types/src/eth/filter.rs @@ -1,6 +1,5 @@ use crate::Log as RpcLog; use itertools::{EitherOrBoth::*, Itertools}; -use jsonrpsee_types::SubscriptionId; use reth_primitives::{ bloom::{Bloom, Input}, keccak256, Address, BlockNumberOrTag, Log, H160, H256, U256, U64, @@ -874,7 +873,7 @@ impl<'de> Deserialize<'de> for FilterChanges { } } -/// Owned equivalent of [SubscriptionId] +/// Owned equivalent of a `SubscriptionId` #[derive(Debug, PartialEq, Clone, Hash, Eq, Deserialize, Serialize)] #[serde(deny_unknown_fields)] #[serde(untagged)] @@ -885,20 +884,22 @@ pub enum FilterId { Str(String), } -impl From for SubscriptionId<'_> { +#[cfg(feature = "jsonrpsee-types")] +impl From for jsonrpsee_types::SubscriptionId<'_> { fn from(value: FilterId) -> Self { match value { - FilterId::Num(n) => SubscriptionId::Num(n), - FilterId::Str(s) => SubscriptionId::Str(s.into()), + FilterId::Num(n) => jsonrpsee_types::SubscriptionId::Num(n), + FilterId::Str(s) => jsonrpsee_types::SubscriptionId::Str(s.into()), } } } -impl From> for FilterId { - fn from(value: SubscriptionId<'_>) -> Self { +#[cfg(feature = "jsonrpsee-types")] +impl From> for FilterId { + fn from(value: jsonrpsee_types::SubscriptionId<'_>) -> Self { match value { - SubscriptionId::Num(n) => FilterId::Num(n), - SubscriptionId::Str(s) => FilterId::Str(s.into_owned()), + jsonrpsee_types::SubscriptionId::Num(n) => FilterId::Num(n), + jsonrpsee_types::SubscriptionId::Str(s) => FilterId::Str(s.into_owned()), } } }