Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feat/filter-eth-re…
Browse files Browse the repository at this point in the history
…quests-for-non-evm-accounts
  • Loading branch information
montelaidev committed Jun 13, 2024
2 parents 8a9bf36 + e3071f2 commit c4b6c1f
Show file tree
Hide file tree
Showing 33 changed files with 1,330 additions and 114 deletions.
15 changes: 15 additions & 0 deletions app/_locales/en/messages.json

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

3 changes: 3 additions & 0 deletions app/manifest/v3/_base.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,8 @@
"webRequest",
"offscreen"
],
"sandbox": {
"pages": ["snaps/index.html"]
},
"short_name": "__MSG_appName__"
}
3 changes: 2 additions & 1 deletion app/manifest/v3/chrome.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"content_security_policy": {
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'none'; frame-ancestors 'none';"
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'none'; frame-ancestors 'none';",
"sandbox": "sandbox allow-scripts; script-src 'self' 'unsafe-inline' 'unsafe-eval'; object-src 'none'; default-src 'none'; connect-src *;"
},
"externally_connectable": {
"matches": ["https://metamask.io/*"],
Expand Down
21 changes: 21 additions & 0 deletions development/build/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,27 @@ function getCopyTargets(
pattern: `*.html`,
dest: '',
},
...(process.env.ENABLE_MV3 === 'true' ||
process.env.ENABLE_MV3 === undefined
? [
{
src: getPathInsideNodeModules(
'@metamask/snaps-execution-environments',
'dist/browserify/iframe/index.html',
),
dest: `snaps/index.html`,
pattern: '',
},
{
src: getPathInsideNodeModules(
'@metamask/snaps-execution-environments',
'dist/browserify/iframe/bundle.js',
),
dest: `snaps/bundle.js`,
pattern: '',
},
]
: []),
];

