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:
realbigsean 2022-03-29 22:59:55 +00:00
parent 26e5281c68
commit 83234ee4ce
2 changed files with 3 additions and 3 deletions

View File

@ -75,7 +75,7 @@ impl HttpJsonRpc {
jsonrpc: JSONRPC_VERSION,
method,
params,
id: STATIC_ID,
id: json!(STATIC_ID),
};
let mut request = self

View File

@ -8,7 +8,7 @@ pub struct JsonRequestBody<'a> {
pub jsonrpc: &'a str,
pub method: &'a str,
pub params: serde_json::Value,
pub id: u32,
pub id: serde_json::Value,
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
@ -25,7 +25,7 @@ pub struct JsonResponseBody {
pub error: Option<JsonError>,
#[serde(default)]
pub result: serde_json::Value,
pub id: u32,
pub id: serde_json::Value,
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]