mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-30 01:28:21 -05:00
chore(deps): make jsonrpsee types a feature (#3999)
This commit is contained in:
@@ -22,7 +22,10 @@ thiserror.workspace = true
|
||||
itertools.workspace = true
|
||||
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
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<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()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user