From 1e421de53255faee3f88ab765539ab5fc2f4fed4 Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Thu, 24 Aug 2023 04:40:50 +0000 Subject: [PATCH] WIP: fix JsonRpcRequest to be valid json 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 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/json.ts b/src/json.ts index 000cd85f2..b405c81ae 100644 --- a/src/json.ts +++ b/src/json.ts @@ -177,10 +177,11 @@ export type JsonRpcError = OptionalField< 'data' >; -export const JsonRpcParamsStruct = optional( +export const JsonRpcParamsStruct: Struct, null> = optional( union([record(string(), JsonStruct), array(JsonStruct)]), -); -export type JsonRpcParams = Infer; +) as any; + +export type JsonRpcParams = Json[] | Record; export const JsonRpcRequestStruct = object({ id: JsonRpcIdStruct,