-
-
Notifications
You must be signed in to change notification settings - Fork 62
Conversation
@@ -487,7 +441,7 @@ export class JsonRpcEngine extends SafeEventEmitter { | |||
res: PendingJsonRpcResponse<unknown>, | |||
isComplete: boolean, | |||
): void { | |||
if (!('result' in res) && !('error' in res)) { | |||
if (!hasProperty(res, 'result') && !hasProperty(res, 'error')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The replaced in
checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good to me!
export type JsonRpcMiddleware<T, U> = ( | ||
req: JsonRpcRequest<T>, | ||
res: PendingJsonRpcResponse<U>, | ||
export type JsonRpcMiddleware<Params, Result> = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like these type parameter names a lot better than T
and U
👍🏻
result?: T; | ||
error?: Error | JsonRpcError; | ||
} | ||
export type PendingJsonRpcResponse<Result> = Omit< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not suggesting any changes, but I wonder if this is type is right, considering that it seems that such a response can theoretically have both result
and error
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type is meant to be used inside middleware functions and internally in JsonRpcEngine
during request processing. It permits both, either, or neither property being present. Or did you mean something else?
Replace various utility types and functions with implementations copied over to
@metamask/utils
. Functionality should be practically identical.The one possible deviation is that two
in
checks have been replaced withhasProperty
, which does not walk the prototype chain. This should not be breaking for our purposes.