Skip to content

Commit

Permalink
Merge branch 'main' into replace-superstruct-with-fork
Browse files Browse the repository at this point in the history
  • Loading branch information
MajorLift committed Jul 11, 2024
2 parents 42e4c1e + 1480459 commit 97b9048
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "root",
"version": "54.0.0",
"version": "55.0.0",
"private": true,
"repository": {
"type": "git",
Expand Down
7 changes: 6 additions & 1 deletion packages/snaps-execution-environments/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [6.6.0]
### Changed
- Inline LavaMoat in WebView bundle ([#2528](https://github.com/MetaMask/snaps/pull/2528), [#2564](https://github.com/MetaMask/snaps/pull/2564))

## [6.5.0]
### Added
- Add `Checkbox` component ([#2501](https://github.com/MetaMask/snaps/pull/2501))
Expand Down Expand Up @@ -220,7 +224,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The version of the package no longer needs to match the version of all other
MetaMask Snaps packages.

[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/[email protected]
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/[email protected]
[6.6.0]: https://github.com/MetaMask/snaps/compare/@metamask/[email protected]...@metamask/[email protected]
[6.5.0]: https://github.com/MetaMask/snaps/compare/@metamask/[email protected]...@metamask/[email protected]
[6.4.0]: https://github.com/MetaMask/snaps/compare/@metamask/[email protected]...@metamask/[email protected]
[6.3.0]: https://github.com/MetaMask/snaps/compare/@metamask/[email protected]...@metamask/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-execution-environments/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/snaps-execution-environments",
"version": "6.5.0",
"version": "6.6.0",
"description": "Snap sandbox environments for executing SES javascript",
"repository": {
"type": "git",
Expand Down
45 changes: 28 additions & 17 deletions packages/snaps-execution-environments/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const ENTRY_POINTS = {
webview: {
entryPoint: './src/webview/index.ts',
html: true,
inlineBundle: true,
},
};

Expand Down Expand Up @@ -94,23 +95,28 @@ async function main() {
JSON.stringify(lavamoatSecurityOptionsBrowser),
);

const htmlFile = `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>MetaMask Snaps Iframe Execution Environment</title>
<script>${lavaMoatRuntimeBrowser}</script>
</head>
<body>
<script src="bundle.js"></script>
</body>
</html>`;
const createHtml = (scriptTag) => `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>MetaMask Snaps Execution Environment</title>
<script>${lavaMoatRuntimeBrowser}</script>
</head>
<body>
${scriptTag}
</body>
</html>`;

const htmlFile = createHtml('<script src="bundle.js"></script>');

const createInlinedHTML = (bundleSource) =>
createHtml(`<script>${bundleSource}</script>`);

await Promise.all(
Object.entries(ENTRY_POINTS).map(async ([key, config]) => {
console.log('Bundling', key);
const { html, node, worker, entryPoint } = config;
const { html, node, worker, entryPoint, inlineBundle } = config;
const insertGlobalVars = node
? { process: undefined, ...LavaMoatBrowserify.args.insertGlobalVars }
: LavaMoatBrowserify.args.insertGlobalVars;
Expand Down Expand Up @@ -218,14 +224,19 @@ async function main() {
outputBundle = `${runtime}\n${outputBundle}`;
}

const bundlePath = path.join(OUTPUT_PATH, key, OUTPUT_BUNDLE);
await fs.mkdir(path.dirname(bundlePath), { recursive: true });
await fs.writeFile(bundlePath, outputBundle);
if (!inlineBundle) {
const bundlePath = path.join(OUTPUT_PATH, key, OUTPUT_BUNDLE);
await fs.mkdir(path.dirname(bundlePath), { recursive: true });
await fs.writeFile(bundlePath, outputBundle);
}

if (html) {
const htmlPath = path.join(OUTPUT_PATH, key, OUTPUT_HTML);
await fs.mkdir(path.dirname(htmlPath), { recursive: true });
await fs.writeFile(htmlPath, htmlFile);
await fs.writeFile(
htmlPath,
inlineBundle ? createInlinedHTML(outputBundle) : htmlFile,
);
}

const outputBytes = stringToBytes(outputBundle);
Expand Down

0 comments on commit 97b9048

Please sign in to comment.