Skip to content

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 added the team-wallet-framework Deprecated: Please use `team-core-platform` instead. label Aug 13, 2024
@kanthesha kanthesha marked this pull request as ready for review August 13, 2024 11:46
@kanthesha kanthesha requested a review from a team 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

Params extends JsonRpcParams,
>(
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
@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

Labels

team-wallet-framework Deprecated: Please use `team-core-platform` instead.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants