From 94ccbd126111c56403e659240e31d4abdaf40571 Mon Sep 17 00:00:00 2001 From: Erik Marks Date: Thu, 13 Mar 2025 13:47:05 -0700 Subject: [PATCH] refactor: Add Json default parameter to JSON-RPC types --- src/json.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/json.ts b/src/json.ts index 0182a332b..c384459ff 100644 --- a/src/json.ts +++ b/src/json.ts @@ -437,7 +437,7 @@ export const PendingJsonRpcResponseStruct = superstructObject({ /** * A JSON-RPC response object that has not yet been resolved. */ -export type PendingJsonRpcResponse = Omit< +export type PendingJsonRpcResponse = Omit< Infer, 'result' > & { @@ -453,7 +453,7 @@ export const JsonRpcSuccessStruct = object({ /** * A successful JSON-RPC response object. */ -export type JsonRpcSuccess = Omit< +export type JsonRpcSuccess = Omit< Infer, 'result' > & { @@ -482,7 +482,7 @@ export const JsonRpcResponseStruct = union([ * * @template Result - The type of the result. */ -export type JsonRpcResponse = +export type JsonRpcResponse = | JsonRpcSuccess | JsonRpcFailure; @@ -495,7 +495,7 @@ export type JsonRpcResponse = */ export function isPendingJsonRpcResponse( response: unknown, -): response is PendingJsonRpcResponse { +): response is PendingJsonRpcResponse { return is(response, PendingJsonRpcResponseStruct); } @@ -512,7 +512,7 @@ export function assertIsPendingJsonRpcResponse( response: unknown, // eslint-disable-next-line @typescript-eslint/naming-convention ErrorWrapper?: AssertionErrorConstructor, -): asserts response is PendingJsonRpcResponse { +): asserts response is PendingJsonRpcResponse { assertStruct( response, PendingJsonRpcResponseStruct, @@ -529,7 +529,7 @@ export function assertIsPendingJsonRpcResponse( */ export function isJsonRpcResponse( response: unknown, -): response is JsonRpcResponse { +): response is JsonRpcResponse { return is(response, JsonRpcResponseStruct); } @@ -545,7 +545,7 @@ export function assertIsJsonRpcResponse( value: unknown, // eslint-disable-next-line @typescript-eslint/naming-convention ErrorWrapper?: AssertionErrorConstructor, -): asserts value is JsonRpcResponse { +): asserts value is JsonRpcResponse { assertStruct( value, JsonRpcResponseStruct, @@ -560,9 +560,7 @@ export function assertIsJsonRpcResponse( * @param value - The value to check. * @returns Whether the given value is a valid {@link JsonRpcSuccess} object. */ -export function isJsonRpcSuccess( - value: unknown, -): value is JsonRpcSuccess { +export function isJsonRpcSuccess(value: unknown): value is JsonRpcSuccess { return is(value, JsonRpcSuccessStruct); } @@ -578,7 +576,7 @@ export function assertIsJsonRpcSuccess( value: unknown, // eslint-disable-next-line @typescript-eslint/naming-convention ErrorWrapper?: AssertionErrorConstructor, -): asserts value is JsonRpcSuccess { +): asserts value is JsonRpcSuccess { assertStruct( value, JsonRpcSuccessStruct,