Skip to content

Commit

Permalink
WIP: fix JsonRpcRequest to be valid json
Browse files Browse the repository at this point in the history
fix/types: JsonRpcParams should be valid JSON values

`undefined` is not valid JSON.

https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf
(Section 5):

    A JSON value can be an object, array, number, string, true, false, or null.
  • Loading branch information
legobeat committed Aug 24, 2023
1 parent 20bb059 commit e1e1ba4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ export type JsonRpcError = OptionalField<
export const JsonRpcParamsStruct = optional(
union([record(string(), JsonStruct), array(JsonStruct)]),
);
export type JsonRpcParams = Infer<typeof JsonRpcParamsStruct>;

export type JsonRpcParams = Json[] | Record<string, Json>;

export const JsonRpcRequestStruct = object({
id: JsonRpcIdStruct,
Expand Down

0 comments on commit e1e1ba4

Please sign in to comment.