From 2c612ffa227c3eb9b997d7f5a7febab85441753e Mon Sep 17 00:00:00 2001 From: legobeat <109787230+legobeat@users.noreply.github.com> Date: Mon, 28 Aug 2023 11:42:00 +0000 Subject: [PATCH] Fix JsonRpcRequest to be valid json (#130) 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. --- src/json.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/json.ts b/src/json.ts index 000cd85f..9f10ef71 100644 --- a/src/json.ts +++ b/src/json.ts @@ -177,10 +177,10 @@ export type JsonRpcError = OptionalField< 'data' >; -export const JsonRpcParamsStruct = optional( - union([record(string(), JsonStruct), array(JsonStruct)]), -); -export type JsonRpcParams = Infer; +export const JsonRpcParamsStruct: Struct, null> = + optional(union([record(string(), JsonStruct), array(JsonStruct)])) as any; + +export type JsonRpcParams = Json[] | Record; export const JsonRpcRequestStruct = object({ id: JsonRpcIdStruct,