-
-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The invalid type Record<never, never> removed from return type #4609
base: main
Are you sure you want to change the base?
Conversation
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.
Making these methods non-generic doesn't seem like a viable option to me. Instead, I think we should allocate more time to finding solutions for the type issues here.
async request<Params extends JsonRpcParams, Result extends Json>( | ||
eip1193Request: Eip1193Request<Params>, | ||
): Promise<Result> { | ||
async request(eip1193Request: Eip1193Request): Promise<Json> { |
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.
Shouldn't request
still be generic over Params
and Result
? This seems like a fundamental alteration of the EIP-1193 provider API that would make it unusable in many downstream call sites.
We should check whether this change breaks downstream packages using a preview build of this branch.
export function convertEip1193RequestToJsonRpcRequest( | ||
eip1193Request: Eip1193Request, | ||
): JsonRpcRequest { |
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.
Same as above, I think this function needs to be generic over Params
. It would potentially be unusable downstream without an exposed way to narrow the params
property of the return object.
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.
In EIP 1193 optional params
is unknown[] | object
. And here we have assigned the same using JsonRpcParams
(it's a default type for params). So it has to be of this type. Just thinking, in which case we need this to be beyond this type?
That said, I agree that it's probably not being used correctly in this case. |
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
Yeah, if there are params, it can be passed. If there're no params for the method, then no need to pass anything (params is optional)! We don't see a purpose of |
Explanation
The
Record<never, never>
type assigned to a response ofconvertEip1193RequestToJsonRpcRequest
function does not belong here (link to the code), no possible return value is represented by that type.References
Changelog
@metamask/eth-json-rpc-provider
Record<never, never>
type has been removed from response ofconvertEip1193RequestToJsonRpcRequest
. And also type assignment simplified.Checklist