Skip to content

Commit 5d6841d

Browse files
committed
fix: ensure id is string and jsonrpc is 2.0
1 parent b375417 commit 5d6841d

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/containers/Inspector.tsx

+12-2
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,21 @@ const Inspector: React.FC<IProps> = (props) => {
7676
jsonrpc: "2.0",
7777
method: props.openrpcMethodObject.name,
7878
params: json.params,
79-
id,
79+
id: id.toString(),
8080
});
8181
}
8282
// eslint-disable-next-line react-hooks/exhaustive-deps
8383
}, []);
84+
useEffect(() => {
85+
if (json) {
86+
setJson({
87+
...json,
88+
jsonrpc: "2.0",
89+
id: id.toString(),
90+
});
91+
}
92+
// eslint-disable-next-line react-hooks/exhaustive-deps
93+
}, [id]);
8494

8595
useEffect(() => {
8696
if (props.url) {
@@ -94,7 +104,7 @@ const Inspector: React.FC<IProps> = (props) => {
94104
incrementId();
95105
try {
96106
const result = await client.request(json.method, json.params);
97-
setResults({ jsonrpc: "2.0", result });
107+
setResults({ jsonrpc: "2.0", result, id });
98108
} catch (e) {
99109
setError(e);
100110
}

src/containers/JSONRPCRequest.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import useDarkMode from "use-dark-mode";
33
import { monaco, ControlledEditor, Monaco } from "@monaco-editor/react";
44
import { MethodObject } from "@open-rpc/meta-schema";
55
import useWindowSize from "@rehooks/window-size";
6-
import { addDiagnostics } from "@etclabscore/monaco-add-json-schema-diagnostics"
6+
import { addDiagnostics } from "@etclabscore/monaco-add-json-schema-diagnostics";
77

88
interface IProps {
99
onChange?: (newValue: any) => void;

0 commit comments

Comments
 (0)