Skip to content

Commit

Permalink
fix: ensure id is string and jsonrpc is 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
shanejonas committed Dec 5, 2019
1 parent b375417 commit 5d6841d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/containers/Inspector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,21 @@ const Inspector: React.FC<IProps> = (props) => {
jsonrpc: "2.0",
method: props.openrpcMethodObject.name,
params: json.params,
id,
id: id.toString(),
});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
useEffect(() => {
if (json) {
setJson({
...json,
jsonrpc: "2.0",
id: id.toString(),
});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [id]);

useEffect(() => {
if (props.url) {
Expand All @@ -94,7 +104,7 @@ const Inspector: React.FC<IProps> = (props) => {
incrementId();
try {
const result = await client.request(json.method, json.params);
setResults({ jsonrpc: "2.0", result });
setResults({ jsonrpc: "2.0", result, id });
} catch (e) {
setError(e);
}
Expand Down
2 changes: 1 addition & 1 deletion src/containers/JSONRPCRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import useDarkMode from "use-dark-mode";
import { monaco, ControlledEditor, Monaco } from "@monaco-editor/react";
import { MethodObject } from "@open-rpc/meta-schema";
import useWindowSize from "@rehooks/window-size";
import { addDiagnostics } from "@etclabscore/monaco-add-json-schema-diagnostics"
import { addDiagnostics } from "@etclabscore/monaco-add-json-schema-diagnostics";

interface IProps {
onChange?: (newValue: any) => void;
Expand Down

0 comments on commit 5d6841d

Please sign in to comment.