diff --git a/.depcheckrc.yml b/.depcheckrc.yml index e8fe7a446ec..c90705901b4 100644 --- a/.depcheckrc.yml +++ b/.depcheckrc.yml @@ -6,6 +6,7 @@ ignores: - '@react-native-community/slider' - 'patch-package' - '@lavamoat/allow-scripts' + - 'babel-plugin-inline-import' # This is used on the patch for TokenRatesController of Assets controllers, for we to be able to use the last version of it - cockatiel diff --git a/app/lib/snaps/SnapsExecutionWebView.tsx b/app/lib/snaps/SnapsExecutionWebView.tsx index 24b8e99a087..ae1b4ebfaee 100644 --- a/app/lib/snaps/SnapsExecutionWebView.tsx +++ b/app/lib/snaps/SnapsExecutionWebView.tsx @@ -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(); @@ -86,11 +86,11 @@ export class SnapsExecutionWebView extends Component { ref={ this.setWebViewRef as unknown as React.RefObject | 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={['https://localhost*']} javaScriptEnabled /> diff --git a/babel.config.js b/babel.config.js index da1d15c592f..2d59074d9c9 100644 --- a/babel.config.js +++ b/babel.config.js @@ -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: { diff --git a/package.json b/package.json index dad216e5954..0dca731ef3d 100644 --- a/package.json +++ b/package.json @@ -435,6 +435,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", diff --git a/yarn.lock b/yarn.lock index eeb198f6585..29605d09131 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13120,6 +13120,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" @@ -24306,6 +24313,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" @@ -26792,6 +26804,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== +require-resolve@0.0.2: + 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" @@ -30222,6 +30241,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"