diff --git a/src/json.ts b/src/json.ts index 000cd85f2..acb9a6779 100644 --- a/src/json.ts +++ b/src/json.ts @@ -180,14 +180,28 @@ export type JsonRpcError = OptionalField< export const JsonRpcParamsStruct = optional( union([record(string(), JsonStruct), array(JsonStruct)]), ); + export type JsonRpcParams = Infer; -export const JsonRpcRequestStruct = object({ +export const JsonRpcRequestStruct: Struct< + { + id: number | null | string; + method: string; + jsonrpc: '2.0'; + params?: Json[] | Record; + }, + { + id: Struct; + jsonrpc: Struct<'2.0', '2.0'>; + method: Struct; + params?: any; + } +> = object({ id: JsonRpcIdStruct, jsonrpc: JsonRpcVersionStruct, method: string(), params: JsonRpcParamsStruct, -}); +}) as any; export type InferWithParams< Type extends Struct,