if (activeFeatures.includes('blockaid')) {
Expand Down
18 changes: 17 additions & 1 deletion lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,8 @@
"@ethereumjs/tx>@ethereumjs/util": true,
"@ethereumjs/tx>ethereum-cryptography": true,
"@metamask/accounts-controller>@metamask/base-controller": true,
"@metamask/accounts-controller>@metamask/keyring-api": true,
"@metamask/eth-snap-keyring": true,
"@metamask/keyring-api": true,
"@metamask/keyring-controller": true,
"@metamask/snaps-utils": true,
"@metamask/utils": true,
Expand All @@ -766,6 +766,22 @@
"immer": true
}
},
"@metamask/accounts-controller>@metamask/keyring-api": {
"globals": {
"URL": true
},
"packages": {
"@metamask/accounts-controller>@metamask/keyring-api>uuid": true,
"@metamask/keyring-api>bech32": true,
"@metamask/utils": true,
"superstruct": true
}
},
"@metamask/accounts-controller>@metamask/keyring-api>uuid": {
"globals": {
"crypto": true
}
},
"@metamask/address-book-controller": {
"packages": {
"@metamask/address-book-controller>@metamask/controller-utils": true,
Expand Down
18 changes: 17 additions & 1 deletion lavamoat/browserify/flask/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,8 @@
"@ethereumjs/tx>@ethereumjs/util": true,
"@ethereumjs/tx>ethereum-cryptography": true,
"@metamask/accounts-controller>@metamask/base-controller": true,
"@metamask/accounts-controller>@metamask/keyring-api": true,
"@metamask/eth-snap-keyring": true,
"@metamask/keyring-api": true,
"@metamask/keyring-controller": true,
"@metamask/snaps-utils": true,
"@metamask/utils": true,
Expand All @@ -766,6 +766,22 @@
"immer": true
}
},
"@metamask/accounts-controller>@metamask/keyring-api": {
"globals": {
"URL": true
},
"packages": {
"@metamask/accounts-controller>@metamask/keyring-api>uuid": true,
"@metamask/keyring-api>bech32": true,
"@metamask/utils": true,
"superstruct": true
}
},
"@metamask/accounts-controller>@metamask/keyring-api>uuid": {
"globals": {
"crypto": true
}
},
"@metamask/address-book-controller": {
"packages": {
"@metamask/address-book-controller>@metamask/controller-utils": true,
Expand Down
18 changes: 17 additions & 1 deletion lavamoat/browserify/main/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,8 @@
"@ethereumjs/tx>@ethereumjs/util": true,
"@ethereumjs/tx>ethereum-cryptography": true,
"@metamask/accounts-controller>@metamask/base-controller": true,
"@metamask/accounts-controller>@metamask/keyring-api": true,
"@metamask/eth-snap-keyring": true,
"@metamask/keyring-api": true,
"@metamask/keyring-controller": true,
"@metamask/snaps-utils": true,
"@metamask/utils": true,
Expand All @@ -766,6 +766,22 @@
"immer": true
}
},
"@metamask/accounts-controller>@metamask/keyring-api": {
"globals": {
"URL": true
},
"packages": {
"@metamask/accounts-controller>@metamask/keyring-api>uuid": true,
"@metamask/keyring-api>bech32": true,
"@metamask/utils": true,
"superstruct": true
}
},
"@metamask/accounts-controller>@metamask/keyring-api>uuid": {
"globals": {
"crypto": true
}
},
"@metamask/address-book-controller": {
"packages": {
"@metamask/address-book-controller>@metamask/controller-utils": true,
Expand Down
18 changes: 17 additions & 1 deletion lavamoat/browserify/mmi/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1035,8 +1035,8 @@
"@ethereumjs/tx>@ethereumjs/util": true,
"@ethereumjs/tx>ethereum-cryptography": true,
"@metamask/accounts-controller>@metamask/base-controller": true,
"@metamask/accounts-controller>@metamask/keyring-api": true,
"@metamask/eth-snap-keyring": true,
"@metamask/keyring-api": true,
"@metamask/keyring-controller": true,
"@metamask/snaps-utils": true,
"@metamask/utils": true,
Expand All @@ -1051,6 +1051,22 @@
"immer": true
}
},
"@metamask/accounts-controller>@metamask/keyring-api": {
"globals": {
"URL": true
},
"packages": {
"@metamask/accounts-controller>@metamask/keyring-api>uuid": true,
"@metamask/keyring-api>bech32": true,
"@metamask/utils": true,
"superstruct": true
}
},
"@metamask/accounts-controller>@metamask/keyring-api>uuid": {
"globals": {
"crypto": true
}
},
"@metamask/address-book-controller": {
"packages": {
"@metamask/address-book-controller>@metamask/controller-utils": true,
Expand Down
2 changes: 1 addition & 1 deletion offscreen/scripts/offscreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ const parentStream = new BrowserRuntimePostMessageStream({
target: 'parent',
});

ProxySnapExecutor.initialize(parentStream);
ProxySnapExecutor.initialize(parentStream, './snaps/index.html');
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
"@metamask/eth-ledger-bridge-keyring": "^2.0.1",
"@metamask/eth-query": "^4.0.0",
"@metamask/eth-sig-util": "^7.0.1",
"@metamask/eth-snap-keyring": "^4.2.1",
"@metamask/eth-snap-keyring": "^4.3.1",
"@metamask/eth-token-tracker": "^8.0.0",
"@metamask/eth-trezor-keyring": "^3.1.0",
"@metamask/etherscan-link": "^3.0.0",
Expand All @@ -307,7 +307,7 @@
"@metamask/ethjs-query": "^0.7.1",
"@metamask/gas-fee-controller": "^15.1.2",
"@metamask/jazzicon": "^2.0.0",
"@metamask/keyring-api": "^6.3.1",
"@metamask/keyring-api": "^8.0.0",
"@metamask/keyring-controller": "patch:@metamask/keyring-controller@npm%3A15.0.0#~/.yarn/patches/@metamask-keyring-controller-npm-15.0.0-fa070ce311.patch",
"@metamask/logging-controller": "^3.0.1",
"@metamask/logo": "^3.1.2",
Expand Down Expand Up @@ -489,6 +489,7 @@
"@types/gulp-sourcemaps": "^0.0.35",
"@types/he": "^1",
"@types/jest": "^29.5.12",
"@types/luxon": "^3.4.2",
"@types/mocha": "^10.0.3",
"@types/node": "^20",
"@types/pify": "^5.0.1",
Expand Down
38 changes: 38 additions & 0 deletions test/data/confirmations/personal_sign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,41 @@ export const signatureRequestSIWE = {
},
},
};

