Skip to content
Draft
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
2 changes: 1 addition & 1 deletion 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
2 changes: 1 addition & 1 deletion 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
2 changes: 1 addition & 1 deletion 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
2 changes: 1 addition & 1 deletion 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
32 changes: 11 additions & 21 deletions lavamoat/build-system/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"packages": {
"@babel/core>@babel/types": true,
"terser>@jridgewell/source-map>@jridgewell/gen-mapping": true,
"terser-webpack-plugin>@jridgewell/trace-mapping": true,
"@babel/core>@babel/generator>@jridgewell/trace-mapping": true,
"@babel/core>@babel/generator>jsesc": true
}
},
Expand Down Expand Up @@ -940,6 +940,15 @@
"define": true
}
},
"@babel/core>@babel/generator>@jridgewell/trace-mapping": {
"globals": {
"define": true
},
"packages": {
"terser-webpack-plugin>@jridgewell/trace-mapping>@jridgewell/resolve-uri": true,
"terser-webpack-plugin>@jridgewell/trace-mapping>@jridgewell/sourcemap-codec": true
}
},
"ts-node>@cspotcode/source-map-support>@jridgewell/trace-mapping": {
"globals": {
"define": true
Expand Down Expand Up @@ -1027,7 +1036,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 +1205,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 @@ -2841,24 +2849,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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,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
Contributor 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

"@metamask/superstruct": "^3.2.1",
"@metamask/test-bundler": "^1.0.0",
"@metamask/test-dapp": "9.3.0",
Expand Down
7 changes: 4 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';

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,10 @@ describe('Snap Account - Swap', function () {
it.skip('swaps ETH for DAI using a snap account', async function () {
await withFixtures(
{
dappPaths: ['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
42 changes: 30 additions & 12 deletions test/e2e/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,23 +277,41 @@ async function withFixtures(options, testSuite) {

await phishingPageServer.start();
if (dapp) {
// Auto-detect numberOfDapps from dappPaths array length, or use dappOptions override
if (dappOptions?.numberOfDapps) {
numberOfDapps = dappOptions.numberOfDapps;
} else if (dappPaths && Array.isArray(dappPaths)) {
numberOfDapps = dappPaths.length;
}
for (let i = 0; i < numberOfDapps; i++) {
let dappDirectory;
if (dappPath || (dappPaths && dappPaths[i])) {
dappDirectory = path.resolve(__dirname, dappPath || dappPaths[i]);
} else {
dappDirectory = path.resolve(
__dirname,
'..',
'..',
'node_modules',
'@metamask',
'test-dapp',
'dist',
);
const currentDappPath =
dappPath || (dappPaths && dappPaths[i]) || '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;
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
Contributor 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
Contributor 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 [email protected]

Binary file not shown.
4 changes: 2 additions & 2 deletions [email protected][email protected]
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.
5 changes: 3 additions & 2 deletions test/e2e/tests/account/create-remove-account-snap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import SnapListPage from '../../page-objects/pages/snap-list-page';
import SnapSimpleKeyringPage from '../../page-objects/pages/snap-simple-keyring-page';
import { installSnapSimpleKeyring } from '../../page-objects/flows/snap-simple-keyring.flow';
import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow';
import { mockSimpleKeyringSnap } from '../../mock-response-data/snaps/snap-binary-mocks';
import { mockSnapSimpleKeyringAndSite } from './snap-keyring-site-mocks';

describe('Create and remove Snap Account', function (this: Suite) {
it('create snap account and remove it by removing snap', async function () {
await withFixtures(
{
dappPaths: ['snap-simple-keyring-site'],
fixtures: new FixtureBuilder().build(),
testSpecificMock: mockSimpleKeyringSnap,
testSpecificMock: mockSnapSimpleKeyringAndSite,
title: this.test?.fullTitle(),
},
async ({ driver }: { driver: Driver }) => {
Expand Down
14 changes: 9 additions & 5 deletions test/e2e/tests/account/create-snap-account.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import HeaderNavbar from '../../page-objects/pages/header-navbar';
import SnapSimpleKeyringPage from '../../page-objects/pages/snap-simple-keyring-page';
import { installSnapSimpleKeyring } from '../../page-objects/flows/snap-simple-keyring.flow';
import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow';
import { mockSimpleKeyringSnap } from '../../mock-response-data/snaps/snap-binary-mocks';
import { mockSnapSimpleKeyringAndSite } from './snap-keyring-site-mocks';

describe('Create Snap Account', function (this: Suite) {
it('create Snap account with custom name input ends in approval success', async function () {
await withFixtures(
{
dappPaths: ['snap-simple-keyring-site'],
fixtures: new FixtureBuilder().build(),
testSpecificMock: mockSimpleKeyringSnap,
testSpecificMock: mockSnapSimpleKeyringAndSite,
title: this.test?.fullTitle(),
},
async ({ driver }: { driver: Driver }) => {
Expand All @@ -37,8 +38,9 @@ describe('Create Snap Account', function (this: Suite) {
it('creates multiple Snap accounts with increasing numeric suffixes', async function () {
await withFixtures(
{
dappPaths: ['snap-simple-keyring-site'],
fixtures: new FixtureBuilder().build(),
testSpecificMock: mockSimpleKeyringSnap,
testSpecificMock: mockSnapSimpleKeyringAndSite,
title: this.test?.fullTitle(),
},
async ({ driver }: { driver: Driver }) => {
Expand Down Expand Up @@ -75,8 +77,9 @@ describe('Create Snap Account', function (this: Suite) {
it('create Snap account canceling on confirmation screen results in error on Snap', async function () {
await withFixtures(
{
dappPaths: ['snap-simple-keyring-site'],
fixtures: new FixtureBuilder().build(),
testSpecificMock: mockSimpleKeyringSnap,
testSpecificMock: mockSnapSimpleKeyringAndSite,
title: this.test?.fullTitle(),
},
async ({ driver }: { driver: Driver }) => {
Expand Down Expand Up @@ -109,8 +112,9 @@ describe('Create Snap Account', function (this: Suite) {
it('create Snap account canceling on fill name screen results in error on Snap', async function () {
await withFixtures(
{
dappPaths: ['snap-simple-keyring-site'],
fixtures: new FixtureBuilder().build(),
testSpecificMock: mockSimpleKeyringSnap,
testSpecificMock: mockSnapSimpleKeyringAndSite,
title: this.test?.fullTitle(),
},
async ({ driver }: { driver: Driver }) => {
Expand Down
12 changes: 10 additions & 2 deletions test/e2e/tests/account/snap-account-contract-interaction.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Suite } from 'mocha';
import { Mockttp } from 'mockttp';
import { Driver } from '../../webdriver/driver';
import FixtureBuilder from '../../fixture-builder';
import { Anvil } from '../../seeder/anvil';
Expand All @@ -14,22 +15,29 @@ import TestDapp from '../../page-objects/pages/test-dapp';
import TransactionConfirmation from '../../page-objects/pages/confirmations/redesign/transaction-confirmation';
import { installSnapSimpleKeyring } from '../../page-objects/flows/snap-simple-keyring.flow';
import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow';
import { mockSimpleKeyringSnap } from '../../mock-response-data/snaps/snap-binary-mocks';
import { mockSnapSimpleKeyringAndSite } from './snap-keyring-site-mocks';

describe('Snap Account Contract interaction', function (this: Suite) {
const smartContract = SMART_CONTRACTS.PIGGYBANK;
it('deposits to piggybank contract', async function () {
await withFixtures(
{
dapp: true,
dappPaths: ['test-dapp', 'snap-simple-keyring-site'],
fixtures: new FixtureBuilder()
.withPermissionControllerSnapAccountConnectedToTestDapp()
.build(),
localNodeOptions: {
hardfork: 'london',
},
smartContract,
testSpecificMock: mockSimpleKeyringSnap,
testSpecificMock: async (mockServer: Mockttp) => {
const snapMocks = await mockSnapSimpleKeyringAndSite(
mockServer,
8081,
);
return snapMocks;
},
title: this.test?.fullTitle(),
},
async ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Suite } from 'mocha';
import { Mockttp } from 'mockttp';
import { Driver } from '../../webdriver/driver';
import { WINDOW_TITLES, withFixtures } from '../../helpers';
import FixtureBuilder from '../../fixture-builder';
Expand All @@ -11,15 +12,21 @@ import {
signTypedDataV3WithSnapAccount,
signTypedDataV4WithSnapAccount,
} from '../../page-objects/flows/sign.flow';
import { mockSimpleKeyringSnap } from '../../mock-response-data/snaps/snap-binary-mocks';
import { mockSnapSimpleKeyringAndSite } from './snap-keyring-site-mocks';

describe('Snap Account Signatures and Disconnects', function (this: Suite) {
it('can connect to the Test Dapp, then #signTypedDataV3, disconnect then connect, then #signTypedDataV4 (async flow approve)', async function () {
await withFixtures(
{
dapp: true,
dappPaths: ['test-dapp', 'snap-simple-keyring-site'],
fixtures: new FixtureBuilder().build(),
testSpecificMock: mockSimpleKeyringSnap,
testSpecificMock: async (mockServer: Mockttp) => {
const snapMocks = await mockSnapSimpleKeyringAndSite(
mockServer,
8081,
);
return snapMocks;
},
title: this.test?.fullTitle(),
},
async ({ driver }: { driver: Driver }) => {
Expand Down
12 changes: 10 additions & 2 deletions test/e2e/tests/account/snap-account-signatures.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Suite } from 'mocha';
import { Mockttp } from 'mockttp';
import { Driver } from '../../webdriver/driver';
import { WINDOW_TITLES, withFixtures } from '../../helpers';
import FixtureBuilder from '../../fixture-builder';
Expand All @@ -16,7 +17,7 @@ import {
signTypedDataV4WithSnapAccount,
signTypedDataWithSnapAccount,
} from '../../page-objects/flows/sign.flow';
import { mockSimpleKeyringSnap } from '../../mock-response-data/snaps/snap-binary-mocks';
import { mockSnapSimpleKeyringAndSite } from './snap-keyring-site-mocks';

describe('Snap Account Signatures', function (this: Suite) {
this.timeout(500000); // This test is very long, so we need an unusually high timeout
Expand All @@ -31,8 +32,15 @@ describe('Snap Account Signatures', function (this: Suite) {
await withFixtures(
{
dapp: true,
dappPaths: ['test-dapp', 'snap-simple-keyring-site'],
fixtures: new FixtureBuilder().build(),
testSpecificMock: mockSimpleKeyringSnap,
testSpecificMock: async (mockServer: Mockttp) => {
const snapMocks = await mockSnapSimpleKeyringAndSite(
mockServer,
8081,
);
return snapMocks;
},
title,
},
async ({ driver }: { driver: Driver }) => {
Expand Down
Loading
Loading