From e011c5f03b1b3ce370d531d000e722d2888e76df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Regadas?= Date: Wed, 3 Apr 2024 14:52:18 +0100 Subject: [PATCH 01/51] chore: updates package and RPC middleware methods (#23827) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** Updates MMI package and RPC methods. ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --------- Co-authored-by: MetaMask Bot --- .../institutional/mmi-open-add-hardware-wallet.js | 12 +++--------- .../handlers/institutional/mmi-portfolio.js | 11 +++-------- .../institutional/mmi-set-account-and-network.js | 11 +++-------- lavamoat/browserify/mmi/policy.json | 5 +++++ package.json | 2 +- yarn.lock | 10 +++++----- 6 files changed, 20 insertions(+), 31 deletions(-) diff --git a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-open-add-hardware-wallet.js b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-open-add-hardware-wallet.js index 2518a326a9ef..61af6eb43fe8 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-open-add-hardware-wallet.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-open-add-hardware-wallet.js @@ -1,4 +1,4 @@ -import { RPC_ALLOWED_ORIGINS } from '@metamask-institutional/rpc-allowlist'; +import { isAllowedRPCOrigin } from '@metamask-institutional/rpc-allowlist'; import { MESSAGE_TYPE } from '../../../../../../shared/constants/app'; const mmiOpenAddHardwareWallet = { @@ -30,14 +30,8 @@ async function mmiOpenAddHardwareWalletHandler( { handleMmiOpenAddHardwareWallet }, ) { try { - let validUrl = false; - // if (!RPC_ALLOWED_ORIGINS[MESSAGE_TYPE.MMI_PORTFOLIO].includes(req.origin)) { - RPC_ALLOWED_ORIGINS[MESSAGE_TYPE.MMI_PORTFOLIO].forEach((regexp) => { - // eslint-disable-next-line require-unicode-regexp - if (regexp.test(req.origin)) { - validUrl = true; - } - }); + const validUrl = isAllowedRPCOrigin(MESSAGE_TYPE.MMI_PORTFOLIO, req.origin); + // eslint-disable-next-line no-negated-condition if (!validUrl) { throw new Error('Unauthorized'); diff --git a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-portfolio.js b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-portfolio.js index e52599ee9736..cbe96127682f 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-portfolio.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-portfolio.js @@ -1,4 +1,4 @@ -import { RPC_ALLOWED_ORIGINS } from '@metamask-institutional/rpc-allowlist'; +import { isAllowedRPCOrigin } from '@metamask-institutional/rpc-allowlist'; import { MESSAGE_TYPE } from '../../../../../../shared/constants/app'; const mmiPortfolio = { @@ -36,13 +36,8 @@ async function mmiPortfolioHandler( { handleMmiDashboardData }, ) { try { - let validUrl = false; - RPC_ALLOWED_ORIGINS[MESSAGE_TYPE.MMI_PORTFOLIO].forEach((regexp) => { - // eslint-disable-next-line require-unicode-regexp - if (regexp.test(req.origin)) { - validUrl = true; - } - }); + const validUrl = isAllowedRPCOrigin(MESSAGE_TYPE.MMI_PORTFOLIO, req.origin); + // eslint-disable-next-line no-negated-condition if (!validUrl) { throw new Error('Unauthorized'); diff --git a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-set-account-and-network.js b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-set-account-and-network.js index db880691536e..9dca692601a3 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-set-account-and-network.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-set-account-and-network.js @@ -1,5 +1,5 @@ import { ethErrors } from 'eth-rpc-errors'; -import { RPC_ALLOWED_ORIGINS } from '@metamask-institutional/rpc-allowlist'; +import { isAllowedRPCOrigin } from '@metamask-institutional/rpc-allowlist'; import { MESSAGE_TYPE } from '../../../../../../shared/constants/app'; const mmiSetAccountAndNetwork = { @@ -37,13 +37,8 @@ async function mmiSetAccountAndNetworkHandler( { handleMmiSetAccountAndNetwork }, ) { try { - let validUrl = false; - RPC_ALLOWED_ORIGINS[MESSAGE_TYPE.MMI_PORTFOLIO].forEach((regexp) => { - // eslint-disable-next-line require-unicode-regexp - if (regexp.test(req.origin)) { - validUrl = true; - } - }); + const validUrl = isAllowedRPCOrigin(MESSAGE_TYPE.MMI_PORTFOLIO, req.origin); + // eslint-disable-next-line no-negated-condition if (!validUrl) { throw new Error('Unauthorized'); diff --git a/lavamoat/browserify/mmi/policy.json b/lavamoat/browserify/mmi/policy.json index c8ba0a32e567..20cc6347a087 100644 --- a/lavamoat/browserify/mmi/policy.json +++ b/lavamoat/browserify/mmi/policy.json @@ -761,6 +761,11 @@ "fetch": true } }, + "@metamask-institutional/rpc-allowlist": { + "globals": { + "URL": true + } + }, "@metamask-institutional/sdk": { "globals": { "URLSearchParams": true, diff --git a/package.json b/package.json index 82f9bde79e1e..78097137d5aa 100644 --- a/package.json +++ b/package.json @@ -261,7 +261,7 @@ "@metamask-institutional/extension": "^0.3.18", "@metamask-institutional/institutional-features": "^1.2.11", "@metamask-institutional/portfolio-dashboard": "^1.4.0", - "@metamask-institutional/rpc-allowlist": "^1.0.1", + "@metamask-institutional/rpc-allowlist": "^1.0.2", "@metamask-institutional/sdk": "^0.1.23", "@metamask-institutional/transaction-update": "^0.1.32", "@metamask/abi-utils": "^2.0.2", diff --git a/yarn.lock b/yarn.lock index 4e14a5d6a164..4d070399c9cf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3861,10 +3861,10 @@ __metadata: languageName: node linkType: hard -"@metamask-institutional/rpc-allowlist@npm:^1.0.1": - version: 1.0.1 - resolution: "@metamask-institutional/rpc-allowlist@npm:1.0.1" - checksum: 6ffccae64a42b0c63696929fcfb752b75528394ce04b4e6c2145aebc6118e94ba81f204c91ad1394a0073f8cd85923a13415cbda1c4996a83efba1babeae545d +"@metamask-institutional/rpc-allowlist@npm:^1.0.2": + version: 1.0.2 + resolution: "@metamask-institutional/rpc-allowlist@npm:1.0.2" + checksum: 34939415457c5856c49c01330de976e276d5525b9ca4bdf5eca55570ccb47be77a809bf3a6eb05f817bd91c981e8614b573385e0b9ed7b218233d4b559e58b75 languageName: node linkType: hard @@ -24807,7 +24807,7 @@ __metadata: "@metamask-institutional/extension": "npm:^0.3.18" "@metamask-institutional/institutional-features": "npm:^1.2.11" "@metamask-institutional/portfolio-dashboard": "npm:^1.4.0" - "@metamask-institutional/rpc-allowlist": "npm:^1.0.1" + "@metamask-institutional/rpc-allowlist": "npm:^1.0.2" "@metamask-institutional/sdk": "npm:^0.1.23" "@metamask-institutional/transaction-update": "npm:^0.1.32" "@metamask/abi-utils": "npm:^2.0.2" From a2a832415893a5aa224f746790359276942cf959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Regadas?= Date: Wed, 3 Apr 2024 15:07:00 +0100 Subject: [PATCH 02/51] chore: adds MMI Sentry DSN key to VARIABLES_REQUIRED_IN_PRODUCTION (#23826) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** Adds MMI Sentry DSN key to `VARIABLES_REQUIRED_IN_PRODUCTION`. ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- development/build/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/development/build/config.js b/development/build/config.js index 4e4ee1ea9c8a..030b9e04dad0 100644 --- a/development/build/config.js +++ b/development/build/config.js @@ -15,7 +15,7 @@ const VARIABLES_REQUIRED_IN_PRODUCTION = { 'INFURA_MMI_PROJECT_ID', 'MMI_CONFIGURATION_SERVICE_URL', 'SEGMENT_MMI_WRITE_KEY', - 'SENTRY_DSN', + 'SENTRY_MMI_DSN', ], }; From 0c7f0e685d0ad4e2e8e370f529305eb30f1e3138 Mon Sep 17 00:00:00 2001 From: Guillaume Roux Date: Wed, 3 Apr 2024 17:09:52 +0200 Subject: [PATCH 03/51] fix(snaps): Use MarkDown styling in links (#23840) --- ui/components/app/snaps/snap-ui-markdown/index.scss | 11 ----------- .../app/snaps/snap-ui-markdown/snap-ui-markdown.js | 7 ++++++- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/ui/components/app/snaps/snap-ui-markdown/index.scss b/ui/components/app/snaps/snap-ui-markdown/index.scss index 17cc5a212854..1e206c28151f 100644 --- a/ui/components/app/snaps/snap-ui-markdown/index.scss +++ b/ui/components/app/snaps/snap-ui-markdown/index.scss @@ -4,15 +4,4 @@ font-style: revert; } } - - &__link { - & > span:last-child { - margin-inline-start: 2px; - } - - & .mm-icon--size-inherit { - // Fixes the icon misalignment in ButtonLink when using ButtonLinkSize.Inherit - top: 0.1em; - } - } } diff --git a/ui/components/app/snaps/snap-ui-markdown/snap-ui-markdown.js b/ui/components/app/snaps/snap-ui-markdown/snap-ui-markdown.js index 35bbb8b1f2f0..41c3a61425b0 100644 --- a/ui/components/app/snaps/snap-ui-markdown/snap-ui-markdown.js +++ b/ui/components/app/snaps/snap-ui-markdown/snap-ui-markdown.js @@ -5,11 +5,14 @@ import { TextVariant, OverflowWrap, TextColor, + Display, } from '../../../../helpers/constants/design-system'; import { ButtonLink, ButtonLinkSize, + Icon, IconName, + IconSize, Text, } from '../../../component-library'; import SnapLinkWarning from '../snap-link-warning'; @@ -27,13 +30,15 @@ const Paragraph = (props) => ( const Link = ({ onClick, children, ...rest }) => ( {children} + ); From 301545b325dbc4dd4ea4d3531d9bb979a4176b0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Regadas?= Date: Wed, 3 Apr 2024 16:38:05 +0100 Subject: [PATCH 04/51] chore: updates packages for MMI (#23841) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** Brings MMI packages to their latest versions. ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- package.json | 12 +++--- yarn.lock | 104 +++++++++++++++++++++++++-------------------------- 2 files changed, 58 insertions(+), 58 deletions(-) diff --git a/package.json b/package.json index 78097137d5aa..da505802aee7 100644 --- a/package.json +++ b/package.json @@ -256,14 +256,14 @@ "@lavamoat/lavadome-react": "0.0.17", "@lavamoat/snow": "^2.0.1", "@material-ui/core": "^4.11.0", - "@metamask-institutional/custody-controller": "^0.2.22", - "@metamask-institutional/custody-keyring": "^1.0.10", - "@metamask-institutional/extension": "^0.3.18", - "@metamask-institutional/institutional-features": "^1.2.11", + "@metamask-institutional/custody-controller": "^0.2.23", + "@metamask-institutional/custody-keyring": "^1.0.11", + "@metamask-institutional/extension": "^0.3.19", + "@metamask-institutional/institutional-features": "^1.2.14", "@metamask-institutional/portfolio-dashboard": "^1.4.0", "@metamask-institutional/rpc-allowlist": "^1.0.2", - "@metamask-institutional/sdk": "^0.1.23", - "@metamask-institutional/transaction-update": "^0.1.32", + "@metamask-institutional/sdk": "^0.1.25", + "@metamask-institutional/transaction-update": "^0.1.37", "@metamask/abi-utils": "^2.0.2", "@metamask/accounts-controller": "^11.0.0", "@metamask/address-book-controller": "^3.1.7", diff --git a/yarn.lock b/yarn.lock index 4d070399c9cf..cdb3654ce1ee 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3797,60 +3797,60 @@ __metadata: languageName: node linkType: hard -"@metamask-institutional/custody-controller@npm:^0.2.22": - version: 0.2.22 - resolution: "@metamask-institutional/custody-controller@npm:0.2.22" +"@metamask-institutional/custody-controller@npm:^0.2.23": + version: 0.2.23 + resolution: "@metamask-institutional/custody-controller@npm:0.2.23" dependencies: "@ethereumjs/util": "npm:^8.0.5" - "@metamask-institutional/custody-keyring": "npm:^1.0.10" - "@metamask-institutional/sdk": "npm:^0.1.24" + "@metamask-institutional/custody-keyring": "npm:^1.0.11" + "@metamask-institutional/sdk": "npm:^0.1.25" "@metamask-institutional/types": "npm:^1.0.4" "@metamask/obs-store": "npm:^8.0.0" - checksum: e5ee0ce9dfca87ddaff977a48e4914263de9f930797ad9adc0568381ec2a4373f8e307bafc1162c0215eccfa93b8b42ce684bac4b294758c53164958e44a7d69 + checksum: 774855c8f96007034aa1e5bd5858a7b2ac1733ebad9e01d1aea6439abf5275a000bf56cf7806f72fa44809ae4b7f7c9c56244e455f6ac52a1cd13a5875eb9c17 languageName: node linkType: hard -"@metamask-institutional/custody-keyring@npm:^1.0.10, @metamask-institutional/custody-keyring@npm:^1.0.8": - version: 1.0.10 - resolution: "@metamask-institutional/custody-keyring@npm:1.0.10" +"@metamask-institutional/custody-keyring@npm:^1.0.11": + version: 1.0.11 + resolution: "@metamask-institutional/custody-keyring@npm:1.0.11" dependencies: "@ethereumjs/tx": "npm:^4.1.1" "@ethereumjs/util": "npm:^8.0.5" "@metamask-institutional/configuration-client": "npm:^2.0.1" - "@metamask-institutional/sdk": "npm:^0.1.24" + "@metamask-institutional/sdk": "npm:^0.1.25" "@metamask-institutional/types": "npm:^1.0.4" "@metamask/obs-store": "npm:^8.0.0" crypto: "npm:^1.0.1" lodash.clonedeep: "npm:^4.5.0" - checksum: 5009f4d0bd6779898b632a0f00ad3f572678ec3cf36dafac2365199645f0702dba76e62ad1b08dc405b502d501070f3efadac1409c3c1eeade5d6b66aefd8eb3 + checksum: 63f76e15ee665ca8f3cbdb5a7137139d1b765a3596513e8f150a8fcc11ae06e933a2e7b4f7765b3977bb8b0cdbce0a0ab894d26824e298e0305eeba1c581743a languageName: node linkType: hard -"@metamask-institutional/extension@npm:^0.3.18": - version: 0.3.18 - resolution: "@metamask-institutional/extension@npm:0.3.18" +"@metamask-institutional/extension@npm:^0.3.19": + version: 0.3.19 + resolution: "@metamask-institutional/extension@npm:0.3.19" dependencies: "@ethereumjs/util": "npm:^8.0.5" - "@metamask-institutional/custody-controller": "npm:^0.2.22" - "@metamask-institutional/custody-keyring": "npm:^1.0.10" + "@metamask-institutional/custody-controller": "npm:^0.2.23" + "@metamask-institutional/custody-keyring": "npm:^1.0.11" "@metamask-institutional/portfolio-dashboard": "npm:^1.4.0" - "@metamask-institutional/sdk": "npm:^0.1.24" - "@metamask-institutional/transaction-update": "npm:^0.1.36" + "@metamask-institutional/sdk": "npm:^0.1.25" + "@metamask-institutional/transaction-update": "npm:^0.1.37" "@metamask-institutional/types": "npm:^1.0.4" jest-create-mock-instance: "npm:^2.0.0" jest-fetch-mock: "npm:3.0.3" lodash.clonedeep: "npm:^4.5.0" - checksum: 0adcdb89869870b00ec9227d211befcea851ff096c9e029938a81329e8dc0c1c3a1a7b208b9120fe647124223710cfb73a281e150553cf96c7f98e2cf091e7bd + checksum: 96bd4b291e03042fea4b513d435bfd1f5e3a7a6cabd2751c3a256838c7a67b12c3078b932f14f26bed96ace9df5363c5ed5d7ac7739aad80d5720188a2097827 languageName: node linkType: hard -"@metamask-institutional/institutional-features@npm:^1.2.11": - version: 1.2.11 - resolution: "@metamask-institutional/institutional-features@npm:1.2.11" +"@metamask-institutional/institutional-features@npm:^1.2.14": + version: 1.2.14 + resolution: "@metamask-institutional/institutional-features@npm:1.2.14" dependencies: - "@metamask-institutional/custody-keyring": "npm:^1.0.8" + "@metamask-institutional/custody-keyring": "npm:^1.0.11" "@metamask/obs-store": "npm:^8.0.0" - checksum: b9425bb97e310228fe9aa52376375e0205acf1500dd75360e8bb6c7949abbe7068837d5b97c5e15c814d81d115af9dc809c1e2f7aa8979437030a376b8a09164 + checksum: a18cd5cbc2a94c92119d3256c7057c8f74feeebfcc17d5109da72eaf843587557bc331ac5d892dd6faffafdce21b26bb752cffb771fa93cd887a372a44b4b093 languageName: node linkType: hard @@ -3868,17 +3868,17 @@ __metadata: languageName: node linkType: hard -"@metamask-institutional/sdk@npm:^0.1.23, @metamask-institutional/sdk@npm:^0.1.24": - version: 0.1.24 - resolution: "@metamask-institutional/sdk@npm:0.1.24" +"@metamask-institutional/sdk@npm:^0.1.25": + version: 0.1.25 + resolution: "@metamask-institutional/sdk@npm:0.1.25" dependencies: "@metamask-institutional/simplecache": "npm:^1.1.0" "@metamask-institutional/types": "npm:^1.0.4" "@types/jsonwebtoken": "npm:^9.0.1" - "@types/node": "npm:^20.4.2" + "@types/node": "npm:^20.11.17" bignumber.js: "npm:^9.1.1" jsonwebtoken: "npm:^9.0.0" - checksum: 4dd9e065880179fbf770d536deb2309cd7640bc844e7bac13023cd5ffe68636ab97849c0ee827a3026115eaa5d40cf5507644ca6f34d89e7beca2e32419915ae + checksum: ac9fc0d50c7963745ae96e7ba7a845217ff3681571f2ce8729f42e5dc903d4fb1df13fcc1465b2246c551b331e30a685deccbc56e89dd7070d83bdc5c3fe912b languageName: node linkType: hard @@ -3889,17 +3889,17 @@ __metadata: languageName: node linkType: hard -"@metamask-institutional/transaction-update@npm:^0.1.32, @metamask-institutional/transaction-update@npm:^0.1.36": - version: 0.1.36 - resolution: "@metamask-institutional/transaction-update@npm:0.1.36" +"@metamask-institutional/transaction-update@npm:^0.1.37": + version: 0.1.37 + resolution: "@metamask-institutional/transaction-update@npm:0.1.37" dependencies: - "@metamask-institutional/custody-keyring": "npm:^1.0.10" - "@metamask-institutional/sdk": "npm:^0.1.24" + "@metamask-institutional/custody-keyring": "npm:^1.0.11" + "@metamask-institutional/sdk": "npm:^0.1.25" "@metamask-institutional/types": "npm:^1.0.4" - "@metamask-institutional/websocket-client": "npm:^0.1.38" + "@metamask-institutional/websocket-client": "npm:^0.1.39" "@metamask/obs-store": "npm:^8.0.0" ethereumjs-util: "npm:^7.1.5" - checksum: e35fad2e51a541679a36d3f8db11a16114a2516fed7c740ff77560a35cacf67880c8d90e57ba13fd9f179136a9fbdd108b3b58f0dc38c64a85797e8738749ad4 + checksum: 44ba8cffa62a51f6484da6739dcef6cf8dcd2ba802c29c08b4512e0c5daf96c5beb3439284f5581c685366bc518b99b70f0132776401d96c06d5d049f26eded6 languageName: node linkType: hard @@ -3910,15 +3910,15 @@ __metadata: languageName: node linkType: hard -"@metamask-institutional/websocket-client@npm:^0.1.38": - version: 0.1.38 - resolution: "@metamask-institutional/websocket-client@npm:0.1.38" +"@metamask-institutional/websocket-client@npm:^0.1.39": + version: 0.1.39 + resolution: "@metamask-institutional/websocket-client@npm:0.1.39" dependencies: - "@metamask-institutional/custody-keyring": "npm:^1.0.10" - "@metamask-institutional/sdk": "npm:^0.1.24" + "@metamask-institutional/custody-keyring": "npm:^1.0.11" + "@metamask-institutional/sdk": "npm:^0.1.25" "@metamask-institutional/types": "npm:^1.0.4" mock-socket: "npm:^9.2.1" - checksum: 6b1cb6798f58f83b128e55348fbb738d3cfb54c76d557731a8fd1bd3c1dde5604d958699d8c030ede225017fdc8977112d2397d161a5f9da6d9fced8452494e8 + checksum: c22443f6a81e1dc750f14f9566f68908520eb7ccef9c9536214562abe281063c15618047520c911bcb9fac2c7f9fed963cb3cd55681a1844bb11178c14c259c2 languageName: node linkType: hard @@ -9894,12 +9894,12 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:*, @types/node@npm:>=13.7.0, @types/node@npm:^20, @types/node@npm:^20.4.2": - version: 20.11.13 - resolution: "@types/node@npm:20.11.13" +"@types/node@npm:*, @types/node@npm:>=13.7.0, @types/node@npm:^20, @types/node@npm:^20.11.17": + version: 20.12.3 + resolution: "@types/node@npm:20.12.3" dependencies: undici-types: "npm:~5.26.4" - checksum: ffe143dd5e52d0d29f5bcea165b752c5355eaff8b6b933441108b540419e14c0c7e0e7912783e914125ab957e30db93f9c827e8dd437ec7e5f03def995e9a5e6 + checksum: 3f3c5c6ba118a18aa997c51cdc3c66259d69021f87475a99ed6c913a6956e22de49748e09843bf6447a7a63ae474e61945a6dbcca93e23b2359fc0b6f9914f7a languageName: node linkType: hard @@ -24802,14 +24802,14 @@ __metadata: "@lavamoat/snow": "npm:^2.0.1" "@lgbot/madge": "npm:^6.2.0" "@material-ui/core": "npm:^4.11.0" - "@metamask-institutional/custody-controller": "npm:^0.2.22" - "@metamask-institutional/custody-keyring": "npm:^1.0.10" - "@metamask-institutional/extension": "npm:^0.3.18" - "@metamask-institutional/institutional-features": "npm:^1.2.11" + "@metamask-institutional/custody-controller": "npm:^0.2.23" + "@metamask-institutional/custody-keyring": "npm:^1.0.11" + "@metamask-institutional/extension": "npm:^0.3.19" + "@metamask-institutional/institutional-features": "npm:^1.2.14" "@metamask-institutional/portfolio-dashboard": "npm:^1.4.0" "@metamask-institutional/rpc-allowlist": "npm:^1.0.2" - "@metamask-institutional/sdk": "npm:^0.1.23" - "@metamask-institutional/transaction-update": "npm:^0.1.32" + "@metamask-institutional/sdk": "npm:^0.1.25" + "@metamask-institutional/transaction-update": "npm:^0.1.37" "@metamask/abi-utils": "npm:^2.0.2" "@metamask/accounts-controller": "npm:^11.0.0" "@metamask/address-book-controller": "npm:^3.1.7" From 9e21127c010782cf509b4c3ac97c7754426b07ce Mon Sep 17 00:00:00 2001 From: sahar-fehri Date: Thu, 4 Apr 2024 00:43:50 +0200 Subject: [PATCH 05/51] fix: add display warning for mumbai (#23846) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** This adds a display of deprecation warning for users when they switch to Mumbai network. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/23846?quickstart=1) ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to settings => networks => add a network => add network manually 2. Fill in the name:Mumbai ; RPC_URL(exp) : https://80001.rpc.thirdweb.com; chainID: 80001, symbol:MATIC 3. Switch to this network 4. you should be able to see a warning "This network is deprecated" ## **Screenshots/Recordings** ### **Before** https://github.com/MetaMask/metamask-extension/assets/10994169/acd505f4-4c79-4623-8819-de91dbf2fc2b ### **After** https://github.com/MetaMask/metamask-extension/assets/10994169/b1db81c6-fdff-4d11-9e1e-cdbf6125e65b ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- shared/constants/network.ts | 1 + .../tests/network/deprecated-networks.spec.js | 85 +++++++++++++++++++ .../deprecated-networks.js | 12 ++- 3 files changed, 94 insertions(+), 4 deletions(-) diff --git a/shared/constants/network.ts b/shared/constants/network.ts index 1181a63338ef..8aba942052c7 100644 --- a/shared/constants/network.ts +++ b/shared/constants/network.ts @@ -213,6 +213,7 @@ export const DEPRECATED_NETWORKS = [ CHAIN_IDS.GOERLI, CHAIN_IDS.ARBITRUM_GOERLI, CHAIN_IDS.OPTIMISM_GOERLI, + CHAIN_IDS.POLYGON_TESTNET, CHAIN_IDS.LINEA_GOERLI, ]; diff --git a/test/e2e/tests/network/deprecated-networks.spec.js b/test/e2e/tests/network/deprecated-networks.spec.js index b1e6d2e2df5a..c40061eb6d0a 100644 --- a/test/e2e/tests/network/deprecated-networks.spec.js +++ b/test/e2e/tests/network/deprecated-networks.spec.js @@ -201,4 +201,89 @@ describe('Deprecated networks', function () { }, ); }); + + it('Should show deprecation warning when switching to Polygon mumbai', async function () { + const TEST_CHAIN_ID = CHAIN_IDS.POLYGON_TESTNET; + async function mockRPCURLAndChainId(mockServer) { + return [ + await mockServer + .forPost('https://responsive-rpc.url/') + .thenCallback(() => ({ + statusCode: 200, + json: { + id: '1694444405781', + jsonrpc: '2.0', + result: TEST_CHAIN_ID, + }, + })), + ]; + } + + await withFixtures( + { + dapp: true, + fixtures: new FixtureBuilder() + .withPermissionControllerConnectedToTestDapp() + .withPreferencesController({ useSafeChainsListValidation: false }) + .build(), + title: this.test.fullTitle(), + testSpecificMock: mockRPCURLAndChainId, + }, + async ({ driver }) => { + await unlockWallet(driver); + + await openDapp(driver); + await driver.executeScript(` + var params = [{ + chainId: "${TEST_CHAIN_ID}", + chainName: "Polygon Mumbai", + nativeCurrency: { + name: "", + symbol: "MATIC", + decimals: 18 + }, + rpcUrls: ["https://responsive-rpc.url/"], + blockExplorerUrls: [ "http://localhost:8080/api/customRPC" ] + }] + window.ethereum.request({ + method: 'wallet_addEthereumChain', + params + }) + `); + await driver.waitUntilXWindowHandles(3); + const windowHandles = await driver.getAllWindowHandles(); + const [extension] = windowHandles; + + await driver.switchToWindowWithTitle( + WINDOW_TITLES.Dialog, + windowHandles, + ); + + await driver.clickElement({ + tag: 'button', + text: 'Approve', + }); + + const switchNetworkBtn = await driver.findElement({ + tag: 'button', + text: 'Switch network', + }); + + await switchNetworkBtn.click(); + + await driver.waitUntilXWindowHandles(2); + await driver.switchToWindow(extension); + const deprecationWarningText = 'This network is deprecated'; + const isDeprecationWarningDisplayed = await driver.isElementPresent({ + text: deprecationWarningText, + }); + + assert.equal( + isDeprecationWarningDisplayed, + true, + 'Goerli deprecation warning is not displayed', + ); + }, + ); + }); }); diff --git a/ui/components/ui/deprecated-networks/deprecated-networks.js b/ui/components/ui/deprecated-networks/deprecated-networks.js index 869e316f163e..69a583304deb 100644 --- a/ui/components/ui/deprecated-networks/deprecated-networks.js +++ b/ui/components/ui/deprecated-networks/deprecated-networks.js @@ -43,7 +43,7 @@ export default function DeprecatedNetworks() { severity={Severity.Warning} description={bannerAlertDescription} onClose={() => setIsShowingWarning(false)} - actionButtonLabel={t('learnMoreUpperCase')} + actionButtonLabel={actionBtnLinkURL && t('learnMoreUpperCase')} actionButtonProps={{ className: 'deprecated-networks__content__inline-link', href: actionBtnLinkURL, @@ -62,9 +62,13 @@ function getDeprecationWarningCopy(t, currentChainID) { bannerAlertDescription = t('deprecatedAuroraNetworkMsg'); actionBtnLinkURL = 'https://mainnet.aurora.dev/'; } else if (DEPRECATED_NETWORKS.includes(currentChainID)) { - bannerAlertDescription = t('deprecatedGoerliNtwrkMsg'); - actionBtnLinkURL = - 'https://github.com/eth-clients/goerli#goerli-goerlitzer-testnet'; + if (currentChainID === CHAIN_IDS.POLYGON_TESTNET) { + bannerAlertDescription = t('deprecatedNetwork'); + } else { + bannerAlertDescription = t('deprecatedGoerliNtwrkMsg'); + actionBtnLinkURL = + 'https://github.com/eth-clients/goerli#goerli-goerlitzer-testnet'; + } } return { bannerAlertDescription, actionBtnLinkURL }; From 75a9ff833c26667debad1de27f5d153a53084f3f Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Thu, 4 Apr 2024 20:31:07 +0200 Subject: [PATCH 06/51] chore: update LABELING_GUIDELINES.md paths (#23118) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** The reference links to the `LABELING_GUIDELINES.md` were wrong. If your PR has bad labeling (like [this one](https://github.com/MetaMask/metamask-extension/actions/runs/8003182771/job/21857941345?pr=23116)) you'll get a 404 by clicking the link. ## **Related issues** Fixes: N/A ## **Manual testing steps** N/A ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've clearly explained what problem this PR is solving and how it is solved. - [ ] I've linked related issues - [ ] I've included manual testing steps - [ ] I've included screenshots/recordings if applicable - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. - [x] I’ve properly set the pull request status: - [ ] In case it's not yet "ready for review", I've set it to "draft". - [x] In case it's "ready for review", I've changed it from "draft" to "non-draft". ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. Co-authored-by: Brad Decker Co-authored-by: Gauthier Petetin --- .github/scripts/check-pr-has-required-labels.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/check-pr-has-required-labels.ts b/.github/scripts/check-pr-has-required-labels.ts index 15ef77022ceb..354dc2c2aa7d 100644 --- a/.github/scripts/check-pr-has-required-labels.ts +++ b/.github/scripts/check-pr-has-required-labels.ts @@ -73,7 +73,7 @@ async function main(): Promise { if (!hasTeamLabel) { errorMessage += 'No team labels found on the PR. '; } - errorMessage += `Please make sure the PR is appropriately labeled before merging it.\n\nSee labeling guidelines for more detail: https://github.com/MetaMask/metamask-extension/blob/develop/.github/LABELING_GUIDELINES.md`; + errorMessage += `Please make sure the PR is appropriately labeled before merging it.\n\nSee labeling guidelines for more detail: https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md`; core.setFailed(errorMessage); process.exit(1); } From 34421942343e52e737f2f02bfd4d32aa5b105eed Mon Sep 17 00:00:00 2001 From: David Murdoch <187813+davidmurdoch@users.noreply.github.com> Date: Thu, 4 Apr 2024 15:43:45 -0400 Subject: [PATCH 07/51] ci: conditionally run optional MMI test (#23831) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In CI, the Optional MMI job fails for various reasons, and this causes our GitHub checks to _look_ like they've failed (❌) even though the failure is allowed. To minimize the PRs this failure affects I've configured CI to run only when a PR is labeled with `team-mmi` or the branch is `develop`. --- .circleci/config.yml | 68 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 49df23bc9c28..9952a1303c79 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -67,6 +67,18 @@ aliases: git checkout -B "$CIRCLE_BRANCH" "$CIRCLE_SHA1" fi + # Check if MMI Optional tests should run + - &check-mmi-optional + name: Check if MMI Optional tests should run + command: | + RUN_MMI_OPTIONAL=$(cat ./RUN_MMI_OPTIONAL) + if [[ "${CIRCLE_BRANCH}" == "develop" || "${RUN_MMI_OPTIONAL}" == "true" ]]; then + echo "Running MMI Optional tests" + else + echo "Skipping MMI Optional tests" + circleci step halt + fi + workflows: test_and_release: jobs: @@ -77,6 +89,7 @@ workflows: - trigger-beta-build: requires: - prep-deps + - check-pr-tag - prep-deps - test-deps-audit: requires: @@ -132,6 +145,7 @@ workflows: - prep-build-test-mmi-playwright: requires: - prep-deps + - check-pr-tag - prep-build-storybook: requires: - prep-deps @@ -373,6 +387,57 @@ jobs: name: Create GitHub Pull Request for version command: .circleci/scripts/release-create-release-pr.sh + check-pr-tag: + docker: + - image: cimg/base:stable + steps: + - run: + name: Check for MMI Team Tag + command: | + #!/bin/bash + + # GitHub Personal Access Token for API Authentication + GITHUB_TOKEN="${GITHUB_TOKEN}" + BRANCH="${CIRCLE_BRANCH}" + + # Fetch the PRs associated with the current branch and check the response + PR_RESPONSE=$(curl -s -H "Authorization: token ${GITHUB_TOKEN}" \ + "https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls?state=open&head=${CIRCLE_PROJECT_USERNAME}:${BRANCH}") + echo "https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls?state=open&head=${CIRCLE_PROJECT_USERNAME}:${BRANCH}" + # Check if the response contains valid JSON + if ! echo "$PR_RESPONSE" | jq empty; then + echo "Failed to parse JSON response." + echo "$PR_RESPONSE" + exit 1 + fi + + # Check if we received an array of PRs + if ! echo "$PR_RESPONSE" | jq -e '. | type == "array"'; then + echo "$PR_RESPONSE" + echo "Expected an array of PRs, got something else." + exit 1 + fi + + # Extract label names from the PR_RESPONSE + LABEL_NAMES=$(echo "$PR_RESPONSE" | jq -r '.[0].labels[].name') + + echo "Labels found: $LABEL_NAMES" + + # Check if "team-mmi" label is present + if echo "$LABEL_NAMES" | grep -qw "team-mmi"; then + echo "team-mmi tag found." + # assign the RUN_MMI_OPTIONAL variable to true + echo "true" > ./RUN_MMI_OPTIONAL + else + echo "team-mmi tag not found." + # assign the RUN_MMI_OPTIONAL variable to false + echo "false" > ./RUN_MMI_OPTIONAL + fi + - persist_to_workspace: + root: . + paths: + - RUN_MMI_OPTIONAL + prep-deps: executor: node-browsers-medium steps: @@ -640,6 +705,7 @@ jobs: - run: *shallow-git-clone - attach_workspace: at: . + - run: *check-mmi-optional - run: name: Build MMI extension for Playwright e2e command: | @@ -654,6 +720,7 @@ jobs: - persist_to_workspace: root: . paths: + - RUN_MMI_OPTIONAL - dist-test-mmi-playwright - builds-test-mmi-playwright - store_artifacts: @@ -1121,6 +1188,7 @@ jobs: - run: *shallow-git-clone - attach_workspace: at: . + - run: *check-mmi-optional - run: name: Move test build to dist command: mv ./dist-test-mmi-playwright ./dist From 58f380cb9f456bf33f7df96ad59ad825cc4e1eee Mon Sep 17 00:00:00 2001 From: Garrett Bear Date: Thu, 4 Apr 2024 14:46:31 -0700 Subject: [PATCH 08/51] fix: add role img to app header picker network (#23842) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** To improve the accessibility of our ~Avatar components~, especially when a screen reader is used, we propose adding the role="img" attribute to these components. This enhancement aims to prevent screen readers from reading out the fallback letter, providing a more meaningful and contextually appropriate description. For instance, when tabbing through networks in the extension, the screen reader should announce "S, Sepolia" instead of just "S". This change will ensure our UI is more accessible and user-friendly for individuals relying on screen readers. Upon further investigation with @georgewrmarshall, we came to the conclusion that it is best suited for the issue to be applied to the `app header network picker`. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/23832?quickstart=1) ## **Related issues** Fixes: #23251 ## **Manual testing steps** 1. Turn on your computers screen reader (mac: CMD + F5) 2. Run local build of extension 3. Tab to a component that uses an avatar component (e.g. see screenshot for example component) ## **Screenshots/Recordings** ### **Before** https://github.com/MetaMask/metamask-extension/assets/8112138/ec6ab28f-8fbf-4cd2-b0ea-787f82d7bcae ### **After** https://github.com/MetaMask/metamask-extension/assets/26469696/bef063ff-41d7-4738-98b3-625013861d75 ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- .../app-header/__snapshots__/app-header.test.js.snap | 2 ++ ui/components/multichain/app-header/app-header.js | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ui/components/multichain/app-header/__snapshots__/app-header.test.js.snap b/ui/components/multichain/app-header/__snapshots__/app-header.test.js.snap index 5bafc35a2208..742c2c5aac86 100644 --- a/ui/components/multichain/app-header/__snapshots__/app-header.test.js.snap +++ b/ui/components/multichain/app-header/__snapshots__/app-header.test.js.snap @@ -207,12 +207,14 @@ exports[`App Header should match snapshot 1`] = ` >
{t('simulationsSettingSubHeader')}
- {t('simulationsSettingDescription')} + {t('simulationsSettingDescription', [ + + {t('learnMoreUpperCase')} + , + ])}
From 0cacaccf87e49b83e33f2cd674ebed2beed4dc7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Regadas?= Date: Tue, 9 Apr 2024 11:07:09 +0100 Subject: [PATCH 16/51] chore: MMI adds Sentry to MMI custody keyring (#23868) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** Passes Sentry captureException to custody keyring and updates MMI packages. ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --------- Co-authored-by: MetaMask Bot --- app/scripts/metamask-controller.js | 1 + lavamoat/browserify/mmi/policy.json | 1 + package.json | 10 ++-- yarn.lock | 74 ++++++++++++++--------------- 4 files changed, 44 insertions(+), 42 deletions(-) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 375026336adf..4c694564a139 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -978,6 +978,7 @@ export default class MetamaskController extends EventEmitter { additionalKeyrings.push( mmiKeyringBuilderFactory(CUSTODIAN_TYPES[custodianType].keyringClass, { mmiConfigurationController: this.mmiConfigurationController, + captureException, }), ); } diff --git a/lavamoat/browserify/mmi/policy.json b/lavamoat/browserify/mmi/policy.json index 20cc6347a087..163e0e0f7fb8 100644 --- a/lavamoat/browserify/mmi/policy.json +++ b/lavamoat/browserify/mmi/policy.json @@ -718,6 +718,7 @@ }, "@metamask-institutional/custody-keyring": { "globals": { + "console.error": true, "console.log": true, "console.warn": true }, diff --git a/package.json b/package.json index 4cb786381326..8aa3a783239d 100644 --- a/package.json +++ b/package.json @@ -256,14 +256,14 @@ "@lavamoat/lavadome-react": "0.0.17", "@lavamoat/snow": "^2.0.1", "@material-ui/core": "^4.11.0", - "@metamask-institutional/custody-controller": "^0.2.23", - "@metamask-institutional/custody-keyring": "^1.0.11", - "@metamask-institutional/extension": "^0.3.19", - "@metamask-institutional/institutional-features": "^1.2.14", + "@metamask-institutional/custody-controller": "^0.2.24", + "@metamask-institutional/custody-keyring": "^1.0.12", + "@metamask-institutional/extension": "^0.3.20", + "@metamask-institutional/institutional-features": "^1.2.15", "@metamask-institutional/portfolio-dashboard": "^1.4.0", "@metamask-institutional/rpc-allowlist": "^1.0.2", "@metamask-institutional/sdk": "^0.1.25", - "@metamask-institutional/transaction-update": "^0.1.37", + "@metamask-institutional/transaction-update": "^0.1.38", "@metamask/abi-utils": "^2.0.2", "@metamask/accounts-controller": "^11.0.0", "@metamask/address-book-controller": "^3.1.7", diff --git a/yarn.lock b/yarn.lock index 97ff321dbffd..29f5e7e3b800 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3797,22 +3797,22 @@ __metadata: languageName: node linkType: hard -"@metamask-institutional/custody-controller@npm:^0.2.23": - version: 0.2.23 - resolution: "@metamask-institutional/custody-controller@npm:0.2.23" +"@metamask-institutional/custody-controller@npm:^0.2.24": + version: 0.2.24 + resolution: "@metamask-institutional/custody-controller@npm:0.2.24" dependencies: "@ethereumjs/util": "npm:^8.0.5" - "@metamask-institutional/custody-keyring": "npm:^1.0.11" + "@metamask-institutional/custody-keyring": "npm:^1.0.12" "@metamask-institutional/sdk": "npm:^0.1.25" "@metamask-institutional/types": "npm:^1.0.4" "@metamask/obs-store": "npm:^8.0.0" - checksum: 774855c8f96007034aa1e5bd5858a7b2ac1733ebad9e01d1aea6439abf5275a000bf56cf7806f72fa44809ae4b7f7c9c56244e455f6ac52a1cd13a5875eb9c17 + checksum: 6815d46eeb97d0d9188eba2af5c948f281ed554f3d920905431d3093bb864a9a43aebea6a773f59d5e34e8d4c2f7cbca0d2c4eff6bb8c4e05595505af5bbfccc languageName: node linkType: hard -"@metamask-institutional/custody-keyring@npm:^1.0.11": - version: 1.0.11 - resolution: "@metamask-institutional/custody-keyring@npm:1.0.11" +"@metamask-institutional/custody-keyring@npm:^1.0.12": + version: 1.0.12 + resolution: "@metamask-institutional/custody-keyring@npm:1.0.12" dependencies: "@ethereumjs/tx": "npm:^4.1.1" "@ethereumjs/util": "npm:^8.0.5" @@ -3822,35 +3822,35 @@ __metadata: "@metamask/obs-store": "npm:^8.0.0" crypto: "npm:^1.0.1" lodash.clonedeep: "npm:^4.5.0" - checksum: 63f76e15ee665ca8f3cbdb5a7137139d1b765a3596513e8f150a8fcc11ae06e933a2e7b4f7765b3977bb8b0cdbce0a0ab894d26824e298e0305eeba1c581743a + checksum: adc993dcfd86aaf263567f26aea88fd76b69aae76380d266d68f5aaf28b9b37c8d44e8849e1479ab8febed65bbe9f84b203e702ba11e4ba6e350c8ba09b2bc43 languageName: node linkType: hard -"@metamask-institutional/extension@npm:^0.3.19": - version: 0.3.19 - resolution: "@metamask-institutional/extension@npm:0.3.19" +"@metamask-institutional/extension@npm:^0.3.20": + version: 0.3.20 + resolution: "@metamask-institutional/extension@npm:0.3.20" dependencies: "@ethereumjs/util": "npm:^8.0.5" - "@metamask-institutional/custody-controller": "npm:^0.2.23" - "@metamask-institutional/custody-keyring": "npm:^1.0.11" + "@metamask-institutional/custody-controller": "npm:^0.2.24" + "@metamask-institutional/custody-keyring": "npm:^1.0.12" "@metamask-institutional/portfolio-dashboard": "npm:^1.4.0" "@metamask-institutional/sdk": "npm:^0.1.25" - "@metamask-institutional/transaction-update": "npm:^0.1.37" + "@metamask-institutional/transaction-update": "npm:^0.1.38" "@metamask-institutional/types": "npm:^1.0.4" jest-create-mock-instance: "npm:^2.0.0" jest-fetch-mock: "npm:3.0.3" lodash.clonedeep: "npm:^4.5.0" - checksum: 96bd4b291e03042fea4b513d435bfd1f5e3a7a6cabd2751c3a256838c7a67b12c3078b932f14f26bed96ace9df5363c5ed5d7ac7739aad80d5720188a2097827 + checksum: bacb836f2dd20d7800ec6062185359d5c32720be1db06700d6b96b902968f7860195564bbf532a8524d2a03b15d0c031520d96dafb7aa78f5a0bf5a3ec512d0b languageName: node linkType: hard -"@metamask-institutional/institutional-features@npm:^1.2.14": - version: 1.2.14 - resolution: "@metamask-institutional/institutional-features@npm:1.2.14" +"@metamask-institutional/institutional-features@npm:^1.2.15": + version: 1.2.15 + resolution: "@metamask-institutional/institutional-features@npm:1.2.15" dependencies: - "@metamask-institutional/custody-keyring": "npm:^1.0.11" + "@metamask-institutional/custody-keyring": "npm:^1.0.12" "@metamask/obs-store": "npm:^8.0.0" - checksum: a18cd5cbc2a94c92119d3256c7057c8f74feeebfcc17d5109da72eaf843587557bc331ac5d892dd6faffafdce21b26bb752cffb771fa93cd887a372a44b4b093 + checksum: c67421567e85e34b9c8de8460ff8836cf0acf04d06927273c3120eb2dc8748294f6aa5690dbf587d886155842b66b6464957b9ff30d1d78a8e1931e2f119e77d languageName: node linkType: hard @@ -3889,17 +3889,17 @@ __metadata: languageName: node linkType: hard -"@metamask-institutional/transaction-update@npm:^0.1.37": - version: 0.1.37 - resolution: "@metamask-institutional/transaction-update@npm:0.1.37" +"@metamask-institutional/transaction-update@npm:^0.1.38": + version: 0.1.38 + resolution: "@metamask-institutional/transaction-update@npm:0.1.38" dependencies: - "@metamask-institutional/custody-keyring": "npm:^1.0.11" + "@metamask-institutional/custody-keyring": "npm:^1.0.12" "@metamask-institutional/sdk": "npm:^0.1.25" "@metamask-institutional/types": "npm:^1.0.4" - "@metamask-institutional/websocket-client": "npm:^0.1.39" + "@metamask-institutional/websocket-client": "npm:^0.1.40" "@metamask/obs-store": "npm:^8.0.0" ethereumjs-util: "npm:^7.1.5" - checksum: 44ba8cffa62a51f6484da6739dcef6cf8dcd2ba802c29c08b4512e0c5daf96c5beb3439284f5581c685366bc518b99b70f0132776401d96c06d5d049f26eded6 + checksum: 4dac477b175c870545f48e57ed6d3bb503f69bed0fb50e909ca630080c9427b44a2a44a82f16abfc289cd302ffdb82306b725faf20a4a6d2395938e657821650 languageName: node linkType: hard @@ -3910,15 +3910,15 @@ __metadata: languageName: node linkType: hard -"@metamask-institutional/websocket-client@npm:^0.1.39": - version: 0.1.39 - resolution: "@metamask-institutional/websocket-client@npm:0.1.39" +"@metamask-institutional/websocket-client@npm:^0.1.40": + version: 0.1.40 + resolution: "@metamask-institutional/websocket-client@npm:0.1.40" dependencies: - "@metamask-institutional/custody-keyring": "npm:^1.0.11" + "@metamask-institutional/custody-keyring": "npm:^1.0.12" "@metamask-institutional/sdk": "npm:^0.1.25" "@metamask-institutional/types": "npm:^1.0.4" mock-socket: "npm:^9.2.1" - checksum: c22443f6a81e1dc750f14f9566f68908520eb7ccef9c9536214562abe281063c15618047520c911bcb9fac2c7f9fed963cb3cd55681a1844bb11178c14c259c2 + checksum: c1cef7416fb40778403e4e34225a948fa6849266c12fa42ff645d208429a5f55441c8cd0be121d0b525098e3d96e3f529f059bc76480497da97e8ab7b7f6924d languageName: node linkType: hard @@ -24844,14 +24844,14 @@ __metadata: "@lavamoat/snow": "npm:^2.0.1" "@lgbot/madge": "npm:^6.2.0" "@material-ui/core": "npm:^4.11.0" - "@metamask-institutional/custody-controller": "npm:^0.2.23" - "@metamask-institutional/custody-keyring": "npm:^1.0.11" - "@metamask-institutional/extension": "npm:^0.3.19" - "@metamask-institutional/institutional-features": "npm:^1.2.14" + "@metamask-institutional/custody-controller": "npm:^0.2.24" + "@metamask-institutional/custody-keyring": "npm:^1.0.12" + "@metamask-institutional/extension": "npm:^0.3.20" + "@metamask-institutional/institutional-features": "npm:^1.2.15" "@metamask-institutional/portfolio-dashboard": "npm:^1.4.0" "@metamask-institutional/rpc-allowlist": "npm:^1.0.2" "@metamask-institutional/sdk": "npm:^0.1.25" - "@metamask-institutional/transaction-update": "npm:^0.1.37" + "@metamask-institutional/transaction-update": "npm:^0.1.38" "@metamask/abi-utils": "npm:^2.0.2" "@metamask/accounts-controller": "npm:^11.0.0" "@metamask/address-book-controller": "npm:^3.1.7" From 553746eb0b17ad72cc35c980b3e144e5ee24367c Mon Sep 17 00:00:00 2001 From: salimtb Date: Tue, 9 Apr 2024 15:20:24 +0200 Subject: [PATCH 17/51] feat: update popular network list (#23880) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** We are updating the popular networks list each quarter based on usage found in this Looker Dashboard: [https://consensysus.cloud.looker.com/dashboards/511?Is+Testnet+(Yes+%2F+No)=No](https://consensysus.cloud.looker.com/dashboards/511?Is+Testnet+%28Yes+%2F+No%29=No) - network Gnosis and Celo removed, network base mainnet added. ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to the add network modal and click on add network 2. check the list of popular network ## **Screenshots/Recordings** ### **Before** Screenshot 2024-04-08 at 10 49 37 ### **After** Screenshot 2024-04-08 at 10 47 21 ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- shared/constants/network.test.ts | 67 ++++++++++++++++++++++++++++++++ shared/constants/network.ts | 20 ---------- 2 files changed, 67 insertions(+), 20 deletions(-) diff --git a/shared/constants/network.test.ts b/shared/constants/network.test.ts index 0c4f50b87b7f..ac427914fbaa 100644 --- a/shared/constants/network.test.ts +++ b/shared/constants/network.test.ts @@ -3,6 +3,7 @@ import { join } from 'path'; import { CHAIN_IDS, CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP, + FEATURED_RPCS, NETWORK_TO_NAME_MAP, } from './network'; @@ -24,4 +25,70 @@ describe('NetworkConstants', () => { expect(NETWORK_TO_NAME_MAP[CHAIN_IDS.OPTIMISM]).toBe('OP Mainnet'); expect(NETWORK_TO_NAME_MAP[CHAIN_IDS.POLYGON]).toBe('Polygon'); }); + describe('popularNetwork', () => { + it('should have correct chainIds for all popular network', () => { + const expectedChainIds: { [key: string]: string } = { + 'Arbitrum One': CHAIN_IDS.ARBITRUM, + 'Avalanche Network C-Chain': CHAIN_IDS.AVALANCHE, + 'BNB Chain': CHAIN_IDS.BSC, + 'OP Mainnet': CHAIN_IDS.OPTIMISM, + 'Polygon Mainnet': CHAIN_IDS.POLYGON, + 'zkSync Era Mainnet': CHAIN_IDS.ZKSYNC_ERA, + 'Base Mainnet': CHAIN_IDS.BASE, + }; + + FEATURED_RPCS.forEach((rpc) => { + expect(rpc.chainId).toBe(expectedChainIds[rpc.nickname]); + }); + }); + }); + + describe('FEATURED_RPCS Infura Usage Tests', () => { + it('arbitrum entry should use Infura', () => { + const arbitrumRpc = FEATURED_RPCS.find( + (rpc) => rpc.chainId === CHAIN_IDS.ARBITRUM, + ); + expect(arbitrumRpc?.rpcUrl).toContain('infura.io'); + }); + + it('avalanche entry should use Infura', () => { + const avalancheRpc = FEATURED_RPCS.find( + (rpc) => rpc.chainId === CHAIN_IDS.AVALANCHE, + ); + expect(avalancheRpc?.rpcUrl).toContain('infura.io'); + }); + + it('bsc entry should not use Infura', () => { + const bscRpc = FEATURED_RPCS.find((rpc) => rpc.chainId === CHAIN_IDS.BSC); + expect(bscRpc?.rpcUrl).not.toContain('infura.io'); + }); + + it('optimism entry should use Infura', () => { + const optimismRpc = FEATURED_RPCS.find( + (rpc) => rpc.chainId === CHAIN_IDS.OPTIMISM, + ); + expect(optimismRpc?.rpcUrl).toContain('infura.io'); + }); + + it('polygon entry should use Infura', () => { + const polygonRpc = FEATURED_RPCS.find( + (rpc) => rpc.chainId === CHAIN_IDS.POLYGON, + ); + expect(polygonRpc?.rpcUrl).toContain('infura.io'); + }); + + it('zkSync Era entry should not use Infura', () => { + const zksyncEraRpc = FEATURED_RPCS.find( + (rpc) => rpc.chainId === CHAIN_IDS.ZKSYNC_ERA, + ); + expect(zksyncEraRpc?.rpcUrl).not.toContain('infura.io'); + }); + + it('base entry should not use Infura', () => { + const baseRpc = FEATURED_RPCS.find( + (rpc) => rpc.chainId === CHAIN_IDS.BASE, + ); + expect(baseRpc?.rpcUrl).not.toContain('infura.io'); + }); + }); }); diff --git a/shared/constants/network.ts b/shared/constants/network.ts index 8aba942052c7..3b2908cea942 100644 --- a/shared/constants/network.ts +++ b/shared/constants/network.ts @@ -1006,26 +1006,6 @@ export const FEATURED_RPCS: RPCDefinition[] = [ imageUrl: MATIC_TOKEN_IMAGE_URL, }, }, - { - chainId: CHAIN_IDS.CELO, - nickname: CELO_DISPLAY_NAME, - rpcUrl: `https://celo-mainnet.infura.io/v3/${infuraProjectId}`, - ticker: CURRENCY_SYMBOLS.CELO, - rpcPrefs: { - blockExplorerUrl: 'https://celoscan.io', - imageUrl: CELO_TOKEN_IMAGE_URL, - }, - }, - { - chainId: CHAIN_IDS.GNOSIS, - nickname: GNOSIS_DISPLAY_NAME, - rpcUrl: `https://rpc.gnosischain.com`, - ticker: CURRENCY_SYMBOLS.GNOSIS, - rpcPrefs: { - blockExplorerUrl: 'https://gnosisscan.io', - imageUrl: GNOSIS_TOKEN_IMAGE_URL, - }, - }, { chainId: CHAIN_IDS.ZKSYNC_ERA, nickname: ZK_SYNC_ERA_DISPLAY_NAME, From b37fb6c2aed894344e9e6895958b7cd7ed31cfe3 Mon Sep 17 00:00:00 2001 From: David Walsh Date: Tue, 9 Apr 2024 09:10:14 -0500 Subject: [PATCH 18/51] fix: UX: Prevent proptype error for switchedNetworkDetails in routes (#23810) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** Simple update to a proptype that was throwing a warning on `develop` [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/23810?quickstart=1) ## **Related issues** Fixes: N/A ## **Manual testing steps** 1. Go to extension full view 2. Don't see propType error ## **Screenshots/Recordings** ### **Before** N/A ### **After** N/A ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- ui/pages/routes/routes.component.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/pages/routes/routes.component.js b/ui/pages/routes/routes.component.js index 5f2398116557..6e06d925aca2 100644 --- a/ui/pages/routes/routes.component.js +++ b/ui/pages/routes/routes.component.js @@ -190,7 +190,7 @@ export default class Routes extends Component { isDeprecatedNetworkModalOpen: PropTypes.bool.isRequired, hideDeprecatedNetworkModal: PropTypes.func.isRequired, addPermittedAccount: PropTypes.func.isRequired, - switchedNetworkDetails: PropTypes.oneOfType([PropTypes.object, null]), + switchedNetworkDetails: PropTypes.object, clearSwitchedNetworkDetails: PropTypes.func.isRequired, setSwitchedNetworkNeverShowMessage: PropTypes.func.isRequired, networkToAutomaticallySwitchTo: PropTypes.object, From acf01498278f28ae0289f30571a3ec7155dfa9a6 Mon Sep 17 00:00:00 2001 From: David Walsh Date: Tue, 9 Apr 2024 09:26:57 -0500 Subject: [PATCH 19/51] fix: UX: Multichain: Remove tabs from Connections view (#23815) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** Removes the ``/`` interface from Connections view because we aren't currently supporting Snaps. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/23815?quickstart=1) ## **Related issues** Fixes: N/A ## **Manual testing steps** 1. Open the connections view of Popup 2. Don't see "Site connections" tab heading ## **Screenshots/Recordings** ### **Before** N/A ### **After** SCR-20240329-srml ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- app/_locales/en/messages.json | 3 - .../__snapshots__/connections.test.tsx.snap | 213 ++++++++---------- .../pages/connections/connections.tsx | 81 +++---- 3 files changed, 132 insertions(+), 165 deletions(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 0da642eb18ac..4c2bad9688f3 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -914,9 +914,6 @@ "connectedWith": { "message": "Connected with" }, - "connectedaccountsTabKey": { - "message": "Connected accounts" - }, "connecting": { "message": "Connecting..." }, diff --git a/ui/components/multichain/pages/connections/__snapshots__/connections.test.tsx.snap b/ui/components/multichain/pages/connections/__snapshots__/connections.test.tsx.snap index 090162728095..bd3f68847e98 100644 --- a/ui/components/multichain/pages/connections/__snapshots__/connections.test.tsx.snap +++ b/ui/components/multichain/pages/connections/__snapshots__/connections.test.tsx.snap @@ -52,165 +52,148 @@ exports[`Connections Content should render correctly 1`] = ` class="mm-box multichain-page-content mm-box--padding-0 mm-box--display-flex mm-box--flex-direction-column mm-box--width-full mm-box--height-full" >
-
    -
  • - -
  • -
diff --git a/ui/components/multichain/pages/connections/connections.tsx b/ui/components/multichain/pages/connections/connections.tsx index 121b8216e40c..904d75668e18 100644 --- a/ui/components/multichain/pages/connections/connections.tsx +++ b/ui/components/multichain/pages/connections/connections.tsx @@ -45,8 +45,6 @@ import { IconSize, Text, } from '../../../component-library'; -import { Tab } from '../../../ui/tabs'; -import Tabs from '../../../ui/tabs/tabs.component'; import { mergeAccounts } from '../../account-list-menu/account-list-menu'; import { AccountListItem, @@ -89,7 +87,6 @@ export const Connections = () => { setShowDisconnectedAllAccountsUpdatedToast, ] = useState(false); - const CONNECTED_ACCOUNTS_TAB_KEY = 'connected-accounts'; const activeTabOrigin: string = useSelector(getOriginOfCurrentTab); // TODO: Replace `any` with type // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -233,51 +230,41 @@ export const Connections = () => { {connectedSubjectsMetadata && mergeAccounts.length > 0 ? ( - - { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - - {/* TODO: Replace `any` with type */} - {/* eslint-disable-next-line @typescript-eslint/no-explicit-any */} - {mergedAccounts.map((account: AccountType, index: any) => { - const connectedSites: ConnectedSites = {}; - const connectedSite = connectedSites[account.address]?.find( - ({ origin }) => origin === activeTabOrigin, - ); - const isSelectedAccount = - selectedAccount.address === account.address; - // Match the index of latestSelected Account with the index of all the accounts and set the active status - let mergedAccountsProps; - if (index === latestSelected) { - mergedAccountsProps = { ...account, isAccountActive: true }; - } else { - mergedAccountsProps = { ...account }; + + {/* TODO: Replace `any` with type */} + {/* eslint-disable-next-line @typescript-eslint/no-explicit-any */} + {mergedAccounts.map((account: AccountType, index: any) => { + const connectedSites: ConnectedSites = {}; + const connectedSite = connectedSites[account.address]?.find( + ({ origin }) => origin === activeTabOrigin, + ); + const isSelectedAccount = + selectedAccount.address === account.address; + // Match the index of latestSelected Account with the index of all the accounts and set the active status + let mergedAccountsProps; + if (index === latestSelected) { + mergedAccountsProps = { ...account, isAccountActive: true }; + } else { + mergedAccountsProps = { ...account }; + } + return ( + - ); - })} - - } - + onActionClick={setShowAccountDisconnectedToast} + /> + ); + })} + ) : ( )} From 1e62efb2555cf4420be6a06e4946b93912480237 Mon Sep 17 00:00:00 2001 From: Harika Jetpoluru <153644847+hjetpoluru@users.noreply.github.com> Date: Tue, 9 Apr 2024 11:30:33 -0400 Subject: [PATCH 20/51] test: Added unit test for onboarding controller 23461 (#23807) Added unit test for onboarding controller Fixes: #23461 ## **Manual testing steps** Run the test in codespace or locally --> Checkout to the branch yarn install yarn jest app/scripts/controllers/onboarding.test.ts --------- Co-authored-by: Plasma Corral <32695229+plasmacorral@users.noreply.github.com> --- app/scripts/controllers/onboarding.test.ts | 57 ++++++++++++++++++++++ jest.config.js | 1 + 2 files changed, 58 insertions(+) create mode 100644 app/scripts/controllers/onboarding.test.ts diff --git a/app/scripts/controllers/onboarding.test.ts b/app/scripts/controllers/onboarding.test.ts new file mode 100644 index 000000000000..61b9cf8de589 --- /dev/null +++ b/app/scripts/controllers/onboarding.test.ts @@ -0,0 +1,57 @@ +import { FirstTimeFlowType } from '../../../shared/constants/onboarding'; +import OnboardingController, { OnboardingControllerState } from './onboarding'; + +describe('OnboardingController', () => { + let onboardingController: OnboardingController; + + beforeEach(() => { + onboardingController = new OnboardingController({ + initState: { + seedPhraseBackedUp: null, + firstTimeFlowType: null, + completedOnboarding: false, + onboardingTabs: {}, + }, + }); + }); + + it('should set the seedPhraseBackedUp property', () => { + const newSeedPhraseBackUpState = true; + onboardingController.setSeedPhraseBackedUp(newSeedPhraseBackUpState); + const state: OnboardingControllerState = + onboardingController.store.getState(); + expect(state.seedPhraseBackedUp).toBe(newSeedPhraseBackUpState); + }); + + it('should set the firstTimeFlowType property', () => { + const type: FirstTimeFlowType = FirstTimeFlowType.create; + onboardingController.setFirstTimeFlowType(type); + const state: OnboardingControllerState = + onboardingController.store.getState(); + expect(state.firstTimeFlowType).toBe(type); + }); + + it('should register a site for onboarding', async () => { + const location = 'example.com'; + const tabId = '123'; + await onboardingController.registerOnboarding(location, tabId); + const state: OnboardingControllerState = + onboardingController.store.getState(); + expect(state.onboardingTabs?.[location]).toBe(tabId); + }); + + it('should skip update state if the location is already onboard', async () => { + const location = 'example.com'; + const tabId = '123'; + await onboardingController.registerOnboarding(location, tabId); + const state: OnboardingControllerState = + onboardingController.store.getState(); + const updateStateSpy = jest.spyOn( + onboardingController.store, + 'updateState', + ); + + expect(state.onboardingTabs?.[location]).toBe(tabId); + expect(updateStateSpy).not.toHaveBeenCalled(); + }); +}); diff --git a/jest.config.js b/jest.config.js index dd42be4196a1..bd8d58f867ed 100644 --- a/jest.config.js +++ b/jest.config.js @@ -45,6 +45,7 @@ module.exports = { '/app/scripts/controllers/transactions/etherscan.test.ts', '/app/scripts/controllers/transactions/EtherscanRemoteTransactionSource.test.ts', '/app/scripts/controllers/transactions/IncomingTransactionHelper.test.ts', + '/app/scripts/controllers/onboarding.test.ts', '/app/scripts/controllers/mmi-controller.test.ts', '/app/scripts/controllers/permissions/**/*.test.js', '/app/scripts/controllers/preferences.test.js', From 455a70b301a2ea2e40ebcb2bf81f0bc51e6bc04f Mon Sep 17 00:00:00 2001 From: sahar-fehri Date: Tue, 9 Apr 2024 17:33:06 +0200 Subject: [PATCH 21/51] fix: track remove NFT event (#23828) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** PR that fixes notification display when an error is thrown on removeNFT. It also adds trackEvent when user clicks on removeNFT button [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/23828?quickstart=1) ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to NFT page 2. Import NFT 3. Click on options on top 4. Click remove NFT 5. You should see a green notif saying that NFT was successfully removed Might be tricky to test the failure notif, i had to go into the codebase and add a throw statement to see the behavior (See after video) ## **Screenshots/Recordings** ### **Before** https://github.com/MetaMask/metamask-extension/assets/10994169/ab2d3876-9ac7-43a8-a522-948beb91d428 ### **After** https://github.com/MetaMask/metamask-extension/assets/10994169/d93e03a9-47f9-4f7b-9e67-61c38be727a0 Screenshot for emitted event in background Screenshot 2024-04-09 at 17 29 47 ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- app/_locales/en/messages.json | 3 ++ shared/constants/metametrics.ts | 1 + test/e2e/tests/tokens/nft/remove-nft.spec.js | 52 +++++++++++++++++-- ui/components/app/nft-details/nft-details.js | 36 ++++++++++--- .../app/nft-details/nft-details.test.js | 27 +++++++++- ui/pages/home/home.component.js | 24 ++++++++- ui/store/actions.test.js | 34 ++++++++++++ ui/store/actions.ts | 5 +- 8 files changed, 168 insertions(+), 14 deletions(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 4c2bad9688f3..3c41a15a2fa5 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -3876,6 +3876,9 @@ "removeNFT": { "message": "Remove NFT" }, + "removeNftErrorMessage": { + "message": "We could not remove this NFT." + }, "removeNftMessage": { "message": "NFT was successfully removed!" }, diff --git a/shared/constants/metametrics.ts b/shared/constants/metametrics.ts index cd5a89e8aadf..9017381f7419 100644 --- a/shared/constants/metametrics.ts +++ b/shared/constants/metametrics.ts @@ -610,6 +610,7 @@ export enum MetaMetricsEventName { TokenImportButtonClicked = 'Import Token Button Clicked', TokenScreenOpened = 'Token Screen Opened', TokenAdded = 'Token Added', + NFTRemoved = 'NFT Removed', TokenDetected = 'Token Detected', TokenHidden = 'Token Hidden', TokenImportCanceled = 'Token Import Canceled', diff --git a/test/e2e/tests/tokens/nft/remove-nft.spec.js b/test/e2e/tests/tokens/nft/remove-nft.spec.js index 16dad20de072..7d54df845ba8 100644 --- a/test/e2e/tests/tokens/nft/remove-nft.spec.js +++ b/test/e2e/tests/tokens/nft/remove-nft.spec.js @@ -3,25 +3,57 @@ const { defaultGanacheOptions, withFixtures, unlockWallet, + getEventPayloads, } = require('../../../helpers'); const { SMART_CONTRACTS } = require('../../../seeder/smart-contracts'); const FixtureBuilder = require('../../../fixture-builder'); +const { + MetaMetricsEventName, +} = require('../../../../../shared/constants/metametrics'); +const { CHAIN_IDS } = require('../../../../../shared/constants/network'); + +async function mockedNftRemoved(mockServer) { + return await mockServer + .forPost('https://api.segment.io/v1/batch') + .withJsonBodyIncluding({ + batch: [{ type: 'track', event: MetaMetricsEventName.NFTRemoved }], + }) + .thenCallback(() => { + return { + statusCode: 200, + }; + }); +} describe('Remove NFT', function () { const smartContract = SMART_CONTRACTS.NFTS; - it('user should be able to remove ERC721 NFT on details page', async function () { + it('user should be able to remove ERC721 NFT on details page and removeNft event should be emitted', async function () { + async function mockSegment(mockServer) { + return [await mockedNftRemoved(mockServer)]; + } await withFixtures( { dapp: true, - fixtures: new FixtureBuilder().withNftControllerERC721().build(), + fixtures: new FixtureBuilder() + .withNftControllerERC721() + .withMetaMetricsController({ + metaMetricsId: 'fake-metrics-id', + participateInMetaMetrics: true, + }) + .build(), ganacheOptions: defaultGanacheOptions, smartContract, title: this.test.fullTitle(), + testSpecificMock: mockSegment, }, - async ({ driver }) => { + async ({ driver, mockedEndpoint: mockedEndpoints, contractRegistry }) => { await unlockWallet(driver); + const contractAddress = await contractRegistry.getContractAddress( + smartContract, + ); + // Open the details and click remove nft button await driver.clickElement('[data-testid="home__nfts-tab"]'); await driver.clickElement('.nft-item__container'); @@ -41,6 +73,20 @@ describe('Remove NFT', function () { text: 'No NFTs yet', }); assert.equal(await noNftInfo.isDisplayed(), true); + + // Check if event was emitted + const events = await getEventPayloads(driver, mockedEndpoints); + const nftRemovedProperties = events[0].properties; + assert.equal( + nftRemovedProperties.token_contract_address, + contractAddress, + ); + assert.equal(nftRemovedProperties.tokenId, '1'); + assert.equal(nftRemovedProperties.asset_type, 'NFT'); + assert.equal(nftRemovedProperties.token_standard, 'ERC721'); + assert.equal(nftRemovedProperties.token_standard, 'ERC721'); + assert.equal(nftRemovedProperties.isSuccessful, true); + assert.equal(nftRemovedProperties.chain_id, CHAIN_IDS.LOCALHOST); }, ); }); diff --git a/ui/components/app/nft-details/nft-details.js b/ui/components/app/nft-details/nft-details.js index 7a9ebeea6ca9..16e544940b0b 100644 --- a/ui/components/app/nft-details/nft-details.js +++ b/ui/components/app/nft-details/nft-details.js @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React, { useEffect, useContext } from 'react'; import PropTypes from 'prop-types'; import { useDispatch, useSelector } from 'react-redux'; import { useHistory } from 'react-router-dom'; @@ -54,6 +54,8 @@ import { ButtonIcon, IconName, Text } from '../../component-library'; import Tooltip from '../../ui/tooltip'; import { decWEIToDecETH } from '../../../../shared/modules/conversion.utils'; import { NftItem } from '../../multichain/nft-item'; +import { MetaMetricsEventName } from '../../../../shared/constants/metametrics'; +import { MetaMetricsContext } from '../../../contexts/metametrics'; export default function NftDetails({ nft }) { const { @@ -74,6 +76,7 @@ export default function NftDetails({ nft }) { const nftContracts = useSelector(getNftContracts); const currentNetwork = useSelector(getCurrentChainId); const currentChain = useSelector(getCurrentNetwork); + const trackEvent = useContext(MetaMetricsContext); const [addressCopied, handleAddressCopy] = useCopyToClipboard(); @@ -94,11 +97,32 @@ export default function NftDetails({ nft }) { 'M/d/y', ); - const onRemove = () => { - dispatch(removeAndIgnoreNft(address, tokenId)); - dispatch(setNewNftAddedMessage('')); - dispatch(setRemoveNftMessage('success')); - history.push(DEFAULT_ROUTE); + const onRemove = async () => { + let isSuccessfulEvent = false; + try { + await dispatch(removeAndIgnoreNft(address, tokenId)); + dispatch(setNewNftAddedMessage('')); + dispatch(setRemoveNftMessage('success')); + isSuccessfulEvent = true; + } catch (err) { + dispatch(setNewNftAddedMessage('')); + dispatch(setRemoveNftMessage('error')); + } finally { + // track event + trackEvent({ + event: MetaMetricsEventName.NFTRemoved, + category: 'Wallet', + sensitiveProperties: { + token_contract_address: address, + tokenId: tokenId.toString(), + asset_type: AssetType.NFT, + token_standard: standard, + chain_id: currentNetwork, + isSuccessful: isSuccessfulEvent, + }, + }); + history.push(DEFAULT_ROUTE); + } }; const prevNft = usePrevious(nft); diff --git a/ui/components/app/nft-details/nft-details.test.js b/ui/components/app/nft-details/nft-details.test.js index 4aae1d61f995..91eea81ff634 100644 --- a/ui/components/app/nft-details/nft-details.test.js +++ b/ui/components/app/nft-details/nft-details.test.js @@ -85,7 +85,7 @@ describe('NFT Details', () => { expect(mockHistoryPush).toHaveBeenCalledWith(DEFAULT_ROUTE); }); - it(`should call removeAndIgnoreNFT with proper nft details and route to '/' when removing nft`, () => { + it(`should call removeAndIgnoreNFT with proper nft details and route to '/' when removing nft`, async () => { const { queryByTestId } = renderWithProvider( , mockStore, @@ -97,7 +97,7 @@ describe('NFT Details', () => { const removeNftButton = queryByTestId('nft-item-remove'); fireEvent.click(removeNftButton); - expect(removeAndIgnoreNft).toHaveBeenCalledWith( + await expect(removeAndIgnoreNft).toHaveBeenCalledWith( nfts[5].address, nfts[5].tokenId, ); @@ -105,6 +105,29 @@ describe('NFT Details', () => { expect(mockHistoryPush).toHaveBeenCalledWith(DEFAULT_ROUTE); }); + it(`should call setRemoveNftMessage with error when removeAndIgnoreNft fails and route to '/'`, async () => { + const { queryByTestId } = renderWithProvider( + , + mockStore, + ); + removeAndIgnoreNft.mockImplementation(() => { + throw new Error('Error'); + }); + + const openOptionMenuButton = queryByTestId('nft-options__button'); + fireEvent.click(openOptionMenuButton); + + const removeNftButton = queryByTestId('nft-item-remove'); + fireEvent.click(removeNftButton); + + await expect(removeAndIgnoreNft).toHaveBeenCalledWith( + nfts[5].address, + nfts[5].tokenId, + ); + expect(setRemoveNftMessage).toHaveBeenCalledWith('error'); + expect(mockHistoryPush).toHaveBeenCalledWith(DEFAULT_ROUTE); + }); + it('should copy nft address', async () => { const { queryByTestId } = renderWithProvider( , diff --git a/ui/pages/home/home.component.js b/ui/pages/home/home.component.js index 094802c7d223..8764e62c37ae 100644 --- a/ui/pages/home/home.component.js +++ b/ui/pages/home/home.component.js @@ -507,7 +507,7 @@ export default class Home extends PureComponent { ) : null} {removeNftMessage === 'success' ? ( ) : null} + {removeNftMessage === 'error' ? ( + + + + {t('removeNftErrorMessage')} + + + + } + /> + ) : null} {newNetworkAddedName ? ( { expect(expectedAction.payload.originalTransactionId).toBe(txId); }); }); + + describe('#removeAndIgnoreNft', () => { + afterEach(() => { + sinon.restore(); + }); + + it('should throw when no address found', async () => { + const store = mockStore(); + + await expect( + store.dispatch(actions.removeAndIgnoreNft(undefined, '55')), + ).rejects.toThrow('MetaMask - Cannot ignore NFT without address'); + }); + + it('should throw when no tokenId found', async () => { + const store = mockStore(); + + await expect( + store.dispatch(actions.removeAndIgnoreNft('Oxtest', undefined)), + ).rejects.toThrow('MetaMask - Cannot ignore NFT without tokenID'); + }); + + it('should throw when removeAndIgnoreNft throws an error', async () => { + const store = mockStore(); + const error = new Error('remove nft fake error'); + background.removeAndIgnoreNft = sinon.stub().throws(error); + + setBackgroundConnection(background); + + await expect( + store.dispatch(actions.removeAndIgnoreNft('Oxtest', '6')), + ).rejects.toThrow(error); + }); + }); }); diff --git a/ui/store/actions.ts b/ui/store/actions.ts index 4986eea1176d..9dcf88add236 100644 --- a/ui/store/actions.ts +++ b/ui/store/actions.ts @@ -2083,7 +2083,7 @@ export function addNftVerifyOwnership( export function removeAndIgnoreNft( address: string, tokenID: string, - dontShowLoadingIndicator: boolean, + shouldShowLoadingIndicator?: boolean, ): ThunkAction { return async (dispatch: MetaMaskReduxDispatch) => { if (!address) { @@ -2092,7 +2092,7 @@ export function removeAndIgnoreNft( if (!tokenID) { throw new Error('MetaMask - Cannot ignore NFT without tokenID'); } - if (!dontShowLoadingIndicator) { + if (!shouldShowLoadingIndicator) { dispatch(showLoadingIndication()); } try { @@ -2100,6 +2100,7 @@ export function removeAndIgnoreNft( } catch (error) { logErrorWithMessage(error); dispatch(displayWarning(error)); + throw error; } finally { await forceUpdateMetamaskState(dispatch); dispatch(hideLoadingIndication()); From 67555ba9336486f1c8201e87bfbb20392cfc486e Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Tue, 9 Apr 2024 17:18:58 +0100 Subject: [PATCH 22/51] fix: Fix `increaseAllowance` bugs (#23897) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** Fixes two bugs: one related to the site suggested value and another to the function name on the view details panel. See linked issues for repro instructions. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/23897?quickstart=1) ## **Related issues** Fixes: #23884 and #23885 ## **Manual testing steps** 1. Go to test dApp 2. Deploy an erc20 contract 3. Click increase token allowance ## **Screenshots/Recordings** ### **After** ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [x] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [x] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- app/_locales/en/messages.json | 3 ++ shared/lib/metamask-controller-utils.js | 5 +++ .../tokens/increase-token-allowance.spec.js | 34 +++++++++++++++++-- .../approve-content-card.js | 10 ++++-- 4 files changed, 47 insertions(+), 5 deletions(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 3c41a15a2fa5..d97f0b411255 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -1822,6 +1822,9 @@ "fromTokenLists": { "message": "From token lists: $1" }, + "function": { + "message": "Function: $1" + }, "functionApprove": { "message": "Function: Approve" }, diff --git a/shared/lib/metamask-controller-utils.js b/shared/lib/metamask-controller-utils.js index dcc76476fdb8..c10e17c37763 100644 --- a/shared/lib/metamask-controller-utils.js +++ b/shared/lib/metamask-controller-utils.js @@ -1,3 +1,8 @@ +import { TransactionType } from '@metamask/transaction-controller'; + export function getTokenValueParam(tokenData = {}) { + if (tokenData?.name === TransactionType.tokenMethodIncreaseAllowance) { + return tokenData?.args?.increment?.toString(); + } return tokenData?.args?._value?.toString(); } diff --git a/test/e2e/tests/tokens/increase-token-allowance.spec.js b/test/e2e/tests/tokens/increase-token-allowance.spec.js index b80d7249d960..1a1e861d6bad 100644 --- a/test/e2e/tests/tokens/increase-token-allowance.spec.js +++ b/test/e2e/tests/tokens/increase-token-allowance.spec.js @@ -1,3 +1,4 @@ +const { strict: assert } = require('assert'); const FixtureBuilder = require('../../fixture-builder'); const { defaultGanacheOptions, @@ -11,6 +12,8 @@ const { } = require('../../helpers'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); +const DEFAULT_TEST_DAPP_INCREASE_ALLOWANCE_SPENDING_CAP = '1'; + describe('Increase Token Allowance', function () { const smartContract = SMART_CONTRACTS.HST; @@ -233,10 +236,37 @@ describe('Increase Token Allowance', function () { await driver.delay(2000); await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - const setSpendingCap = await driver.findElement( + let spendingCapElement = await driver.findElement( + '[data-testid="custom-spending-cap-input"]', + ); + + let spendingCapValue = await spendingCapElement.getProperty('value'); + assert.equal( + spendingCapValue, + DEFAULT_TEST_DAPP_INCREASE_ALLOWANCE_SPENDING_CAP, + 'Default Test Dapp Increase Allowance Spending Cap is unexpected', + ); + + spendingCapElement = await driver.findElement( '[data-testid="custom-spending-cap-input"]', ); - await setSpendingCap.fill(finalSpendingCap); + await spendingCapElement.clear(); + + await spendingCapElement.fill('0'); + + await driver.clickElement({ + text: 'Use site suggestion', + tag: 'button', + }); + + spendingCapValue = await spendingCapElement.getProperty('value'); + assert.equal( + spendingCapValue, + DEFAULT_TEST_DAPP_INCREASE_ALLOWANCE_SPENDING_CAP, + 'Test Dapp Suggestion Increase Allowance Spending Cap is unexpected', + ); + + await spendingCapElement.fill(finalSpendingCap); await driver.clickElement({ tag: 'button', diff --git a/ui/pages/confirmations/components/approve-content-card/approve-content-card.js b/ui/pages/confirmations/components/approve-content-card/approve-content-card.js index 43dc625e4ab9..8499471b4967 100644 --- a/ui/pages/confirmations/components/approve-content-card/approve-content-card.js +++ b/ui/pages/confirmations/components/approve-content-card/approve-content-card.js @@ -19,6 +19,7 @@ import { import { I18nContext } from '../../../../contexts/i18n'; import { ConfirmGasDisplay } from '../confirm-gas-display'; import { formatCurrency } from '../../../../helpers/utils/confirm-tx.util'; +import { parseStandardTokenTransactionData } from '../../../../../shared/modules/transaction.utils'; export default function ApproveContentCard({ showHeader = true, @@ -45,6 +46,11 @@ export default function ApproveContentCard({ }) { const t = useContext(I18nContext); + const tokenData = parseStandardTokenTransactionData(data); + const functionName = tokenData?.name; + const capitalizedFnName = + functionName?.charAt(0).toUpperCase() + functionName?.slice(1); + return ( - {isSetApproveForAll - ? t('functionSetApprovalForAll') - : t('functionApprove')} + {`${t('function', [capitalizedFnName])}`} {isSetApproveForAll && isApprovalOrRejection !== undefined ? ( From 1e66cac6dca661ef466c0aa39c364bda6bdc8a69 Mon Sep 17 00:00:00 2001 From: David Walsh Date: Tue, 9 Apr 2024 15:37:07 -0500 Subject: [PATCH 23/51] fix: UX: Multichain: Only show pointer cursor for AccountListItem when clickable (#23814) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** A few minor changes to the `AccountListItem`: 1. Only shows the `pointer` cursor when the item is clickable 2. Only updates the background upon `hover` when not selected This is useful for the Connections page when there is no clickable element [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/23814?quickstart=1) ## **Related issues** Fixes: N/A ## **Manual testing steps** 1. Open the Accounts Menu 2. Hover over any AccountListItem 3. See the `pointer` cursor 4. Connect to any dapp 5. Click the favicon for the site 6. Hover over any AccountListItem 7. No pointer cursor ## **Screenshots/Recordings** ### **Before** N/A ### **After** https://github.com/MetaMask/metamask-extension/assets/46655/c0847524-cc70-4d75-8f00-50d3e406e106 ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- .../__snapshots__/account-list-item.test.js.snap | 2 +- .../account-list-item/account-list-item.js | 1 + .../multichain/account-list-item/index.scss | 16 ++++++++++++++-- .../pages/send/__snapshots__/send.test.js.snap | 2 +- .../__snapshots__/your-accounts.test.tsx.snap | 12 ++++++------ 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/ui/components/multichain/account-list-item/__snapshots__/account-list-item.test.js.snap b/ui/components/multichain/account-list-item/__snapshots__/account-list-item.test.js.snap index bc77e6a4276f..ff700fe86852 100644 --- a/ui/components/multichain/account-list-item/__snapshots__/account-list-item.test.js.snap +++ b/ui/components/multichain/account-list-item/__snapshots__/account-list-item.test.js.snap @@ -3,7 +3,7 @@ exports[`AccountListItem renders AccountListItem component and shows account name, address, and balance 1`] = `