Skip to content
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

Fixed SafeEventEmitterProvider invalid default params #4603

Merged
merged 2 commits into from
Aug 13, 2024

Conversation

kanthesha
Copy link
Contributor

Explanation

The SafeEventEmitterProvider is failing to send net_version requests correctly because it's using an empty object as the default params when none are provided.

While some methods do use an object for params, the vast majority use an array instead. Passing an empty object as the params for a method that has array parameters can result in failure (as is the case for net_version).

References

Changelog

@metamask/eth-json-rpc-provider

  • FIXED: The default value for params in the request has been replaced from empty object to an empty array

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@kanthesha kanthesha marked this pull request as ready for review August 13, 2024 11:46
@kanthesha kanthesha requested a review from a team as a code owner August 13, 2024 11:46
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be safer to omit rather than using any default, see here for details

@@ -31,18 +31,19 @@ export function convertEip1193RequestToJsonRpcRequest<
>(
eip1193Request: Eip1193Request<Params>,
): JsonRpcRequest<Params | Record<never, never>> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this return type is invalid. The Record<never, never> does not belong here, no possible return value is represented by that type. Yet if we remove it, we get the type error I referenced in the other thread. How odd.

Maybe we can fix it in a later PR, since it's a pre-existing issue. This type is used later in this file as well.

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kanthesha kanthesha merged commit 5e90500 into main Aug 13, 2024
116 checks passed
@kanthesha kanthesha deleted the fix/safe-event-emitter-invalid-default-params branch August 13, 2024 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[safe-event-emitter-provider] Invalid default params
3 participants