Skip to content

Commit

Permalink
Merge branch 'develop' into MMI-4847-gh-action-autotag-mmi-team
Browse files Browse the repository at this point in the history
  • Loading branch information
zone-live authored Apr 1, 2024
2 parents 92e94f5 + f29a78e commit 9455a78
Show file tree
Hide file tree
Showing 263 changed files with 7,294 additions and 2,658 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ module.exports = {
path.resolve(__dirname, '.eslintrc.typescript-compat.js'),
],
rules: {
'@typescript-eslint/no-explicit-any': 'error',
// this rule is new, but we didn't use it before, so it's off now
'@typescript-eslint/no-duplicate-enum-values': 'off',
'@typescript-eslint/no-shadow': [
Expand Down
9 changes: 9 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ module.exports = {
config.plugins.push(
new CopyWebpackPlugin({
patterns: [
{
from: path.join(
'ui',
'css',
'utilities',
'fonts/',
),
to: 'fonts',
},
{
from: path.join(
'node_modules',
Expand Down
32 changes: 30 additions & 2 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/background.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
</head>
<body>
<script src="./load-background.js" type="text/javascript" charset="utf-8"></script>
<script src="./chromereload.js" type="text/javascript" charset="utf-8"></script>
<script src="./load-background.js"></script>
<script src="./chromereload.js"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions app/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
<% } else { %>
<title>MetaMask</title>
<% } %>
<link rel="stylesheet" type="text/css" href="./index.css">
<link rel="stylesheet" href="./index.css">
</head>
<body>
<div id="app-content">
<img class="loading-logo" src="./images/logo/metamask-fox.svg" alt="" loading="lazy" />
<img class="loading-spinner" src="./images/spinner.gif" alt="" loading="lazy" />
</div>
<div id="popover-content"></div>
<script src="./load-app.js" type="text/javascript" charset="utf-8" async></script>
<script src="./load-app.js" async></script>
</body>
</html>
4 changes: 2 additions & 2 deletions app/loading.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<script src="./snow.js" type="text/javascript" charset="utf-8"></script>
<script src="./use-snow.js" type="text/javascript" charset="utf-8"></script>
<meta charset="UTF-8">
<script src="./scripts/snow.js"></script>
<script src="./scripts/use-snow.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>MetaMask Loading</title>
Expand Down
12 changes: 6 additions & 6 deletions app/manifest/v2/_base.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
{
"matches": ["file://*/*", "http://*/*", "https://*/*"],
"js": [
"disable-console.js",
"lockdown-install.js",
"lockdown-run.js",
"lockdown-more.js",
"contentscript.js",
"inpage.js"
"scripts/disable-console.js",
"scripts/lockdown-install.js",
"scripts/lockdown-run.js",
"scripts/lockdown-more.js",
"scripts/contentscript.js",
"scripts/inpage.js"
],
"run_at": "document_start",
"all_frames": true
Expand Down
12 changes: 6 additions & 6 deletions app/manifest/v3/_base.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"author": "https://metamask.io",
"background": {
"service_worker": "app-init.js"
"service_worker": "scripts/app-init.js"
},
"commands": {
"_execute_browser_action": {
Expand All @@ -30,11 +30,11 @@
{
"matches": ["file://*/*", "http://*/*", "https://*/*"],
"js": [
"disable-console.js",
"lockdown-install.js",
"lockdown-run.js",
"lockdown-more.js",
"contentscript.js"
"scripts/disable-console.js",
"scripts/lockdown-install.js",
"scripts/lockdown-run.js",
"scripts/lockdown-more.js",
"scripts/contentscript.js"
],
"run_at": "document_start",
"all_frames": true
Expand Down
9 changes: 2 additions & 7 deletions app/notification.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
margin-top: 1rem;
}
</style>
<link rel="stylesheet" type="text/css" href="./index.css" />
<link rel="stylesheet" href="./index.css" />
</head>
<body class="notification">
<div id="app-content">
Expand All @@ -50,11 +50,6 @@
/>
</div>
<div id="popover-content"></div>
<script
src="./load-app.js"
type="text/javascript"
charset="utf-8"
async
></script>
<script src="./load-app.js" async></script>
</body>
</html>
4 changes: 2 additions & 2 deletions app/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1 user-scalable=no">
<title>MetaMask</title>
<link rel="stylesheet" type="text/css" href="./index.css">
<link rel="stylesheet" href="./index.css">
</head>
<body style="width:357px; height:600px;">
<div id="app-content">
<img class="loading-logo" src="./images/logo/metamask-fox.svg" alt="" loading="lazy" />
<img class="loading-spinner" src="./images/spinner.gif" alt="" loading="lazy" />
</div>
<div id="popover-content"></div>
<script src="./load-app.js" type="text/javascript" charset="utf-8" async></script>
<script src="./load-app.js" async></script>
</body>
</html>
24 changes: 12 additions & 12 deletions app/scripts/app-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,27 @@ function importAllScripts() {
throw new Error('Missing APPLY_LAVAMOAT environment variable');
}

loadFile('./sentry-install.js');
loadFile('./scripts/sentry-install.js');

// eslint-disable-next-line no-undef
const isWorker = !self.document;
if (!isWorker) {
loadFile('./snow.js');
loadFile('./scripts/snow.js');
}

loadFile('./use-snow.js');
loadFile('./scripts/use-snow.js');

// Always apply LavaMoat in e2e test builds, so that we can capture initialization stats
if (testMode || applyLavaMoat) {
loadFile('./runtime-lavamoat.js');
loadFile('./lockdown-more.js');
loadFile('./policy-load.js');
loadFile('./scripts/runtime-lavamoat.js');
loadFile('./scripts/lockdown-more.js');
loadFile('./scripts/policy-load.js');
} else {
loadFile('./init-globals.js');
loadFile('./lockdown-install.js');
loadFile('./lockdown-run.js');
loadFile('./lockdown-more.js');
loadFile('./runtime-cjs.js');
loadFile('./scripts/init-globals.js');
loadFile('./scripts/lockdown-install.js');
loadFile('./scripts/lockdown-run.js');
loadFile('./scripts/lockdown-more.js');
loadFile('./scripts/runtime-cjs.js');
}

// This environment variable is set to a string of comma-separated relative file paths.
Expand Down Expand Up @@ -145,7 +145,7 @@ const registerInPageContentScript = async () => {
{
id: 'inpage',
matches: ['file://*/*', 'http://*/*', 'https://*/*'],
js: ['inpage.js'],
js: ['scripts/inpage.js'],
runAt: 'document_start',
world: 'MAIN',
},
Expand Down
32 changes: 32 additions & 0 deletions app/scripts/controllers/app-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export default class AppStateController extends EventEmitter {
},
surveyLinkLastClickedOrClosed: null,
signatureSecurityAlertResponses: {},
// States used for displaying the changed network toast
switchedNetworkDetails: null,
switchedNetworkNeverShowMessage: false,
});
this.timer = null;

Expand Down Expand Up @@ -401,6 +404,35 @@ export default class AppStateController extends EventEmitter {
this.store.updateState({ showAccountBanner });
}

/**
* Track which network MetaMask has just automatically switched to, or call this with `null` to clear that state.
*
* @param {{ origin: string, networkClientId: string } | null} switchedNetworkDetails - Details about the network that MetaMask just switched to.
*/
setSwitchedNetworkDetails(switchedNetworkDetails) {
this.store.updateState({ switchedNetworkDetails });
}

/**
* Clears the switched network details in state
*/
clearSwitchedNetworkDetails() {
this.store.updateState({ switchedNetworkDetails: null });
}

/**
* Remembers if the user prefers to never see the
* network switched message again
*
* @param {boolean} switchedNetworkNeverShowMessage
*/
setSwitchedNetworkNeverShowMessage(switchedNetworkNeverShowMessage) {
this.store.updateState({
switchedNetworkDetails: null,
switchedNetworkNeverShowMessage,
});
}

/**
* Sets a property indicating the model of the user's Trezor hardware wallet
*
Expand Down
32 changes: 32 additions & 0 deletions app/scripts/controllers/authentication/auth-snap-requests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { SnapId } from '@metamask/snaps-sdk';
import type { HandleSnapRequest } from '@metamask/snaps-controllers';
import { HandlerType } from '@metamask/snaps-utils';

type SnapRPCRequest = Parameters<HandleSnapRequest['handler']>[0];

const snapId = 'npm:@metamask/message-signing-snap' as SnapId;

export function createSnapPublicKeyRequest(): SnapRPCRequest {
return {
snapId,
origin: '',
handler: HandlerType.OnRpcRequest,
request: {
method: 'getPublicKey',
},
};
}

export function createSnapSignMessageRequest(
message: `metamask:${string}`,
): SnapRPCRequest {
return {
snapId,
origin: '',
handler: HandlerType.OnRpcRequest,
request: {
method: 'signMessage',
params: { message },
},
};
}
Loading

0 comments on commit 9455a78

Please sign in to comment.