diff --git a/chain/jsonrpc-adversarial-primitives/Cargo.toml b/chain/jsonrpc-adversarial-primitives/Cargo.toml index 2d6cf1e1b1b..813be117da7 100644 --- a/chain/jsonrpc-adversarial-primitives/Cargo.toml +++ b/chain/jsonrpc-adversarial-primitives/Cargo.toml @@ -8,19 +8,14 @@ rust-version = "1.60.0" edition = "2021" [dependencies] -serde = { version = "1", features = ["derive"], optional = true } -serde_json = { version = "1", optional = true } +serde = { version = "1", features = ["derive"] } +serde_json = "1" near-primitives = { path = "../../core/primitives" } -near-jsonrpc-primitives = { path = "../jsonrpc-primitives", optional = true } +near-jsonrpc-primitives = { path = "../jsonrpc-primitives" } near-network-primitives = { path = "../network-primitives" } deepsize = { version = "0.2.0", optional = true } [features] -ser_de = [ - "serde_json", - "serde", - "near-jsonrpc-primitives", - "near-network-primitives/test_features" -] -deepsize_feature = ["deepsize", "near-primitives/deepsize_feature"] \ No newline at end of file +test_features = ["near-network-primitives/test_features"] +deepsize_feature = ["deepsize", "near-primitives/deepsize_feature"] diff --git a/chain/jsonrpc-adversarial-primitives/src/lib.rs b/chain/jsonrpc-adversarial-primitives/src/lib.rs index 8c582daeb65..f8910be397e 100644 --- a/chain/jsonrpc-adversarial-primitives/src/lib.rs +++ b/chain/jsonrpc-adversarial-primitives/src/lib.rs @@ -1,13 +1,8 @@ -#[cfg(feature = "ser_de")] -use near_jsonrpc_primitives::errors::RpcError; use near_network_primitives::types::{Edge, SimpleEdge}; use near_primitives::network::PeerId; -#[cfg(feature = "ser_de")] use serde::Deserialize; -#[cfg(feature = "ser_de")] -use serde_json::Value; -#[cfg_attr(feature = "ser_de", derive(Deserialize))] +#[cfg_attr(feature = "test_features", derive(Deserialize))] #[cfg_attr(feature = "deepsize_feature", derive(deepsize::DeepSizeOf))] pub struct SetRoutingTableRequest { pub add_edges: Option>, @@ -15,26 +10,31 @@ pub struct SetRoutingTableRequest { pub prune_edges: Option, } -#[cfg(feature = "ser_de")] +#[cfg(feature = "test_features")] impl SetRoutingTableRequest { - pub fn parse(value: Option) -> Result { + pub fn parse( + value: Option, + ) -> Result { if let Some(value) = value { - serde_json::from_value(value) - .map_err(|err| RpcError::parse_error(format!("Error {:?}", err))) + serde_json::from_value(value).map_err(|err| { + near_jsonrpc_primitives::errors::RpcError::parse_error(format!("Error {:?}", err)) + }) } else { - Err(RpcError::parse_error("Require at least one parameter".to_owned())) + Err(near_jsonrpc_primitives::errors::RpcError::parse_error( + "Require at least one parameter".to_owned(), + )) } } } -#[cfg_attr(feature = "ser_de", derive(Deserialize))] +#[derive(Deserialize)] pub struct SetAdvOptionsRequest { pub disable_edge_signature_verification: Option, pub disable_edge_propagation: Option, pub disable_edge_pruning: Option, } -#[cfg_attr(feature = "ser_de", derive(Deserialize))] +#[derive(Deserialize)] pub struct StartRoutingTableSyncRequest { pub peer_id: PeerId, } diff --git a/chain/jsonrpc/Cargo.toml b/chain/jsonrpc/Cargo.toml index 45b09a0fad3..9be18358cbe 100644 --- a/chain/jsonrpc/Cargo.toml +++ b/chain/jsonrpc/Cargo.toml @@ -40,7 +40,7 @@ test_features = [ "near-client/test_features", "near-network/test_features", "near-jsonrpc-primitives/test_features", - "near-jsonrpc-adversarial-primitives/ser_de", + "near-jsonrpc-adversarial-primitives/test_features", ] nightly = ["nightly_protocol"] nightly_protocol = ["near-primitives/nightly_protocol"]