From d21d32504ae9c0cb14f580fd22e567cdb9f369f5 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Tue, 17 May 2022 18:29:21 +0200 Subject: [PATCH] fix: regression of `sync_state_genSyncSpec` #11435 (#11437) * fix: #11435 * address grumbles: better safe than sorry --- client/sync-state-rpc/src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/sync-state-rpc/src/lib.rs b/client/sync-state-rpc/src/lib.rs index a0a5b66cb86fc..02a22a838b8b2 100644 --- a/client/sync-state-rpc/src/lib.rs +++ b/client/sync-state-rpc/src/lib.rs @@ -128,7 +128,7 @@ pub struct LightSyncState { pub trait SyncStateRpcApi { /// Returns the JSON serialized chainspec running the node, with a sync state. #[method(name = "sync_state_genSyncSpec")] - fn system_gen_sync_spec(&self, raw: bool) -> RpcResult; + fn system_gen_sync_spec(&self, raw: bool) -> RpcResult; } /// An api for sync state RPC calls. @@ -185,7 +185,7 @@ where Block: BlockT, Backend: HeaderBackend + sc_client_api::AuxStore + 'static, { - fn system_gen_sync_spec(&self, raw: bool) -> RpcResult { + fn system_gen_sync_spec(&self, raw: bool) -> RpcResult { let current_sync_state = self.build_sync_state()?; let mut chain_spec = self.chain_spec.cloned_box(); @@ -197,6 +197,7 @@ where let val = serde_json::to_value(¤t_sync_state)?; *extension = Some(val); - chain_spec.as_json(raw).map_err(|e| Error::::JsonRpc(e).into()) + let json_str = chain_spec.as_json(raw).map_err(|e| Error::::JsonRpc(e))?; + serde_json::from_str(&json_str).map_err(Into::into) } }