-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Feat(MV3): Support Snaps in MV3 #22732
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
Conversation
offscreen/scripts/offscreen.ts
Outdated
| @@ -17,3 +18,5 @@ const parentStream = new BrowserRuntimePostMessageStream({ | |||
| parentStream.on('data', (data) => { | |||
| console.log('Offscreen Document received data from service worker', data); | |||
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.
This line should probably be removed in this PR because the stream now receives messages from snaps! However, its helpful to keep right up until we have validated the approach.
offscreen/scripts/offscreen.ts
Outdated
| @@ -1,4 +1,5 @@ | |||
| import { BrowserRuntimePostMessageStream } from '@metamask/post-message-stream'; | |||
| import { ProxySnapExecutor } from '@metamask/snaps-execution-environments/dist/cjs/proxy/ProxySnapExecutor'; | |||
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 will need to write a .d.ts file to type this or somehow point the import to the types exported for this class from the package
|
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
|
👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎ This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. |
app/scripts/metamask-controller.js
Outdated
|
|
||
| const snapExecutionServiceArgs = { | ||
| iframeUrl: new URL(process.env.IFRAME_EXECUTION_ENVIRONMENT_URL), | ||
| [shouldUseOffscreenExecutionService ? 'frameUrl' : 'iframeUrl']: new URL( |
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.
frameUrl is no longer a constructor argument for OffscreenExecutionService. Instead the URL is hardcoded and tied to the version of the executor package.
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.
@FrederikBolding so i need to just conditionally add the 'iframeUrl' parameter for the IframeExecutionService?
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.
What you did now looks fine to me! 👍
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #22732 +/- ##
===========================================
+ Coverage 68.60% 68.61% +0.01%
===========================================
Files 1096 1096
Lines 43253 43240 -13
Branches 11525 11531 +6
===========================================
- Hits 29672 29668 -4
+ Misses 13581 13572 -9 ☔ View full report in Codecov by Sentry. |
Builds ready [12db2c4]
Page Load Metrics (843 ± 32 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
|
@metamaskbot update-policies |
|
Policies updated |
Builds ready [05993e0]
Page Load Metrics (767 ± 38 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
Builds ready [ac6a733]
Page Load Metrics (713 ± 11 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
|
@metamaskbot update-policies |
|
Policies updated |
Builds ready [71825f6]
Page Load Metrics (806 ± 47 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
Builds ready [8bde090]
Page Load Metrics (834 ± 27 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
8bde090 to
8019c7b
Compare
|
@metamaskbot update-policies |
|
Policies updated |
Builds ready [1dd3b5a]
Page Load Metrics (1003 ± 49 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
|
@metamaskbot update-policies |
|
Policies updated |
Builds ready [7ac3c86]
Page Load Metrics (947 ± 45 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
weizman
left a comment
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.
lgtm
Builds ready [da7cf87]
Page Load Metrics (1128 ± 55 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
Builds ready [7ab4230]
Page Load Metrics (1073 ± 48 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
|
@SocketSecurity ignore npm/@metamask/post-message-stream@8.0.0 |
4cff51e
7ab4230 to
4cff51e
Compare
|
@metamaskbot update-policies |
|
Policies updated |
Builds ready [a35f8cc]
Page Load Metrics (1781 ± 76 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
a35f8cc to
7fb66af
Compare
|
@metamaskbot update-policies |
|
Policies updated |
Builds ready [a6004dc]
Page Load Metrics (1215 ± 403 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
Description
The work done in the proceeding offscreen PRs was done explicitly to hopefully make adopting the snaps executor written for offscreen support without much additional effort. This PR is not complete because it has a type error but sharing the code changes now.
This PR pulls forward the ProxySnapsExecutor from the snaps-execution-environments repository and initializes it with a runtime message stream. This allows the snaps executor to communicate through the offscreen document and enable support for snaps in MV3
Related issues
MetaMask-planning#1998
Manual testing steps
yarnyarn start:mv3Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist