Skip to content
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

feat: Implement partially local Snaps execution environment #11653

Merged
merged 8 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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: 5 additions & 5 deletions app/lib/snaps/SnapsExecutionWebView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import React, { Component, RefObject } from 'react';
import { View, ScrollView, NativeSyntheticEvent } from 'react-native';
import { WebViewMessageEvent, WebView } from '@metamask/react-native-webview';
import { createStyles } from './styles';
import { WebViewError } from '@metamask/react-native-webview/lib/WebViewTypes';
import { WebViewInterface } from '@metamask/snaps-controllers/react-native';
import { WebViewError } from '@metamask/react-native-webview/lib/WebViewTypes';
import { PostMessageEvent } from '@metamask/post-message-stream';

const SNAPS_EE_URL = 'https://execution.metamask.io/webview/6.7.1/index.html';
// @ts-expect-error Types are currently broken for this.
import WebViewHTML from '@metamask/snaps-execution-environments/dist/browserify/webview/index.html';

const styles = createStyles();

Expand Down Expand Up @@ -86,11 +86,11 @@ export class SnapsExecutionWebView extends Component {
ref={
this.setWebViewRef as unknown as React.RefObject<WebView> | null
}
source={{ uri: SNAPS_EE_URL}}
source={{ html: WebViewHTML, baseUrl: 'https://localhost' }}
onMessage={this.onWebViewMessage}
onError={this.onWebViewError}
onLoadEnd={this.onWebViewLoad}
originWhitelist={['https://execution.metamask.io*']}
originWhitelist={['*']}
FrederikBolding marked this conversation as resolved.
Show resolved Hide resolved
javaScriptEnabled
/>
</View>
Expand Down
4 changes: 4 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ module.exports = {
test: './node_modules/@metamask/notification-services-controller',
plugins: [['@babel/plugin-transform-private-methods', { loose: true }]],
},
{
test: './app/lib/snaps',
plugins: [['babel-plugin-inline-import', { extensions: ['.html'] }]],
},
],
env: {
production: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@
"assert": "^1.5.0",
"babel-jest": "^29.7.0",
"babel-loader": "^9.1.3",
"babel-plugin-inline-import": "^3.0.0",
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
"babel-plugin-transform-remove-console": "6.9.4",
"browserstack-local": "^1.5.1",
Expand Down
30 changes: 28 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7235,7 +7235,7 @@
integrity sha512-7boYb0PjrwWy3amevP1DVqhT2LdVla8WEF4HV7Nrs55ZO8jQ2Pymsj4WinxTokXQ45YvdWVOLdqMhtYGJgRDTQ==
dependencies:
"@sentry/babel-plugin-component-annotate" "2.20.1"
"@sentry/browser" "7.119.1"
"@sentry/browser" "7.119.0"
FrederikBolding marked this conversation as resolved.
Show resolved Hide resolved
"@sentry/cli" "2.36.1"
"@sentry/core" "7.119.0"
"@sentry/hub" "7.119.0"
Expand All @@ -7249,7 +7249,7 @@
resolved "https://registry.yarnpkg.com/@sentry/react/-/react-7.119.0.tgz#79f2c9d94322a3afbfa8af9f5b872f7c2e9b0820"
integrity sha512-cf8Cei+qdSA26gx+IMAuc/k44PeBImNzIpXi3930SLhUe44ypT5OZ/44L6xTODHZzTIyMSJPduf59vT2+eW9yg==
dependencies:
"@sentry/browser" "7.119.1"
"@sentry/browser" "7.119.0"
"@sentry/core" "7.119.0"
"@sentry/types" "7.119.0"
"@sentry/utils" "7.119.0"
Expand Down Expand Up @@ -13112,6 +13112,13 @@ babel-plugin-emotion@^10.0.27:
find-root "^1.1.0"
source-map "^0.5.7"

babel-plugin-inline-import@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/babel-plugin-inline-import/-/babel-plugin-inline-import-3.0.0.tgz#220eb2a52f8e779d8fb89447f950275e1e3f5981"
integrity sha512-thnykl4FMb8QjMjVCuZoUmAM7r2mnTn5qJwrryCvDv6rugbJlTHZMctdjDtEgD0WBAXJOLJSGXN3loooEwx7UQ==
dependencies:
require-resolve "0.0.2"

babel-plugin-istanbul@^6.1.1:
version "6.1.1"
resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz#fa88ec59232fd9b4e36dbbc540a8ec9a9b47da73"
Expand Down Expand Up @@ -24298,6 +24305,11 @@ path-exists@^5.0.0:
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-5.0.0.tgz#a6aad9489200b21fab31e49cf09277e5116fb9e7"
integrity sha512-RjhtfwJOxzcFmNOi6ltcbcu4Iu+FL3zEj83dk4kAS+fVpTxXLO1b38RvJgT/0QwvV/L3aY9TAnyv0EOqW4GoMQ==

path-extra@^1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/path-extra/-/path-extra-1.0.3.tgz#7c112189a6e50d595790e7ad2037e44e410c1166"
integrity sha512-vYm3+GCkjUlT1rDvZnDVhNLXIRvwFPaN8ebHAFcuMJM/H0RBOPD7JrcldiNLd9AS3dhAyUHLa4Hny5wp1A+Ffw==

path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
Expand Down Expand Up @@ -26784,6 +26796,13 @@ require-package-name@^2.0.1:
resolved "https://registry.yarnpkg.com/require-package-name/-/require-package-name-2.0.1.tgz#c11e97276b65b8e2923f75dabf5fb2ef0c3841b9"
integrity sha512-uuoJ1hU/k6M0779t3VMVIYpb2VMJk05cehCaABFhXaibcbvfgR8wKiozLjVFSzJPmQMRqIcO0HMyTFqfV09V6Q==

[email protected]:
version "0.0.2"
resolved "https://registry.yarnpkg.com/require-resolve/-/require-resolve-0.0.2.tgz#bab410ab1aee2f3f55b79317451dd3428764e6f3"
integrity sha512-eafQVaxdQsWUB8HybwognkdcIdKdQdQBwTxH48FuE6WI0owZGKp63QYr1MRp73PoX0AcyB7MDapZThYUY8FD0A==
dependencies:
x-path "^0.0.2"

requires-port@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
Expand Down Expand Up @@ -30214,6 +30233,13 @@ ws@^6.2.2, ws@^6.2.3:
dependencies:
async-limiter "~1.0.0"

x-path@^0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/x-path/-/x-path-0.0.2.tgz#294d076bb97a7706cc070bbb2a6fd8c54df67b12"
integrity sha512-zQ4WFI0XfJN1uEkkrB19Y4TuXOlHqKSxUJo0Yt+axPjRm8tCG6SJ6+Wo3/+Kjg4c2c8IvBXuJ0uYoshxNn4qMw==
dependencies:
path-extra "^1.0.2"

xcode@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/xcode/-/xcode-3.0.1.tgz#3efb62aac641ab2c702458f9a0302696146aa53c"
Expand Down
Loading