json rpc id to value (#3110)
## Issue Addressed N/A ## Proposed Changes - Update the JSON-RPC id field for both our request and response objects to be a `serde_json::Value` rather than a `u32`. This field could be a string or a number according to the JSON-RPC 2.0 spec. We only ever set it to a number, but if, for example, we get a response that wraps this number in quotes, we would fail to deserialize it. I think because we're not doing any validation around this id otherwise, we should be less strict with it in this regard. ## Additional Info Co-authored-by: realbigsean <sean@sigmaprime.io>
This commit is contained in:
parent
26e5281c68
commit
83234ee4ce
@ -75,7 +75,7 @@ impl HttpJsonRpc {
|
|||||||
jsonrpc: JSONRPC_VERSION,
|
jsonrpc: JSONRPC_VERSION,
|
||||||
method,
|
method,
|
||||||
params,
|
params,
|
||||||
id: STATIC_ID,
|
id: json!(STATIC_ID),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut request = self
|
let mut request = self
|
||||||
|
@ -8,7 +8,7 @@ pub struct JsonRequestBody<'a> {
|
|||||||
pub jsonrpc: &'a str,
|
pub jsonrpc: &'a str,
|
||||||
pub method: &'a str,
|
pub method: &'a str,
|
||||||
pub params: serde_json::Value,
|
pub params: serde_json::Value,
|
||||||
pub id: u32,
|
pub id: serde_json::Value,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
@ -25,7 +25,7 @@ pub struct JsonResponseBody {
|
|||||||
pub error: Option<JsonError>,
|
pub error: Option<JsonError>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub result: serde_json::Value,
|
pub result: serde_json::Value,
|
||||||
pub id: u32,
|
pub id: serde_json::Value,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
Loading…
Reference in New Issue
Block a user