Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cf13591
Build Snaps execution environments with Webpack
Mrtenz Apr 15, 2025
407c4bd
Update CI
Mrtenz Apr 15, 2025
2712851
Add `node-thread` and `node-process` aliases for Jest
Mrtenz Apr 15, 2025
70f7b28
Fix Webpack version
Mrtenz Apr 15, 2025
ad05896
Add `@swc/core-linux-x64-gnu` to policy override
Mrtenz Apr 15, 2025
2974ddd
Remove unused dependencies
Mrtenz Apr 15, 2025
951d097
Update policy
Mrtenz Apr 15, 2025
af93758
Update `snaps-controllers` Vitest config
Mrtenz Apr 15, 2025
79a3b2f
Update shasums
Mrtenz Apr 15, 2025
d8c1e30
Simplify policy override
Mrtenz Apr 15, 2025
68fbd5f
Simplify build script
Mrtenz Apr 16, 2025
8be20a4
Bump `@metamask/post-message-stream` to `^10.0.0`
Mrtenz Apr 16, 2025
b4b37a2
Fix Jest config
Mrtenz Apr 16, 2025
2411a60
Set minimum browser versions
Mrtenz Apr 24, 2025
767db1f
Enable scuttling
Mrtenz Apr 24, 2025
9a16da6
Add more exceptions to `scuttleGlobalThis` config
Mrtenz Apr 25, 2025
50bdb54
Update scuttleGlobalThis config again
Mrtenz Apr 25, 2025
4d75747
Add `WebAssembly` to scuttling exceptions
Mrtenz Apr 28, 2025
0fcf26e
Simplify build script
Mrtenz Apr 28, 2025
4b78ffa
Only enable scuttling for specific builds and allow build-specific ex…
Mrtenz Apr 29, 2025
baab881
Fix coverage
Mrtenz Apr 29, 2025
57e6670
Remove unused patches
Mrtenz May 2, 2025
476c72c
Update iframe title
Mrtenz May 2, 2025
fc74ba9
Add log message
Mrtenz May 2, 2025
f5c19bc
Remove unnecessary policy override
Mrtenz May 2, 2025
e499c17
Remove `@swc/core` from policy
Mrtenz May 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
node-version: ${{ matrix.node-version }}
cache-node-modules: ${{ matrix.node-version == '20.x' }}
- name: Prepare "@metamask/snaps-execution-environments" build
run: yarn workspace @metamask/snaps-execution-environments run build:lavamoat
run: yarn workspace @metamask/snaps-execution-environments run build:lavamoat:test
- name: Save "@metamask/snaps-execution-environments" build
id: cache-snaps-execution-environments-build
uses: actions/upload-artifact@v4
Expand All @@ -35,7 +35,7 @@ jobs:
retention-days: 1
path: |
.nvmrc
packages/snaps-execution-environments/dist/browserify
packages/snaps-execution-environments/dist/webpack
- name: Fetch workspace package names
id: workspace-package-names
run: |
Expand Down Expand Up @@ -95,12 +95,16 @@ jobs:
policy:
name: Generate LavaMoat policy
runs-on: ubuntu-latest
needs: prepare
needs: build
steps:
- name: Checkout and setup environment
uses: MetaMask/action-checkout-and-setup@v1
with:
is-high-risk-environment: false
- name: Restore build files
uses: actions/download-artifact@v4
with:
name: build-source-${{ runner.os }}-${{ github.sha }}
- name: Generate LavaMoat policy
run: yarn workspace @metamask/snaps-execution-environments build:lavamoat:policy
- name: Require clean working directory
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ jobs:
aws-region: ${{ vars.AWS_REGION }}
- name: Deploy to `${{ inputs.destination_dir }}` directory of remote storage
run: |
aws s3 cp ./packages/snaps-execution-environments/dist/browserify/iframe s3://${{ vars.AWS_BUCKET_NAME }}/iframe/${{ inputs.destination_dir }} --recursive --acl private
aws s3 cp ./packages/snaps-execution-environments/dist/browserify/webview s3://${{ vars.AWS_BUCKET_NAME }}/webview/${{ inputs.destination_dir }} --recursive --acl private
aws s3 cp ./packages/snaps-execution-environments/dist/webpack/iframe s3://${{ vars.AWS_BUCKET_NAME }}/iframe/${{ inputs.destination_dir }} --recursive --acl private
aws s3 cp ./packages/snaps-execution-environments/dist/webpack/webview s3://${{ vars.AWS_BUCKET_NAME }}/webview/${{ inputs.destination_dir }} --recursive --acl private
22 changes: 0 additions & 22 deletions .yarn/patches/@lavamoat-lavapack-npm-6.1.1-b81af21193.patch

