Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .depcheckrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ ignores:
- '@metamask/test-dapp'
- '@metamask/test-dapp-multichain'
- '@metamask/test-dapp-solana'
- '@metamask/snap-simple-keyring-site'
Copy link
Member Author

@seaona seaona Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ added to exceptions to fix the unused dependencies error, because that's not used anywhere (only in the e2e)

- '@metamask/design-tokens' # Only imported in index.css
- '@tsconfig/node22' # required dynamically by TS, used in tsconfig.json
- '@sentry/cli' # invoked as `sentry-cli`
Expand Down
1 change: 1 addition & 0 deletions development/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ async function defineAndRunBuildTasks() {
'browser', // for testing vault corruption
'chrome', // for testing vault corruption
`indexedDB`, // for testing vault corruption
'devicePixelRatio', // for using snap simple keyring site
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we allow this, only for tests

];
}

Expand Down
4 changes: 3 additions & 1 deletion development/webpack/utils/plugins/LavamoatPlugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ export const lavamoatPlugin = (args: Args) =>
// globals opera needs to function
'opr',
// globals used by e2e
...(args.test ? ['ret_nodes', 'browser', 'chrome', 'indexedDB'] : []),
...(args.test
? ['ret_nodes', 'browser', 'chrome', 'indexedDB', 'devicePixelRatio']
: []),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for webpack

],
},
});
Expand Down
7 changes: 3 additions & 4 deletions lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@
"packages": {
"@babel/runtime": true,
"@material-ui/core>@material-ui/utils": true,
"@material-ui/core>clsx": true,
"@material-ui/core>@material-ui/styles>clsx": true,
"react-redux>hoist-non-react-statics": true,
"@material-ui/core>@material-ui/styles>jss-plugin-camel-case": true,
"@material-ui/core>@material-ui/styles>jss-plugin-default-unit": true,
Expand Down Expand Up @@ -2224,10 +2224,9 @@
"Element": true,
"HTMLElement": true,
"ShadowRoot": true,
"console.error": true,
"console.warn": true,
"document": true,
"navigator.userAgent": true
"navigator.userAgent": true,
"navigator.userAgentData": true
}
},
"@trezor/connect-web>@trezor/connect>@trezor/protobuf>protobufjs>@protobufjs/codegen": {
Expand Down
7 changes: 3 additions & 4 deletions lavamoat/browserify/experimental/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@
"packages": {
"@babel/runtime": true,
"@material-ui/core>@material-ui/utils": true,
"@material-ui/core>clsx": true,
"@material-ui/core>@material-ui/styles>clsx": true,
"react-redux>hoist-non-react-statics": true,
"@material-ui/core>@material-ui/styles>jss-plugin-camel-case": true,
"@material-ui/core>@material-ui/styles>jss-plugin-default-unit": true,
Expand Down Expand Up @@ -2224,10 +2224,9 @@
"Element": true,
"HTMLElement": true,
"ShadowRoot": true,
"console.error": true,
"console.warn": true,
"document": true,
"navigator.userAgent": true
"navigator.userAgent": true,
"navigator.userAgentData": true
}
},
"@trezor/connect-web>@trezor/connect>@trezor/protobuf>protobufjs>@protobufjs/codegen": {
Expand Down
7 changes: 3 additions & 4 deletions lavamoat/browserify/flask/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@
"packages": {
"@babel/runtime": true,
"@material-ui/core>@material-ui/utils": true,
"@material-ui/core>clsx": true,
"@material-ui/core>@material-ui/styles>clsx": true,
"react-redux>hoist-non-react-statics": true,
"@material-ui/core>@material-ui/styles>jss-plugin-camel-case": true,
"@material-ui/core>@material-ui/styles>jss-plugin-default-unit": true,
Expand Down Expand Up @@ -2224,10 +2224,9 @@
"Element": true,
"HTMLElement": true,
"ShadowRoot": true,
"console.error": true,
"console.warn": true,
"document": true,
"navigator.userAgent": true
"navigator.userAgent": true,
"navigator.userAgentData": true
}
},
"@trezor/connect-web>@trezor/connect>@trezor/protobuf>protobufjs>@protobufjs/codegen": {
Expand Down
7 changes: 3 additions & 4 deletions lavamoat/browserify/main/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@
"packages": {
"@babel/runtime": true,
"@material-ui/core>@material-ui/utils": true,
"@material-ui/core>clsx": true,
"@material-ui/core>@material-ui/styles>clsx": true,
"react-redux>hoist-non-react-statics": true,
"@material-ui/core>@material-ui/styles>jss-plugin-camel-case": true,
"@material-ui/core>@material-ui/styles>jss-plugin-default-unit": true,
Expand Down Expand Up @@ -2224,10 +2224,9 @@
"Element": true,
"HTMLElement": true,
"ShadowRoot": true,
"console.error": true,
"console.warn": true,
"document": true,
"navigator.userAgent": true
"navigator.userAgent": true,
"navigator.userAgentData": true
}
},
"@trezor/connect-web>@trezor/connect>@trezor/protobuf>protobufjs>@protobufjs/codegen": {
Expand Down
58 changes: 36 additions & 22 deletions lavamoat/build-system/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -786,12 +786,26 @@
"packages": {
"@babel/code-frame": true,
"@babel/core>@babel/generator": true,
"depcheck>@babel/traverse>@babel/helper-globals": true,
"@babel/core>@babel/parser": true,
"@babel/core>@babel/template": true,
"@babel/core>@babel/types": true,
"babel/preset-env>b@babel/types": true,
"nock>debug": true
}
},
"lavamoat>lavamoat-tofu>@babel/traverse": {
"globals": {
"console.log": true
},
"packages": {
"@babel/code-frame": true,
"@babel/core>@babel/generator": true,
"lavamoat>lavamoat-tofu>@babel/traverse>@babel/parser": true,
"@babel/core>@babel/template": true,
"lavamoat>lavamoat-tofu>@babel/traverse>@babel/types": true,
"nock>debug": true,
"depcheck>@babel/traverse>globals": true
"lavamoat>lavamoat-tofu>@babel/traverse>globals": true
}
},
"@babel/core>@babel/types": {
Expand All @@ -804,6 +818,16 @@
"@babel/code-frame>@babel/helper-validator-identifier": true
}
},
"lavamoat>lavamoat-tofu>@babel/traverse>@babel/types": {
"globals": {
"console.warn": true,
"process.env.BABEL_TYPES_8_BREAKING": true
},
"packages": {
"@babel/core>@babel/types>@babel/helper-string-parser": true,
"@babel/code-frame>@babel/helper-validator-identifier": true
}
},
"sass-embedded>@bufbuild/protobuf": {
"globals": {
"TextDecoder": true,
Expand Down Expand Up @@ -1027,7 +1051,7 @@
},
"@babel/eslint-parser>@nicolo-ribaudo/eslint-scope-5-internals": {
"packages": {
"@babel/eslint-parser>@nicolo-ribaudo/eslint-scope-5-internals>eslint-scope": true
"webpack>eslint-scope": true
}
},
"@noble/hashes": {
Expand Down Expand Up @@ -1196,7 +1220,6 @@
"eslint-plugin-jest>@typescript-eslint/utils>@typescript-eslint/types": true,
"@typescript-eslint/parser>@typescript-eslint": true,
"eslint": true,
"eslint-plugin-jest>@typescript-eslint/utils>eslint-scope": true,
"eslint>eslint-scope": true,
"webpack>eslint-scope": true,
"eslint-plugin-jest>@typescript-eslint/utils>webpack>eslint-scope": true,
Expand Down Expand Up @@ -1536,6 +1559,13 @@
"gulp>gulp-cli>matchdep>micromatch>snapdragon>base>pascalcase": true
}
},
"browserslist>baseline-browser-mapping": {
"globals": {
"console.log": true,
"console.warn": true,
"process.exit": true
}
},
"bify-module-groups": {
"packages": {
"pify": true,
Expand Down Expand Up @@ -1676,6 +1706,7 @@
"path.basename": true,
"path.dirname": true,
"path.join": true,
"path.posix.join": true,
"path.relative": true,
"path.resolve": true
},
Expand All @@ -1685,6 +1716,7 @@
"process.versions.node": true
},
"packages": {
"browserslist>baseline-browser-mapping": true,
"autoprefixer>caniuse-lite": true,
"browserslist>electron-to-chromium": true,
"browserslist>node-releases": true
Expand Down Expand Up @@ -2841,24 +2873,6 @@
"process.env.NODE_ENV": true
}
},
"@babel/eslint-parser>@nicolo-ribaudo/eslint-scope-5-internals>eslint-scope": {
"builtin": {
"assert": true
},
"packages": {
"eslint>eslint-scope>esrecurse": true,
"@babel/eslint-parser>@nicolo-ribaudo/eslint-scope-5-internals>eslint-scope>estraverse": true
}
},
"eslint-plugin-jest>@typescript-eslint/utils>eslint-scope": {
"builtin": {
"assert": true
},
"packages": {
"eslint>eslint-scope>esrecurse": true,
"eslint-plugin-jest>@typescript-eslint/utils>eslint-scope>estraverse": true
}
},
"eslint>eslint-scope": {
"builtin": {
"assert": true
Expand Down Expand Up @@ -4420,7 +4434,7 @@
},
"packages": {
"lavamoat>lavamoat-tofu>@babel/parser": true,
"depcheck>@babel/traverse": true
"lavamoat>lavamoat-tofu>@babel/traverse": true
}
},
"lavamoat>lavamoat-core>merge-deep>clone-deep>lazy-cache": {
Expand Down
5 changes: 2 additions & 3 deletions lavamoat/webpack/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -2298,10 +2298,9 @@
"Element": true,
"HTMLElement": true,
"ShadowRoot": true,
"console.error": true,
"console.warn": true,
"document": true,
"navigator.userAgent": true
"navigator.userAgent": true,
"navigator.userAgentData": true
}
},
"@trezor/connect-web>@trezor/connect>@trezor/protobuf>protobufjs>@protobufjs/codegen": {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@
"@metamask/foundryup": "^1.0.1",
"@metamask/phishing-warning": "^5.0.1",
"@metamask/preferences-controller": "^19.0.0",
"@metamask/snap-simple-keyring-site": "^2.0.0",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ we can now use the npm package

MetaMask/snap-simple-keyring#163

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MetaMask/policy-reviewers I'm adding this new dev dependency which is our snap simple keyring site, so we can use it in our e2e. That pulls in UI libs (MUI, Popper, Emotion/styled-components), which trigger policy entries.

  • devicePixelRatio global (runtime): Needed for UI layout calculations
  • navigator.userAgentData (runtime overrides): Used for modern UA feature checks by positioning libs

"@metamask/superstruct": "^3.2.1",
"@metamask/test-bundler": "^1.0.0",
"@metamask/test-dapp": "9.3.0",
Expand Down
8 changes: 5 additions & 3 deletions test/e2e/accounts/snap-account-eth-swap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { TRADES_API_MOCK_RESULT } from '../../data/mock-data';
import { installSnapSimpleKeyring } from '../page-objects/flows/snap-simple-keyring.flow';
import { loginWithBalanceValidation } from '../page-objects/flows/login.flow';
import { Mockttp } from '../mock-e2e';
import { mockSimpleKeyringSnap } from '../mock-response-data/snaps/snap-binary-mocks';
import { mockSnapSimpleKeyringAndSite } from '../tests/account/snap-keyring-site-mocks';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ in all places we used the mock for the snap simple keyring binary, now we also mock the website


const DAI = 'DAI';
const TEST_ETH = 'TESTETH';
Expand All @@ -29,7 +29,7 @@ async function mockSwapsTransactionQuote(mockServer: Mockttp) {

async function mockSwapsAndSimpleKeyringSnap(mockServer: Mockttp) {
return [
await mockSimpleKeyringSnap(mockServer),
...(await mockSnapSimpleKeyringAndSite(mockServer)),
await mockSwapsTransactionQuote(mockServer),
];
}
Expand All @@ -39,9 +39,11 @@ describe('Snap Account - Swap', function () {
it.skip('swaps ETH for DAI using a snap account', async function () {
await withFixtures(
{
dapp: true,
dappPaths: ['snap-simple-keyring-site'],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ with this key, we can indicate we want a local server for the snap simple keyring site

fixtures: new FixtureBuilder().build(),
title: this.test?.fullTitle(),
testSpecificMock: mockSwapsAndSimpleKeyringSnap,
title: this.test?.fullTitle(),
},
async ({ driver }: { driver: Driver }) => {
await loginWithBalanceValidation(driver);
Expand Down
58 changes: 47 additions & 11 deletions test/e2e/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,21 +279,57 @@ async function withFixtures(options, testSuite) {
if (dapp) {
if (dappOptions?.numberOfDapps) {
numberOfDapps = dappOptions.numberOfDapps;
// Note: We don't cap numberOfDapps here even if dappPaths is shorter,
// because tests may need multiple dapps where some use default paths
} else if (dappPaths && Array.isArray(dappPaths)) {
numberOfDapps = dappPaths.length;
} else {
// Default to 1 dapp when dapp=true but no specific configuration
numberOfDapps = 1;
}

for (let i = 0; i < numberOfDapps; i++) {
let dappDirectory;
if (dappPath || (dappPaths && dappPaths[i])) {
dappDirectory = path.resolve(__dirname, dappPath || dappPaths[i]);
let currentDappPath;
if (dappPath) {
// Single dappPath takes precedence
currentDappPath = dappPath;
} else if (
dappPaths &&
Array.isArray(dappPaths) &&
i < dappPaths.length
) {
// Use dappPaths[i] if within bounds
currentDappPath = dappPaths[i];
} else {
dappDirectory = path.resolve(
__dirname,
'..',
'..',
'node_modules',
'@metamask',
'test-dapp',
'dist',
);
// Fallback to default
currentDappPath = 'test-dapp';
}

switch (currentDappPath) {
case 'snap-simple-keyring-site':
dappDirectory = path.resolve(
__dirname,
'..',
'..',
'node_modules',
'@metamask/snap-simple-keyring-site',
'public',
);
break;
case 'test-dapp':
dappDirectory = path.resolve(
__dirname,
'..',
'..',
'node_modules',
'@metamask/test-dapp',
'dist',
);
break;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ we'll add more cases in the future, for supporting the rest of live site requests to other dapps we use in our test

default:
dappDirectory = path.resolve(__dirname, currentDappPath);
break;
}
dappServer.push(
createStaticServer({ public: dappDirectory, ...staticServerOptions }),
Expand Down
9 changes: 0 additions & 9 deletions test/e2e/mock-e2e-allowlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ const ALLOWLISTED_URLS = [
'https://metamask.github.io/snap-account-abstraction-keyring/0.5.0/page-data/app-data.json',
'https://metamask.github.io/snap-account-abstraction-keyring/0.5.0/page-data/index/page-data.json',
'https://metamask.github.io/snap-account-abstraction-keyring/0.5.0/webpack-runtime-eb27ff9e27bd689ff465.js',
'https://metamask.github.io/snap-simple-keyring/1.1.6/',
'https://metamask.github.io/snap-simple-keyring/1.1.6/72585f70-b0685205a809efe121dc.js',
'https://metamask.github.io/snap-simple-keyring/1.1.6/f36c6662-7e78236bba23a76b6101.js',
'https://metamask.github.io/snap-simple-keyring/1.1.6/app-f4c2969992b9afb13e7f.js',
'https://metamask.github.io/snap-simple-keyring/1.1.6/component---src-pages-index-tsx-1bd38618fcde51a7fab0.js',
'https://metamask.github.io/snap-simple-keyring/1.1.6/framework-fe667a09be4a08a9b5f4.js',
'https://metamask.github.io/snap-simple-keyring/1.1.6/page-data/app-data.json',
'https://metamask.github.io/snap-simple-keyring/1.1.6/page-data/index/page-data.json',
'https://metamask.github.io/snap-simple-keyring/1.1.6/webpack-runtime-f26b9ef4aabef2136bf7.js',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

less live requests in our e2e, yay! 🎉

'https://metamask.github.io/snaps/test-snaps/2.28.1',
'https://metamask.github.io/snaps/test-snaps/2.28.1/',
'https://metamask.github.io/snaps/test-snaps/2.28.1/main.js',
Expand Down
Copy link
Member Author

@seaona seaona Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ the snap file binary changes are just the result of updating the snap package, by running this command: yarn update-snap-binary --snap-simple-keyring-snap@2.0.0

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Accept-Ranges": "bytes",
"Content-Length": "746597",
"Content-Length": "289072",
"Content-Type": "application/octet-stream",
"Etag": "\"5e3236532d71422b12b808da978c2fbf\"",
"Etag": "\"6e270316be30ae430f404e1d920de4db\"",
"Vary": "Accept-Encoding"
}
Binary file not shown.
Loading
Loading