export const SignatureRequestSIWEWithResources = {
id: '210ca3b0-1ccb-11ef-b096-89c4d726ebb5',
securityAlertResponse: {
reason: 'loading',
result_type: 'validation_in_progress',
securityAlertId: 'b826df20-2eda-41bf-becf-6a100141a8be',
},
status: 'unapproved',
time: 1716884423019,
type: 'personal_sign',
msgParams: {
from: '0x935e73edb9ff52e23bac7f7e049a1ecd06d05477',
data: '0x6d6574616d61736b2e6769746875622e696f2077616e747320796f7520746f207369676e20696e207769746820796f757220457468657265756d206163636f756e743a0a3078393335653733656462396666353265323362616337663765303433613165636430366430353437370a0a492061636365707420746865204d6574614d61736b205465726d73206f6620536572766963653a2068747470733a2f2f636f6d6d756e6974792e6d6574616d61736b2e696f2f746f730a0a5552493a2068747470733a2f2f6d6574616d61736b2e6769746875622e696f0a56657273696f6e3a20310a436861696e2049443a20310a4e6f6e63653a2033323839313735370a4973737565642041743a20323032312d30392d33305431363a32353a32342e3030305a',
signatureMethod: 'personal_sign',
origin: 'https://metamask.github.io',
siwe: {
isSIWEMessage: true,
parsedMessage: {
domain: 'metamask.github.io',
address: '0x935e73edb9ff52e23bac7f7e043a1ecd06d05477',
statement:
'I accept the MetaMask Terms of Service: https://community.metamask.io/tos',
uri: 'https://metamask.github.io',
version: '1',
chainId: 1,
nonce: '32891757',
issuedAt: '2021-09-30T16:25:24.000Z',
notBefore: '2022-03-17T12:45:13.610Z',
requestId: 'some_id',
resources: [
'ipfs://Qme7ss3ARVgxv6rXqVPiikMJ8u2NLgmgszg13pYrDKEoiu',
'https://example.com/my-web2-claim.json',
],
},
},
},
};
29 changes: 8 additions & 21 deletions test/e2e/tests/tokens/nft/send-nft.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const { strict: assert } = require('assert');
const {
defaultGanacheOptions,
withFixtures,
logInWithBalanceValidation,
unlockWallet,
withFixtures,
} = require('../../../helpers');
const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts');
const FixtureBuilder = require('../../../fixture-builder');
Expand Down Expand Up @@ -93,16 +94,13 @@ describe('Send NFT', function () {
smartContract: erc1155SmartContract,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await unlockWallet(driver);
async ({ driver, ganacheServer }) => {
await logInWithBalanceValidation(driver, ganacheServer);

// Fill the send NFT form and confirm the transaction
await driver.clickElement('[data-testid="account-overview__nfts-tab"]');

await driver.delay(1000);
const erc1155Token = await driver.findElement('.nft-item__container');
await driver.scrollToElement(erc1155Token);
await driver.delay(1000);
await driver.clickElement('[data-testid="nft-network-badge"]');
await driver.clickElement(
'.nft-item__container .mm-badge-wrapper__badge-container',
);
Expand All @@ -112,7 +110,6 @@ describe('Send NFT', function () {
'input[placeholder="Enter public address (0x) or ENS name"]',
'0xc427D562164062a23a5cFf596A4a3208e72Acd28',
);
await driver.delay(1000);

await driver.fill('input[placeholder="0"]', '1');

Expand Down Expand Up @@ -148,11 +145,6 @@ describe('Send NFT', function () {
// Go back to NFTs tab and check the imported NFT is shown as previously owned
await driver.clickElement('[data-testid="account-overview__nfts-tab"]');

const refreshList = await driver.findElement(
'[data-testid="refresh-list-button"]',
);
await driver.scrollToElement(refreshList);
await driver.delay(1000);
await driver.clickElement('[data-testid="refresh-list-button"]');

const previouslyOwnedNft = await driver.findElement({
Expand All @@ -173,21 +165,16 @@ describe('Send NFT', function () {
smartContract: erc1155SmartContract,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await unlockWallet(driver);
async ({ driver, ganacheServer }) => {
await logInWithBalanceValidation(driver, ganacheServer);

// Fill the send NFT form and confirm the transaction
await driver.clickElement('[data-testid="account-overview__nfts-tab"]');

const erc1155Token = await driver.findElement('.nft-item__container');
await driver.scrollToElement(erc1155Token);
await driver.delay(1000);
await driver.clickElement('.nft-item__container');
await driver.clickElement('[data-testid="nft-network-badge"]');

await driver.clickElement({ text: 'Send', tag: 'button' });

await driver.delay(10000);

await driver.fill(
'input[placeholder="Enter public address (0x) or ENS name"]',
'0xc427D562164062a23a5cFf596A4a3208e72Acd28',
Expand Down
17 changes: 15 additions & 2 deletions test/e2e/tests/transaction/ens.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ const FixtureBuilder = require('../../fixture-builder');

describe('ENS', function () {
const sampleAddress = '1111111111111111111111111111111111111111';

// Having 2 versions of the address is a bug(#25286)
const shortSampleAddress = '0x1111...1111';
const shortSampleAddresV2 = '0x11111...11111';

const sampleEnsDomain = 'test.eth';
const infuraUrl =
'https://mainnet.infura.io/v3/00000000000000000000000000000000';
Expand Down Expand Up @@ -95,15 +100,23 @@ describe('ENS', function () {
css: '[data-testid="multichain-send-page__recipient__item__title"]',
});

await driver.clickElement('.multichain-send-page__recipient__item');
await driver.waitForSelector({
text: shortSampleAddress,
css: '.multichain-send-page__recipient__item__subtitle',
});

await driver.clickElement({
text: sampleEnsDomain,
css: '[data-testid="multichain-send-page__recipient__item__title"]',
});

await driver.findElement({
css: '.ens-input__selected-input__title',
text: 'test.eth',
});

await driver.findElement({
text: '0x11111...11111',
text: shortSampleAddresV2,
});
},
);
Expand Down
Loading

0 comments on commit c4b6c1f

Please sign in to comment.