This file was deleted.

39 changes: 0 additions & 39 deletions .yarn/patches/lavamoat-browserify-npm-17.0.5-16c00e9ef9.patch

This file was deleted.

9 changes: 9 additions & 0 deletions jest.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,19 @@ module.exports = {

// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
moduleNameMapper: {
'^@metamask/snaps-execution-environments/node-thread': [
'<rootDir>/../snaps-execution-environments/dist/webpack/node-thread/bundle.js',
],
'^@metamask/snaps-execution-environments/node-process': [
'<rootDir>/../snaps-execution-environments/dist/webpack/node-process/bundle.js',
],
'^@metamask/(.+)/production/jsx-runtime': [
'<rootDir>/../$1/src/jsx/production',
],
'^@metamask/(.+)/test-utils$': ['<rootDir>/../$1/src/test-utils'],
'^@metamask/post-message-stream/node$': [
'@metamask/post-message-stream/node',
],
'^@metamask/(.+)/node$': ['<rootDir>/../$1/src/node'],
'^@metamask/(.+)/jsx': ['<rootDir>/../$1/src/jsx'],
'^@metamask/(.+)$': [
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"resolutions": {
"@babel/core": "patch:@babel/core@npm%3A7.23.2#./.yarn/patches/@babel-core-npm-7.23.2-b93f586907.patch",
"@esbuild-plugins/node-modules-polyfill@^0.2.2": "patch:@esbuild-plugins/node-modules-polyfill@npm%3A0.2.2#./.yarn/patches/@esbuild-plugins-node-modules-polyfill-npm-0.2.2-f612681798.patch",
"@lavamoat/lavapack@^6.1.1": "patch:@lavamoat/lavapack@npm%3A6.1.1#./.yarn/patches/@lavamoat-lavapack-npm-6.1.1-b81af21193.patch",
"@puppeteer/[email protected]": "patch:@puppeteer/browsers@npm%3A1.7.0#./.yarn/patches/@puppeteer-browsers-npm-1.7.0-203cb4f44b.patch",
"@puppeteer/browsers@^1.6.0": "patch:@puppeteer/browsers@npm%3A1.7.0#./.yarn/patches/@puppeteer-browsers-npm-1.7.0-203cb4f44b.patch",
"@types/glob@*": "patch:@types/glob@npm%3A7.1.4#./.yarn/patches/@types-glob-npm-7.1.4-d45247eaa2.patch",
Expand All @@ -72,7 +71,6 @@
"jest-fetch-mock@^3.0.3": "patch:jest-fetch-mock@npm:3.0.3#.yarn/patches/jest-fetch-mock-npm-3.0.3-ac072ca8af.patch",
"jest-util@^29.5.0": "patch:jest-util@npm%3A29.6.3#./.yarn/patches/jest-util-npm-29.6.3-6ffdea2c1c.patch",
"jest-util@^29.6.3": "patch:jest-util@npm%3A29.6.3#./.yarn/patches/jest-util-npm-29.6.3-6ffdea2c1c.patch",
"lavamoat-browserify@^17.0.5": "patch:lavamoat-browserify@npm%3A17.0.5#./.yarn/patches/lavamoat-browserify-npm-17.0.5-16c00e9ef9.patch",
"luxon@^3.2.1": "patch:luxon@npm%3A3.3.0#./.yarn/patches/luxon-npm-3.3.0-bdbae9bfd5.patch",
"tsconfig-paths@^3.11.0": "patch:tsconfig-paths@npm%3A3.14.2#./.yarn/patches/tsconfig-paths-npm-3.14.2-90ce75420d.patch",
"tsconfig-paths@^3.14.1": "patch:tsconfig-paths@npm%3A3.14.2#./.yarn/patches/tsconfig-paths-npm-3.14.2-90ce75420d.patch",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/bip32/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "k2lRqMHzUAsSfYAQvfHaotZ+GjevHXfCYq31N6rLbpI=",
"shasum": "S8JJzZaDPhHp16nyJVCPY++KVgOpYSCUrEVp/dmbsRE=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/bip44/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "OKsspaf6yslVwkh3t0EEkgLe2ZXVUeOSuARHBYh5QO8=",
"shasum": "S9Rxcf90yagtJcBEV2lPs4eSASBPP+KkiACJjkye7ho=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "JuqQZZ60QV9h7WNpCeNCNoomvPVzkoAGMqF+wXMi7vM=",
"shasum": "zip0FTlGFS2oV/Hm6lLWzBAhw/UtphSCFG4kecgojAg=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "5WnCGlClRMxrjPXzuSZybJuEBDfo+oIjkfCRhcvFzzw=",
"shasum": "KaI5if/V5l02632+bVHOa6UtSbmWO+NR/kr8q8Ck1zs=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/wasm/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "/ZxCTLB2buQSGwrTdtIh6wkzzoPS0QOZCD8uGq5WGEY=",
"shasum": "0iz4fr9QPZehD0EQCZ5rkpOKiKCKVhUwKEZ7ZhjUBLk=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"@metamask/object-multiplex": "^2.1.0",
"@metamask/permission-controller": "^11.0.6",
"@metamask/phishing-controller": "^12.5.0",
"@metamask/post-message-stream": "^9.0.0",
"@metamask/post-message-stream": "^10.0.0",
"@metamask/rpc-errors": "^7.0.2",
"@metamask/snaps-registry": "^3.2.3",
"@metamask/snaps-rpc-methods": "workspace:^",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { BasePostMessageStream } from '@metamask/post-message-stream';
import { ProcessParentMessageStream } from '@metamask/post-message-stream';
import { ProcessParentMessageStream } from '@metamask/post-message-stream/node';
import type { ChildProcess } from 'child_process';
import { fork } from 'child_process';

Expand All @@ -12,9 +12,7 @@ export class NodeProcessExecutionService extends AbstractExecutionService<ChildP
stream: BasePostMessageStream;
}> {
const worker = fork(
require.resolve(
'@metamask/snaps-execution-environments/dist/browserify/node-process/bundle.js',
),
require.resolve('@metamask/snaps-execution-environments/node-process'),
{
stdio: 'pipe',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { BasePostMessageStream } from '@metamask/post-message-stream';
import { ThreadParentMessageStream } from '@metamask/post-message-stream';
import { ThreadParentMessageStream } from '@metamask/post-message-stream/node';
import { Worker } from 'worker_threads';

import type { TerminateJobArgs } from '..';
Expand All @@ -11,9 +11,7 @@ export class NodeThreadExecutionService extends AbstractExecutionService<Worker>
stream: BasePostMessageStream;
}> {
const worker = new Worker(
require.resolve(
'@metamask/snaps-execution-environments/dist/browserify/node-thread/bundle.js',
),
require.resolve('@metamask/snaps-execution-environments/node-thread'),
{
stdout: true,
stderr: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { PostMessageEvent } from '@metamask/post-message-stream';
import { BasePostMessageStream } from '@metamask/post-message-stream';
import { isValidStreamMessage } from '@metamask/post-message-stream/dist/utils';
import {
BasePostMessageStream,
isValidStreamMessage,
} from '@metamask/post-message-stream';
import { assert } from '@metamask/utils';

export type WebViewInterface = {
Expand Down
12 changes: 6 additions & 6 deletions packages/snaps-controllers/vitest.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { defineConfig } from 'vitest/config';

const IFRAME_PATH = join(
import.meta.dirname,
'../snaps-execution-environments/dist/browserify/iframe',
'../snaps-execution-environments/dist/webpack/iframe',
);

const IFRAME_TEST_PATH = join(
Expand All @@ -16,12 +16,12 @@ const IFRAME_TEST_PATH = join(

const WORKER_EXECUTOR_PATH = join(
import.meta.dirname,
'../snaps-execution-environments/dist/browserify/worker-executor',
'../snaps-execution-environments/dist/webpack/worker-executor',
);

const WORKER_POOL_PATH = join(
import.meta.dirname,
'../snaps-execution-environments/dist/browserify/worker-pool',
'../snaps-execution-environments/dist/webpack/worker-pool',
);

export default defineConfig({
Expand Down Expand Up @@ -54,9 +54,9 @@ export default defineConfig({
strict: true,
allow: [
'./src/services/iframe/test',
'../snaps-execution-environments/dist/browserify/iframe',
'../snaps-execution-environments/dist/browserify/worker-executor',
'../snaps-execution-environments/dist/browserify/worker-pool',
'../snaps-execution-environments/dist/webpack/iframe',
'../snaps-execution-environments/dist/webpack/worker-executor',
'../snaps-execution-environments/dist/webpack/worker-pool',
],
},
},
Expand Down
3 changes: 3 additions & 0 deletions packages/snaps-execution-environments/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# The minimum browser versions supported by MetaMask.
chrome >= 90
firefox >= 91
2 changes: 1 addition & 1 deletion packages/snaps-execution-environments/coverage.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"branches": 90.78,
"functions": 94.96,
"lines": 90.84,
"statements": 90.26
"statements": 90.25
}

This file was deleted.

Loading
Loading