Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): make jsonrpsee types a feature #3999

Merged
merged 1 commit into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion crates/rpc/rpc-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions crates/rpc/rpc-types/src/eth/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ pub struct BlockOverrides {
#[cfg(test)]
mod tests {
use super::*;
use jsonrpsee_types::SubscriptionResponse;

#[test]
fn test_full_conversion() {
Expand All @@ -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();

Expand Down
1 change: 1 addition & 0 deletions crates/rpc/rpc-types/src/eth/engine/forkchoice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub enum ForkchoiceUpdateError {
UnknownFinalBlock,
}

#[cfg(feature = "jsonrpsee-types")]
impl From<ForkchoiceUpdateError> for jsonrpsee_types::error::ErrorObject<'static> {
fn from(value: ForkchoiceUpdateError) -> Self {
match value {
Expand Down
19 changes: 10 additions & 9 deletions crates/rpc/rpc-types/src/eth/filter.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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)]
Expand All @@ -885,20 +884,22 @@ pub enum FilterId {
Str(String),
}

impl From<FilterId> for SubscriptionId<'_> {
#[cfg(feature = "jsonrpsee-types")]
impl From<FilterId> 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<SubscriptionId<'_>> for FilterId {
fn from(value: SubscriptionId<'_>) -> Self {
#[cfg(feature = "jsonrpsee-types")]
impl From<jsonrpsee_types::SubscriptionId<'_>> 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()),
}
}
}
Expand Down
Loading