Skip to content

Conversation

@FrederikBolding
Copy link
Member

@FrederikBolding FrederikBolding commented Jun 3, 2025

Rewrites SIP-20 with a more narrow WebSockets scope, to be implemented in the very near future.

Closes https://github.com/MetaMask/MetaMask-planning/issues/3665

@GuillaumeRx GuillaumeRx self-assigned this Jun 5, 2025
@GuillaumeRx GuillaumeRx marked this pull request as ready for review June 5, 2025 13:32
@GuillaumeRx GuillaumeRx requested review from a team and Montoya as code owners June 5, 2025 13:32
@FrederikBolding FrederikBolding requested a review from Mrtenz June 5, 2025 14:13
@FrederikBolding FrederikBolding changed the title wip: SIP-20 rewrite SIP-20: WebSockets rewrite Jun 6, 2025
GuillaumeRx and others added 3 commits June 6, 2025 12:15
};
export type WebSocketBinaryMessage = {
type: "binary";
message: number[];
Copy link
Member

Choose a reason for hiding this comment

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

Wondering if this should be a base64 string, since we use that in other places for binary data.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

What would be the reasoning? When I proposed this I was thinking we wanted to mirror the browser WebSocket API as much as possible

Copy link
Member

Choose a reason for hiding this comment

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

Just consistency with other APIs. Even better if we could have a translation layer on the execution side turning it into Uint8Array before passing to the Snap, but 🤷

@GuillaumeRx GuillaumeRx requested review from GuillaumeRx and Mrtenz and removed request for GuillaumeRx June 10, 2025 14:20
Co-authored-by: Daniel Rocha <68558152+danroc@users.noreply.github.com>
#### Example
`id` - The unique identifier of the WebSocket connection associated with the event.

`origin` - The origin of the WebSocket connection.
Copy link
Contributor

Choose a reason for hiding this comment

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

What will be the origin in this context? The Snap ID?

Copy link
Member Author

Choose a reason for hiding this comment

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

The WebSocket origin for easy access to what origin you have open, similar to https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/origin

Copy link
Contributor

Choose a reason for hiding this comment

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

It's clear in the case of a MessageEvent:

... origin of the message emitter.

But in the case of a WebSocketOpenEvent event, the origin is the Snap. Is it correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

The idea is to just mirror that property across all events, so it would be the WebSocket origin for all cases.

FrederikBolding and others added 3 commits June 13, 2025 12:37
Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com>
@FrederikBolding FrederikBolding requested a review from Mrtenz June 13, 2025 10:51
Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com>
@FrederikBolding FrederikBolding requested a review from Mrtenz June 13, 2025 11:13
@FrederikBolding
Copy link
Member Author

LGTM but I cannot approve my own PR 😅

@FrederikBolding FrederikBolding enabled auto-merge (squash) June 13, 2025 13:00
@FrederikBolding FrederikBolding merged commit 8b614c1 into main Jun 13, 2025
3 checks passed
@FrederikBolding FrederikBolding deleted the sip-20-rewrite branch June 13, 2025 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants