-
Notifications
You must be signed in to change notification settings - Fork 273
Open
Description
I can't find in the json-rpc 2.0 spec where a notify params can't be objects. Current implementation only allows null or array.
jsonrpc/core-client/transports/src/lib.rs
Lines 298 to 307 in 38af3c9
pub fn notify<T: Serialize>(&self, method: &str, args: T) -> RpcResult<()> { | |
let args = | |
serde_json::to_value(args).expect("Only types with infallible serialisation can be used for JSON-RPC"); | |
let params = match args { | |
Value::Array(vec) => Params::Array(vec), | |
Value::Null => Params::None, | |
_ => { | |
return Err(RpcError::Client( | |
"RPC params should serialize to a JSON array, or null".into(), | |
)) |
I believe it should implement the same logic as the call_method implementation above it
jsonrpc/core-client/transports/src/lib.rs
Lines 269 to 284 in 38af3c9
pub fn call_method<T: Serialize, R: DeserializeOwned>( | |
&self, | |
method: &str, | |
returns: &str, | |
args: T, | |
) -> impl Future<Output = RpcResult<R>> { | |
let returns = returns.to_owned(); | |
let args = | |
serde_json::to_value(args).expect("Only types with infallible serialisation can be used for JSON-RPC"); | |
let params = match args { | |
Value::Array(vec) => Ok(Params::Array(vec)), | |
Value::Null => Ok(Params::None), | |
Value::Object(map) => Ok(Params::Map(map)), | |
_ => Err(RpcError::Client( | |
"RPC params should serialize to a JSON array, JSON object or null".into(), | |
)), |
I can do a PR if I'm correct in my research.
Wonderful project. Thank you.
Metadata
Metadata
Assignees
Labels
No labels