From 30d7f1c6d0d5386eab3368691144c7625375b60c Mon Sep 17 00:00:00 2001 From: MetaMask Bot Date: Mon, 21 Oct 2024 18:44:41 +0000 Subject: [PATCH 01/23] Version v12.6.0 --- CHANGELOG.md | 216 ++++++++++++++++++++++++++++++++++++++++++++++++++- package.json | 2 +- 2 files changed, 216 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b33f07fb3d5..fda366ce5558 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,219 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [12.6.0] +### Uncategorized +- ci: reduced Sentry frequency on CircleCI develop ([#27912](https://github.com/MetaMask/metamask-extension/pull/27912)) +- chore:Master sync ([#27935](https://github.com/MetaMask/metamask-extension/pull/27935)) +- Merge origin/develop into master-sync +- test: Completing missing step for import ERC1155 token origin dapp in existing E2E test ([#27680](https://github.com/MetaMask/metamask-extension/pull/27680)) +- fix: error in navigating between transaction when one of the transaction is approve all ([#27985](https://github.com/MetaMask/metamask-extension/pull/27985)) +- fix: Automatically expand first insight ([#27872](https://github.com/MetaMask/metamask-extension/pull/27872)) +- feat(metametrics): use specific `account_hardware_type` for OneKey devices ([#27296](https://github.com/MetaMask/metamask-extension/pull/27296)) +- feat: add migration 131 ([#27364](https://github.com/MetaMask/metamask-extension/pull/27364)) +- fix(snaps): Remove arrows of custom UI inputs ([#27953](https://github.com/MetaMask/metamask-extension/pull/27953)) +- chore: Disable account syncing in prod ([#27943](https://github.com/MetaMask/metamask-extension/pull/27943)) +- test: Remove delays from onboarding tests ([#27961](https://github.com/MetaMask/metamask-extension/pull/27961)) +- perf: Create custom trace to measure performance of opening the account list ([#27907](https://github.com/MetaMask/metamask-extension/pull/27907)) +- feat: add BTC send flow ([#27964](https://github.com/MetaMask/metamask-extension/pull/27964)) +- fix: flaky test `Confirmation Redesign ERC721 Approve Component Submit an Approve transaction @no-mmi Sends a type 2 transaction (EIP1559)` ([#27928](https://github.com/MetaMask/metamask-extension/pull/27928)) +- fix: lint-lockfile flaky job by changing resources from medium to medium-plus ([#27950](https://github.com/MetaMask/metamask-extension/pull/27950)) +- feat: add “Incomplete Asset Displayed” metric & fix: should only set default decimals if ERC20 ([#27494](https://github.com/MetaMask/metamask-extension/pull/27494)) +- feat: Convert AppStateController to typescript ([#27572](https://github.com/MetaMask/metamask-extension/pull/27572)) +- chore(deps): upgrade from json-rpc-engine to @metamask/json-rpc-engine ([#22875](https://github.com/MetaMask/metamask-extension/pull/22875)) +- feat: dapp initiated token transfer ([#27875](https://github.com/MetaMask/metamask-extension/pull/27875)) +- chore: bump signature controller to remove message managers ([#27787](https://github.com/MetaMask/metamask-extension/pull/27787)) +- chore: add testing-library/dom dependency ([#27493](https://github.com/MetaMask/metamask-extension/pull/27493)) +- test: [POM] Migrate contract interaction with snap account e2e tests to page object modal ([#27924](https://github.com/MetaMask/metamask-extension/pull/27924)) +- fix: bump message signing snap to support portfolio automatic connections ([#27936](https://github.com/MetaMask/metamask-extension/pull/27936)) +- fix: hide options menu that was being shown for preinstalled Snaps ([#27937](https://github.com/MetaMask/metamask-extension/pull/27937)) +- fix: bump `@metamask/ppom-validator` from `0.34.0` to `0.35.1` ([#27939](https://github.com/MetaMask/metamask-extension/pull/27939)) +- fix: add APE network icon ([#27841](https://github.com/MetaMask/metamask-extension/pull/27841)) +- feat: NFT permit simulations ([#27825](https://github.com/MetaMask/metamask-extension/pull/27825)) +- fix: fix currency display when tokenToFiatConversion rate is not avai… ([#27893](https://github.com/MetaMask/metamask-extension/pull/27893)) +- feat: convert AlertController to typescript ([#27764](https://github.com/MetaMask/metamask-extension/pull/27764)) +- feat(TXL-435): turn smart transactions on by default for new users ([#27885](https://github.com/MetaMask/metamask-extension/pull/27885)) +- feat: Add transaction flow and details sections ([#27654](https://github.com/MetaMask/metamask-extension/pull/27654)) +- fix: flaky test `Vault Decryptor Page is able to decrypt the vault pasting the text in the vault-decryptor webapp` ([#27921](https://github.com/MetaMask/metamask-extension/pull/27921)) +- chore: bump `@metamask/eth-snap-keyring` to version 4.4.0 ([#27864](https://github.com/MetaMask/metamask-extension/pull/27864)) +- fix: flaky tests `Add existing token using search renders the balance for the chosen token` ([#27853](https://github.com/MetaMask/metamask-extension/pull/27853)) +- feat(logging): add extension request logging and retrieval ([#27655](https://github.com/MetaMask/metamask-extension/pull/27655)) +- test: Update test-dapp to verison 8.7.0 ([#27816](https://github.com/MetaMask/metamask-extension/pull/27816)) +- fix: fall back to bundled chainlist ([#23392](https://github.com/MetaMask/metamask-extension/pull/23392)) +- fix: SonarCloud for forks ([#27700](https://github.com/MetaMask/metamask-extension/pull/27700)) +- fix(deps): update from eth-rpc-errors to @metamask/rpc-errors (cause edition) ([#24496](https://github.com/MetaMask/metamask-extension/pull/24496)) +- fix: swapQuotesError as a property in the reported metric ([#27712](https://github.com/MetaMask/metamask-extension/pull/27712)) +- chore: Bump Snaps packages ([#27376](https://github.com/MetaMask/metamask-extension/pull/27376)) +- chore: update @metamask/bitcoin-wallet-snap to 0.7.0 ([#27730](https://github.com/MetaMask/metamask-extension/pull/27730)) +- fix: Onboarding: Code style nits ([#27767](https://github.com/MetaMask/metamask-extension/pull/27767)) +- fix: updated edit modals ([#27623](https://github.com/MetaMask/metamask-extension/pull/27623)) +- feat: use asset pickers with network dropdown in cross-chain swaps page ([#27522](https://github.com/MetaMask/metamask-extension/pull/27522)) +- test: set ENABLE_MV3 automatically ([#27748](https://github.com/MetaMask/metamask-extension/pull/27748)) +- feat: Adding typed sign support for NFT permit ([#27796](https://github.com/MetaMask/metamask-extension/pull/27796)) +- fix: Contract Interaction - cannot read the property `text_signature` ([#27686](https://github.com/MetaMask/metamask-extension/pull/27686)) +- feat: Use requested permissions as default selected values for AmonHenV2 connection flow with case insensitive address comparison ([#27517](https://github.com/MetaMask/metamask-extension/pull/27517)) +- test: [POM] Migrate signature with snap account e2e tests to page object modal ([#27829](https://github.com/MetaMask/metamask-extension/pull/27829)) +- fix: flaky test `ERC1155 NFTs testdapp interaction should batch transfers ERC1155 token` ([#27897](https://github.com/MetaMask/metamask-extension/pull/27897)) +- chore: Master sync following v12.4.1 ([#27793](https://github.com/MetaMask/metamask-extension/pull/27793)) +- fix: flaky test `Permissions sets permissions and connect to Dapp` ([#27888](https://github.com/MetaMask/metamask-extension/pull/27888)) +- fix: flaky test `ERC721 NFTs testdapp interaction should prompt users to add their NFTs to their wallet (all at once)` ([#27889](https://github.com/MetaMask/metamask-extension/pull/27889)) +- fix: flaky test `Wallet Revoke Permissions should revoke eth_accounts permissions via test dapp` ([#27894](https://github.com/MetaMask/metamask-extension/pull/27894)) +- fix: flaky test `Snap Account Signatures and Disconnects can connect to the Test Dapp, then #signTypedDataV3, disconnect then connect, then #signTypedDataV4 (async flow approve)` ([#27887](https://github.com/MetaMask/metamask-extension/pull/27887)) +- test(mock-e2e): add private domains logic for the privacy report ([#27844](https://github.com/MetaMask/metamask-extension/pull/27844)) +- fix: SENTRY_DSN_FAKE problem ([#27881](https://github.com/MetaMask/metamask-extension/pull/27881)) +- chore: remove unused swaps code ([#27679](https://github.com/MetaMask/metamask-extension/pull/27679)) +- test(TXL-308): initial e2e for stx using swaps ([#27215](https://github.com/MetaMask/metamask-extension/pull/27215)) +- feat: upgrade assets-controllers to v38.3.0 ([#27755](https://github.com/MetaMask/metamask-extension/pull/27755)) +- fix: nonce value when there are multiple transactions in parallel ([#27874](https://github.com/MetaMask/metamask-extension/pull/27874)) +- fix: phishing test to not check c2 domains ([#27846](https://github.com/MetaMask/metamask-extension/pull/27846)) +- feat: use messenger in AccountTracker to get Preferences state ([#27711](https://github.com/MetaMask/metamask-extension/pull/27711)) +- fix: "Update Network: should update added rpc url for exis..." flaky tests ([#27437](https://github.com/MetaMask/metamask-extension/pull/27437)) +- feat: update copy for 'Default settings' ([#27821](https://github.com/MetaMask/metamask-extension/pull/27821)) +- fix: updated permissions flow copy changes ([#27658](https://github.com/MetaMask/metamask-extension/pull/27658)) +- fix: flaky test `Add account should not affect public address when using secret recovery phrase to recover account with non-zero balance @no-mmi` ([#27834](https://github.com/MetaMask/metamask-extension/pull/27834)) +- fix: hackily wait longer for linea swap approval tx to increase chance of success ([#27810](https://github.com/MetaMask/metamask-extension/pull/27810)) +- fix: flaky test `MultiRpc: should select rpc from settings @no-mmi` ([#27858](https://github.com/MetaMask/metamask-extension/pull/27858)) +- perf: include custom traces in benchmark results ([#27701](https://github.com/MetaMask/metamask-extension/pull/27701)) +- fix: Reset nonce as network is switched ([#27789](https://github.com/MetaMask/metamask-extension/pull/27789)) +- fix: dismiss addToken modal for mmi ([#27855](https://github.com/MetaMask/metamask-extension/pull/27855)) +- fix(multichain): fix eth send flow (from dapp) when a btc account is selected ([#27566](https://github.com/MetaMask/metamask-extension/pull/27566)) +- chore: Add react-beautiful-dnd to deprecated packages list ([#27856](https://github.com/MetaMask/metamask-extension/pull/27856)) +- feat: Create a quality gate for typescript coverage ([#27717](https://github.com/MetaMask/metamask-extension/pull/27717)) +- feat: preferences controller to base controller v2 ([#27398](https://github.com/MetaMask/metamask-extension/pull/27398)) +- revert: use networkClientId to resolve chainId in PPOM Middleware ([#27570](https://github.com/MetaMask/metamask-extension/pull/27570)) +- feat: Added metrics for edit networks and accounts ([#27820](https://github.com/MetaMask/metamask-extension/pull/27820)) +- fix: no connected state for permissions page ([#27660](https://github.com/MetaMask/metamask-extension/pull/27660)) +- feat: remove phishing detection from onboarding Security group ([#27819](https://github.com/MetaMask/metamask-extension/pull/27819)) +- ci: Revert minimum E2E timeout to 20 minutes ([#27827](https://github.com/MetaMask/metamask-extension/pull/27827)) +- fix: disable balance checker for Sepolia in account tracker ([#27763](https://github.com/MetaMask/metamask-extension/pull/27763)) +- ci: Improve validation for `sentry:publish` script ([#26580](https://github.com/MetaMask/metamask-extension/pull/26580)) +- test: Fix Vault Decryptor Page e2e test on develop branch ([#27794](https://github.com/MetaMask/metamask-extension/pull/27794)) +- chore: remove old token details page ([#27774](https://github.com/MetaMask/metamask-extension/pull/27774)) +- chore: remove token list display component ([#27772](https://github.com/MetaMask/metamask-extension/pull/27772)) +- chore: update Trezor Connect to v9.4.0, remove workarounds ([#27112](https://github.com/MetaMask/metamask-extension/pull/27112)) +- test: [POM] Migrate transaction with snap account e2e tests to page object modal ([#27760](https://github.com/MetaMask/metamask-extension/pull/27760)) +- fix(snaps): Restore confirmation switching on routed confirmation ([#27753](https://github.com/MetaMask/metamask-extension/pull/27753)) +- Merge origin/develop into master-sync +- test: Onboarding: Fix vault-decryption-chrome.spec.js ([#27779](https://github.com/MetaMask/metamask-extension/pull/27779)) +- feat: support gas fee flows in standard swaps ([#27612](https://github.com/MetaMask/metamask-extension/pull/27612)) +- feat: Token send heading component ([#27562](https://github.com/MetaMask/metamask-extension/pull/27562)) +- feat: adds the new default settings view to onboarding ([#24562](https://github.com/MetaMask/metamask-extension/pull/24562)) +- chore(3212): remove alert settings ([#27709](https://github.com/MetaMask/metamask-extension/pull/27709)) +- docs: remove outdated Medium link, update "Twitter" to "X" ([#26692](https://github.com/MetaMask/metamask-extension/pull/26692)) +- fix: Replace 'transaction fees' with 'network fees' in the insufficie… ([#27762](https://github.com/MetaMask/metamask-extension/pull/27762)) +- fix: issue with Snap title in Snap Authorship Header ([#27752](https://github.com/MetaMask/metamask-extension/pull/27752)) +- fix: SIWE signature page displays parsed URI instead of domain ([#27754](https://github.com/MetaMask/metamask-extension/pull/27754)) +- fix: updated toasts component and copy ([#27656](https://github.com/MetaMask/metamask-extension/pull/27656)) +- feat: add network picker to AssetPicker ([#26559](https://github.com/MetaMask/metamask-extension/pull/26559)) +- fix(btc): fix jazzicons generations ([#27662](https://github.com/MetaMask/metamask-extension/pull/27662)) +- feat: Release Chain Permissions ([#27561](https://github.com/MetaMask/metamask-extension/pull/27561)) +- feat: upgrade assets-controllers to v38.2.0 ([#27629](https://github.com/MetaMask/metamask-extension/pull/27629)) +- ci: followup to CircleCI Sentry reporting ([#27548](https://github.com/MetaMask/metamask-extension/pull/27548)) +- chore: Master sync ([#27729](https://github.com/MetaMask/metamask-extension/pull/27729)) +- fix(multichain): fix getMultichainCurrentCurrency selector ([#27726](https://github.com/MetaMask/metamask-extension/pull/27726)) +- fix: Limit amount of decimals on spending cap modal ([#27672](https://github.com/MetaMask/metamask-extension/pull/27672)) +- Merge origin/develop into master-sync +- test: [POM] Migrate create snap account e2e tests to page object modal ([#27697](https://github.com/MetaMask/metamask-extension/pull/27697)) +- fix: Prefer token symbol to token name ([#27693](https://github.com/MetaMask/metamask-extension/pull/27693)) +- fix(btc): fetch btc balance right after account creation ([#27628](https://github.com/MetaMask/metamask-extension/pull/27628)) +- fix: UI startup with no Sentry DSN ([#27714](https://github.com/MetaMask/metamask-extension/pull/27714)) +- feat: Sort/Import Tokens in Extension ([#27184](https://github.com/MetaMask/metamask-extension/pull/27184)) +- ci: make git-diff-develop work for PRs from foreign repos ([#27268](https://github.com/MetaMask/metamask-extension/pull/27268)) +- test: Convert json-rpc e2e tests to TypeScript ([#27659](https://github.com/MetaMask/metamask-extension/pull/27659)) +- fix: allow getAddTransactionRequest to pass through other params ([#27117](https://github.com/MetaMask/metamask-extension/pull/27117)) +- perf: add tags to UI startup trace ([#27550](https://github.com/MetaMask/metamask-extension/pull/27550)) +- fix: Disable redirecting Extension users using beta & flask build and dev env to the existing offboarding page ([#27226](https://github.com/MetaMask/metamask-extension/pull/27226)) +- feat(NOTIFY-1193): add profile sync dev menu ([#27666](https://github.com/MetaMask/metamask-extension/pull/27666)) +- refactor: Typescript conversion of log-web3-shim-usage.js ([#23732](https://github.com/MetaMask/metamask-extension/pull/23732)) +- test: removing race condition for asserting inner values (PR-#2) ([#27664](https://github.com/MetaMask/metamask-extension/pull/27664)) +- fix(btc): fix address validation ([#27690](https://github.com/MetaMask/metamask-extension/pull/27690)) +- chore: Update coverage.json ([#27696](https://github.com/MetaMask/metamask-extension/pull/27696)) +- fix: test coverage quality gate ([#27691](https://github.com/MetaMask/metamask-extension/pull/27691)) +- fix: banner alert to render multiple general alerts ([#27339](https://github.com/MetaMask/metamask-extension/pull/27339)) +- refactor: routes constants ([#27078](https://github.com/MetaMask/metamask-extension/pull/27078)) +- fix: Test coverage quality gate ([#27581](https://github.com/MetaMask/metamask-extension/pull/27581)) +- feat: Adding delete metametrics data to security and privacy tab ([#24571](https://github.com/MetaMask/metamask-extension/pull/24571)) +- feat(stx): animations and cosmetic changes to smart transaction status page ([#27650](https://github.com/MetaMask/metamask-extension/pull/27650)) +- build: add lottie-web dependency to extension ([#27632](https://github.com/MetaMask/metamask-extension/pull/27632)) +- fix(btc): do not show percentage for tokens ([#27637](https://github.com/MetaMask/metamask-extension/pull/27637)) +- feat: support Etherscan API keys ([#27611](https://github.com/MetaMask/metamask-extension/pull/27611)) +- feat: change survey timeout time from a week to a day ([#27603](https://github.com/MetaMask/metamask-extension/pull/27603)) +- fix: Design papercuts for redesigned transactions ([#27605](https://github.com/MetaMask/metamask-extension/pull/27605)) +- test: removing race condition for asserting inner values (PR-#1) ([#27606](https://github.com/MetaMask/metamask-extension/pull/27606)) +- test: [POM] Migrate Snap Simple Keyring page and Snap List page to page object modal ([#27327](https://github.com/MetaMask/metamask-extension/pull/27327)) +- fix: fix sentry reading undefined ([#27584](https://github.com/MetaMask/metamask-extension/pull/27584)) +- fix: fix sentry reading null ([#27582](https://github.com/MetaMask/metamask-extension/pull/27582)) +- fix(btc): disable balanceIsCached flag ([#27636](https://github.com/MetaMask/metamask-extension/pull/27636)) +- chore: update accounts related packages ([#27284](https://github.com/MetaMask/metamask-extension/pull/27284)) +- chore: set bridge src network, tokens and top assets ([#26214](https://github.com/MetaMask/metamask-extension/pull/26214)) +- test: [Snaps E2E] add delay to installed snaps test to reduce flaking ([#27521](https://github.com/MetaMask/metamask-extension/pull/27521)) +- chore: set bridge dest network, tokens and top assets ([#26213](https://github.com/MetaMask/metamask-extension/pull/26213)) +- fix: fix reading address from market data ([#27604](https://github.com/MetaMask/metamask-extension/pull/27604)) +- feat: Migrate AccountTrackerController to BaseController v2 ([#27258](https://github.com/MetaMask/metamask-extension/pull/27258)) +- fix: disable transaction data decode if deployment ([#27586](https://github.com/MetaMask/metamask-extension/pull/27586)) +- fix: revert jest collect coverage patterns ([#27583](https://github.com/MetaMask/metamask-extension/pull/27583)) +- fix: add amount row for contract deployment ([#27594](https://github.com/MetaMask/metamask-extension/pull/27594)) +- fix: "Dapp viewed Event @no-mmi is sent when refreshing da..." flaky test ([#27381](https://github.com/MetaMask/metamask-extension/pull/27381)) +- chore: fix deps audit ([#27620](https://github.com/MetaMask/metamask-extension/pull/27620)) +- fix: Max approval and array value spending cap bugs ([#27573](https://github.com/MetaMask/metamask-extension/pull/27573)) +- feat: add power users survey support ([#27361](https://github.com/MetaMask/metamask-extension/pull/27361)) +- fix: Recreate offscreen document if it already exists ([#27596](https://github.com/MetaMask/metamask-extension/pull/27596)) +- fix: flaky test `Block Explorer links to the token tracker in the explorer` ([#27599](https://github.com/MetaMask/metamask-extension/pull/27599)) +- fix(snaps): `Copyable` more button color ([#27600](https://github.com/MetaMask/metamask-extension/pull/27600)) +- fix: flaky test `Import flow allows importing multiple tokens from search` ([#27567](https://github.com/MetaMask/metamask-extension/pull/27567)) +- fix(27428): fix if we type enter anything followed by a \ in settings search ([#27432](https://github.com/MetaMask/metamask-extension/pull/27432)) +- fix: flaky test `Address Book Edit entry in address book` due to race condition with mmi menu ([#27557](https://github.com/MetaMask/metamask-extension/pull/27557)) +- refactor: Typescript conversion of get-provider-state.js ([#23635](https://github.com/MetaMask/metamask-extension/pull/23635)) +- chore: Use "gas_included" event prop ([#27559](https://github.com/MetaMask/metamask-extension/pull/27559)) +- fix: mock locale in unit test ([#27574](https://github.com/MetaMask/metamask-extension/pull/27574)) +- feat: codefence Account Watcher for flask ([#27543](https://github.com/MetaMask/metamask-extension/pull/27543)) +- chore: start upgrade to React Router v6 ([#27185](https://github.com/MetaMask/metamask-extension/pull/27185)) +- fix: AmonHenV2 connection flow incremental permitted chain approval and account address case comparison ([#27518](https://github.com/MetaMask/metamask-extension/pull/27518)) +- fix: flaky test `Backup and Restore should backup the account settings` ([#27565](https://github.com/MetaMask/metamask-extension/pull/27565)) +- fix: Apply flex to Snaps buttons only when containing images and icons ([#27564](https://github.com/MetaMask/metamask-extension/pull/27564)) +- feat: aggregated balance feature ([#27097](https://github.com/MetaMask/metamask-extension/pull/27097)) +- feat: Add redesign integration tests ([#27259](https://github.com/MetaMask/metamask-extension/pull/27259)) +- fix: flaky test `4byte setting does not try to get contract method name from 4byte when the setting is off` ([#27560](https://github.com/MetaMask/metamask-extension/pull/27560)) +- feat: add merge queue ([#26871](https://github.com/MetaMask/metamask-extension/pull/26871)) +- feat: remove squiggle animation from swaps smart transactions ([#27264](https://github.com/MetaMask/metamask-extension/pull/27264)) +- feat: Enable gas included swaps ([#27427](https://github.com/MetaMask/metamask-extension/pull/27427)) +- fix(snaps): Fix custom UI buttons submitting forms ([#27531](https://github.com/MetaMask/metamask-extension/pull/27531)) +- chore: Master sync following v12.3.1 ([#27538](https://github.com/MetaMask/metamask-extension/pull/27538)) +- Merge origin/develop into master-sync +- fix(NOTIFY-1171): account syncing performance and bug fixes ([#27529](https://github.com/MetaMask/metamask-extension/pull/27529)) +- fix: genUnapprovedApproveConfirmation import path ([#27530](https://github.com/MetaMask/metamask-extension/pull/27530)) +- fix(snaps): Keep focus on input if interface re-renders ([#27429](https://github.com/MetaMask/metamask-extension/pull/27429)) +- fix: Allow state updates in Snaps interfaces to state values that are falsy ([#27488](https://github.com/MetaMask/metamask-extension/pull/27488)) +- fix: updated ui for connect and review page ([#27478](https://github.com/MetaMask/metamask-extension/pull/27478)) +- feat: Custom header for wallet initiated confirmations ([#27391](https://github.com/MetaMask/metamask-extension/pull/27391)) +- feat: convert account tracker to typescript ([#27231](https://github.com/MetaMask/metamask-extension/pull/27231)) +- fix: Fix snaps permission connection for `CHAIN_PERMISSIONS` feature flag ([#27459](https://github.com/MetaMask/metamask-extension/pull/27459)) +- fix: flaky test `Navigation Signature - Different signature types initiates multiple signatures and rejects all` ([#27481](https://github.com/MetaMask/metamask-extension/pull/27481)) +- feat: Double Sentry performance trace sample rate ([#27468](https://github.com/MetaMask/metamask-extension/pull/27468)) +- ci: Expand github bot policy update comment to be more actionable ([#27242](https://github.com/MetaMask/metamask-extension/pull/27242)) +- chore: Add `useLedgerConnection` unit tests ([#27358](https://github.com/MetaMask/metamask-extension/pull/27358)) +- ci: Sentry reporting only on develop branch, with Git message overrides ([#27412](https://github.com/MetaMask/metamask-extension/pull/27412)) +- test: Fix flaky permit test ([#27450](https://github.com/MetaMask/metamask-extension/pull/27450)) +- fix: removed closeMenu for ConnectedAccountsMenu ([#27460](https://github.com/MetaMask/metamask-extension/pull/27460)) +- fix(snaps): Set proper text color for secondary button ([#27335](https://github.com/MetaMask/metamask-extension/pull/27335)) +- chore: set bridge selected tokens and amount ([#26212](https://github.com/MetaMask/metamask-extension/pull/26212)) +- fix: flaky test `Add account should not affect public address when using secret recovery phrase to recover account with non-zero balance @no-mmi`aded ([#27420](https://github.com/MetaMask/metamask-extension/pull/27420)) +- fix: flaky test `Responsive UI Send Transaction from responsive window` ([#27417](https://github.com/MetaMask/metamask-extension/pull/27417)) +- fix: flaky test `Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx should queue send tx after switch network confirmation and transaction should target the correct network after switch is confirmed` ([#27352](https://github.com/MetaMask/metamask-extension/pull/27352)) +- fix: Change speed key color ([#27416](https://github.com/MetaMask/metamask-extension/pull/27416)) +- feat: Display setApprovalForAll and revoke setApprovalForAll to users… ([#27401](https://github.com/MetaMask/metamask-extension/pull/27401)) +- fix: "Warning: Invalid argument supplied to oneOfType" ([#27267](https://github.com/MetaMask/metamask-extension/pull/27267)) +- feat: Editing flow ([#26635](https://github.com/MetaMask/metamask-extension/pull/26635)) +- chore: bump profile-sync-controller to 0.9.3 ([#27415](https://github.com/MetaMask/metamask-extension/pull/27415)) +- fix: Remove duplication ([#27421](https://github.com/MetaMask/metamask-extension/pull/27421)) +- fix: Confirm Page test failing in CI/CD ([#27423](https://github.com/MetaMask/metamask-extension/pull/27423)) +- feat: Display approve, increaseAllowance and revoke approval to users… ([#26985](https://github.com/MetaMask/metamask-extension/pull/26985)) +- feat: Add performance metrics for signature requests ([#26967](https://github.com/MetaMask/metamask-extension/pull/26967)) +- fix: Permit DataTree token decimals ([#27328](https://github.com/MetaMask/metamask-extension/pull/27328)) +- fix: alert system and refine SIWE and contract interaction alerts ([#27205](https://github.com/MetaMask/metamask-extension/pull/27205)) +- fix(NOTIFY-1166): rename account sync event names ([#27413](https://github.com/MetaMask/metamask-extension/pull/27413)) +- feat: ERC20 Revoke Allowance ([#26906](https://github.com/MetaMask/metamask-extension/pull/26906)) + ## [12.5.0] ### Added - New UI and functionality for adding and managing networks ([#26433](https://github.com/MetaMask/metamask-extension/pull/26433)), ([#27085](https://github.com/MetaMask/metamask-extension/pull/27085)) @@ -5223,7 +5436,8 @@ Update styles and spacing on the critical error page ([#20350](https://github.c - Added the ability to restore accounts from seed words. -[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v12.5.0...HEAD +[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v12.6.0...HEAD +[12.6.0]: https://github.com/MetaMask/metamask-extension/compare/v12.5.0...v12.6.0 [12.5.0]: https://github.com/MetaMask/metamask-extension/compare/v12.4.2...v12.5.0 [12.4.2]: https://github.com/MetaMask/metamask-extension/compare/v12.4.1...v12.4.2 [12.4.1]: https://github.com/MetaMask/metamask-extension/compare/v12.4.0...v12.4.1 diff --git a/package.json b/package.json index c3b60bfa1e48..fec8f2ffb498 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "metamask-crx", - "version": "12.5.0", + "version": "12.6.0", "private": true, "repository": { "type": "git", From b940d04e8c9bef42841aa3816a91d7e8c1a7bea9 Mon Sep 17 00:00:00 2001 From: martahj Date: Wed, 23 Oct 2024 15:56:53 -0500 Subject: [PATCH 02/23] fix: adjust spacing of quote rate in swaps (#28051) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** Cherry-pick of https://github.com/MetaMask/metamask-extension/pull/28016 into v12.6 [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28016?quickstart=1) ## **Manual testing steps** 1. Start a swap 2. Notice that the quote rate is back on one line and the value is left-aligned ## **Screenshots/Recordings** ### **Before** ![Screenshot 2024-10-11 at 11 32 09 AM](https://github.com/user-attachments/assets/aae5da2f-ae66-46f5-9168-6c6ed496a2a8) ### **After** Screenshot 2024-10-22 at 12 13 50 PM ## **Pre-merge author checklist** - [X] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension 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** - [ ] 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/swaps/prepare-swap-page/index.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/pages/swaps/prepare-swap-page/index.scss b/ui/pages/swaps/prepare-swap-page/index.scss index 60e24c6cdbce..b443006330d3 100644 --- a/ui/pages/swaps/prepare-swap-page/index.scss +++ b/ui/pages/swaps/prepare-swap-page/index.scss @@ -263,7 +263,7 @@ } &__exchange-rate-display { - color: var(--color-text-alternative); + width: auto !important; } } From 77cbfe8a01f00c5b9a95cf58c6fb9494ddd999fa Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Thu, 24 Oct 2024 19:00:01 +0100 Subject: [PATCH 03/23] fix: cherry-pick: Gas changes for low Max base fee and Priority fee (#28037) (#28073) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cherry-pick: https://github.com/MetaMask/metamask-extension/pull/28037 ## **Description** Previously, if the Max base fee and Priority fee were reduced to very low values, the Network fee wouldn't update accordingly. This is a discrepancy with the gas calculations in the old flows. What fixes it is, for low enough values of `maxFeePerGas` (low enough to be lower than `minimumFeePerGas`), the Network fee becomes the Max fee -- `maxFeePerGas` times `gasLimit` directly. Apart from fixing the symptom explained above, this ensures that the Network fee is never higher than the Max fee. The PR also fixes this calculation when it comes to the L2 fees (inside `useTransactionGasFeeEstimate`). It also adds a missing override of `dappSuggestedFees` for both `maxFeePerGas` and `maxPriorityFeePerGas` (inside `useEIP1559TxFees`). [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28037?quickstart=1) ## **Related issues** Fixes: https://github.com/MetaMask/metamask-extension/issues/27802 ## **Manual testing steps** See original report above. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension 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. ## **Description** [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28073?quickstart=1) ## **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 Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension 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. --- .../confirm/info/hooks/useEIP1559TxFees.ts | 5 ++++- .../confirm/info/hooks/useFeeCalculations.ts | 13 ++++++++++++- .../info/hooks/useTransactionGasFeeEstimate.ts | 12 +++++++++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/ui/pages/confirmations/components/confirm/info/hooks/useEIP1559TxFees.ts b/ui/pages/confirmations/components/confirm/info/hooks/useEIP1559TxFees.ts index 40aca7cf2d31..e4bfaad8d779 100644 --- a/ui/pages/confirmations/components/confirm/info/hooks/useEIP1559TxFees.ts +++ b/ui/pages/confirmations/components/confirm/info/hooks/useEIP1559TxFees.ts @@ -8,8 +8,11 @@ export const useEIP1559TxFees = ( maxFeePerGas: string; maxPriorityFeePerGas: string; } => { - const hexMaxFeePerGas = transactionMeta?.txParams?.maxFeePerGas; + const hexMaxFeePerGas = + transactionMeta.dappSuggestedGasFees?.maxFeePerGas || + transactionMeta?.txParams?.maxFeePerGas; const hexMaxPriorityFeePerGas = + transactionMeta.dappSuggestedGasFees?.maxPriorityFeePerGas || transactionMeta?.txParams?.maxPriorityFeePerGas; return useMemo(() => { diff --git a/ui/pages/confirmations/components/confirm/info/hooks/useFeeCalculations.ts b/ui/pages/confirmations/components/confirm/info/hooks/useFeeCalculations.ts index ceb8a4b2d248..587d70c9c9ef 100644 --- a/ui/pages/confirmations/components/confirm/info/hooks/useFeeCalculations.ts +++ b/ui/pages/confirmations/components/confirm/info/hooks/useFeeCalculations.ts @@ -12,6 +12,7 @@ import { getValueFromWeiHex, multiplyHexes, } from '../../../../../../../shared/modules/conversion.utils'; +import { Numeric } from '../../../../../../../shared/modules/Numeric'; import { getConversionRate } from '../../../../../../ducks/metamask/metamask'; import { useFiatFormatter } from '../../../../../../hooks/useFiatFormatter'; import { useGasFeeEstimates } from '../../../../../../hooks/useGasFeeEstimates'; @@ -114,11 +115,21 @@ export function useFeeCalculations(transactionMeta: TransactionMeta) { } // Logic for any network without L1 and L2 fee components - const minimumFeePerGas = addHexes( + let minimumFeePerGas = addHexes( decGWEIToHexWEI(estimatedBaseFee) || HEX_ZERO, decimalToHex(maxPriorityFeePerGas), ); + // `minimumFeePerGas` should never be higher than the `maxFeePerGas` + if ( + new Numeric(minimumFeePerGas, 16).greaterThan( + decimalToHex(maxFeePerGas), + 16, + ) + ) { + minimumFeePerGas = decimalToHex(maxFeePerGas); + } + const estimatedFee = multiplyHexes( supportsEIP1559 ? (minimumFeePerGas as Hex) : (gasPrice as Hex), gasLimit as Hex, diff --git a/ui/pages/confirmations/components/confirm/info/hooks/useTransactionGasFeeEstimate.ts b/ui/pages/confirmations/components/confirm/info/hooks/useTransactionGasFeeEstimate.ts index 31802eb22feb..f5866a283935 100644 --- a/ui/pages/confirmations/components/confirm/info/hooks/useTransactionGasFeeEstimate.ts +++ b/ui/pages/confirmations/components/confirm/info/hooks/useTransactionGasFeeEstimate.ts @@ -5,6 +5,7 @@ import { addHexes, multiplyHexes, } from '../../../../../../../shared/modules/conversion.utils'; +import { Numeric } from '../../../../../../../shared/modules/Numeric'; import { useGasFeeEstimates } from '../../../../../../hooks/useGasFeeEstimates'; import { HEX_ZERO } from '../shared/constants'; @@ -28,15 +29,24 @@ export function useTransactionGasFeeEstimate( transactionMeta.dappSuggestedGasFees?.maxPriorityFeePerGas || transactionMeta.txParams?.maxPriorityFeePerGas || HEX_ZERO; + const maxFeePerGas = + transactionMeta.dappSuggestedGasFees?.maxFeePerGas || + transactionMeta.txParams?.maxFeePerGas || + HEX_ZERO; let gasEstimate: Hex; if (supportsEIP1559) { // Minimum Total Fee = (estimatedBaseFee + maxPriorityFeePerGas) * gasLimit - const minimumFeePerGas = addHexes( + let minimumFeePerGas = addHexes( estimatedBaseFee || HEX_ZERO, maxPriorityFeePerGas, ); + // `minimumFeePerGas` should never be higher than the `maxFeePerGas` + if (new Numeric(minimumFeePerGas, 16).greaterThan(maxFeePerGas, 16)) { + minimumFeePerGas = maxFeePerGas; + } + gasEstimate = multiplyHexes(minimumFeePerGas as Hex, gasLimit as Hex); } else { gasEstimate = multiplyHexes(gasPrice as Hex, gasLimit as Hex); From d1da8609213d4ca682a2e972b5c3db15d0abf256 Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Thu, 24 Oct 2024 19:01:35 +0100 Subject: [PATCH 04/23] fix: Cherry-pick Support dynamic native token name on gas component (#28048) (#28071) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cherry-pick https://github.com/MetaMask/metamask-extension/pull/28048 ## **Description** Uses the multinetwork ticker. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28048?quickstart=1) ## **Related issues** Fixes: https://github.com/MetaMask/metamask-extension/issues/28001 ## **Manual testing steps** See original ticket linked above. ## **Screenshots/Recordings** ### **Before** ### **After** Screenshot 2024-10-23 at 16 16 19 ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension 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. ## **Description** [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28071?quickstart=1) ## **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 Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension 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. --- .../transactions/contract-deployment.test.tsx | 4 ++-- .../transactions/contract-interaction.test.tsx | 4 ++-- .../confirm/info/hooks/useFeeCalculations.test.ts | 4 ++-- .../confirm/info/hooks/useFeeCalculations.ts | 12 ++++++++---- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/test/integration/confirmations/transactions/contract-deployment.test.tsx b/test/integration/confirmations/transactions/contract-deployment.test.tsx index ecef04f30861..c2625e06e3e7 100644 --- a/test/integration/confirmations/transactions/contract-deployment.test.tsx +++ b/test/integration/confirmations/transactions/contract-deployment.test.tsx @@ -283,7 +283,7 @@ describe('Contract Deployment Confirmation', () => { expect(editGasFeesRow).toHaveTextContent(tEn('networkFee') as string); const firstGasField = within(editGasFeesRow).getByTestId('first-gas-field'); - expect(firstGasField).toHaveTextContent('0.0001 ETH'); + expect(firstGasField).toHaveTextContent('0.0001 SepoliaETH'); const editGasFeeNativeCurrency = within(editGasFeesRow).getByTestId('native-currency'); expect(editGasFeeNativeCurrency).toHaveTextContent('$0.47'); @@ -371,7 +371,7 @@ describe('Contract Deployment Confirmation', () => { const maxFee = screen.getByTestId('gas-fee-details-max-fee'); expect(gasFeesSection).toContainElement(maxFee); expect(maxFee).toHaveTextContent(tEn('maxFee') as string); - expect(maxFee).toHaveTextContent('0.0023 ETH'); + expect(maxFee).toHaveTextContent('0.0023 SepoliaETH'); expect(maxFee).toHaveTextContent('$7.72'); const nonceSection = screen.getByTestId('advanced-details-nonce-section'); diff --git a/test/integration/confirmations/transactions/contract-interaction.test.tsx b/test/integration/confirmations/transactions/contract-interaction.test.tsx index 1102cb21c67d..b77e48f1d660 100644 --- a/test/integration/confirmations/transactions/contract-interaction.test.tsx +++ b/test/integration/confirmations/transactions/contract-interaction.test.tsx @@ -301,7 +301,7 @@ describe('Contract Interaction Confirmation', () => { expect(editGasFeesRow).toHaveTextContent(tEn('networkFee') as string); const firstGasField = within(editGasFeesRow).getByTestId('first-gas-field'); - expect(firstGasField).toHaveTextContent('0.0001 ETH'); + expect(firstGasField).toHaveTextContent('0.0001 SepoliaETH'); const editGasFeeNativeCurrency = within(editGasFeesRow).getByTestId('native-currency'); expect(editGasFeeNativeCurrency).toHaveTextContent('$0.47'); @@ -402,7 +402,7 @@ describe('Contract Interaction Confirmation', () => { const maxFee = screen.getByTestId('gas-fee-details-max-fee'); expect(gasFeesSection).toContainElement(maxFee); expect(maxFee).toHaveTextContent(tEn('maxFee') as string); - expect(maxFee).toHaveTextContent('0.0023 ETH'); + expect(maxFee).toHaveTextContent('0.0023 SepoliaETH'); expect(maxFee).toHaveTextContent('$7.72'); const nonceSection = screen.getByTestId('advanced-details-nonce-section'); diff --git a/ui/pages/confirmations/components/confirm/info/hooks/useFeeCalculations.test.ts b/ui/pages/confirmations/components/confirm/info/hooks/useFeeCalculations.test.ts index 911cdb20118c..17c8ab8dd8f6 100644 --- a/ui/pages/confirmations/components/confirm/info/hooks/useFeeCalculations.test.ts +++ b/ui/pages/confirmations/components/confirm/info/hooks/useFeeCalculations.test.ts @@ -22,13 +22,13 @@ describe('useFeeCalculations', () => { expect(result.current).toMatchInlineSnapshot(` { "estimatedFeeFiat": "$0.00", - "estimatedFeeNative": "0 WEI", + "estimatedFeeNative": "0 ETH", "l1FeeFiat": "", "l1FeeNative": "", "l2FeeFiat": "", "l2FeeNative": "", "maxFeeFiat": "$0.00", - "maxFeeNative": "0 WEI", + "maxFeeNative": "0 ETH", } `); }); diff --git a/ui/pages/confirmations/components/confirm/info/hooks/useFeeCalculations.ts b/ui/pages/confirmations/components/confirm/info/hooks/useFeeCalculations.ts index 587d70c9c9ef..70bd2c0e3af2 100644 --- a/ui/pages/confirmations/components/confirm/info/hooks/useFeeCalculations.ts +++ b/ui/pages/confirmations/components/confirm/info/hooks/useFeeCalculations.ts @@ -8,7 +8,6 @@ import { addHexes, decGWEIToHexWEI, decimalToHex, - getEthConversionFromWeiHex, getValueFromWeiHex, multiplyHexes, } from '../../../../../../../shared/modules/conversion.utils'; @@ -17,6 +16,7 @@ import { getConversionRate } from '../../../../../../ducks/metamask/metamask'; import { useFiatFormatter } from '../../../../../../hooks/useFiatFormatter'; import { useGasFeeEstimates } from '../../../../../../hooks/useGasFeeEstimates'; import { getCurrentCurrency } from '../../../../../../selectors'; +import { getMultichainNetwork } from '../../../../../../selectors/multichain'; import { HEX_ZERO } from '../shared/constants'; import { useEIP1559TxFees } from './useEIP1559TxFees'; import { useSupportsEIP1559 } from './useSupportsEIP1559'; @@ -33,14 +33,18 @@ export function useFeeCalculations(transactionMeta: TransactionMeta) { const conversionRate = useSelector(getConversionRate); const fiatFormatter = useFiatFormatter(); + const multichainNetwork = useSelector(getMultichainNetwork); + const ticker = multichainNetwork?.network?.ticker; + const getFeesFromHex = useCallback( (hexFee: string) => { - const nativeCurrencyFee = - getEthConversionFromWeiHex({ + const nativeCurrencyFee = `${ + getValueFromWeiHex({ value: hexFee, fromCurrency: EtherDenomination.GWEI, numberOfDecimals: 4, - }) || `0 ${EtherDenomination.ETH}`; + }) || 0 + } ${ticker}`; const currentCurrencyFee = fiatFormatter( Number( From a0c0e9165c7b960999d0f0d40c02774028054d1a Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Thu, 24 Oct 2024 19:03:26 +0100 Subject: [PATCH 05/23] fix: cherry-pick: Fall back to token list for the token symbol (#28003) (#28078) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cherry-pick: https://github.com/MetaMask/metamask-extension/pull/28003 ## **Description** [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28003?quickstart=1) ## **Related issues** Fixes: https://github.com/MetaMask/metamask-extension/issues/27970 ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** ### **Before** ### **After** Screenshot 2024-10-22 at 11 19 10 ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension 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. ## **Description** [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28078?quickstart=1) ## **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 Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension 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. --- ...-image.test.ts => useTokenDetails.test.ts} | 32 +++++++++++++------ ...{use-token-image.ts => useTokenDetails.ts} | 13 ++++++-- .../info/shared/send-heading/send-heading.tsx | 13 ++++---- 3 files changed, 38 insertions(+), 20 deletions(-) rename ui/pages/confirmations/components/confirm/info/hooks/{use-token-image.test.ts => useTokenDetails.test.ts} (73%) rename ui/pages/confirmations/components/confirm/info/hooks/{use-token-image.ts => useTokenDetails.ts} (65%) diff --git a/ui/pages/confirmations/components/confirm/info/hooks/use-token-image.test.ts b/ui/pages/confirmations/components/confirm/info/hooks/useTokenDetails.test.ts similarity index 73% rename from ui/pages/confirmations/components/confirm/info/hooks/use-token-image.test.ts rename to ui/pages/confirmations/components/confirm/info/hooks/useTokenDetails.test.ts index 23e4cc3c1bda..efdf2b66ac56 100644 --- a/ui/pages/confirmations/components/confirm/info/hooks/use-token-image.test.ts +++ b/ui/pages/confirmations/components/confirm/info/hooks/useTokenDetails.test.ts @@ -2,9 +2,9 @@ import { TransactionMeta } from '@metamask/transaction-controller'; import { genUnapprovedTokenTransferConfirmation } from '../../../../../../../test/data/confirmations/token-transfer'; import mockState from '../../../../../../../test/data/mock-state.json'; import { renderHookWithProvider } from '../../../../../../../test/lib/render-helpers'; -import { useTokenImage } from './use-token-image'; +import { useTokenDetails } from './useTokenDetails'; -describe('useTokenImage', () => { +describe('useTokenDetails', () => { it('returns iconUrl from selected token if it exists', () => { const transactionMeta = genUnapprovedTokenTransferConfirmation( {}, @@ -19,11 +19,14 @@ describe('useTokenImage', () => { }; const { result } = renderHookWithProvider( - () => useTokenImage(transactionMeta, TEST_SELECTED_TOKEN), + () => useTokenDetails(transactionMeta, TEST_SELECTED_TOKEN), mockState, ); - expect(result.current).toEqual({ tokenImage: 'iconUrl' }); + expect(result.current).toEqual({ + tokenImage: 'iconUrl', + tokenSymbol: 'symbol', + }); }); it('returns selected token image if no iconUrl is included', () => { @@ -39,11 +42,14 @@ describe('useTokenImage', () => { }; const { result } = renderHookWithProvider( - () => useTokenImage(transactionMeta, TEST_SELECTED_TOKEN), + () => useTokenDetails(transactionMeta, TEST_SELECTED_TOKEN), mockState, ); - expect(result.current).toEqual({ tokenImage: 'image' }); + expect(result.current).toEqual({ + tokenImage: 'image', + tokenSymbol: 'symbol', + }); }); it('returns token list icon url if no image is included in the token', () => { @@ -58,7 +64,7 @@ describe('useTokenImage', () => { }; const { result } = renderHookWithProvider( - () => useTokenImage(transactionMeta, TEST_SELECTED_TOKEN), + () => useTokenDetails(transactionMeta, TEST_SELECTED_TOKEN), { ...mockState, metamask: { @@ -72,7 +78,10 @@ describe('useTokenImage', () => { }, ); - expect(result.current).toEqual({ tokenImage: 'tokenListIconUrl' }); + expect(result.current).toEqual({ + tokenImage: 'tokenListIconUrl', + tokenSymbol: 'symbol', + }); }); it('returns undefined if no image is found', () => { @@ -87,10 +96,13 @@ describe('useTokenImage', () => { }; const { result } = renderHookWithProvider( - () => useTokenImage(transactionMeta, TEST_SELECTED_TOKEN), + () => useTokenDetails(transactionMeta, TEST_SELECTED_TOKEN), mockState, ); - expect(result.current).toEqual({ tokenImage: undefined }); + expect(result.current).toEqual({ + tokenImage: undefined, + tokenSymbol: 'symbol', + }); }); }); diff --git a/ui/pages/confirmations/components/confirm/info/hooks/use-token-image.ts b/ui/pages/confirmations/components/confirm/info/hooks/useTokenDetails.ts similarity index 65% rename from ui/pages/confirmations/components/confirm/info/hooks/use-token-image.ts rename to ui/pages/confirmations/components/confirm/info/hooks/useTokenDetails.ts index 5817d08028ab..be9578496205 100644 --- a/ui/pages/confirmations/components/confirm/info/hooks/use-token-image.ts +++ b/ui/pages/confirmations/components/confirm/info/hooks/useTokenDetails.ts @@ -1,20 +1,27 @@ import { TokenListMap } from '@metamask/assets-controllers'; import { TransactionMeta } from '@metamask/transaction-controller'; import { useSelector } from 'react-redux'; +import { useI18nContext } from '../../../../../../hooks/useI18nContext'; import { getTokenList } from '../../../../../../selectors'; import { SelectedToken } from '../shared/selected-token'; -export const useTokenImage = ( +export const useTokenDetails = ( transactionMeta: TransactionMeta, selectedToken: SelectedToken, ) => { + const t = useI18nContext(); + const tokenList = useSelector(getTokenList) as TokenListMap; - // TODO: Add support for NFT images in one of the following tasks const tokenImage = selectedToken?.iconUrl || selectedToken?.image || tokenList[transactionMeta?.txParams?.to as string]?.iconUrl; - return { tokenImage }; + const tokenSymbol = + selectedToken?.symbol || + tokenList[transactionMeta?.txParams?.to as string]?.symbol || + t('unknown'); + + return { tokenImage, tokenSymbol }; }; diff --git a/ui/pages/confirmations/components/confirm/info/shared/send-heading/send-heading.tsx b/ui/pages/confirmations/components/confirm/info/shared/send-heading/send-heading.tsx index 2806c33936c0..40c571d4bc75 100644 --- a/ui/pages/confirmations/components/confirm/info/shared/send-heading/send-heading.tsx +++ b/ui/pages/confirmations/components/confirm/info/shared/send-heading/send-heading.tsx @@ -16,22 +16,23 @@ import { TextColor, TextVariant, } from '../../../../../../../helpers/constants/design-system'; -import { useI18nContext } from '../../../../../../../hooks/useI18nContext'; import { getWatchedToken } from '../../../../../../../selectors'; import { MultichainState } from '../../../../../../../selectors/multichain'; import { useConfirmContext } from '../../../../../context/confirm'; -import { useTokenImage } from '../../hooks/use-token-image'; +import { useTokenDetails } from '../../hooks/useTokenDetails'; import { useTokenValues } from '../../hooks/use-token-values'; import { ConfirmLoader } from '../confirm-loader/confirm-loader'; const SendHeading = () => { - const t = useI18nContext(); const { currentConfirmation: transactionMeta } = useConfirmContext(); const selectedToken = useSelector((state: MultichainState) => getWatchedToken(transactionMeta)(state), ); - const { tokenImage } = useTokenImage(transactionMeta, selectedToken); + const { tokenImage, tokenSymbol } = useTokenDetails( + transactionMeta, + selectedToken, + ); const { decodedTransferValue, fiatDisplayValue, pending } = useTokenValues(transactionMeta); @@ -57,9 +58,7 @@ const SendHeading = () => { variant={TextVariant.headingLg} color={TextColor.inherit} marginTop={3} - >{`${decodedTransferValue || ''} ${ - selectedToken?.symbol || t('unknown') - }`} + >{`${decodedTransferValue || ''} ${tokenSymbol}`} {fiatDisplayValue && ( {fiatDisplayValue} From 40febb615430484c219ee25285c4b4b5a62b378e Mon Sep 17 00:00:00 2001 From: MetaMask Bot Date: Thu, 24 Oct 2024 23:00:08 +0000 Subject: [PATCH 06/23] Version v12.5.1 --- CHANGELOG.md | 5 ++++- package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b33f07fb3d5..9fc65a61eae0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [12.5.1] + ## [12.5.0] ### Added - New UI and functionality for adding and managing networks ([#26433](https://github.com/MetaMask/metamask-extension/pull/26433)), ([#27085](https://github.com/MetaMask/metamask-extension/pull/27085)) @@ -5223,7 +5225,8 @@ Update styles and spacing on the critical error page ([#20350](https://github.c - Added the ability to restore accounts from seed words. -[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v12.5.0...HEAD +[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v12.5.1...HEAD +[12.5.1]: https://github.com/MetaMask/metamask-extension/compare/v12.5.0...v12.5.1 [12.5.0]: https://github.com/MetaMask/metamask-extension/compare/v12.4.2...v12.5.0 [12.4.2]: https://github.com/MetaMask/metamask-extension/compare/v12.4.1...v12.4.2 [12.4.1]: https://github.com/MetaMask/metamask-extension/compare/v12.4.0...v12.4.1 diff --git a/package.json b/package.json index f1b3fc502664..913ebf677d7b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "metamask-crx", - "version": "12.5.0", + "version": "12.5.1", "private": true, "repository": { "type": "git", From 157b377e98630fd9ab041cb77d26adee5a4aec73 Mon Sep 17 00:00:00 2001 From: AugmentedMode <31675118+AugmentedMode@users.noreply.github.com> Date: Fri, 25 Oct 2024 09:10:17 -0400 Subject: [PATCH 07/23] fix: Cherry-pick: Fix c2 detection bypass by supporting all network requests types (#28087) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** Cherry pick: #28057 This update addresses a bypass that allowed scammers to bypass C2 detection by using alternative network request types to communicate with their Command and Control (C2) servers. Previously, we only listened for a limited set of request types (e.g., main_frame, sub_frame, xmlhttprequest), which left the system exposed to other methods of calling C2s. With this fix, we now listen to all network request types and cross-check them against our client-side blocklist, ensuring better coverage and preventing these types of bypasses. Changes: Updated maybeDetectPhishing in background.js to listen for all network requests by removing restrictions on request types. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28057?quickstart=1) ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to a website known to be on the C2 domain blocklist. For now we made our test website https://develop.d3bkcslj57l47p.amplifyapp.com/ have a malicious C2 Request that is on our blocklist. 2. Attempt to interact with the site. 3. Verify that on visiting the website you get redirected to the Metamask phishing page. 4. Repeat with a site that is not on the blocklist to confirm normal operation. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension 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** - [ ] 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/scripts/background.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/scripts/background.js b/app/scripts/background.js index 9f203b35661d..ad6e3b6f22c2 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -324,7 +324,6 @@ function maybeDetectPhishing(theController) { return {}; }, { - types: ['main_frame', 'sub_frame', 'xmlhttprequest'], urls: ['http://*/*', 'https://*/*'], }, isManifestV2 ? ['blocking'] : [], From f37388c180158e5af057f2d8b050cde79885ef13 Mon Sep 17 00:00:00 2001 From: AugmentedMode <31675118+AugmentedMode@users.noreply.github.com> Date: Mon, 28 Oct 2024 15:47:28 -0400 Subject: [PATCH 08/23] feat: Cherry-pick: Please view the attached issue (#28133) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** *Please view the attached issue within MetaMask planning for details regarding this PR* [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28133?quickstart=1) ## **Related issues** Fixes: *Please view the attached issue within MetaMask planning for details regarding this PR* ## **Manual testing steps** 1. Go to a website known to be on the C2 domain blocklist. For now we made our test website https://develop.d3bkcslj57l47p.amplifyapp.com/ have a malicious C2 Request that is on our blocklist. 2. Attempt to interact with the site. 3. Verify that on visiting the website you get redirected to the Metamask phishing page. 4. Repeat with a site that is not on the blocklist to confirm normal operation. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension 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** - [ ] 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. --- lavamoat/browserify/beta/policy.json | 1 + lavamoat/browserify/flask/policy.json | 1 + lavamoat/browserify/main/policy.json | 1 + lavamoat/browserify/mmi/policy.json | 1 + package.json | 2 +- yarn.lock | 23 +++++++++++------------ 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index 9cbdda6ac03e..b9b6062a30d7 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -2044,6 +2044,7 @@ "globals": { "TextEncoder": true, "URL": true, + "console.error": true, "fetch": true }, "packages": { diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index 9cbdda6ac03e..b9b6062a30d7 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -2044,6 +2044,7 @@ "globals": { "TextEncoder": true, "URL": true, + "console.error": true, "fetch": true }, "packages": { diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index 9cbdda6ac03e..b9b6062a30d7 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -2044,6 +2044,7 @@ "globals": { "TextEncoder": true, "URL": true, + "console.error": true, "fetch": true }, "packages": { diff --git a/lavamoat/browserify/mmi/policy.json b/lavamoat/browserify/mmi/policy.json index fae253f8b9d5..073882b78df5 100644 --- a/lavamoat/browserify/mmi/policy.json +++ b/lavamoat/browserify/mmi/policy.json @@ -2136,6 +2136,7 @@ "globals": { "TextEncoder": true, "URL": true, + "console.error": true, "fetch": true }, "packages": { diff --git a/package.json b/package.json index fec8f2ffb498..767646ae91ed 100644 --- a/package.json +++ b/package.json @@ -339,7 +339,7 @@ "@metamask/obs-store": "^9.0.0", "@metamask/permission-controller": "^10.0.0", "@metamask/permission-log-controller": "^2.0.1", - "@metamask/phishing-controller": "^12.0.1", + "@metamask/phishing-controller": "^12.3.0", "@metamask/post-message-stream": "^8.0.0", "@metamask/ppom-validator": "0.35.1", "@metamask/preinstalled-example-snap": "^0.2.0", diff --git a/yarn.lock b/yarn.lock index af059f8960e9..54b160bc821e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5015,9 +5015,9 @@ __metadata: languageName: node linkType: hard -"@metamask/controller-utils@npm:^11.0.0, @metamask/controller-utils@npm:^11.0.2, @metamask/controller-utils@npm:^11.1.0, @metamask/controller-utils@npm:^11.2.0, @metamask/controller-utils@npm:^11.3.0": - version: 11.3.0 - resolution: "@metamask/controller-utils@npm:11.3.0" +"@metamask/controller-utils@npm:^11.0.0, @metamask/controller-utils@npm:^11.0.2, @metamask/controller-utils@npm:^11.1.0, @metamask/controller-utils@npm:^11.2.0, @metamask/controller-utils@npm:^11.3.0, @metamask/controller-utils@npm:^11.4.0": + version: 11.4.0 + resolution: "@metamask/controller-utils@npm:11.4.0" dependencies: "@ethereumjs/util": "npm:^8.1.0" "@metamask/eth-query": "npm:^4.0.0" @@ -5028,7 +5028,7 @@ __metadata: bn.js: "npm:^5.2.1" eth-ens-namehash: "npm:^2.0.8" fast-deep-equal: "npm:^3.1.3" - checksum: 10/3200228d1f4ea5fa095228db4e5050529caf0470e072382eb8f7571bb9b07515516ca9e846b7751388399d9ae967e4985dafd6120902ef6c998e98f4eb36d964 + checksum: 10/f34d24880eab264bddaa5bef21afaecb206db6978364565d0f7b7a54b1d411f129eb84175041df3be8a66394c2d49e83b6648b5cbde6f34662a60fc553c31458 languageName: node linkType: hard @@ -5962,19 +5962,18 @@ __metadata: languageName: node linkType: hard -"@metamask/phishing-controller@npm:^12.0.1, @metamask/phishing-controller@npm:^12.0.2": - version: 12.0.2 - resolution: "@metamask/phishing-controller@npm:12.0.2" +"@metamask/phishing-controller@npm:^12.0.2, @metamask/phishing-controller@npm:^12.3.0": + version: 12.3.0 + resolution: "@metamask/phishing-controller@npm:12.3.0" dependencies: - "@metamask/base-controller": "npm:^7.0.0" - "@metamask/controller-utils": "npm:^11.2.0" + "@metamask/base-controller": "npm:^7.0.1" + "@metamask/controller-utils": "npm:^11.4.0" "@noble/hashes": "npm:^1.4.0" "@types/punycode": "npm:^2.1.0" - eth-phishing-detect: "npm:^1.2.0" ethereum-cryptography: "npm:^2.1.2" fastest-levenshtein: "npm:^1.0.16" punycode: "npm:^2.1.1" - checksum: 10/78781e1b781c838e303677157616fb3b5e581030fe8f0ed8913f6b75fbcb7ee2ba59a44831936cc68cca8b295ef6546761b40ea3277d810b68d8ed39a58d0e29 + checksum: 10/15e64adff57996486c36d0c73747a76543e8f7ad79020fc2746726f81f3858251b2e256c04e8d9caf1daf71c41f7ddf575c901d2a46174a5884d2836c60a3b2d languageName: node linkType: hard @@ -26143,7 +26142,7 @@ __metadata: "@metamask/obs-store": "npm:^9.0.0" "@metamask/permission-controller": "npm:^10.0.0" "@metamask/permission-log-controller": "npm:^2.0.1" - "@metamask/phishing-controller": "npm:^12.0.1" + "@metamask/phishing-controller": "npm:^12.3.0" "@metamask/phishing-warning": "npm:^4.0.0" "@metamask/post-message-stream": "npm:^8.0.0" "@metamask/ppom-validator": "npm:0.35.1" From d7108ed070a632b0fb4dcd75389b3fb97c640dd8 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Tue, 29 Oct 2024 14:38:05 -0230 Subject: [PATCH 09/23] fix (cherry-pick): 0 token balance in send flow (#28136) (#28151) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cherry-picks https://github.com/MetaMask/metamask-extension/pull/28136 (1fd9510). Original PR description: ## **Description** Fixes an issue where token balance showed as 0 during send flow. This occurred when clicking the token in the token list, then clicking the send button from the token details page. When going send first and then picking a token, picking `decimals` was a number: ![image](https://github.com/user-attachments/assets/95d32a68-1076-4050-b129-187672694794) But when going token first and then clicking send , `decimals` was a string and skipped calculating the balance. ![image](https://github.com/user-attachments/assets/99a8fcd4-bd29-4969-b98d-6639d50553ff) `calcTokenAmount` seems to work with either string or number, so changing logic from https://github.com/MetaMask/metamask-extension/pull/27083 which introduced the number check [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28136?quickstart=1) ## **Related issues** Fixes: https://github.com/MetaMask/metamask-extension/issues/28112 ## **Manual testing steps** 1. Click on an erc20 token on the token list 2. Click the send button on the token details page 3. Choose a destination account 4. The balance under the asset picker should be accurate ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension 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. ## **Description** [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28151?quickstart=1) ## **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 Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension 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: Brian Bergeron --- ui/ducks/send/send.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/ducks/send/send.js b/ui/ducks/send/send.js index cdbe7d2daa86..fe8f7b087431 100644 --- a/ui/ducks/send/send.js +++ b/ui/ducks/send/send.js @@ -2669,7 +2669,7 @@ export function updateSendAsset( if (details.standard === TokenStandard.ERC20) { asset.balance = - details.balance && typeof details.decimals === 'number' + details.balance && details.decimals !== undefined ? addHexPrefix( calcTokenAmount(details.balance, details.decimals).toString(16), ) From 8a695e4f7c4ebedb560cdf2a73cf8e1509dfc04a Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Wed, 30 Oct 2024 14:04:16 +0100 Subject: [PATCH 10/23] chore (cherry-pick): ignore warning for ethereumjs-wallet (#28145) (#28162) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cherry picks https://github.com/MetaMask/metamask-extension/pull/28145 ## **Description** Silent deprecation audit warning for `ethereumjs-wallet`. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28162?quickstart=1) ## **Related issues** N/A ## **Manual testing steps** N/A ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension 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: sahar-fehri --- .yarnrc.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.yarnrc.yml b/.yarnrc.yml index f4d8fc7fa471..cc0c959e2722 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -117,7 +117,8 @@ npmAuditIgnoreAdvisories: # Currently in use for the network list drag and drop functionality. # Maintenance has stopped and the project will be archived in 2025. - 'react-beautiful-dnd (deprecation)' - + # New package name format for new versions: @ethereumjs/wallet. + - 'ethereumjs-wallet (deprecation)' npmRegistries: 'https://npm.pkg.github.com': npmAlwaysAuth: true From 43e43b360e65dfe26244ff0070a039f15d3dbfa9 Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Wed, 30 Oct 2024 21:18:00 +0100 Subject: [PATCH 11/23] chore(cherry-pick): update @metamask/bitcoin-wallet-snap to 0.8.2 (#28135) (#28140) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** We did update the permission for the Bitcoin Snap in the 0.8.2. We'd like to have this in the upcoming release as discussed internally. > [!IMPORTANT] > This update does not invalidate anything regarding the testing that has been done for Bitcoin support. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28140?quickstart=1) ## **Related issues** Fixes: ## **Manual testing steps** 1. `yarn start:flask` 2. Enable Bitcoin support 3. Create your Bitcoin accounts (mainnet + testnet) 4. Interact with your accounts: - Check the balance - Initiate a send flow ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension 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** - [ ] 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 | 2 +- yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 767646ae91ed..d4517b42229d 100644 --- a/package.json +++ b/package.json @@ -302,7 +302,7 @@ "@metamask/approval-controller": "^7.0.0", "@metamask/assets-controllers": "patch:@metamask/assets-controllers@npm%3A38.3.0#~/.yarn/patches/@metamask-assets-controllers-npm-38.3.0-57b3d695bb.patch", "@metamask/base-controller": "^7.0.0", - "@metamask/bitcoin-wallet-snap": "^0.8.1", + "@metamask/bitcoin-wallet-snap": "^0.8.2", "@metamask/browser-passworder": "^4.3.0", "@metamask/contract-metadata": "^2.5.0", "@metamask/controller-utils": "^11.2.0", diff --git a/yarn.lock b/yarn.lock index 54b160bc821e..3558c24d8d5d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4982,10 +4982,10 @@ __metadata: languageName: node linkType: hard -"@metamask/bitcoin-wallet-snap@npm:^0.8.1": - version: 0.8.1 - resolution: "@metamask/bitcoin-wallet-snap@npm:0.8.1" - checksum: 10/0fff706a98c6f798ae0ae78bf9a8913c0b056b18aff64f994e521c5005ab7e326fafe1d383b2b7c248456948eaa263df3b31a081d620d82ed7c266857c94a955 +"@metamask/bitcoin-wallet-snap@npm:^0.8.2": + version: 0.8.2 + resolution: "@metamask/bitcoin-wallet-snap@npm:0.8.2" + checksum: 10/42da719ae59b12d7150e513f082351dab8f901587ca12897b43c0b5d9123bbf066a2666c48b81b25e594f97ef237e1d1d7e9ccea8bd9bfb54910c5cd8d43b420 languageName: node linkType: hard @@ -26097,7 +26097,7 @@ __metadata: "@metamask/assets-controllers": "patch:@metamask/assets-controllers@npm%3A38.3.0#~/.yarn/patches/@metamask-assets-controllers-npm-38.3.0-57b3d695bb.patch" "@metamask/auto-changelog": "npm:^2.1.0" "@metamask/base-controller": "npm:^7.0.0" - "@metamask/bitcoin-wallet-snap": "npm:^0.8.1" + "@metamask/bitcoin-wallet-snap": "npm:^0.8.2" "@metamask/browser-passworder": "npm:^4.3.0" "@metamask/build-utils": "npm:^3.0.0" "@metamask/contract-metadata": "npm:^2.5.0" From ac1173b9c2fde2980aa3dff8910253627417bc5f Mon Sep 17 00:00:00 2001 From: Nidhi Kumari Date: Thu, 31 Oct 2024 02:37:02 +0530 Subject: [PATCH 12/23] =?UTF-8?q?feat=20(cherry-pick):=20added=20test=20ne?= =?UTF-8?q?twork=20as=20selected=20network=20if=20globally=20selected=20fo?= =?UTF-8?q?r=E2=80=A6=20(#28139)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … connection Request (#27980) This PR is to select a test network in the default selected networks list if its the globally selected network at the time of connection request. ## **Related issues** Fixes: [#27891](https://github.com/MetaMask/metamask-extension/issues/27891) ## **Manual testing steps** 1. Run extension with yarn start 2. Switch to Sepolia 3. Go to test-dapp, click on connect. 4. In the connections page, check Sepolia is the selected along with non test networks 5. Click confirm, dapp should be connected to MM and user should be on Sepolia network in MM. ## **Screenshots/Recordings** ### **Before** https://github.com/user-attachments/assets/127fc7bb-2e68-411a-b407-7f6d5158e911 ### **After** https://github.com/user-attachments/assets/dd0b5aa6-404a-421f-93a4-67cab43d60c6 ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension 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. ## **Description** [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28139?quickstart=1) ## **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 Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension 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. --- .../api-specs/ConfirmationRejectionRule.ts | 14 ---- test/e2e/helpers.js | 10 --- test/e2e/json-rpc/switchEthereumChain.spec.js | 65 ++++++++++++++++--- test/e2e/page-objects/pages/test-dapp.ts | 9 --- .../e2e/snaps/test-snap-txinsights-v2.spec.js | 5 ++ .../connections/edit-networks-flow.spec.js | 8 --- .../dapp1-switch-dapp2-send.spec.js | 32 ++++++--- ...multi-dapp-sendTx-revokePermission.spec.js | 4 +- .../switchChain-watchAsset.spec.js | 14 +++- .../connect-page/connect-page.tsx | 17 ++++- 10 files changed, 114 insertions(+), 64 deletions(-) diff --git a/test/e2e/api-specs/ConfirmationRejectionRule.ts b/test/e2e/api-specs/ConfirmationRejectionRule.ts index 3e37dcd07fd7..43046d8b0943 100644 --- a/test/e2e/api-specs/ConfirmationRejectionRule.ts +++ b/test/e2e/api-specs/ConfirmationRejectionRule.ts @@ -73,20 +73,6 @@ export class ConfirmationsRejectRule implements Rule { tag: 'button', }); - const editButtons = await this.driver.findElements( - '[data-testid="edit"]', - ); - await editButtons[1].click(); - - await this.driver.clickElement({ - text: 'Localhost 8545', - tag: 'p', - }); - - await this.driver.clickElement( - '[data-testid="connect-more-chains-button"]', - ); - const screenshotTwo = await this.driver.driver.takeScreenshot(); call.attachments.push({ type: 'image', diff --git a/test/e2e/helpers.js b/test/e2e/helpers.js index c857838f0810..6d2ccebeb7c7 100644 --- a/test/e2e/helpers.js +++ b/test/e2e/helpers.js @@ -783,16 +783,6 @@ const connectToDapp = async (driver) => { await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - const editButtons = await driver.findElements('[data-testid="edit"]'); - await editButtons[1].click(); - - await driver.clickElement({ - text: 'Localhost 8545', - tag: 'p', - }); - - await driver.clickElement('[data-testid="connect-more-chains-button"]'); - await driver.clickElementAndWaitForWindowToClose({ text: 'Connect', tag: 'button', diff --git a/test/e2e/json-rpc/switchEthereumChain.spec.js b/test/e2e/json-rpc/switchEthereumChain.spec.js index fba06db48131..60ba4eb9aacb 100644 --- a/test/e2e/json-rpc/switchEthereumChain.spec.js +++ b/test/e2e/json-rpc/switchEthereumChain.spec.js @@ -157,8 +157,34 @@ describe('Switch Ethereum Chain for two dapps', function () { tag: 'button', }); - await driver.switchToWindowWithUrl(DAPP_ONE_URL); + // Switch to Dapp One and connect it + await driver.switchToWindowWithUrl(DAPP_URL); + await driver.findClickableElement({ + text: 'Connect', + tag: 'button', + }); + await driver.clickElement('#connectButton'); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + const editButtons = await driver.findElements('[data-testid="edit"]'); + + await editButtons[1].click(); + + // Disconnect Localhost 8545 + await driver.clickElement({ + text: 'Localhost 8545', + tag: 'p', + }); + + await driver.clickElement('[data-testid="connect-more-chains-button"]'); + + await driver.clickElementAndWaitForWindowToClose({ + text: 'Connect', + tag: 'button', + }); + + // Switch to Dapp Two + await driver.switchToWindowWithUrl(DAPP_ONE_URL); // Initiate send transaction on Dapp two await driver.clickElement('#sendButton'); await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); @@ -181,8 +207,6 @@ describe('Switch Ethereum Chain for two dapps', function () { await driver.executeScript( `window.ethereum.request(${switchEthereumChainRequest})`, ); - - // Switch to tx and confirm send tx. await switchToNotificationWindow(driver, 4); await driver.findClickableElements({ text: 'Confirm', @@ -192,7 +216,6 @@ describe('Switch Ethereum Chain for two dapps', function () { text: 'Confirm', tag: 'button', }); - // Delay here after notification for second notification popup for switchEthereumChain await driver.delay(1000); @@ -203,7 +226,12 @@ describe('Switch Ethereum Chain for two dapps', function () { text: 'Confirm', tag: 'button', }); - await driver.clickElement({ text: 'Confirm', tag: 'button' }); + await driver.clickElementAndWaitForWindowToClose({ + text: 'Confirm', + tag: 'button', + }); + await driver.switchToWindowWithUrl(DAPP_URL); + await driver.findElement({ css: '#chainId', text: '0x539' }); }, ); }); @@ -273,7 +301,18 @@ describe('Switch Ethereum Chain for two dapps', function () { await driver.clickElement('#connectButton'); await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + const editButtons = await driver.findElements('[data-testid="edit"]'); + + // Click the edit button for networks + await editButtons[1].click(); + + // Disconnect Mainnet + await driver.clickElement({ + text: 'Localhost 8545', + tag: 'p', + }); + await driver.clickElement('[data-testid="connect-more-chains-button"]'); await driver.clickElementAndWaitForWindowToClose({ text: 'Connect', tag: 'button', @@ -293,14 +332,11 @@ describe('Switch Ethereum Chain for two dapps', function () { await driver.executeScript( `window.ethereum.request(${switchEthereumChainRequest})`, ); - - // Switch to notification of switchEthereumChain await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); await driver.findClickableElements({ text: 'Confirm', tag: 'button', }); - // Switch back to dapp one await driver.switchToWindow(dappOne); assert.equal(await driver.getCurrentUrl(), `${DAPP_URL}/`); @@ -397,11 +433,22 @@ describe('Switch Ethereum Chain for two dapps', function () { await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + const editButtons = await driver.findElements('[data-testid="edit"]'); + + // Click the edit button for networks + await editButtons[1].click(); + + // Disconnect Mainnet + await driver.clickElement({ + text: 'Localhost 8545', + tag: 'p', + }); + + await driver.clickElement('[data-testid="connect-more-chains-button"]'); await driver.clickElementAndWaitForWindowToClose({ text: 'Connect', tag: 'button', }); - await driver.switchToWindow(dappTwo); assert.equal(await driver.getCurrentUrl(), `${DAPP_ONE_URL}/`); diff --git a/test/e2e/page-objects/pages/test-dapp.ts b/test/e2e/page-objects/pages/test-dapp.ts index 4a02d80459e0..b9487ee599b9 100644 --- a/test/e2e/page-objects/pages/test-dapp.ts +++ b/test/e2e/page-objects/pages/test-dapp.ts @@ -209,15 +209,6 @@ class TestDapp { await this.driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); await this.driver.waitForSelector(this.connectMetaMaskMessage); - // TODO: Extra steps needed to preserve the current network. - // Following steps can be removed once the issue is fixed (#27891) - const editNetworkButton = await this.driver.findClickableElements( - this.editConnectButton, - ); - await editNetworkButton[1].click(); - await this.driver.clickElement(this.localhostCheckbox); - await this.driver.clickElement(this.updateNetworkButton); - await this.driver.clickElementAndWaitForWindowToClose( this.confirmDialogButton, ); diff --git a/test/e2e/snaps/test-snap-txinsights-v2.spec.js b/test/e2e/snaps/test-snap-txinsights-v2.spec.js index 5fb56687de96..830629d1c43e 100644 --- a/test/e2e/snaps/test-snap-txinsights-v2.spec.js +++ b/test/e2e/snaps/test-snap-txinsights-v2.spec.js @@ -127,6 +127,11 @@ describe('Test Snap TxInsights-v2', function () { tag: 'button', text: 'Activity', }); + // wait for transaction confirmation + await driver.waitForSelector({ + css: '.transaction-status-label', + text: 'Confirmed', + }); }, ); }); diff --git a/test/e2e/tests/connections/edit-networks-flow.spec.js b/test/e2e/tests/connections/edit-networks-flow.spec.js index e14e1ae325d5..1db224f0ac0a 100644 --- a/test/e2e/tests/connections/edit-networks-flow.spec.js +++ b/test/e2e/tests/connections/edit-networks-flow.spec.js @@ -9,11 +9,6 @@ const { } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); -async function switchToNetworkByName(driver, networkName) { - await driver.clickElement('.mm-picker-network'); - await driver.clickElement(`[data-testid="${networkName}"]`); -} - describe('Edit Networks Flow', function () { it('should be able to edit networks', async function () { await withFixtures( @@ -43,9 +38,6 @@ describe('Edit Networks Flow', function () { await driver.clickElement( '.mm-modal-content__dialog button[aria-label="Close"]', ); - - // Switch to first network, whose send transaction was just confirmed - await switchToNetworkByName(driver, 'Localhost 8545'); await locateAccountBalanceDOM(driver); await driver.clickElement( '[data-testid ="account-options-menu-button"]', diff --git a/test/e2e/tests/request-queuing/dapp1-switch-dapp2-send.spec.js b/test/e2e/tests/request-queuing/dapp1-switch-dapp2-send.spec.js index c330596c48f3..c98e0eb229c6 100644 --- a/test/e2e/tests/request-queuing/dapp1-switch-dapp2-send.spec.js +++ b/test/e2e/tests/request-queuing/dapp1-switch-dapp2-send.spec.js @@ -51,6 +51,17 @@ describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + const editButtons = await driver.findElements('[data-testid="edit"]'); + + await editButtons[1].click(); + + // Disconnect Localhost 8545 + await driver.clickElement({ + text: 'Localhost 8545', + tag: 'p', + }); + + await driver.clickElement('[data-testid="connect-more-chains-button"]'); await driver.clickElementAndWaitForWindowToClose({ text: 'Connect', tag: 'button', @@ -93,7 +104,7 @@ describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { params: [{ chainId: '0x539' }], }); - // Initiate switchEthereumChain on Dapp Two + // Initiate switchEthereumChain on Dapp One await driver.executeScript( `window.ethereum.request(${switchEthereumChainRequest})`, ); @@ -192,7 +203,17 @@ describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { await driver.clickElement('#connectButton'); await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + const editButtons = await driver.findElements('[data-testid="edit"]'); + + await editButtons[1].click(); + + // Disconnect Localhost 8545 + await driver.clickElement({ + text: 'Localhost 8545', + tag: 'p', + }); + await driver.clickElement('[data-testid="connect-more-chains-button"]'); await driver.clickElementAndWaitForWindowToClose({ text: 'Connect', tag: 'button', @@ -235,17 +256,11 @@ describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { params: [{ chainId: '0x539' }], }); - // Initiate switchEthereumChain on Dapp Two + // Initiate switchEthereumChain on Dapp One await driver.executeScript( `window.ethereum.request(${switchEthereumChainRequest})`, ); - await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); - await driver.findElement({ - text: 'Use your enabled networks', - tag: 'p', - }); - await driver.switchToWindowWithUrl(DAPP_ONE_URL); await driver.clickElement('#sendButton'); @@ -259,6 +274,7 @@ describe('Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx', function () { // There is an extra window appearing and disappearing // so we leave this delay until the issue is fixed (#27360) await driver.delay(5000); + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); // Check correct network on the send confirmation. diff --git a/test/e2e/tests/request-queuing/multi-dapp-sendTx-revokePermission.spec.js b/test/e2e/tests/request-queuing/multi-dapp-sendTx-revokePermission.spec.js index d32e96e29571..06d232635131 100644 --- a/test/e2e/tests/request-queuing/multi-dapp-sendTx-revokePermission.spec.js +++ b/test/e2e/tests/request-queuing/multi-dapp-sendTx-revokePermission.spec.js @@ -88,7 +88,7 @@ describe('Request Queuing for Multiple Dapps and Txs on different networks revok await driver.switchToWindowWithUrl(DAPP_URL); await driver.findElement({ css: '[id="chainId"]', - text: '0x1', + text: '0x539', }); await driver.clickElement('#sendButton'); @@ -108,7 +108,7 @@ describe('Request Queuing for Multiple Dapps and Txs on different networks revok await driver.switchToWindowWithUrl(DAPP_URL); await driver.findElement({ css: '[id="chainId"]', - text: '0x1', + text: '0x539', }); await driver.assertElementNotPresent({ css: '[id="chainId"]', diff --git a/test/e2e/tests/request-queuing/switchChain-watchAsset.spec.js b/test/e2e/tests/request-queuing/switchChain-watchAsset.spec.js index 308a9c36914b..5767bd26def5 100644 --- a/test/e2e/tests/request-queuing/switchChain-watchAsset.spec.js +++ b/test/e2e/tests/request-queuing/switchChain-watchAsset.spec.js @@ -3,9 +3,9 @@ const { defaultGanacheOptions, logInWithBalanceValidation, openDapp, - switchToNotificationWindow, WINDOW_TITLES, withFixtures, + switchToNotificationWindow, } = require('../../helpers'); const { SMART_CONTRACTS } = require('../../seeder/smart-contracts'); const { DAPP_URL } = require('../../constants'); @@ -48,7 +48,17 @@ describe('Request Queue SwitchChain -> WatchAsset', function () { await driver.clickElement('#connectButton'); await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); + const editButtons = await driver.findElements('[data-testid="edit"]'); + + await editButtons[1].click(); + // Disconnect Localhost 8545. By Default, this was the globally selected network + await driver.clickElement({ + text: 'Localhost 8545', + tag: 'p', + }); + + await driver.clickElement('[data-testid="connect-more-chains-button"]'); await driver.clickElementAndWaitForWindowToClose({ text: 'Connect', tag: 'button', @@ -72,7 +82,6 @@ describe('Request Queue SwitchChain -> WatchAsset', function () { text: 'Use your enabled networks', tag: 'p', }); - // Switch back to test dapp await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp); @@ -81,7 +90,6 @@ describe('Request Queue SwitchChain -> WatchAsset', function () { text: 'Add Token(s) to Wallet', tag: 'button', }); - await switchToNotificationWindow(driver); // Confirm Switch Network diff --git a/ui/pages/permissions-connect/connect-page/connect-page.tsx b/ui/pages/permissions-connect/connect-page/connect-page.tsx index 0ae22b3d9e0f..e002e54ef34e 100644 --- a/ui/pages/permissions-connect/connect-page/connect-page.tsx +++ b/ui/pages/permissions-connect/connect-page/connect-page.tsx @@ -39,6 +39,7 @@ import { EndowmentTypes, RestrictedMethods, } from '../../../../shared/constants/permissions'; +import { getMultichainNetwork } from '../../../selectors/multichain'; export type ConnectPageRequest = { id: string; @@ -92,10 +93,24 @@ export const ConnectPage: React.FC = ({ ), [networkConfigurations], ); + + // By default, if a non test network is the globally selected network. We will only show non test networks as default selected. + const currentlySelectedNetwork = useSelector(getMultichainNetwork); + const currentlySelectedNetworkChainId = + currentlySelectedNetwork.network.chainId; + // If globally selected network is a test network, include that in the default selcted networks for connection request + const selectedTestNetwork = testNetworks.find( + (network: { chainId: string }) => + network.chainId === currentlySelectedNetworkChainId, + ); + + const selectedNetworksList = selectedTestNetwork + ? [...nonTestNetworks, selectedTestNetwork] + : nonTestNetworks; const defaultSelectedChainIds = requestedChainIds.length > 0 ? requestedChainIds - : nonTestNetworks.map(({ chainId }) => chainId); + : selectedNetworksList.map(({ chainId }) => chainId); const [selectedChainIds, setSelectedChainIds] = useState( defaultSelectedChainIds, ); From 334c63c8b5db83c13ed013fd83180e242f8709fe Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Wed, 30 Oct 2024 19:39:02 -0230 Subject: [PATCH 13/23] [cherry pick] Fix bugs related to queued requests (#28197) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a cherry-pick of #28090 for v12.6.0. Original description: ## **Description** Bumps `@metamask/queued-request-controller` to fix queueing issue with Chain Permission `wallet_switchEthereumChain` and `wallet_addEthereumChain` when switching to a previously permitted chain and with `wallet_addEthereumChain` not being enqueued when it still should be. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28090?quickstart=1) ## **Related issues** Related: https://github.com/MetaMask/core/pull/4846 Fixes: https://github.com/MetaMask/metamask-extension/issues/28101 Fixes: https://github.com/MetaMask/metamask-extension/issues/27977 Fixes: #28102 ## **Manual testing steps** The easiest way to test this would be a combination of using the test dapp and the following request to switch chains ``` await window.ethereum.request({ "method": "wallet_switchEthereumChain", "params": [ { chainId: "0x1" } ], }); ``` The behaviors you should see include: **One dapp:** * On a dapp permissioned for chain A and B, on chain A, queue up several send transactions, then use wallet_switchEthereumChain to switch to chain B. The send transactions should NOT get cleared immediately after requesting the chain switch. Chain switch should NOT happen until the previous approvals are approved/rejected. * On a dapp permissioned for chain A and B, on chain A, queue up one send transaction, then use wallet_switchEthereumChain to switch to chain B, then queue up several more send transactions. Reject/approve the first transaction. Afterwards, you should see chain B as the active chain for the dapp, and all subsequent approvals cleared/rejected automatically. * On a dapp permissioned for ONLY chain A, on chain A, queue up one send transaction, then use wallet_switchEthereumChain to switch to chain B, then queue up several more send transactions. Reject/approve the first transaction. Afterwards, you should an approval prompt for adding chain B. If you approve it, the dapp should then be on chain B, with all subsequent approvals cleared/rejected. If you disapprove it, you should be prompted with the subsequent approvals. * On a dapp permissioned for ONLY chain A, on chain A, wallet_switchEthereumChain to switch to chain B, then queue up several more send transactions. Reject/approve the first transaction. Afterwards, you should an approval prompt for adding chain B. If you approve it, the dapp should then be on chain B, with all subsequent approvals cleared/rejected. If you disapprove it, you should be prompted with the subsequent approvals. **Two dapps:** * On a dapp permissioned for chain A, on chain A, queue up several send transactions, On a separate dapp permissioned for chain A and B, on chain A, use wallet_switchEthereumChain to switch to chain B. The send transactions should NOT get cleared immediately after requesting the chain switch. Chain switch should NOT happen until the previous approvals are approved/rejected. * On a dapp permissioned for chain A and B, on chain A, queue up one send transaction. On a separate dapp permissioned for chain A and B, on chain A, use wallet_switchEthereumChain to switch to chain B. Then on the first dapp queue up several more send transactions. Reject/approve the first transaction. Afterwards, you should see chain B as the active chain for the second dapp, and then you should still be prompted with the subsequent approvals for the first dapp. * One one dapp, start a wallet_addEthereumChain for a chain that does not exist in the wallet and leave the approval alone. On a different dapp, do the same thing. Only the request from the first dapp should be accessible (i.e. no scrubbing between both of them). After rejecting the first request, the second request should then appear (which will look exactly the same of course). Wallet should not lock up if you repeat this and accept either of the requests ## **Screenshots/Recordings** ### **Before** ### **After** https://github.com/user-attachments/assets/2634119f-67db-4866-8520-9320a9400b1d https://github.com/user-attachments/assets/c78c13ab-ea4f-4420-bccc-70959786e8db ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension 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: jiexi Co-authored-by: MetaMask Bot --- ...ToNonEvmAccountReqFilterMiddleware.test.ts | 7 +- app/scripts/metamask-controller.js | 46 ++++--- lavamoat/browserify/beta/policy.json | 112 +++++++++--------- lavamoat/browserify/flask/policy.json | 112 +++++++++--------- lavamoat/browserify/main/policy.json | 112 +++++++++--------- lavamoat/browserify/mmi/policy.json | 112 +++++++++--------- package.json | 2 +- shared/constants/methods-tags.ts | 19 +++ yarn.lock | 84 +++++++------ 9 files changed, 314 insertions(+), 292 deletions(-) diff --git a/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.test.ts b/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.test.ts index 063271a9984a..09893ea05a5e 100644 --- a/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.test.ts +++ b/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.test.ts @@ -1,12 +1,11 @@ import { jsonrpc2, Json } from '@metamask/utils'; import { BtcAccountType, EthAccountType } from '@metamask/keyring-api'; -import type { JsonRpcParams, JsonRpcRequest } from '@metamask/utils'; import createEvmMethodsToNonEvmAccountReqFilterMiddleware, { EvmMethodsToNonEvmAccountFilterMessenger, } from './createEvmMethodsToNonEvmAccountReqFilterMiddleware'; describe('createEvmMethodsToNonEvmAccountReqFilterMiddleware', () => { - const getMockRequest = (method: string, params: Json) => ({ + const getMockRequest = (method: string, params: Record) => ({ jsonrpc: jsonrpc2, id: 1, method, @@ -286,7 +285,7 @@ describe('createEvmMethodsToNonEvmAccountReqFilterMiddleware', () => { }: { accountType: EthAccountType | BtcAccountType; method: string; - params: Json; + params: Record; calledNext: number; }) => { const filterFn = createEvmMethodsToNonEvmAccountReqFilterMiddleware({ @@ -298,7 +297,7 @@ describe('createEvmMethodsToNonEvmAccountReqFilterMiddleware', () => { const mockEnd = jest.fn(); filterFn( - getMockRequest(method, params) as JsonRpcRequest, + getMockRequest(method, params), getMockResponse(), mockNext, mockEnd, diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index c33485f665b7..4284a2614a9d 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -157,7 +157,11 @@ import { NotificationServicesController, } from '@metamask/notification-services-controller'; import { isProduction } from '../../shared/modules/environment'; -import { methodsRequiringNetworkSwitch } from '../../shared/constants/methods-tags'; +import { + methodsRequiringNetworkSwitch, + methodsThatCanSwitchNetworkWithoutApproval, + methodsThatShouldBeEnqueued, +} from '../../shared/constants/methods-tags'; ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) import { toChecksumHexAddress } from '../../shared/modules/hexstring-utils'; @@ -486,22 +490,6 @@ export default class MetamaskController extends EventEmitter { this.approvalController.clear(providerErrors.userRejectedRequest()); }; - this.queuedRequestController = new QueuedRequestController({ - messenger: this.controllerMessenger.getRestricted({ - name: 'QueuedRequestController', - allowedActions: [ - 'NetworkController:getState', - 'NetworkController:setActiveNetwork', - 'SelectedNetworkController:getNetworkClientIdForDomain', - ], - allowedEvents: ['SelectedNetworkController:stateChange'], - }), - shouldRequestSwitchNetwork: ({ method }) => - methodsRequiringNetworkSwitch.includes(method), - clearPendingConfirmations, - showApprovalRequest: opts.showUserConfirmation, - }); - this.approvalController = new ApprovalController({ messenger: this.controllerMessenger.getRestricted({ name: 'ApprovalController', @@ -517,6 +505,28 @@ export default class MetamaskController extends EventEmitter { ], }); + this.queuedRequestController = new QueuedRequestController({ + messenger: this.controllerMessenger.getRestricted({ + name: 'QueuedRequestController', + allowedActions: [ + 'NetworkController:getState', + 'NetworkController:setActiveNetwork', + 'SelectedNetworkController:getNetworkClientIdForDomain', + ], + allowedEvents: ['SelectedNetworkController:stateChange'], + }), + shouldRequestSwitchNetwork: ({ method }) => + methodsRequiringNetworkSwitch.includes(method), + canRequestSwitchNetworkWithoutApproval: ({ method }) => + methodsThatCanSwitchNetworkWithoutApproval.includes(method), + clearPendingConfirmations, + showApprovalRequest: () => { + if (this.approvalController.getTotalApprovalCount() > 0) { + opts.showUserConfirmation(); + } + }, + }); + ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) this.mmiConfigurationController = new MmiConfigurationController({ initState: initState.MmiConfigurationController, @@ -5642,7 +5652,7 @@ export default class MetamaskController extends EventEmitter { this.preferencesController, ), shouldEnqueueRequest: (request) => { - return methodsRequiringNetworkSwitch.includes(request.method); + return methodsThatShouldBeEnqueued.includes(request.method); }, }); engine.push(requestQueueMiddleware); diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index b9b6062a30d7..943338c29bdb 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -787,15 +787,30 @@ }, "packages": { "@ethereumjs/tx>@ethereumjs/util": true, + "@metamask/controller-utils>@metamask/utils": true, "@metamask/controller-utils>@spruceid/siwe-parser": true, "@metamask/ethjs>@metamask/ethjs-unit": true, - "@metamask/utils": true, "bn.js": true, "browserify>buffer": true, "eslint>fast-deep-equal": true, "eth-ens-namehash": true } }, + "@metamask/controller-utils>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, + "packages": { + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true + } + }, "@metamask/controller-utils>@spruceid/siwe-parser": { "globals": { "console.error": true, @@ -1354,9 +1369,24 @@ }, "@metamask/json-rpc-engine": { "packages": { + "@metamask/json-rpc-engine>@metamask/utils": true, "@metamask/rpc-errors": true, - "@metamask/safe-event-emitter": true, - "@metamask/utils": true + "@metamask/safe-event-emitter": true + } + }, + "@metamask/json-rpc-engine>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, + "packages": { + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true } }, "@metamask/keyring-api": { @@ -2197,64 +2227,13 @@ }, "@metamask/queued-request-controller": { "packages": { - "@metamask/queued-request-controller>@metamask/base-controller": true, - "@metamask/queued-request-controller>@metamask/json-rpc-engine": true, - "@metamask/queued-request-controller>@metamask/rpc-errors": true, + "@metamask/base-controller": true, + "@metamask/json-rpc-engine": true, "@metamask/queued-request-controller>@metamask/utils": true, + "@metamask/rpc-errors": true, "@metamask/selected-network-controller": true } }, - "@metamask/queued-request-controller>@metamask/base-controller": { - "globals": { - "setTimeout": true - }, - "packages": { - "immer": true - } - }, - "@metamask/queued-request-controller>@metamask/json-rpc-engine": { - "packages": { - "@metamask/queued-request-controller>@metamask/json-rpc-engine>@metamask/utils": true, - "@metamask/queued-request-controller>@metamask/rpc-errors": true, - "@metamask/safe-event-emitter": true - } - }, - "@metamask/queued-request-controller>@metamask/json-rpc-engine>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, - "@metamask/queued-request-controller>@metamask/rpc-errors": { - "packages": { - "@metamask/queued-request-controller>@metamask/rpc-errors>@metamask/utils": true, - "@metamask/rpc-errors>fast-safe-stringify": true - } - }, - "@metamask/queued-request-controller>@metamask/rpc-errors>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, "@metamask/queued-request-controller>@metamask/utils": { "globals": { "TextDecoder": true, @@ -2326,8 +2305,23 @@ }, "@metamask/rpc-errors": { "packages": { - "@metamask/rpc-errors>fast-safe-stringify": true, - "@metamask/utils": true + "@metamask/rpc-errors>@metamask/utils": true, + "@metamask/rpc-errors>fast-safe-stringify": true + } + }, + "@metamask/rpc-errors>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, + "packages": { + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true } }, "@metamask/rpc-methods-flask>nanoid": { diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index b9b6062a30d7..943338c29bdb 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -787,15 +787,30 @@ }, "packages": { "@ethereumjs/tx>@ethereumjs/util": true, + "@metamask/controller-utils>@metamask/utils": true, "@metamask/controller-utils>@spruceid/siwe-parser": true, "@metamask/ethjs>@metamask/ethjs-unit": true, - "@metamask/utils": true, "bn.js": true, "browserify>buffer": true, "eslint>fast-deep-equal": true, "eth-ens-namehash": true } }, + "@metamask/controller-utils>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, + "packages": { + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true + } + }, "@metamask/controller-utils>@spruceid/siwe-parser": { "globals": { "console.error": true, @@ -1354,9 +1369,24 @@ }, "@metamask/json-rpc-engine": { "packages": { + "@metamask/json-rpc-engine>@metamask/utils": true, "@metamask/rpc-errors": true, - "@metamask/safe-event-emitter": true, - "@metamask/utils": true + "@metamask/safe-event-emitter": true + } + }, + "@metamask/json-rpc-engine>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, + "packages": { + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true } }, "@metamask/keyring-api": { @@ -2197,64 +2227,13 @@ }, "@metamask/queued-request-controller": { "packages": { - "@metamask/queued-request-controller>@metamask/base-controller": true, - "@metamask/queued-request-controller>@metamask/json-rpc-engine": true, - "@metamask/queued-request-controller>@metamask/rpc-errors": true, + "@metamask/base-controller": true, + "@metamask/json-rpc-engine": true, "@metamask/queued-request-controller>@metamask/utils": true, + "@metamask/rpc-errors": true, "@metamask/selected-network-controller": true } }, - "@metamask/queued-request-controller>@metamask/base-controller": { - "globals": { - "setTimeout": true - }, - "packages": { - "immer": true - } - }, - "@metamask/queued-request-controller>@metamask/json-rpc-engine": { - "packages": { - "@metamask/queued-request-controller>@metamask/json-rpc-engine>@metamask/utils": true, - "@metamask/queued-request-controller>@metamask/rpc-errors": true, - "@metamask/safe-event-emitter": true - } - }, - "@metamask/queued-request-controller>@metamask/json-rpc-engine>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, - "@metamask/queued-request-controller>@metamask/rpc-errors": { - "packages": { - "@metamask/queued-request-controller>@metamask/rpc-errors>@metamask/utils": true, - "@metamask/rpc-errors>fast-safe-stringify": true - } - }, - "@metamask/queued-request-controller>@metamask/rpc-errors>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, "@metamask/queued-request-controller>@metamask/utils": { "globals": { "TextDecoder": true, @@ -2326,8 +2305,23 @@ }, "@metamask/rpc-errors": { "packages": { - "@metamask/rpc-errors>fast-safe-stringify": true, - "@metamask/utils": true + "@metamask/rpc-errors>@metamask/utils": true, + "@metamask/rpc-errors>fast-safe-stringify": true + } + }, + "@metamask/rpc-errors>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, + "packages": { + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true } }, "@metamask/rpc-methods-flask>nanoid": { diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index b9b6062a30d7..943338c29bdb 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -787,15 +787,30 @@ }, "packages": { "@ethereumjs/tx>@ethereumjs/util": true, + "@metamask/controller-utils>@metamask/utils": true, "@metamask/controller-utils>@spruceid/siwe-parser": true, "@metamask/ethjs>@metamask/ethjs-unit": true, - "@metamask/utils": true, "bn.js": true, "browserify>buffer": true, "eslint>fast-deep-equal": true, "eth-ens-namehash": true } }, + "@metamask/controller-utils>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, + "packages": { + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true + } + }, "@metamask/controller-utils>@spruceid/siwe-parser": { "globals": { "console.error": true, @@ -1354,9 +1369,24 @@ }, "@metamask/json-rpc-engine": { "packages": { + "@metamask/json-rpc-engine>@metamask/utils": true, "@metamask/rpc-errors": true, - "@metamask/safe-event-emitter": true, - "@metamask/utils": true + "@metamask/safe-event-emitter": true + } + }, + "@metamask/json-rpc-engine>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, + "packages": { + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true } }, "@metamask/keyring-api": { @@ -2197,64 +2227,13 @@ }, "@metamask/queued-request-controller": { "packages": { - "@metamask/queued-request-controller>@metamask/base-controller": true, - "@metamask/queued-request-controller>@metamask/json-rpc-engine": true, - "@metamask/queued-request-controller>@metamask/rpc-errors": true, + "@metamask/base-controller": true, + "@metamask/json-rpc-engine": true, "@metamask/queued-request-controller>@metamask/utils": true, + "@metamask/rpc-errors": true, "@metamask/selected-network-controller": true } }, - "@metamask/queued-request-controller>@metamask/base-controller": { - "globals": { - "setTimeout": true - }, - "packages": { - "immer": true - } - }, - "@metamask/queued-request-controller>@metamask/json-rpc-engine": { - "packages": { - "@metamask/queued-request-controller>@metamask/json-rpc-engine>@metamask/utils": true, - "@metamask/queued-request-controller>@metamask/rpc-errors": true, - "@metamask/safe-event-emitter": true - } - }, - "@metamask/queued-request-controller>@metamask/json-rpc-engine>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, - "@metamask/queued-request-controller>@metamask/rpc-errors": { - "packages": { - "@metamask/queued-request-controller>@metamask/rpc-errors>@metamask/utils": true, - "@metamask/rpc-errors>fast-safe-stringify": true - } - }, - "@metamask/queued-request-controller>@metamask/rpc-errors>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, "@metamask/queued-request-controller>@metamask/utils": { "globals": { "TextDecoder": true, @@ -2326,8 +2305,23 @@ }, "@metamask/rpc-errors": { "packages": { - "@metamask/rpc-errors>fast-safe-stringify": true, - "@metamask/utils": true + "@metamask/rpc-errors>@metamask/utils": true, + "@metamask/rpc-errors>fast-safe-stringify": true + } + }, + "@metamask/rpc-errors>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, + "packages": { + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true } }, "@metamask/rpc-methods-flask>nanoid": { diff --git a/lavamoat/browserify/mmi/policy.json b/lavamoat/browserify/mmi/policy.json index 073882b78df5..321e8ea7e6ff 100644 --- a/lavamoat/browserify/mmi/policy.json +++ b/lavamoat/browserify/mmi/policy.json @@ -879,15 +879,30 @@ }, "packages": { "@ethereumjs/tx>@ethereumjs/util": true, + "@metamask/controller-utils>@metamask/utils": true, "@metamask/controller-utils>@spruceid/siwe-parser": true, "@metamask/ethjs>@metamask/ethjs-unit": true, - "@metamask/utils": true, "bn.js": true, "browserify>buffer": true, "eslint>fast-deep-equal": true, "eth-ens-namehash": true } }, + "@metamask/controller-utils>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, + "packages": { + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true + } + }, "@metamask/controller-utils>@spruceid/siwe-parser": { "globals": { "console.error": true, @@ -1446,9 +1461,24 @@ }, "@metamask/json-rpc-engine": { "packages": { + "@metamask/json-rpc-engine>@metamask/utils": true, "@metamask/rpc-errors": true, - "@metamask/safe-event-emitter": true, - "@metamask/utils": true + "@metamask/safe-event-emitter": true + } + }, + "@metamask/json-rpc-engine>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, + "packages": { + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true } }, "@metamask/keyring-api": { @@ -2289,64 +2319,13 @@ }, "@metamask/queued-request-controller": { "packages": { - "@metamask/queued-request-controller>@metamask/base-controller": true, - "@metamask/queued-request-controller>@metamask/json-rpc-engine": true, - "@metamask/queued-request-controller>@metamask/rpc-errors": true, + "@metamask/base-controller": true, + "@metamask/json-rpc-engine": true, "@metamask/queued-request-controller>@metamask/utils": true, + "@metamask/rpc-errors": true, "@metamask/selected-network-controller": true } }, - "@metamask/queued-request-controller>@metamask/base-controller": { - "globals": { - "setTimeout": true - }, - "packages": { - "immer": true - } - }, - "@metamask/queued-request-controller>@metamask/json-rpc-engine": { - "packages": { - "@metamask/queued-request-controller>@metamask/json-rpc-engine>@metamask/utils": true, - "@metamask/queued-request-controller>@metamask/rpc-errors": true, - "@metamask/safe-event-emitter": true - } - }, - "@metamask/queued-request-controller>@metamask/json-rpc-engine>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, - "@metamask/queued-request-controller>@metamask/rpc-errors": { - "packages": { - "@metamask/queued-request-controller>@metamask/rpc-errors>@metamask/utils": true, - "@metamask/rpc-errors>fast-safe-stringify": true - } - }, - "@metamask/queued-request-controller>@metamask/rpc-errors>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, "@metamask/queued-request-controller>@metamask/utils": { "globals": { "TextDecoder": true, @@ -2418,8 +2397,23 @@ }, "@metamask/rpc-errors": { "packages": { - "@metamask/rpc-errors>fast-safe-stringify": true, - "@metamask/utils": true + "@metamask/rpc-errors>@metamask/utils": true, + "@metamask/rpc-errors>fast-safe-stringify": true + } + }, + "@metamask/rpc-errors>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, + "packages": { + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true } }, "@metamask/rpc-methods-flask>nanoid": { diff --git a/package.json b/package.json index d4517b42229d..bd0ec3a52409 100644 --- a/package.json +++ b/package.json @@ -345,7 +345,7 @@ "@metamask/preinstalled-example-snap": "^0.2.0", "@metamask/profile-sync-controller": "^0.9.7", "@metamask/providers": "^14.0.2", - "@metamask/queued-request-controller": "^2.0.0", + "@metamask/queued-request-controller": "^7.0.0", "@metamask/rate-limit-controller": "^6.0.0", "@metamask/rpc-errors": "^7.0.0", "@metamask/safe-event-emitter": "^3.1.1", diff --git a/shared/constants/methods-tags.ts b/shared/constants/methods-tags.ts index a35954769b1b..329c0d493244 100644 --- a/shared/constants/methods-tags.ts +++ b/shared/constants/methods-tags.ts @@ -16,3 +16,22 @@ export const methodsRequiringNetworkSwitch = [ 'eth_signTypedData_v4', 'personal_sign', ] as const; + +/** + * This is a list of methods that may change the globally selected network + * without prompting for user approval. For UI/UX reasons these type of + * requests must be treated specially in the QueuedRequestController. + */ +export const methodsThatCanSwitchNetworkWithoutApproval = [ + 'wallet_addEthereumChain', + 'wallet_switchEthereumChain', +]; + +/** + * This is a list of methods that require special handling and must + * be enqueued and processed by the QueuedRequestController. + */ +export const methodsThatShouldBeEnqueued = [ + ...methodsRequiringNetworkSwitch, + ...methodsThatCanSwitchNetworkWithoutApproval, +]; diff --git a/yarn.lock b/yarn.lock index 3558c24d8d5d..2643747a815a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4972,13 +4972,13 @@ __metadata: languageName: node linkType: hard -"@metamask/base-controller@npm:^7.0.0, @metamask/base-controller@npm:^7.0.1": - version: 7.0.1 - resolution: "@metamask/base-controller@npm:7.0.1" +"@metamask/base-controller@npm:^7.0.0, @metamask/base-controller@npm:^7.0.1, @metamask/base-controller@npm:^7.0.2": + version: 7.0.2 + resolution: "@metamask/base-controller@npm:7.0.2" dependencies: - "@metamask/utils": "npm:^9.1.0" + "@metamask/utils": "npm:^10.0.0" immer: "npm:^9.0.6" - checksum: 10/774b6d68ac95a5ec187e890d321bede50065f8a6f1ba7b49a19f5971366274054ac0e401548b51d3b014d0bca5d650409fb554dd13ce120e7fb3495b4e8e67b1 + checksum: 10/6f78ec5af840c9947aa8eac6e402df6469600260d613a92196daefd5b072097a176fe5da1c386f2d36853513254b74140d667d817a12880c46f088e18ff3606a languageName: node linkType: hard @@ -5015,20 +5015,21 @@ __metadata: languageName: node linkType: hard -"@metamask/controller-utils@npm:^11.0.0, @metamask/controller-utils@npm:^11.0.2, @metamask/controller-utils@npm:^11.1.0, @metamask/controller-utils@npm:^11.2.0, @metamask/controller-utils@npm:^11.3.0, @metamask/controller-utils@npm:^11.4.0": - version: 11.4.0 - resolution: "@metamask/controller-utils@npm:11.4.0" +"@metamask/controller-utils@npm:^11.0.0, @metamask/controller-utils@npm:^11.0.2, @metamask/controller-utils@npm:^11.1.0, @metamask/controller-utils@npm:^11.2.0, @metamask/controller-utils@npm:^11.3.0, @metamask/controller-utils@npm:^11.4.0, @metamask/controller-utils@npm:^11.4.1": + version: 11.4.2 + resolution: "@metamask/controller-utils@npm:11.4.2" dependencies: "@ethereumjs/util": "npm:^8.1.0" "@metamask/eth-query": "npm:^4.0.0" "@metamask/ethjs-unit": "npm:^0.3.0" - "@metamask/utils": "npm:^9.1.0" + "@metamask/utils": "npm:^10.0.0" "@spruceid/siwe-parser": "npm:2.1.0" "@types/bn.js": "npm:^5.1.5" + bignumber.js: "npm:^9.1.2" bn.js: "npm:^5.2.1" eth-ens-namehash: "npm:^2.0.8" fast-deep-equal: "npm:^3.1.3" - checksum: 10/f34d24880eab264bddaa5bef21afaecb206db6978364565d0f7b7a54b1d411f129eb84175041df3be8a66394c2d49e83b6648b5cbde6f34662a60fc553c31458 + checksum: 10/fdae49ee97e7a2a1bb6414011ca59932f8712a768a9c4c43673a2504c9fa9e61d83df53a21ff0506ef6a8cf774704f2df58a6d71385c8786ec5cab4359c051e1 languageName: node linkType: hard @@ -5582,14 +5583,14 @@ __metadata: languageName: node linkType: hard -"@metamask/json-rpc-engine@npm:^10.0.0": - version: 10.0.0 - resolution: "@metamask/json-rpc-engine@npm:10.0.0" +"@metamask/json-rpc-engine@npm:^10.0.0, @metamask/json-rpc-engine@npm:^10.0.1": + version: 10.0.1 + resolution: "@metamask/json-rpc-engine@npm:10.0.1" dependencies: - "@metamask/rpc-errors": "npm:^7.0.0" + "@metamask/rpc-errors": "npm:^7.0.1" "@metamask/safe-event-emitter": "npm:^3.0.0" - "@metamask/utils": "npm:^9.1.0" - checksum: 10/2c401a4a64392aeb11c4f7ca8d7b458ba1106cff1e0b3dba8b3e0cc90e82f8c55ac2dc9fdfcd914b289e3298fb726d637cf21382336dde2c207cf76129ce5eab + "@metamask/utils": "npm:^10.0.0" + checksum: 10/15a8eeab9af39b9ed87311da728e81169484ace733a8ef9fc469bd887654e37afa19f9e5228246dc80daad3fbf9b16067e73b2969d37d44acf5bc6ffa2c70082 languageName: node linkType: hard @@ -6137,20 +6138,20 @@ __metadata: languageName: node linkType: hard -"@metamask/queued-request-controller@npm:^2.0.0": - version: 2.0.0 - resolution: "@metamask/queued-request-controller@npm:2.0.0" +"@metamask/queued-request-controller@npm:^7.0.0": + version: 7.0.0 + resolution: "@metamask/queued-request-controller@npm:7.0.0" dependencies: - "@metamask/base-controller": "npm:^6.0.0" - "@metamask/controller-utils": "npm:^11.0.0" - "@metamask/json-rpc-engine": "npm:^9.0.0" - "@metamask/rpc-errors": "npm:^6.2.1" + "@metamask/base-controller": "npm:^7.0.2" + "@metamask/controller-utils": "npm:^11.4.1" + "@metamask/json-rpc-engine": "npm:^10.0.1" + "@metamask/rpc-errors": "npm:^7.0.1" "@metamask/swappable-obj-proxy": "npm:^2.2.0" - "@metamask/utils": "npm:^8.3.0" + "@metamask/utils": "npm:^10.0.0" peerDependencies: - "@metamask/network-controller": ^19.0.0 - "@metamask/selected-network-controller": ^15.0.0 - checksum: 10/b618fa05465a52e5b689d932d99b47552b5987a9141d58260966611f1057190132f14b1a2123c48399f218fc57c577e1c86375e8ee2b43871cdc597fbaeedb7a + "@metamask/network-controller": ^22.0.0 + "@metamask/selected-network-controller": ^19.0.0 + checksum: 10/69118c11e3faecdbec7c9f02f4ecec4734ce0950115bfac0cdd4338309898690ae3187bcef1cc4f75f54c5c02eff07d80286d3ef29088a665039c13cb50bef88 languageName: node linkType: hard @@ -6175,13 +6176,13 @@ __metadata: languageName: node linkType: hard -"@metamask/rpc-errors@npm:^7.0.0": - version: 7.0.0 - resolution: "@metamask/rpc-errors@npm:7.0.0" +"@metamask/rpc-errors@npm:^7.0.0, @metamask/rpc-errors@npm:^7.0.1": + version: 7.0.1 + resolution: "@metamask/rpc-errors@npm:7.0.1" dependencies: - "@metamask/utils": "npm:^9.0.0" + "@metamask/utils": "npm:^10.0.0" fast-safe-stringify: "npm:^2.0.6" - checksum: 10/f25e2a5506d4d0d6193c88aef8f035ec189a1177f8aee8fa01c9a33d73b1536ca7b5eea2fb33a477768bbd2abaf16529e68f0b3cf714387e5d6c9178225354fd + checksum: 10/819708b4a7d9695ee67fd867d8f94bb5a273b479a242b17bd53c83d1fceec421fc42928f0bb340f4f138ec803dd82ec9659ce7b09a86aedad6a81d5a39ec5c35 languageName: node linkType: hard @@ -6583,6 +6584,23 @@ __metadata: languageName: node linkType: hard +"@metamask/utils@npm:^10.0.0": + version: 10.0.0 + resolution: "@metamask/utils@npm:10.0.0" + dependencies: + "@ethereumjs/tx": "npm:^4.2.0" + "@metamask/superstruct": "npm:^3.1.0" + "@noble/hashes": "npm:^1.3.1" + "@scure/base": "npm:^1.1.3" + "@types/debug": "npm:^4.1.7" + debug: "npm:^4.3.4" + pony-cause: "npm:^2.1.10" + semver: "npm:^7.5.4" + uuid: "npm:^9.0.1" + checksum: 10/9c2e6421f685d8a45145b6026a6f9fd0701eb5a2e8490fc6d18e64c103d5a62097f301cbc797790da52ceb5853bd9f65845c934b00299e69e5e6736c52b32f0f + languageName: node + linkType: hard + "@metamask/utils@npm:^8.1.0, @metamask/utils@npm:^8.2.0, @metamask/utils@npm:^8.3.0": version: 8.5.0 resolution: "@metamask/utils@npm:8.5.0" @@ -26150,7 +26168,7 @@ __metadata: "@metamask/preinstalled-example-snap": "npm:^0.2.0" "@metamask/profile-sync-controller": "npm:^0.9.7" "@metamask/providers": "npm:^14.0.2" - "@metamask/queued-request-controller": "npm:^2.0.0" + "@metamask/queued-request-controller": "npm:^7.0.0" "@metamask/rate-limit-controller": "npm:^6.0.0" "@metamask/rpc-errors": "npm:^7.0.0" "@metamask/safe-event-emitter": "npm:^3.1.1" From 77064317eba54d76bba0338c75c8416b8fb63886 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Thu, 31 Oct 2024 00:16:02 -0230 Subject: [PATCH 14/23] fix (cherry-pick): Fix audit failures v12.5.1 (#28187) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cherry-picks https://github.com/MetaMask/metamask-extension/pull/28145 to v12.5.1, and brings https://github.com/MetaMask/metamask-extension/pull/28177 into v12.5.1 as well. The latter originally targeted v12.6.0, but we need it for a hotfix ahead of that. The PR description for that was: ## **Description** Forcing resolutions to fix `yarn audit` warnings and more specifically this issue: - https://github.com/advisories/GHSA-584q-6j8j-r5pm I decided to be very explicit about the resolution itself based on the output of: ```console $ yarn why secp256k1 ├─ ethereum-cryptography@npm:0.1.3 │ └─ secp256k1@npm:4.0.4 (via npm:^4.0.1) │ ├─ ganache@npm:7.9.2 │ └─ secp256k1@npm:4.0.3 (via npm:4.0.3) │ ├─ ganache@patch:ganache@npm%3A7.9.2#~/.yarn/patches/ganache-npm-7.9.2-a70dc8da34.patch::version=7.9.2&hash=7d7c66 │ └─ secp256k1@npm:4.0.3 (via npm:4.0.3) │ ├─ gridplus-sdk@npm:2.5.1 │ └─ secp256k1@npm:4.0.2 (via npm:4.0.2) │ └─ hdkey@npm:2.1.0 └─ secp256k1@npm:4.0.4 (via npm:^4.0.0) ``` We could also have a more straightforward resolution like: ```json ... "resolutions": { ... "secp256k1": "4.0.4" } ... ``` But that could also catch version with different major. Let me know what would be the preferred solution here. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28176?quickstart=1) ## **Related issues** Fixes: https://github.com/advisories/GHSA-584q-6j8j-r5pm ## **Manual testing steps** N/A ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension 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: Charly Chevalier Co-authored-by: sahar-fehri --- .yarnrc.yml | 3 +- lavamoat/browserify/beta/policy.json | 18 +----------- lavamoat/browserify/flask/policy.json | 18 +----------- lavamoat/browserify/main/policy.json | 18 +----------- lavamoat/browserify/mmi/policy.json | 18 +----------- package.json | 6 +++- yarn.lock | 41 +++++++++++++-------------- 7 files changed, 30 insertions(+), 92 deletions(-) diff --git a/.yarnrc.yml b/.yarnrc.yml index fb335f532861..9d0f9e431392 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -123,7 +123,8 @@ npmAuditIgnoreAdvisories: # Currently in use for the network list drag and drop functionality. # Maintenance has stopped and the project will be archived in 2025. - 'react-beautiful-dnd (deprecation)' - + # New package name format for new versions: @ethereumjs/wallet. + - 'ethereumjs-wallet (deprecation)' npmRegistries: 'https://npm.pkg.github.com': npmAlwaysAuth: true diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index 0ce8a5ab4899..4ce4933e2153 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -3879,10 +3879,10 @@ "eth-lattice-keyring>gridplus-sdk>elliptic": true, "eth-lattice-keyring>gridplus-sdk>eth-eip712-util-browser": true, "eth-lattice-keyring>gridplus-sdk>rlp": true, - "eth-lattice-keyring>gridplus-sdk>secp256k1": true, "eth-lattice-keyring>gridplus-sdk>uuid": true, "ethereumjs-util>ethereum-cryptography>bs58check": true, "ethers>@ethersproject/sha2>hash.js": true, + "ganache>secp256k1": true, "lodash": true } }, @@ -3995,22 +3995,6 @@ "TextEncoder": true } }, - "eth-lattice-keyring>gridplus-sdk>secp256k1": { - "packages": { - "eth-lattice-keyring>gridplus-sdk>secp256k1>elliptic": true - } - }, - "eth-lattice-keyring>gridplus-sdk>secp256k1>elliptic": { - "packages": { - "@metamask/ppom-validator>elliptic>brorand": true, - "@metamask/ppom-validator>elliptic>hmac-drbg": true, - "@metamask/ppom-validator>elliptic>minimalistic-assert": true, - "@metamask/ppom-validator>elliptic>minimalistic-crypto-utils": true, - "bn.js": true, - "ethers>@ethersproject/sha2>hash.js": true, - "pumpify>inherits": true - } - }, "eth-lattice-keyring>gridplus-sdk>uuid": { "globals": { "crypto": true diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index 0ce8a5ab4899..4ce4933e2153 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -3879,10 +3879,10 @@ "eth-lattice-keyring>gridplus-sdk>elliptic": true, "eth-lattice-keyring>gridplus-sdk>eth-eip712-util-browser": true, "eth-lattice-keyring>gridplus-sdk>rlp": true, - "eth-lattice-keyring>gridplus-sdk>secp256k1": true, "eth-lattice-keyring>gridplus-sdk>uuid": true, "ethereumjs-util>ethereum-cryptography>bs58check": true, "ethers>@ethersproject/sha2>hash.js": true, + "ganache>secp256k1": true, "lodash": true } }, @@ -3995,22 +3995,6 @@ "TextEncoder": true } }, - "eth-lattice-keyring>gridplus-sdk>secp256k1": { - "packages": { - "eth-lattice-keyring>gridplus-sdk>secp256k1>elliptic": true - } - }, - "eth-lattice-keyring>gridplus-sdk>secp256k1>elliptic": { - "packages": { - "@metamask/ppom-validator>elliptic>brorand": true, - "@metamask/ppom-validator>elliptic>hmac-drbg": true, - "@metamask/ppom-validator>elliptic>minimalistic-assert": true, - "@metamask/ppom-validator>elliptic>minimalistic-crypto-utils": true, - "bn.js": true, - "ethers>@ethersproject/sha2>hash.js": true, - "pumpify>inherits": true - } - }, "eth-lattice-keyring>gridplus-sdk>uuid": { "globals": { "crypto": true diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index 0ce8a5ab4899..4ce4933e2153 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -3879,10 +3879,10 @@ "eth-lattice-keyring>gridplus-sdk>elliptic": true, "eth-lattice-keyring>gridplus-sdk>eth-eip712-util-browser": true, "eth-lattice-keyring>gridplus-sdk>rlp": true, - "eth-lattice-keyring>gridplus-sdk>secp256k1": true, "eth-lattice-keyring>gridplus-sdk>uuid": true, "ethereumjs-util>ethereum-cryptography>bs58check": true, "ethers>@ethersproject/sha2>hash.js": true, + "ganache>secp256k1": true, "lodash": true } }, @@ -3995,22 +3995,6 @@ "TextEncoder": true } }, - "eth-lattice-keyring>gridplus-sdk>secp256k1": { - "packages": { - "eth-lattice-keyring>gridplus-sdk>secp256k1>elliptic": true - } - }, - "eth-lattice-keyring>gridplus-sdk>secp256k1>elliptic": { - "packages": { - "@metamask/ppom-validator>elliptic>brorand": true, - "@metamask/ppom-validator>elliptic>hmac-drbg": true, - "@metamask/ppom-validator>elliptic>minimalistic-assert": true, - "@metamask/ppom-validator>elliptic>minimalistic-crypto-utils": true, - "bn.js": true, - "ethers>@ethersproject/sha2>hash.js": true, - "pumpify>inherits": true - } - }, "eth-lattice-keyring>gridplus-sdk>uuid": { "globals": { "crypto": true diff --git a/lavamoat/browserify/mmi/policy.json b/lavamoat/browserify/mmi/policy.json index f8cd1fdfca54..742e978f06e8 100644 --- a/lavamoat/browserify/mmi/policy.json +++ b/lavamoat/browserify/mmi/policy.json @@ -3971,10 +3971,10 @@ "eth-lattice-keyring>gridplus-sdk>elliptic": true, "eth-lattice-keyring>gridplus-sdk>eth-eip712-util-browser": true, "eth-lattice-keyring>gridplus-sdk>rlp": true, - "eth-lattice-keyring>gridplus-sdk>secp256k1": true, "eth-lattice-keyring>gridplus-sdk>uuid": true, "ethereumjs-util>ethereum-cryptography>bs58check": true, "ethers>@ethersproject/sha2>hash.js": true, + "ganache>secp256k1": true, "lodash": true } }, @@ -4087,22 +4087,6 @@ "TextEncoder": true } }, - "eth-lattice-keyring>gridplus-sdk>secp256k1": { - "packages": { - "eth-lattice-keyring>gridplus-sdk>secp256k1>elliptic": true - } - }, - "eth-lattice-keyring>gridplus-sdk>secp256k1>elliptic": { - "packages": { - "@metamask/ppom-validator>elliptic>brorand": true, - "@metamask/ppom-validator>elliptic>hmac-drbg": true, - "@metamask/ppom-validator>elliptic>minimalistic-assert": true, - "@metamask/ppom-validator>elliptic>minimalistic-crypto-utils": true, - "bn.js": true, - "ethers>@ethersproject/sha2>hash.js": true, - "pumpify>inherits": true - } - }, "eth-lattice-keyring>gridplus-sdk>uuid": { "globals": { "crypto": true diff --git a/package.json b/package.json index 913ebf677d7b..be3247aad496 100644 --- a/package.json +++ b/package.json @@ -267,7 +267,11 @@ "@metamask/network-controller@npm:^19.0.0": "patch:@metamask/network-controller@npm%3A21.0.0#~/.yarn/patches/@metamask-network-controller-npm-21.0.0-559aa8e395.patch", "@metamask/network-controller@npm:^20.0.0": "patch:@metamask/network-controller@npm%3A21.0.0#~/.yarn/patches/@metamask-network-controller-npm-21.0.0-559aa8e395.patch", "path-to-regexp": "1.9.0", - "@metamask/snaps-utils@npm:^8.1.1": "patch:@metamask/snaps-utils@npm%3A8.1.1#~/.yarn/patches/@metamask-snaps-utils-npm-8.1.1-7d5dd6a26a.patch" + "@metamask/snaps-utils@npm:^8.1.1": "patch:@metamask/snaps-utils@npm%3A8.1.1#~/.yarn/patches/@metamask-snaps-utils-npm-8.1.1-7d5dd6a26a.patch", + "secp256k1@npm:^4.0.0": "4.0.4", + "secp256k1@npm:^4.0.1": "4.0.4", + "secp256k1@npm:4.0.2": "4.0.4", + "secp256k1@npm:4.0.3": "4.0.4" }, "dependencies": { "@babel/runtime": "patch:@babel/runtime@npm%3A7.24.0#~/.yarn/patches/@babel-runtime-npm-7.24.0-7eb1dd11a2.patch", diff --git a/yarn.lock b/yarn.lock index 8e842fb9c927..3e3cc8b809c1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17235,9 +17235,9 @@ __metadata: languageName: node linkType: hard -"elliptic@npm:^6.0.0, elliptic@npm:^6.4.0, elliptic@npm:^6.5.2, elliptic@npm:^6.5.4": - version: 6.5.6 - resolution: "elliptic@npm:6.5.6" +"elliptic@npm:^6.0.0, elliptic@npm:^6.4.0, elliptic@npm:^6.5.4, elliptic@npm:^6.5.7": + version: 6.6.0 + resolution: "elliptic@npm:6.6.0" dependencies: bn.js: "npm:^4.11.9" brorand: "npm:^1.1.0" @@ -17246,7 +17246,7 @@ __metadata: inherits: "npm:^2.0.4" minimalistic-assert: "npm:^1.0.1" minimalistic-crypto-utils: "npm:^1.0.1" - checksum: 10/09377ec924fdb37775d63e5d7e5ebb2845842e6f08880b68265b1108863e968970c4a4e1c43df622078c8262417deec9a04aeb9d34e8d09a9693e19b5454e1df + checksum: 10/27575b0403e010e5d7e7a131fcadce6a7dd1ae82ccb24cc7c20b275d32ab1cb7ecb6a070225795df08407441dc8c7a32efd986596d48d1d6846f64ff8f094af7 languageName: node linkType: hard @@ -27676,6 +27676,15 @@ __metadata: languageName: node linkType: hard +"node-addon-api@npm:^5.0.0": + version: 5.1.0 + resolution: "node-addon-api@npm:5.1.0" + dependencies: + node-gyp: "npm:latest" + checksum: 10/595f59ffb4630564f587c502119cbd980d302e482781021f3b479f5fc7e41cf8f2f7280fdc2795f32d148e4f3259bd15043c52d4a3442796aa6f1ae97b959636 + languageName: node + linkType: hard + "node-addon-api@npm:^7.0.0": version: 7.1.0 resolution: "node-addon-api@npm:7.1.0" @@ -32575,27 +32584,15 @@ __metadata: languageName: node linkType: hard -"secp256k1@npm:4.0.2": - version: 4.0.2 - resolution: "secp256k1@npm:4.0.2" - dependencies: - elliptic: "npm:^6.5.2" - node-addon-api: "npm:^2.0.0" - node-gyp: "npm:latest" - node-gyp-build: "npm:^4.2.0" - checksum: 10/80f0a5b44dbe0a062ed0fbf2a82044037a2598a0ea6ec5a0924bfa1f53006b423a43db82ff1cb2924d280b06f2a34235a1733631b3459b86b7a886c0ef41e0c5 - languageName: node - linkType: hard - -"secp256k1@npm:4.0.3, secp256k1@npm:^4.0.0, secp256k1@npm:^4.0.1": - version: 4.0.3 - resolution: "secp256k1@npm:4.0.3" +"secp256k1@npm:4.0.4": + version: 4.0.4 + resolution: "secp256k1@npm:4.0.4" dependencies: - elliptic: "npm:^6.5.4" - node-addon-api: "npm:^2.0.0" + elliptic: "npm:^6.5.7" + node-addon-api: "npm:^5.0.0" node-gyp: "npm:latest" node-gyp-build: "npm:^4.2.0" - checksum: 10/8b45820cd90fd2f95cc8fdb9bf8a71e572de09f2311911ae461a951ffa9e30c99186a129d0f1afeb380dd67eca0c10493f8a7513c39063fda015e99995088e3b + checksum: 10/45000f348c853df7c1e2b67c48efb062ae78c0620ab1a5cfb02fa20d3aad39c641f4e7a18b3de3b54a7c0cc1e0addeb8ecd9d88bc332e92df17a92b60c36122a languageName: node linkType: hard From 5dbbda37c7da03ccb72f5377b345588f3b1306dd Mon Sep 17 00:00:00 2001 From: OGPoyraz Date: Thu, 31 Oct 2024 03:46:16 +0100 Subject: [PATCH 15/23] chore: Cherry-pick resimulate into `V12.5.1` (#28178) This PR cherry-picks https://github.com/MetaMask/metamask-extension/commit/2c86162cba2f52bd6ee6ab33b32244b2483be461#diff-63ab7391d870a62d8bcd3cc5d5371432068538deb98e5effcb899434ed8649bb --------- Co-authored-by: MetaMask Bot Co-authored-by: Matthew Walsh --- .metamaskrc.dist | 4 + app/_locales/en/messages.json | 6 + .../lib/transaction/smart-transactions.ts | 4 +- app/scripts/metamask-controller.js | 4 + builds.yml | 5 +- lavamoat/browserify/beta/policy.json | 42 +++++- lavamoat/browserify/flask/policy.json | 42 +++++- lavamoat/browserify/main/policy.json | 42 +++++- lavamoat/browserify/mmi/policy.json | 42 +++++- package.json | 2 +- ...rs-after-init-opt-in-background-state.json | 1 + .../errors-after-init-opt-in-ui-state.json | 1 + .../mock-request-buy-erc721.ts | 5 +- .../mock-request-no-changes.ts | 3 +- .../app/confirm/info/row/constants.ts | 3 +- ui/index.js | 3 - .../info/__snapshots__/info.test.tsx.snap | 41 +++--- .../base-transaction-info.test.tsx.snap | 123 ++++++++++------- .../simulation-details.test.tsx | 15 +++ .../simulation-details/simulation-details.tsx | 122 ++++++++++++----- .../transactions/useResimulationAlert.test.ts | 126 ++++++++++++++++++ .../transactions/useResimulationAlert.ts | 34 +++++ .../hooks/useConfirmationAlerts.ts | 5 +- yarn.lock | 69 +++++++--- 24 files changed, 601 insertions(+), 143 deletions(-) create mode 100644 ui/pages/confirmations/hooks/alerts/transactions/useResimulationAlert.test.ts create mode 100644 ui/pages/confirmations/hooks/alerts/transactions/useResimulationAlert.ts diff --git a/.metamaskrc.dist b/.metamaskrc.dist index 601105e2af44..fc2a5a831a4b 100644 --- a/.metamaskrc.dist +++ b/.metamaskrc.dist @@ -45,3 +45,7 @@ BLOCKAID_PUBLIC_KEY= ; Enable/disable why did you render debug tool: https://github.com/welldone-software/why-did-you-render ; This should NEVER be enabled in production since it slows down react ; ENABLE_WHY_DID_YOU_RENDER=false + +; API key used in Etherscan requests to prevent rate limiting. +; Only applies to Mainnet and Sepolia. +; ETHERSCAN_API_KEY= diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index e312be4794e5..903a5f2b2b33 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -426,6 +426,9 @@ "alertMessageAddressMismatchWarning": { "message": "Attackers sometimes mimic sites by making small changes to the site address. Make sure you're interacting with the intended site before you continue." }, + "alertMessageChangeInSimulationResults": { + "message": "Estimated changes for this transaction have been updated. Review them closely before proceeding." + }, "alertMessageGasEstimateFailed": { "message": "We’re unable to provide an accurate fee and this estimate might be high. We suggest you to input a custom gas limit, but there’s a risk the transaction will still fail." }, @@ -465,6 +468,9 @@ "alertModalReviewAllAlerts": { "message": "Review all alerts" }, + "alertReasonChangeInSimulationResults": { + "message": "Results have changed" + }, "alertReasonGasEstimateFailed": { "message": "Inaccurate fee" }, diff --git a/app/scripts/lib/transaction/smart-transactions.ts b/app/scripts/lib/transaction/smart-transactions.ts index acf17c306a5f..9f9d81567847 100644 --- a/app/scripts/lib/transaction/smart-transactions.ts +++ b/app/scripts/lib/transaction/smart-transactions.ts @@ -313,7 +313,9 @@ class SmartTransactionHook { signedTransactions, signedCanceledTransactions: [], txParams: this.#txParams, - transactionMeta: this.#transactionMeta, + // TODO: Replace `any` with type - version mismatch between smart-transactions-controller and transaction-controller breaking type safety + // eslint-disable-next-line @typescript-eslint/no-explicit-any + transactionMeta: this.#transactionMeta as any, }); } diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index ea8fa297cd2f..679f2f9a4be8 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -1849,6 +1849,10 @@ export default class MetamaskController extends EventEmitter { getCurrentChainId({ metamask: this.networkController.state }) ], incomingTransactions: { + etherscanApiKeysByChainId: { + [CHAIN_IDS.MAINNET]: process.env.ETHERSCAN_API_KEY, + [CHAIN_IDS.SEPOLIA]: process.env.ETHERSCAN_API_KEY, + }, includeTokenTransfers: false, isEnabled: () => Boolean( diff --git a/builds.yml b/builds.yml index acee49063822..ceeb6ae2b17d 100644 --- a/builds.yml +++ b/builds.yml @@ -272,8 +272,10 @@ env: - SECURITY_ALERTS_API_ENABLED: '' # URL of security alerts API used to validate dApp requests - SECURITY_ALERTS_API_URL: 'http://localhost:3000' + # API key to authenticate Etherscan requests to avoid rate limiting + - ETHERSCAN_API_KEY: '' - # Enables the notifications feature within the build: + # Enables the notifications feature within the build: - NOTIFICATIONS: '' - METAMASK_RAMP_API_CONTENT_BASE_URL: https://on-ramp-content.api.cx.metamask.io @@ -290,6 +292,7 @@ env: ### - EIP_4337_ENTRYPOINT: null + ### # Enable/disable why did you render debug tool: https://github.com/welldone-software/why-did-you-render # This should NEVER be enabled in production since it slows down react diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index 4ce4933e2153..52c3250ffa65 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -783,15 +783,30 @@ }, "packages": { "@ethereumjs/tx>@ethereumjs/util": true, + "@metamask/controller-utils>@metamask/utils": true, "@metamask/controller-utils>@spruceid/siwe-parser": true, "@metamask/ethjs>@metamask/ethjs-unit": true, - "@metamask/utils": true, "bn.js": true, "browserify>buffer": true, "eslint>fast-deep-equal": true, "eth-ens-namehash": true } }, + "@metamask/controller-utils>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, + "packages": { + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true + } + }, "@metamask/controller-utils>@spruceid/siwe-parser": { "globals": { "console.error": true, @@ -2726,9 +2741,9 @@ "@metamask/metamask-eth-abis": true, "@metamask/name-controller>async-mutex": true, "@metamask/network-controller": true, - "@metamask/rpc-errors": true, "@metamask/transaction-controller>@metamask/nonce-tracker": true, - "@metamask/utils": true, + "@metamask/transaction-controller>@metamask/rpc-errors": true, + "@metamask/transaction-controller>@metamask/utils": true, "bn.js": true, "browserify>buffer": true, "eth-method-registry": true, @@ -2754,6 +2769,27 @@ "@swc/helpers>tslib": true } }, + "@metamask/transaction-controller>@metamask/rpc-errors": { + "packages": { + "@metamask/transaction-controller>@metamask/utils": true, + "eth-rpc-errors>fast-safe-stringify": true + } + }, + "@metamask/transaction-controller>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, + "packages": { + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true + } + }, "@metamask/user-operation-controller": { "globals": { "fetch": true diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index 4ce4933e2153..52c3250ffa65 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -783,15 +783,30 @@ }, "packages": { "@ethereumjs/tx>@ethereumjs/util": true, + "@metamask/controller-utils>@metamask/utils": true, "@metamask/controller-utils>@spruceid/siwe-parser": true, "@metamask/ethjs>@metamask/ethjs-unit": true, - "@metamask/utils": true, "bn.js": true, "browserify>buffer": true, "eslint>fast-deep-equal": true, "eth-ens-namehash": true } }, + "@metamask/controller-utils>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, + "packages": { + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true + } + }, "@metamask/controller-utils>@spruceid/siwe-parser": { "globals": { "console.error": true, @@ -2726,9 +2741,9 @@ "@metamask/metamask-eth-abis": true, "@metamask/name-controller>async-mutex": true, "@metamask/network-controller": true, - "@metamask/rpc-errors": true, "@metamask/transaction-controller>@metamask/nonce-tracker": true, - "@metamask/utils": true, + "@metamask/transaction-controller>@metamask/rpc-errors": true, + "@metamask/transaction-controller>@metamask/utils": true, "bn.js": true, "browserify>buffer": true, "eth-method-registry": true, @@ -2754,6 +2769,27 @@ "@swc/helpers>tslib": true } }, + "@metamask/transaction-controller>@metamask/rpc-errors": { + "packages": { + "@metamask/transaction-controller>@metamask/utils": true, + "eth-rpc-errors>fast-safe-stringify": true + } + }, + "@metamask/transaction-controller>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, + "packages": { + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true + } + }, "@metamask/user-operation-controller": { "globals": { "fetch": true diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index 4ce4933e2153..52c3250ffa65 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -783,15 +783,30 @@ }, "packages": { "@ethereumjs/tx>@ethereumjs/util": true, + "@metamask/controller-utils>@metamask/utils": true, "@metamask/controller-utils>@spruceid/siwe-parser": true, "@metamask/ethjs>@metamask/ethjs-unit": true, - "@metamask/utils": true, "bn.js": true, "browserify>buffer": true, "eslint>fast-deep-equal": true, "eth-ens-namehash": true } }, + "@metamask/controller-utils>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, + "packages": { + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true + } + }, "@metamask/controller-utils>@spruceid/siwe-parser": { "globals": { "console.error": true, @@ -2726,9 +2741,9 @@ "@metamask/metamask-eth-abis": true, "@metamask/name-controller>async-mutex": true, "@metamask/network-controller": true, - "@metamask/rpc-errors": true, "@metamask/transaction-controller>@metamask/nonce-tracker": true, - "@metamask/utils": true, + "@metamask/transaction-controller>@metamask/rpc-errors": true, + "@metamask/transaction-controller>@metamask/utils": true, "bn.js": true, "browserify>buffer": true, "eth-method-registry": true, @@ -2754,6 +2769,27 @@ "@swc/helpers>tslib": true } }, + "@metamask/transaction-controller>@metamask/rpc-errors": { + "packages": { + "@metamask/transaction-controller>@metamask/utils": true, + "eth-rpc-errors>fast-safe-stringify": true + } + }, + "@metamask/transaction-controller>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, + "packages": { + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true + } + }, "@metamask/user-operation-controller": { "globals": { "fetch": true diff --git a/lavamoat/browserify/mmi/policy.json b/lavamoat/browserify/mmi/policy.json index 742e978f06e8..6725d2dfa1c6 100644 --- a/lavamoat/browserify/mmi/policy.json +++ b/lavamoat/browserify/mmi/policy.json @@ -875,15 +875,30 @@ }, "packages": { "@ethereumjs/tx>@ethereumjs/util": true, + "@metamask/controller-utils>@metamask/utils": true, "@metamask/controller-utils>@spruceid/siwe-parser": true, "@metamask/ethjs>@metamask/ethjs-unit": true, - "@metamask/utils": true, "bn.js": true, "browserify>buffer": true, "eslint>fast-deep-equal": true, "eth-ens-namehash": true } }, + "@metamask/controller-utils>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, + "packages": { + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true + } + }, "@metamask/controller-utils>@spruceid/siwe-parser": { "globals": { "console.error": true, @@ -2818,9 +2833,9 @@ "@metamask/metamask-eth-abis": true, "@metamask/name-controller>async-mutex": true, "@metamask/network-controller": true, - "@metamask/rpc-errors": true, "@metamask/transaction-controller>@metamask/nonce-tracker": true, - "@metamask/utils": true, + "@metamask/transaction-controller>@metamask/rpc-errors": true, + "@metamask/transaction-controller>@metamask/utils": true, "bn.js": true, "browserify>buffer": true, "eth-method-registry": true, @@ -2846,6 +2861,27 @@ "@swc/helpers>tslib": true } }, + "@metamask/transaction-controller>@metamask/rpc-errors": { + "packages": { + "@metamask/transaction-controller>@metamask/utils": true, + "eth-rpc-errors>fast-safe-stringify": true + } + }, + "@metamask/transaction-controller>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, + "packages": { + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true + } + }, "@metamask/user-operation-controller": { "globals": { "fetch": true diff --git a/package.json b/package.json index be3247aad496..0e0d4ccb67fa 100644 --- a/package.json +++ b/package.json @@ -364,7 +364,7 @@ "@metamask/snaps-rpc-methods": "^11.1.1", "@metamask/snaps-sdk": "^6.5.1", "@metamask/snaps-utils": "patch:@metamask/snaps-utils@npm%3A8.1.1#~/.yarn/patches/@metamask-snaps-utils-npm-8.1.1-7d5dd6a26a.patch", - "@metamask/transaction-controller": "^37.0.0", + "@metamask/transaction-controller": "^38.1.0", "@metamask/user-operation-controller": "^13.0.0", "@metamask/utils": "^9.1.0", "@ngraveio/bc-ur": "^1.1.12", diff --git a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json index c133de6128ca..423d65c681ec 100644 --- a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json +++ b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json @@ -305,6 +305,7 @@ }, "TxController": { "methodData": "object", + "submitHistory": "object", "transactions": "object", "lastFetchedBlockNumbers": "object" }, diff --git a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json index dfee54fbd6cb..95e995c9c466 100644 --- a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json +++ b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json @@ -194,6 +194,7 @@ "isSignedIn": "boolean", "isProfileSyncingEnabled": null, "isProfileSyncingUpdateLoading": "boolean", + "submitHistory": "object", "subscriptionAccountsSeen": "object", "isMetamaskNotificationsFeatureSeen": "boolean", "isNotificationServicesEnabled": "boolean", diff --git a/test/e2e/tests/simulation-details/mock-request-buy-erc721.ts b/test/e2e/tests/simulation-details/mock-request-buy-erc721.ts index fd71e42559aa..9346ee6f83f1 100644 --- a/test/e2e/tests/simulation-details/mock-request-buy-erc721.ts +++ b/test/e2e/tests/simulation-details/mock-request-buy-erc721.ts @@ -269,8 +269,7 @@ export const BUY_ERC721_REQUEST_2_MOCK: MockRequestResponse = { result: { transactions: [ { - return: - '0x0000000000000000000000000000000000000000000000000000000000000000', + return: `0x0000000000000000000000000000000000000000000000000000000000000000`, status: '0x1', gasUsed: '0x5f66', gasLimit: '0x60b9', @@ -388,7 +387,7 @@ export const BUY_ERC721_REQUEST_2_MOCK: MockRequestResponse = { baseFeePerGas: 42103363836, }, { - return: `0x00000000000000000000000000000000${SENDER_ADDRESS_NO_0X_MOCK}`, + return: `0x000000000000000000000000${SENDER_ADDRESS_NO_0X_MOCK}`, status: '0x1', gasUsed: '0x5f66', gasLimit: '0x60b9', diff --git a/test/e2e/tests/simulation-details/mock-request-no-changes.ts b/test/e2e/tests/simulation-details/mock-request-no-changes.ts index 59b7fc9b8b3d..03aa562fd354 100644 --- a/test/e2e/tests/simulation-details/mock-request-no-changes.ts +++ b/test/e2e/tests/simulation-details/mock-request-no-changes.ts @@ -5,7 +5,7 @@ export const NO_CHANGES_TRANSACTION_MOCK = { maxFeePerGas: '0x0', maxPriorityFeePerGas: '0x0', to: SENDER_ADDRESS_MOCK, - value: '0x38d7ea4c68000', + value: '0x0', }; export const NO_CHANGES_REQUEST_MOCK: MockRequestResponse = { @@ -42,6 +42,7 @@ export const NO_CHANGES_REQUEST_MOCK: MockRequestResponse = { stateDiff: { post: { [SENDER_ADDRESS_MOCK]: { + balance: '0x3185e67a46d9066', nonce: '0x3c0', }, }, diff --git a/ui/components/app/confirm/info/row/constants.ts b/ui/components/app/confirm/info/row/constants.ts index f260f9bce282..415358aa5252 100644 --- a/ui/components/app/confirm/info/row/constants.ts +++ b/ui/components/app/confirm/info/row/constants.ts @@ -3,8 +3,9 @@ export const TEST_ADDRESS = '0x5CfE73b6021E818B776b421B1c4Db2474086a7e1'; export enum RowAlertKey { EstimatedFee = 'estimatedFee', SigningInWith = 'signingInWith', - Speed = 'speed', RequestFrom = 'requestFrom', + Resimulation = 'resimulation', + Speed = 'speed', } export enum AlertActionKey { diff --git a/ui/index.js b/ui/index.js index bc427addb55e..8cf2048cba41 100644 --- a/ui/index.js +++ b/ui/index.js @@ -297,9 +297,6 @@ function setupStateHooks(store) { // for more info) state.version = global.platform.getVersion(); state.browser = window.navigator.userAgent; - state.completeTxList = await actions.getTransactions({ - filterToCurrentNetwork: false, - }); return state; }; window.stateHooks.getSentryAppState = function () { diff --git a/ui/pages/confirmations/components/confirm/info/__snapshots__/info.test.tsx.snap b/ui/pages/confirmations/components/confirm/info/__snapshots__/info.test.tsx.snap index 60bb488888b3..0cc41ec89e11 100644 --- a/ui/pages/confirmations/components/confirm/info/__snapshots__/info.test.tsx.snap +++ b/ui/pages/confirmations/components/confirm/info/__snapshots__/info.test.tsx.snap @@ -310,26 +310,35 @@ exports[`Info renders info section for contract interaction request 1`] = ` class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-space-between mm-box--align-items-center" >
-

- Estimated changes -

-
- +

+ Estimated changes +

+
+
+ +
+
diff --git a/ui/pages/confirmations/components/confirm/info/base-transaction-info/__snapshots__/base-transaction-info.test.tsx.snap b/ui/pages/confirmations/components/confirm/info/base-transaction-info/__snapshots__/base-transaction-info.test.tsx.snap index 3cd8e825da01..d9e3fff08108 100644 --- a/ui/pages/confirmations/components/confirm/info/base-transaction-info/__snapshots__/base-transaction-info.test.tsx.snap +++ b/ui/pages/confirmations/components/confirm/info/base-transaction-info/__snapshots__/base-transaction-info.test.tsx.snap @@ -15,26 +15,35 @@ exports[` renders component for contract interaction requ class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-space-between mm-box--align-items-center" >
-

- Estimated changes -

-
- +

+ Estimated changes +

+
+
+ +
+
@@ -352,26 +361,35 @@ exports[` renders component for contract interaction requ class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-space-between mm-box--align-items-center" >
-

- Estimated changes -

-
- +

+ Estimated changes +

+
+
+ +
+
@@ -727,26 +745,35 @@ exports[` renders component for contract interaction requ class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-space-between mm-box--align-items-center" >
-

- Estimated changes -

-
- +

+ Estimated changes +

+
+
+ +
+
diff --git a/ui/pages/confirmations/components/simulation-details/simulation-details.test.tsx b/ui/pages/confirmations/components/simulation-details/simulation-details.test.tsx index 5971e513e3a1..ce8e0686d08b 100644 --- a/ui/pages/confirmations/components/simulation-details/simulation-details.test.tsx +++ b/ui/pages/confirmations/components/simulation-details/simulation-details.test.tsx @@ -25,6 +25,21 @@ jest.mock('./balance-change-list', () => ({ jest.mock('./useSimulationMetrics'); +jest.mock( + '../../../../components/app/confirm/info/row/alert-row/alert-row', + () => ({ + ConfirmInfoAlertRow: jest.fn(({ label }) => <>{label}), + }), +); + +jest.mock('../../context/confirm', () => ({ + useConfirmContext: jest.fn(() => ({ + currentConfirmation: { + id: 'testTransactionId', + }, + })), +})); + const renderSimulationDetails = (simulationData?: Partial) => renderWithProvider( { ); }; +const HeaderWithAlert = ({ transactionId }: { transactionId: string }) => { + const t = useI18nContext(); + + return ( + + {/* Intentional fragment */} + <> + + ); +}; + +const LegacyHeader = () => { + const t = useI18nContext(); + return ( + + + {t('simulationDetailsTitle')} + + + + + + ); +}; + /** * Header at the top of the simulation preview. * * @param props * @param props.children + * @param props.isTransactionsRedesign + * @param props.transactionId */ -const HeaderLayout: React.FC = ({ children }) => { - const t = useI18nContext(); +const HeaderLayout: React.FC<{ + isTransactionsRedesign: boolean; + transactionId: string; +}> = ({ children, isTransactionsRedesign, transactionId }) => { return ( { alignItems={AlignItems.center} justifyContent={JustifyContent.spaceBetween} > - - - {t('simulationDetailsTitle')} - - - - - + {isTransactionsRedesign ? ( + + ) : ( + + )} {children} ); @@ -143,11 +180,13 @@ const HeaderLayout: React.FC = ({ children }) => { * @param props.inHeader * @param props.isTransactionsRedesign * @param props.children + * @param props.transactionId */ const SimulationDetailsLayout: React.FC<{ inHeader?: React.ReactNode; isTransactionsRedesign: boolean; -}> = ({ inHeader, isTransactionsRedesign, children }) => ( + transactionId: string; +}> = ({ inHeader, isTransactionsRedesign, transactionId, children }) => ( - {inHeader} + + {inHeader} + {children} ); @@ -201,6 +245,7 @@ export const SimulationDetails: React.FC = ({ } isTransactionsRedesign={isTransactionsRedesign} + transactionId={transactionId} > ); } @@ -218,7 +263,10 @@ export const SimulationDetails: React.FC = ({ if (error) { return ( - + ); @@ -228,7 +276,10 @@ export const SimulationDetails: React.FC = ({ const empty = balanceChanges.length === 0; if (empty) { return ( - + ); @@ -237,7 +288,10 @@ export const SimulationDetails: React.FC = ({ const outgoing = balanceChanges.filter((bc) => bc.amount.isNegative()); const incoming = balanceChanges.filter((bc) => !bc.amount.isNegative()); return ( - + { + beforeEach(() => { + jest.resetAllMocks(); + }); + + it('returns no alerts if no confirmation', () => { + expect(runHook()).toEqual([]); + }); + + it('returns no alerts if no transactions', () => { + expect( + runHook({ + currentConfirmation: CONFIRMATION_MOCK, + transactions: [], + }), + ).toEqual([]); + }); + + it('returns no alerts if isUpdatedAfterSecurityCheck is false', () => { + const notResimulatedConfirmation = { + ...TRANSACTION_META_MOCK, + simulationData: { + isUpdatedAfterSecurityCheck: false, + tokenBalanceChanges: [], + }, + }; + expect( + runHook({ + currentConfirmation: notResimulatedConfirmation, + }), + ).toEqual([]); + }); + + it('returns alert if isUpdatedAfterSecurityCheck is true', () => { + const resimulatedConfirmation = { + ...CONFIRMATION_MOCK, + simulationData: { + isUpdatedAfterSecurityCheck: true, + tokenBalanceChanges: [], + }, + }; + const alerts = runHook({ + currentConfirmation: resimulatedConfirmation, + }); + + expect(alerts).toEqual([ + { + actions: [], + field: RowAlertKey.Resimulation, + isBlocking: false, + key: 'simulationDetailsTitle', + message: + 'Estimated changes for this transaction have been updated. Review them closely before proceeding.', + reason: 'Results have changed', + severity: Severity.Danger, + }, + ]); + }); +}); diff --git a/ui/pages/confirmations/hooks/alerts/transactions/useResimulationAlert.ts b/ui/pages/confirmations/hooks/alerts/transactions/useResimulationAlert.ts new file mode 100644 index 000000000000..c838e07e62c4 --- /dev/null +++ b/ui/pages/confirmations/hooks/alerts/transactions/useResimulationAlert.ts @@ -0,0 +1,34 @@ +import { useMemo } from 'react'; +import { TransactionMeta } from '@metamask/transaction-controller'; + +import { Alert } from '../../../../../ducks/confirm-alerts/confirm-alerts'; +import { useI18nContext } from '../../../../../hooks/useI18nContext'; +import { Severity } from '../../../../../helpers/constants/design-system'; +import { RowAlertKey } from '../../../../../components/app/confirm/info/row/constants'; +import { useConfirmContext } from '../../../context/confirm'; + +export function useResimulationAlert(): Alert[] { + const t = useI18nContext(); + const { currentConfirmation } = useConfirmContext(); + + const isUpdatedAfterSecurityCheck = (currentConfirmation as TransactionMeta) + ?.simulationData?.isUpdatedAfterSecurityCheck; + + return useMemo(() => { + if (!isUpdatedAfterSecurityCheck) { + return []; + } + + return [ + { + actions: [], + field: RowAlertKey.Resimulation, + isBlocking: false, + key: 'simulationDetailsTitle', + message: t('alertMessageChangeInSimulationResults'), + reason: t('alertReasonChangeInSimulationResults'), + severity: Severity.Danger, + }, + ]; + }, [isUpdatedAfterSecurityCheck, t]); +} diff --git a/ui/pages/confirmations/hooks/useConfirmationAlerts.ts b/ui/pages/confirmations/hooks/useConfirmationAlerts.ts index 3ea9a5e2d254..c5f77f143cb6 100644 --- a/ui/pages/confirmations/hooks/useConfirmationAlerts.ts +++ b/ui/pages/confirmations/hooks/useConfirmationAlerts.ts @@ -10,6 +10,7 @@ import { useNetworkBusyAlerts } from './alerts/transactions/useNetworkBusyAlerts import { useNoGasPriceAlerts } from './alerts/transactions/useNoGasPriceAlerts'; import { usePendingTransactionAlerts } from './alerts/transactions/usePendingTransactionAlerts'; import { useQueuedConfirmationsAlerts } from './alerts/transactions/useQueuedConfirmationsAlerts'; +import { useResimulationAlert } from './alerts/transactions/useResimulationAlert'; ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) import { useSigningOrSubmittingAlerts } from './alerts/transactions/useSigningOrSubmittingAlerts'; ///: END:ONLY_INCLUDE_IF @@ -34,11 +35,11 @@ function useTransactionAlerts(): Alert[] { const networkBusyAlerts = useNetworkBusyAlerts(); const noGasPriceAlerts = useNoGasPriceAlerts(); const pendingTransactionAlerts = usePendingTransactionAlerts(); + const resimulationAlert = useResimulationAlert(); ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) const signingOrSubmittingAlerts = useSigningOrSubmittingAlerts(); ///: END:ONLY_INCLUDE_IF const queuedConfirmationsAlerts = useQueuedConfirmationsAlerts(); - return useMemo( () => [ ...gasEstimateFailedAlerts, @@ -48,6 +49,7 @@ function useTransactionAlerts(): Alert[] { ...networkBusyAlerts, ...noGasPriceAlerts, ...pendingTransactionAlerts, + ...resimulationAlert, ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) ...signingOrSubmittingAlerts, ///: END:ONLY_INCLUDE_IF @@ -61,6 +63,7 @@ function useTransactionAlerts(): Alert[] { networkBusyAlerts, noGasPriceAlerts, pendingTransactionAlerts, + resimulationAlert, ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) signingOrSubmittingAlerts, ///: END:ONLY_INCLUDE_IF diff --git a/yarn.lock b/yarn.lock index 3e3cc8b809c1..81ef4b4de92a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4933,13 +4933,13 @@ __metadata: languageName: node linkType: hard -"@metamask/base-controller@npm:^7.0.0, @metamask/base-controller@npm:^7.0.1": - version: 7.0.1 - resolution: "@metamask/base-controller@npm:7.0.1" +"@metamask/base-controller@npm:^7.0.0, @metamask/base-controller@npm:^7.0.1, @metamask/base-controller@npm:^7.0.2": + version: 7.0.2 + resolution: "@metamask/base-controller@npm:7.0.2" dependencies: - "@metamask/utils": "npm:^9.1.0" + "@metamask/utils": "npm:^10.0.0" immer: "npm:^9.0.6" - checksum: 10/774b6d68ac95a5ec187e890d321bede50065f8a6f1ba7b49a19f5971366274054ac0e401548b51d3b014d0bca5d650409fb554dd13ce120e7fb3495b4e8e67b1 + checksum: 10/6f78ec5af840c9947aa8eac6e402df6469600260d613a92196daefd5b072097a176fe5da1c386f2d36853513254b74140d667d817a12880c46f088e18ff3606a languageName: node linkType: hard @@ -4976,20 +4976,20 @@ __metadata: languageName: node linkType: hard -"@metamask/controller-utils@npm:^11.0.0, @metamask/controller-utils@npm:^11.0.2, @metamask/controller-utils@npm:^11.1.0, @metamask/controller-utils@npm:^11.2.0, @metamask/controller-utils@npm:^11.3.0": - version: 11.3.0 - resolution: "@metamask/controller-utils@npm:11.3.0" +"@metamask/controller-utils@npm:^11.0.0, @metamask/controller-utils@npm:^11.0.2, @metamask/controller-utils@npm:^11.1.0, @metamask/controller-utils@npm:^11.2.0, @metamask/controller-utils@npm:^11.3.0, @metamask/controller-utils@npm:^11.4.1": + version: 11.4.1 + resolution: "@metamask/controller-utils@npm:11.4.1" dependencies: "@ethereumjs/util": "npm:^8.1.0" "@metamask/eth-query": "npm:^4.0.0" "@metamask/ethjs-unit": "npm:^0.3.0" - "@metamask/utils": "npm:^9.1.0" + "@metamask/utils": "npm:^10.0.0" "@spruceid/siwe-parser": "npm:2.1.0" "@types/bn.js": "npm:^5.1.5" bn.js: "npm:^5.2.1" eth-ens-namehash: "npm:^2.0.8" fast-deep-equal: "npm:^3.1.3" - checksum: 10/3200228d1f4ea5fa095228db4e5050529caf0470e072382eb8f7571bb9b07515516ca9e846b7751388399d9ae967e4985dafd6120902ef6c998e98f4eb36d964 + checksum: 10/fff4864858ce2072456537c9b51cb4c10d178a27b39ab5af8d6e9595efb59dd043bb49be336d8ac725d1281279db4365855f024329398508658b2b2d3b5bc2a5 languageName: node linkType: hard @@ -6159,6 +6159,16 @@ __metadata: languageName: node linkType: hard +"@metamask/rpc-errors@npm:^7.0.1": + version: 7.0.1 + resolution: "@metamask/rpc-errors@npm:7.0.1" + dependencies: + "@metamask/utils": "npm:^10.0.0" + fast-safe-stringify: "npm:^2.0.6" + checksum: 10/819708b4a7d9695ee67fd867d8f94bb5a273b479a242b17bd53c83d1fceec421fc42928f0bb340f4f138ec803dd82ec9659ce7b09a86aedad6a81d5a39ec5c35 + languageName: node + linkType: hard + "@metamask/safe-event-emitter@npm:^2.0.0": version: 2.0.0 resolution: "@metamask/safe-event-emitter@npm:2.0.0" @@ -6523,9 +6533,9 @@ __metadata: languageName: node linkType: hard -"@metamask/transaction-controller@npm:^37.0.0": - version: 37.0.0 - resolution: "@metamask/transaction-controller@npm:37.0.0" +"@metamask/transaction-controller@npm:^38.1.0": + version: 38.1.0 + resolution: "@metamask/transaction-controller@npm:38.1.0" dependencies: "@ethereumjs/common": "npm:^3.2.0" "@ethereumjs/tx": "npm:^4.2.0" @@ -6533,13 +6543,13 @@ __metadata: "@ethersproject/abi": "npm:^5.7.0" "@ethersproject/contracts": "npm:^5.7.0" "@ethersproject/providers": "npm:^5.7.0" - "@metamask/base-controller": "npm:^7.0.1" - "@metamask/controller-utils": "npm:^11.3.0" + "@metamask/base-controller": "npm:^7.0.2" + "@metamask/controller-utils": "npm:^11.4.1" "@metamask/eth-query": "npm:^4.0.0" "@metamask/metamask-eth-abis": "npm:^3.1.1" "@metamask/nonce-tracker": "npm:^6.0.0" - "@metamask/rpc-errors": "npm:^6.3.1" - "@metamask/utils": "npm:^9.1.0" + "@metamask/rpc-errors": "npm:^7.0.1" + "@metamask/utils": "npm:^10.0.0" async-mutex: "npm:^0.5.0" bn.js: "npm:^5.2.1" eth-method-registry: "npm:^4.0.0" @@ -6550,9 +6560,9 @@ __metadata: "@babel/runtime": ^7.23.9 "@metamask/accounts-controller": ^18.0.0 "@metamask/approval-controller": ^7.0.0 - "@metamask/gas-fee-controller": ^20.0.0 - "@metamask/network-controller": ^21.0.0 - checksum: 10/b4608260cb86ad1a867926b983a21050a2be899f17af909ad2403b5148eada348b0fbb3f7ecef9ebc7cf8d28c040ce4d6f5009709328cda00fab61e10fa94de6 + "@metamask/gas-fee-controller": ^22.0.0 + "@metamask/network-controller": ^22.0.0 + checksum: 10/c1bdca52bbbce42a76ec9c640197534ec6c223b0f5d5815acfa53490dc1175850ea9aeeb6ae3c5ec34218f0bdbbbeb3e8731e2552aa9411e3ed7798a5dea8ab5 languageName: node linkType: hard @@ -6586,6 +6596,23 @@ __metadata: languageName: node linkType: hard +"@metamask/utils@npm:^10.0.0": + version: 10.0.0 + resolution: "@metamask/utils@npm:10.0.0" + dependencies: + "@ethereumjs/tx": "npm:^4.2.0" + "@metamask/superstruct": "npm:^3.1.0" + "@noble/hashes": "npm:^1.3.1" + "@scure/base": "npm:^1.1.3" + "@types/debug": "npm:^4.1.7" + debug: "npm:^4.3.4" + pony-cause: "npm:^2.1.10" + semver: "npm:^7.5.4" + uuid: "npm:^9.0.1" + checksum: 10/9c2e6421f685d8a45145b6026a6f9fd0701eb5a2e8490fc6d18e64c103d5a62097f301cbc797790da52ceb5853bd9f65845c934b00299e69e5e6736c52b32f0f + languageName: node + linkType: hard + "@metamask/utils@npm:^8.1.0, @metamask/utils@npm:^8.2.0, @metamask/utils@npm:^8.3.0": version: 8.5.0 resolution: "@metamask/utils@npm:8.5.0" @@ -26164,7 +26191,7 @@ __metadata: "@metamask/snaps-utils": "patch:@metamask/snaps-utils@npm%3A8.1.1#~/.yarn/patches/@metamask-snaps-utils-npm-8.1.1-7d5dd6a26a.patch" "@metamask/test-bundler": "npm:^1.0.0" "@metamask/test-dapp": "npm:^8.4.0" - "@metamask/transaction-controller": "npm:^37.0.0" + "@metamask/transaction-controller": "npm:^38.1.0" "@metamask/user-operation-controller": "npm:^13.0.0" "@metamask/utils": "npm:^9.1.0" "@ngraveio/bc-ur": "npm:^1.1.12" From 82a548cd9938976b43faa83263bcb716b1619155 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Thu, 31 Oct 2024 00:49:14 -0230 Subject: [PATCH 16/23] V12.5.1 changelog (#28200) --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fc65a61eae0..3e6b06f0d37d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ## [12.5.1] +### Changed +- Improve accuracy of transaction simulation warnings in some scenarios ([#26845](https://github.com/MetaMask/metamask-extension/pull/26845)) + +### Fixed +- Fix bug that could cause token balances to appear as zero, and a balance error to be displayed, on the send screen ([#28136](https://github.com/MetaMask/metamask-extension/pull/28136)) ## [12.5.0] ### Added From 8b7ad816b3b9481dcc17bbb6f8df799b28fe656d Mon Sep 17 00:00:00 2001 From: Matthew Walsh Date: Thu, 31 Oct 2024 09:06:42 +0000 Subject: [PATCH 17/23] fix (cherry-pick): incorrect standard swap gas fee estimation (#28127) (#28191) --- .../swaps/prepare-swap-page/review-quote.js | 3 +- .../prepare-swap-page/review-quote.test.js | 57 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/ui/pages/swaps/prepare-swap-page/review-quote.js b/ui/pages/swaps/prepare-swap-page/review-quote.js index 13d11a93cd1f..680ece113f5d 100644 --- a/ui/pages/swaps/prepare-swap-page/review-quote.js +++ b/ui/pages/swaps/prepare-swap-page/review-quote.js @@ -257,7 +257,8 @@ export default function ReviewQuote({ setReceiveToAmount }) { ); const smartTransactionFees = useSelector(getSmartTransactionFees, isEqual); const swapsNetworkConfig = useSelector(getSwapsNetworkConfig, shallowEqual); - const { estimatedBaseFee = '0' } = useGasFeeEstimates(); + const { gasFeeEstimates: networkGasFeeEstimates } = useGasFeeEstimates(); + const { estimatedBaseFee = '0' } = networkGasFeeEstimates ?? {}; const gasFeeEstimates = useAsyncResult(async () => { if (!networkAndAccountSupports1559) { diff --git a/ui/pages/swaps/prepare-swap-page/review-quote.test.js b/ui/pages/swaps/prepare-swap-page/review-quote.test.js index cacd52ca47ed..1e4ab9199226 100644 --- a/ui/pages/swaps/prepare-swap-page/review-quote.test.js +++ b/ui/pages/swaps/prepare-swap-page/review-quote.test.js @@ -10,6 +10,7 @@ import { } from '../../../../test/jest'; import { CHAIN_IDS } from '../../../../shared/constants/network'; import { getSwap1559GasFeeEstimates } from '../swaps.util'; +import { getNetworkConfigurationByNetworkClientId } from '../../../store/actions'; import ReviewQuote from './review-quote'; jest.mock( @@ -17,11 +18,18 @@ jest.mock( () => () => '', ); +jest.mock('../../../store/actions', () => ({ + ...jest.requireActual('../../../store/actions'), + getNetworkConfigurationByNetworkClientId: jest.fn(), +})); + jest.mock('../swaps.util', () => ({ ...jest.requireActual('../swaps.util'), getSwap1559GasFeeEstimates: jest.fn(), })); +const ESTIMATED_BASE_FEE_MOCK = '1234'; + const middleware = [thunk]; const createProps = (customProps = {}) => { return { @@ -31,6 +39,15 @@ const createProps = (customProps = {}) => { }; describe('ReviewQuote', () => { + const getNetworkConfigurationByNetworkClientIdMock = jest.mocked( + getNetworkConfigurationByNetworkClientId, + ); + + beforeEach(() => { + jest.resetAllMocks(); + getNetworkConfigurationByNetworkClientIdMock.mockResolvedValue(undefined); + }); + const getSwap1559GasFeeEstimatesMock = jest.mocked( getSwap1559GasFeeEstimates, ); @@ -210,5 +227,45 @@ describe('ReviewQuote', () => { expect(getByText('Max fee:')).toBeInTheDocument(); expect(getByText('$8.15')).toBeInTheDocument(); }); + + it('extracts estimated base fee from network gas fee estimates', async () => { + getNetworkConfigurationByNetworkClientIdMock.mockResolvedValueOnce({ + chainId: CHAIN_IDS.MAINNET, + }); + + smartDisabled1559State.metamask.gasFeeEstimatesByChainId = { + [CHAIN_IDS.MAINNET]: { + gasFeeEstimates: { + estimatedBaseFee: ESTIMATED_BASE_FEE_MOCK, + }, + }, + }; + + getSwap1559GasFeeEstimatesMock.mockResolvedValueOnce({ + estimatedBaseFee: '0x1', + tradeGasFeeEstimates: { + maxFeePerGas: '0x2', + maxPriorityFeePerGas: '0x3', + baseAndPriorityFeePerGas: '0x123456789123', + }, + approveGasFeeEstimates: undefined, + }); + + const store = configureMockStore(middleware)(smartDisabled1559State); + const props = createProps(); + + renderWithProvider(, store); + + await act(() => { + // Intentionally empty + }); + + expect(getSwap1559GasFeeEstimatesMock).toHaveBeenCalledWith( + expect.any(Object), + null, + ESTIMATED_BASE_FEE_MOCK, + CHAIN_IDS.MAINNET, + ); + }); }); }); From 94dc115ccf132bbbc5256cc6d7ef0b3dffc18d75 Mon Sep 17 00:00:00 2001 From: MetaMask Bot Date: Thu, 31 Oct 2024 14:38:44 +0000 Subject: [PATCH 18/23] Update LavaMoat policies --- lavamoat/browserify/beta/policy.json | 37 +++++++++++---------------- lavamoat/browserify/flask/policy.json | 37 +++++++++++---------------- lavamoat/browserify/main/policy.json | 37 +++++++++++---------------- lavamoat/browserify/mmi/policy.json | 37 +++++++++++---------------- 4 files changed, 60 insertions(+), 88 deletions(-) diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index 943338c29bdb..ef4c915328c2 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -2971,9 +2971,9 @@ "@metamask/metamask-eth-abis": true, "@metamask/name-controller>async-mutex": true, "@metamask/network-controller": true, + "@metamask/rpc-errors": true, "@metamask/transaction-controller>@metamask/nonce-tracker": true, - "@metamask/transaction-controller>@metamask/rpc-errors": true, - "@metamask/utils": true, + "@metamask/transaction-controller>@metamask/utils": true, "bn.js": true, "browserify>buffer": true, "eth-method-registry": true, @@ -2999,10 +2999,19 @@ "@swc/helpers>tslib": true } }, - "@metamask/transaction-controller>@metamask/rpc-errors": { + "@metamask/transaction-controller>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, "packages": { - "@metamask/rpc-errors>fast-safe-stringify": true, - "@metamask/utils": true + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true } }, "@metamask/user-operation-controller": { @@ -4151,10 +4160,10 @@ "eth-lattice-keyring>gridplus-sdk>elliptic": true, "eth-lattice-keyring>gridplus-sdk>eth-eip712-util-browser": true, "eth-lattice-keyring>gridplus-sdk>rlp": true, - "eth-lattice-keyring>gridplus-sdk>secp256k1": true, "eth-lattice-keyring>gridplus-sdk>uuid": true, "ethereumjs-util>ethereum-cryptography>bs58check": true, "ethers>@ethersproject/sha2>hash.js": true, + "ganache>secp256k1": true, "lodash": true } }, @@ -4267,22 +4276,6 @@ "TextEncoder": true } }, - "eth-lattice-keyring>gridplus-sdk>secp256k1": { - "packages": { - "eth-lattice-keyring>gridplus-sdk>secp256k1>elliptic": true - } - }, - "eth-lattice-keyring>gridplus-sdk>secp256k1>elliptic": { - "packages": { - "@metamask/ppom-validator>elliptic>brorand": true, - "@metamask/ppom-validator>elliptic>hmac-drbg": true, - "@metamask/ppom-validator>elliptic>minimalistic-assert": true, - "@metamask/ppom-validator>elliptic>minimalistic-crypto-utils": true, - "bn.js": true, - "ethers>@ethersproject/sha2>hash.js": true, - "pumpify>inherits": true - } - }, "eth-lattice-keyring>gridplus-sdk>uuid": { "globals": { "crypto": true diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index 943338c29bdb..ef4c915328c2 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -2971,9 +2971,9 @@ "@metamask/metamask-eth-abis": true, "@metamask/name-controller>async-mutex": true, "@metamask/network-controller": true, + "@metamask/rpc-errors": true, "@metamask/transaction-controller>@metamask/nonce-tracker": true, - "@metamask/transaction-controller>@metamask/rpc-errors": true, - "@metamask/utils": true, + "@metamask/transaction-controller>@metamask/utils": true, "bn.js": true, "browserify>buffer": true, "eth-method-registry": true, @@ -2999,10 +2999,19 @@ "@swc/helpers>tslib": true } }, - "@metamask/transaction-controller>@metamask/rpc-errors": { + "@metamask/transaction-controller>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, "packages": { - "@metamask/rpc-errors>fast-safe-stringify": true, - "@metamask/utils": true + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true } }, "@metamask/user-operation-controller": { @@ -4151,10 +4160,10 @@ "eth-lattice-keyring>gridplus-sdk>elliptic": true, "eth-lattice-keyring>gridplus-sdk>eth-eip712-util-browser": true, "eth-lattice-keyring>gridplus-sdk>rlp": true, - "eth-lattice-keyring>gridplus-sdk>secp256k1": true, "eth-lattice-keyring>gridplus-sdk>uuid": true, "ethereumjs-util>ethereum-cryptography>bs58check": true, "ethers>@ethersproject/sha2>hash.js": true, + "ganache>secp256k1": true, "lodash": true } }, @@ -4267,22 +4276,6 @@ "TextEncoder": true } }, - "eth-lattice-keyring>gridplus-sdk>secp256k1": { - "packages": { - "eth-lattice-keyring>gridplus-sdk>secp256k1>elliptic": true - } - }, - "eth-lattice-keyring>gridplus-sdk>secp256k1>elliptic": { - "packages": { - "@metamask/ppom-validator>elliptic>brorand": true, - "@metamask/ppom-validator>elliptic>hmac-drbg": true, - "@metamask/ppom-validator>elliptic>minimalistic-assert": true, - "@metamask/ppom-validator>elliptic>minimalistic-crypto-utils": true, - "bn.js": true, - "ethers>@ethersproject/sha2>hash.js": true, - "pumpify>inherits": true - } - }, "eth-lattice-keyring>gridplus-sdk>uuid": { "globals": { "crypto": true diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index 943338c29bdb..ef4c915328c2 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -2971,9 +2971,9 @@ "@metamask/metamask-eth-abis": true, "@metamask/name-controller>async-mutex": true, "@metamask/network-controller": true, + "@metamask/rpc-errors": true, "@metamask/transaction-controller>@metamask/nonce-tracker": true, - "@metamask/transaction-controller>@metamask/rpc-errors": true, - "@metamask/utils": true, + "@metamask/transaction-controller>@metamask/utils": true, "bn.js": true, "browserify>buffer": true, "eth-method-registry": true, @@ -2999,10 +2999,19 @@ "@swc/helpers>tslib": true } }, - "@metamask/transaction-controller>@metamask/rpc-errors": { + "@metamask/transaction-controller>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, "packages": { - "@metamask/rpc-errors>fast-safe-stringify": true, - "@metamask/utils": true + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true } }, "@metamask/user-operation-controller": { @@ -4151,10 +4160,10 @@ "eth-lattice-keyring>gridplus-sdk>elliptic": true, "eth-lattice-keyring>gridplus-sdk>eth-eip712-util-browser": true, "eth-lattice-keyring>gridplus-sdk>rlp": true, - "eth-lattice-keyring>gridplus-sdk>secp256k1": true, "eth-lattice-keyring>gridplus-sdk>uuid": true, "ethereumjs-util>ethereum-cryptography>bs58check": true, "ethers>@ethersproject/sha2>hash.js": true, + "ganache>secp256k1": true, "lodash": true } }, @@ -4267,22 +4276,6 @@ "TextEncoder": true } }, - "eth-lattice-keyring>gridplus-sdk>secp256k1": { - "packages": { - "eth-lattice-keyring>gridplus-sdk>secp256k1>elliptic": true - } - }, - "eth-lattice-keyring>gridplus-sdk>secp256k1>elliptic": { - "packages": { - "@metamask/ppom-validator>elliptic>brorand": true, - "@metamask/ppom-validator>elliptic>hmac-drbg": true, - "@metamask/ppom-validator>elliptic>minimalistic-assert": true, - "@metamask/ppom-validator>elliptic>minimalistic-crypto-utils": true, - "bn.js": true, - "ethers>@ethersproject/sha2>hash.js": true, - "pumpify>inherits": true - } - }, "eth-lattice-keyring>gridplus-sdk>uuid": { "globals": { "crypto": true diff --git a/lavamoat/browserify/mmi/policy.json b/lavamoat/browserify/mmi/policy.json index 321e8ea7e6ff..94c331a71ee5 100644 --- a/lavamoat/browserify/mmi/policy.json +++ b/lavamoat/browserify/mmi/policy.json @@ -3063,9 +3063,9 @@ "@metamask/metamask-eth-abis": true, "@metamask/name-controller>async-mutex": true, "@metamask/network-controller": true, + "@metamask/rpc-errors": true, "@metamask/transaction-controller>@metamask/nonce-tracker": true, - "@metamask/transaction-controller>@metamask/rpc-errors": true, - "@metamask/utils": true, + "@metamask/transaction-controller>@metamask/utils": true, "bn.js": true, "browserify>buffer": true, "eth-method-registry": true, @@ -3091,10 +3091,19 @@ "@swc/helpers>tslib": true } }, - "@metamask/transaction-controller>@metamask/rpc-errors": { + "@metamask/transaction-controller>@metamask/utils": { + "globals": { + "TextDecoder": true, + "TextEncoder": true + }, "packages": { - "@metamask/rpc-errors>fast-safe-stringify": true, - "@metamask/utils": true + "@metamask/utils>@metamask/superstruct": true, + "@metamask/utils>@scure/base": true, + "@metamask/utils>pony-cause": true, + "@noble/hashes": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true } }, "@metamask/user-operation-controller": { @@ -4243,10 +4252,10 @@ "eth-lattice-keyring>gridplus-sdk>elliptic": true, "eth-lattice-keyring>gridplus-sdk>eth-eip712-util-browser": true, "eth-lattice-keyring>gridplus-sdk>rlp": true, - "eth-lattice-keyring>gridplus-sdk>secp256k1": true, "eth-lattice-keyring>gridplus-sdk>uuid": true, "ethereumjs-util>ethereum-cryptography>bs58check": true, "ethers>@ethersproject/sha2>hash.js": true, + "ganache>secp256k1": true, "lodash": true } }, @@ -4359,22 +4368,6 @@ "TextEncoder": true } }, - "eth-lattice-keyring>gridplus-sdk>secp256k1": { - "packages": { - "eth-lattice-keyring>gridplus-sdk>secp256k1>elliptic": true - } - }, - "eth-lattice-keyring>gridplus-sdk>secp256k1>elliptic": { - "packages": { - "@metamask/ppom-validator>elliptic>brorand": true, - "@metamask/ppom-validator>elliptic>hmac-drbg": true, - "@metamask/ppom-validator>elliptic>minimalistic-assert": true, - "@metamask/ppom-validator>elliptic>minimalistic-crypto-utils": true, - "bn.js": true, - "ethers>@ethersproject/sha2>hash.js": true, - "pumpify>inherits": true - } - }, "eth-lattice-keyring>gridplus-sdk>uuid": { "globals": { "crypto": true From eb9a2edf465e1429dd54302645e46d6b32f112dd Mon Sep 17 00:00:00 2001 From: Harika <153644847+hjetpoluru@users.noreply.github.com> Date: Thu, 31 Oct 2024 12:57:09 -0400 Subject: [PATCH 19/23] chore: Cherry pick data deletion into v12.6.0 (#28223) ## **Description** Cherry-pick PR https://github.com/MetaMask/metamask-extension/pull/28221 [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28223?quickstart=1) Co-authored-by: Mark Stacey --- app/scripts/services/data-deletion-service.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/scripts/services/data-deletion-service.ts b/app/scripts/services/data-deletion-service.ts index 3bdafc03b582..5ec9ede75a87 100644 --- a/app/scripts/services/data-deletion-service.ts +++ b/app/scripts/services/data-deletion-service.ts @@ -12,11 +12,17 @@ import { import getFetchWithTimeout from '../../../shared/modules/fetch-with-timeout'; import { DeleteRegulationStatus } from '../../../shared/constants/metametrics'; -const DEFAULT_ANALYTICS_DATA_DELETION_SOURCE_ID = - process.env.ANALYTICS_DATA_DELETION_SOURCE_ID ?? 'test'; -const DEFAULT_ANALYTICS_DATA_DELETION_ENDPOINT = - process.env.ANALYTICS_DATA_DELETION_ENDPOINT ?? - 'https://metametrics.metamask.test'; +const inTest = process.env.IN_TEST; +const fallbackSourceId = 'test'; +const fallbackDataDeletionEndpoint = 'https://metametrics.metamask.test'; + +const DEFAULT_ANALYTICS_DATA_DELETION_SOURCE_ID = inTest + ? fallbackSourceId + : process.env.ANALYTICS_DATA_DELETION_SOURCE_ID ?? fallbackSourceId; +const DEFAULT_ANALYTICS_DATA_DELETION_ENDPOINT = inTest + ? fallbackDataDeletionEndpoint + : process.env.ANALYTICS_DATA_DELETION_ENDPOINT ?? + fallbackDataDeletionEndpoint; /** * The number of times we retry a specific failed request to the data deletion API. From 8fa97988b5c2f92e589357b234d9fda6b87dc31c Mon Sep 17 00:00:00 2001 From: Marina Boboc <120041701+benjisclowder@users.noreply.github.com> Date: Thu, 31 Oct 2024 20:30:37 +0200 Subject: [PATCH 20/23] V12.6.0 Changelog (#28166) ## **Description** Adding 12.6.0 changelog entries. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28166?quickstart=1) --------- Co-authored-by: Dan J Miller --- CHANGELOG.md | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db903de48796..59734a8a23f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,77 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ## [12.6.0] +### Added +- Added the APE network icon ([#27841](https://github.com/MetaMask/metamask-extension/pull/27841)) +- Added token sorting and improved token importing on the Asset List page ([#27184](https://github.com/MetaMask/metamask-extension/pull/27184)) +- Added an aggregated balance feature and updated settings to toggle between fiat and native token balances ([#27097](https://github.com/MetaMask/metamask-extension/pull/27097)) +- Added a network picker to the AssetPicker for easier cross-chain swaps ([#26559](https://github.com/MetaMask/metamask-extension/pull/26559)) +- Added new header and conditional simulations for dapp-initiated token transfer confirmations ([#27875](https://github.com/MetaMask/metamask-extension/pull/27875)) +- Added simulation section to NFT permit confirmations ([#27825](https://github.com/MetaMask/metamask-extension/pull/27825)) +- Added transaction flow and details sections for wallet-initiated ERC20 token transfer confirmations ([#27654](https://github.com/MetaMask/metamask-extension/pull/27654)) +- Added support for typed sign requests for NFT permits ([#27796](https://github.com/MetaMask/metamask-extension/pull/27796)) +- Added support for gas fee flows in standard swaps on EIP-1559 networks ([#27612](https://github.com/MetaMask/metamask-extension/pull/27612)) +- Added a Token Send Heading component ([#27562](https://github.com/MetaMask/metamask-extension/pull/27562)) +- Added support for Etherscan API keys and improved transaction history logging ([#27611](https://github.com/MetaMask/metamask-extension/pull/27611)) +- Added a custom header for wallet-initiated ERC20 token transfer confirmations ([#27391](https://github.com/MetaMask/metamask-extension/pull/27391)) +- Added redesigned screens for setApprovalForAll and revoke setApprovalForAll for users who opt into experimental transaction screens ([#27401](https://github.com/MetaMask/metamask-extension/pull/27401)) +- Added new screens for approve, increaseAllowance, and revoke approval for users who enable experimental transaction screens ([#26985](https://github.com/MetaMask/metamask-extension/pull/26985)) +- Added support for revoking ERC20 allowances ([#26906](https://github.com/MetaMask/metamask-extension/pull/26906)) +- Added a "Delete MetaMetrics Data" button to the Security & Privacy tab, allowing users to delete their MetaMetrics data ([#24571](https://github.com/MetaMask/metamask-extension/pull/24571)) +- Added a new Default Settings view and updated Congratulations views in the onboarding process ([#24562](https://github.com/MetaMask/metamask-extension/pull/24562)) +- Added a delay for Linea swap approvals to increase success rate and updated token symbol retrieval on the awaiting swap page ([#27810](https://github.com/MetaMask/metamask-extension/pull/27810)) +- Enabled smart transactions by default for new users and updated selectors to handle user preferences and metrics separately ([#27885](https://github.com/MetaMask/metamask-extension/pull/27885)) +- Added animations and cosmetic changes to the smart transaction status page ([#27650](https://github.com/MetaMask/metamask-extension/pull/27650)) +- Enabled gas-included swaps for users with insufficient ETH when smart transactions are enabled ([#27427](https://github.com/MetaMask/metamask-extension/pull/27427)) +- Added padding to center-align text on the permissions page when no site or snap is connected ([#27660](https://github.com/MetaMask/metamask-extension/pull/27660)) +- Released Chain Permissions by removing feature flags ([#27561](https://github.com/MetaMask/metamask-extension/pull/27561)) +- Added support for power users survey with toast notifications ([#27361](https://github.com/MetaMask/metamask-extension/pull/27361)) +- Added editing flow for switching networks via dapp ([#26635](https://github.com/MetaMask/metamask-extension/pull/26635)) +- [FLASK] Added the ability to send Bitcoin from Bitcoin accounts ([#27964](https://github.com/MetaMask/metamask-extension/pull/27964)) + +### Changed +- Bumped snap-keyring to version 4.4.0 to sanitize redirect URLs passed by a Snap ([#27864](https://github.com/MetaMask/metamask-extension/pull/27864)) +- Updated the insufficient funds alert to replace "transaction fees" with "network fees." ([#27762](https://github.com/MetaMask/metamask-extension/pull/27762)) +- Updated the SIWE signature page to display the parsed URI instead of the domain ([#27754](https://github.com/MetaMask/metamask-extension/pull/27754)) +- Limited the number of decimals on the spending cap modal to match the token's supported decimals ([#27672](https://github.com/MetaMask/metamask-extension/pull/27672)) +- Updated petnames component to prefer displaying token symbols over token names for brevity ([#27693](https://github.com/MetaMask/metamask-extension/pull/27693)) +- Updated banner alert to render multiple general alerts and fixed related UI issues ([#27339](https://github.com/MetaMask/metamask-extension/pull/27339)) +- Updated Trezor Connect to v9.4.0 and removed outdated workarounds ([#27112](https://github.com/MetaMask/metamask-extension/pull/27112)) +- Restored the ability to switch between pending confirmations when routed to a specific confirmation ([#27753](https://github.com/MetaMask/metamask-extension/pull/27753)) +- Updated edit modals with design improvements and a fixed update button ([#27623](https://github.com/MetaMask/metamask-extension/pull/27623)) +- Updated copy for the onboarding message and settings screens ([#27821](https://github.com/MetaMask/metamask-extension/pull/27821)) +- Updated copy and spacing in the Permissions Screen ([#27658](https://github.com/MetaMask/metamask-extension/pull/27658)) +- Removed phishing detection from the onboarding Security group ([#27819](https://github.com/MetaMask/metamask-extension/pull/27819)) +- Removed the "Alerts" section from Settings, keeping alert features enabled by default ([#27709](https://github.com/MetaMask/metamask-extension/pull/27709)) +- Updated the toast component and its copy ([#27656](https://github.com/MetaMask/metamask-extension/pull/27656)) +- Changed survey timeout from one week to one day ([#27603](https://github.com/MetaMask/metamask-extension/pull/27603)) +- Updated UI for the connect and review permissions pages ([#27478](https://github.com/MetaMask/metamask-extension/pull/27478)) + +### Fixed +- Fixed an error when starting a "Send ETH" flow from a dapp with a Bitcoin account selected ([#27566](https://github.com/MetaMask/metamask-extension/pull/27566)) +- Fixed currency display to show token balance when fiat conversion rate is unavailable ([#27893](https://github.com/MetaMask/metamask-extension/pull/27893)) +- Fixed the issue where the add token modal couldn't be dismissed in MMI ([#27855](https://github.com/MetaMask/metamask-extension/pull/27855)) +- Fixed an issue that caused the app to crash when switching networks ([#27604](https://github.com/MetaMask/metamask-extension/pull/27604)) +- Fixed navigation error between transactions when one transaction is of type "Approve All." ([#27985](https://github.com/MetaMask/metamask-extension/pull/27985)) +- Fixed nonce value updating issue when multiple transactions are created in parallel ([#27874](https://github.com/MetaMask/metamask-extension/pull/27874)) +- Fixed issue with nonce not resetting when switching networks ([#27789](https://github.com/MetaMask/metamask-extension/pull/27789)) +- Fixed design issues and spacing in the redesigned transactions, and corrected loader behavior for confirmations ([#27605](https://github.com/MetaMask/metamask-extension/pull/27605)) +- Fixed bugs related to max approval values and array value spending caps ([#27573](https://github.com/MetaMask/metamask-extension/pull/27573)) +- Reverted the color change for the "Speed" key by removing the variant causing the issue ([#27416](https://github.com/MetaMask/metamask-extension/pull/27416)) +- Improved token decimal handling by using verified contract details when available and added support for tokens with null decimals ([#27328](https://github.com/MetaMask/metamask-extension/pull/27328)) +- Improved the alert system and refined alerts for SIWE and contract interactions ([#27205](https://github.com/MetaMask/metamask-extension/pull/27205)) +- Fixed an issue where entering a backslash in the settings search would cause a crash ([#27432](https://github.com/MetaMask/metamask-extension/pull/27432)) +- Automatically expand the first insight on the confirmation page ([#27872](https://github.com/MetaMask/metamask-extension/pull/27872)) +- Removed HTML arrows from custom UI inputs of type number in Snaps ([#27953](https://github.com/MetaMask/metamask-extension/pull/27953)) +- Hid the options menu and info icon in the Snaps header for preinstalled Snaps ([#27937](https://github.com/MetaMask/metamask-extension/pull/27937)) +- Fixed sticky footer UI issue on Snaps Home Page in extended view ([#27799](https://github.com/MetaMask/metamask-extension/pull/27799)) +- Fixed issue with Snap name truncation in the Snap Authorship Header ([#27752](https://github.com/MetaMask/metamask-extension/pull/27752)) +- Fixed the color of the "more" button in the Copyable component ([#27600](https://github.com/MetaMask/metamask-extension/pull/27600)) +- Fixed alignment issue by applying flex to Snaps buttons only when containing images and icons ([#27564](https://github.com/MetaMask/metamask-extension/pull/27564)) +- Fixed issue with input focus being lost on re-render in Snaps interfaces ([#27429](https://github.com/MetaMask/metamask-extension/pull/27429)) +- Fixed issue where state updates with falsy values were ignored in Snaps interfaces ([#27488](https://github.com/MetaMask/metamask-extension/pull/27488)) +- Fixed text color for secondary buttons in Snaps footer on hover and corrected footer variant when only one action is provided ([#27335](https://github.com/MetaMask/metamask-extension/pull/27335)) +- Fixed an issue where hardware wallet users were taken to the "Processing..." screen before approving transactions during swaps ([#27117](https://github.com/MetaMask/metamask-extension/pull/27117)) ### Uncategorized - ci: reduced Sentry frequency on CircleCI develop ([#27912](https://github.com/MetaMask/metamask-extension/pull/27912)) - chore:Master sync ([#27935](https://github.com/MetaMask/metamask-extension/pull/27935)) @@ -231,7 +302,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Instead of having different networks in the network list for the same chain but different RPC urls, there are now multiple selectable RPC urls per chain - For the UI, networks are now added, edited, and deleted directly in the network list. Networks are no longer edited via the settings page. - Users with multiple RPC endpoints per chain are shown a modal upon upgrade, allowing them to select a different endpoint as the default. - - The UI for wallet_addEthereumChain is changed, to message that users may be adding an additional endpoint to an existing network, rather than adding a new network. + - The UI for wallet_addEthereumChain is changed, to message that users may be adding an additional endpoint to an existing network, rather than adding a new network. - Added display of names and images for ERC721 NFTs to the simulations in transaction confirmations ([#25692](https://github.com/MetaMask/metamask-extension/pull/25692)) - Added a modal to edit the spending cap for ERC20 approve and increase allowance ([#26845](https://github.com/MetaMask/metamask-extension/pull/26845)) - Added a new modal to help users with zero balance buy, receive, or transfer tokens ([#26426](https://github.com/MetaMask/metamask-extension/pull/26426)) From 3df0a1683659b5f8d1856c667cb74de94fe28fbe Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Thu, 31 Oct 2024 16:21:41 -0230 Subject: [PATCH 21/23] v12.6.0 changelog lint fix (#28228) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/PR?quickstart=1) ## **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 Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension 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. --- CHANGELOG.md | 212 +-------------------------------------------------- 1 file changed, 1 insertion(+), 211 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59734a8a23f9..af63a4ed61d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,217 +78,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed issue where state updates with falsy values were ignored in Snaps interfaces ([#27488](https://github.com/MetaMask/metamask-extension/pull/27488)) - Fixed text color for secondary buttons in Snaps footer on hover and corrected footer variant when only one action is provided ([#27335](https://github.com/MetaMask/metamask-extension/pull/27335)) - Fixed an issue where hardware wallet users were taken to the "Processing..." screen before approving transactions during swaps ([#27117](https://github.com/MetaMask/metamask-extension/pull/27117)) -### Uncategorized -- ci: reduced Sentry frequency on CircleCI develop ([#27912](https://github.com/MetaMask/metamask-extension/pull/27912)) -- chore:Master sync ([#27935](https://github.com/MetaMask/metamask-extension/pull/27935)) -- Merge origin/develop into master-sync -- test: Completing missing step for import ERC1155 token origin dapp in existing E2E test ([#27680](https://github.com/MetaMask/metamask-extension/pull/27680)) -- fix: error in navigating between transaction when one of the transaction is approve all ([#27985](https://github.com/MetaMask/metamask-extension/pull/27985)) -- fix: Automatically expand first insight ([#27872](https://github.com/MetaMask/metamask-extension/pull/27872)) -- feat(metametrics): use specific `account_hardware_type` for OneKey devices ([#27296](https://github.com/MetaMask/metamask-extension/pull/27296)) -- feat: add migration 131 ([#27364](https://github.com/MetaMask/metamask-extension/pull/27364)) -- fix(snaps): Remove arrows of custom UI inputs ([#27953](https://github.com/MetaMask/metamask-extension/pull/27953)) -- chore: Disable account syncing in prod ([#27943](https://github.com/MetaMask/metamask-extension/pull/27943)) -- test: Remove delays from onboarding tests ([#27961](https://github.com/MetaMask/metamask-extension/pull/27961)) -- perf: Create custom trace to measure performance of opening the account list ([#27907](https://github.com/MetaMask/metamask-extension/pull/27907)) -- feat: add BTC send flow ([#27964](https://github.com/MetaMask/metamask-extension/pull/27964)) -- fix: flaky test `Confirmation Redesign ERC721 Approve Component Submit an Approve transaction @no-mmi Sends a type 2 transaction (EIP1559)` ([#27928](https://github.com/MetaMask/metamask-extension/pull/27928)) -- fix: lint-lockfile flaky job by changing resources from medium to medium-plus ([#27950](https://github.com/MetaMask/metamask-extension/pull/27950)) -- feat: add “Incomplete Asset Displayed” metric & fix: should only set default decimals if ERC20 ([#27494](https://github.com/MetaMask/metamask-extension/pull/27494)) -- feat: Convert AppStateController to typescript ([#27572](https://github.com/MetaMask/metamask-extension/pull/27572)) -- chore(deps): upgrade from json-rpc-engine to @metamask/json-rpc-engine ([#22875](https://github.com/MetaMask/metamask-extension/pull/22875)) -- feat: dapp initiated token transfer ([#27875](https://github.com/MetaMask/metamask-extension/pull/27875)) -- chore: bump signature controller to remove message managers ([#27787](https://github.com/MetaMask/metamask-extension/pull/27787)) -- chore: add testing-library/dom dependency ([#27493](https://github.com/MetaMask/metamask-extension/pull/27493)) -- test: [POM] Migrate contract interaction with snap account e2e tests to page object modal ([#27924](https://github.com/MetaMask/metamask-extension/pull/27924)) -- fix: bump message signing snap to support portfolio automatic connections ([#27936](https://github.com/MetaMask/metamask-extension/pull/27936)) -- fix: hide options menu that was being shown for preinstalled Snaps ([#27937](https://github.com/MetaMask/metamask-extension/pull/27937)) -- fix: bump `@metamask/ppom-validator` from `0.34.0` to `0.35.1` ([#27939](https://github.com/MetaMask/metamask-extension/pull/27939)) -- fix: add APE network icon ([#27841](https://github.com/MetaMask/metamask-extension/pull/27841)) -- feat: NFT permit simulations ([#27825](https://github.com/MetaMask/metamask-extension/pull/27825)) -- fix: fix currency display when tokenToFiatConversion rate is not avai… ([#27893](https://github.com/MetaMask/metamask-extension/pull/27893)) -- feat: convert AlertController to typescript ([#27764](https://github.com/MetaMask/metamask-extension/pull/27764)) -- feat(TXL-435): turn smart transactions on by default for new users ([#27885](https://github.com/MetaMask/metamask-extension/pull/27885)) -- feat: Add transaction flow and details sections ([#27654](https://github.com/MetaMask/metamask-extension/pull/27654)) -- fix: flaky test `Vault Decryptor Page is able to decrypt the vault pasting the text in the vault-decryptor webapp` ([#27921](https://github.com/MetaMask/metamask-extension/pull/27921)) -- chore: bump `@metamask/eth-snap-keyring` to version 4.4.0 ([#27864](https://github.com/MetaMask/metamask-extension/pull/27864)) -- fix: flaky tests `Add existing token using search renders the balance for the chosen token` ([#27853](https://github.com/MetaMask/metamask-extension/pull/27853)) -- feat(logging): add extension request logging and retrieval ([#27655](https://github.com/MetaMask/metamask-extension/pull/27655)) -- test: Update test-dapp to verison 8.7.0 ([#27816](https://github.com/MetaMask/metamask-extension/pull/27816)) -- fix: fall back to bundled chainlist ([#23392](https://github.com/MetaMask/metamask-extension/pull/23392)) -- fix: SonarCloud for forks ([#27700](https://github.com/MetaMask/metamask-extension/pull/27700)) -- fix(deps): update from eth-rpc-errors to @metamask/rpc-errors (cause edition) ([#24496](https://github.com/MetaMask/metamask-extension/pull/24496)) -- fix: swapQuotesError as a property in the reported metric ([#27712](https://github.com/MetaMask/metamask-extension/pull/27712)) -- chore: Bump Snaps packages ([#27376](https://github.com/MetaMask/metamask-extension/pull/27376)) -- chore: update @metamask/bitcoin-wallet-snap to 0.7.0 ([#27730](https://github.com/MetaMask/metamask-extension/pull/27730)) -- fix: Onboarding: Code style nits ([#27767](https://github.com/MetaMask/metamask-extension/pull/27767)) -- fix: updated edit modals ([#27623](https://github.com/MetaMask/metamask-extension/pull/27623)) -- feat: use asset pickers with network dropdown in cross-chain swaps page ([#27522](https://github.com/MetaMask/metamask-extension/pull/27522)) -- test: set ENABLE_MV3 automatically ([#27748](https://github.com/MetaMask/metamask-extension/pull/27748)) -- feat: Adding typed sign support for NFT permit ([#27796](https://github.com/MetaMask/metamask-extension/pull/27796)) -- fix: Contract Interaction - cannot read the property `text_signature` ([#27686](https://github.com/MetaMask/metamask-extension/pull/27686)) -- feat: Use requested permissions as default selected values for AmonHenV2 connection flow with case insensitive address comparison ([#27517](https://github.com/MetaMask/metamask-extension/pull/27517)) -- test: [POM] Migrate signature with snap account e2e tests to page object modal ([#27829](https://github.com/MetaMask/metamask-extension/pull/27829)) -- fix: flaky test `ERC1155 NFTs testdapp interaction should batch transfers ERC1155 token` ([#27897](https://github.com/MetaMask/metamask-extension/pull/27897)) -- chore: Master sync following v12.4.1 ([#27793](https://github.com/MetaMask/metamask-extension/pull/27793)) -- fix: flaky test `Permissions sets permissions and connect to Dapp` ([#27888](https://github.com/MetaMask/metamask-extension/pull/27888)) -- fix: flaky test `ERC721 NFTs testdapp interaction should prompt users to add their NFTs to their wallet (all at once)` ([#27889](https://github.com/MetaMask/metamask-extension/pull/27889)) -- fix: flaky test `Wallet Revoke Permissions should revoke eth_accounts permissions via test dapp` ([#27894](https://github.com/MetaMask/metamask-extension/pull/27894)) -- fix: flaky test `Snap Account Signatures and Disconnects can connect to the Test Dapp, then #signTypedDataV3, disconnect then connect, then #signTypedDataV4 (async flow approve)` ([#27887](https://github.com/MetaMask/metamask-extension/pull/27887)) -- test(mock-e2e): add private domains logic for the privacy report ([#27844](https://github.com/MetaMask/metamask-extension/pull/27844)) -- fix: SENTRY_DSN_FAKE problem ([#27881](https://github.com/MetaMask/metamask-extension/pull/27881)) -- chore: remove unused swaps code ([#27679](https://github.com/MetaMask/metamask-extension/pull/27679)) -- test(TXL-308): initial e2e for stx using swaps ([#27215](https://github.com/MetaMask/metamask-extension/pull/27215)) -- feat: upgrade assets-controllers to v38.3.0 ([#27755](https://github.com/MetaMask/metamask-extension/pull/27755)) -- fix: nonce value when there are multiple transactions in parallel ([#27874](https://github.com/MetaMask/metamask-extension/pull/27874)) -- fix: phishing test to not check c2 domains ([#27846](https://github.com/MetaMask/metamask-extension/pull/27846)) -- feat: use messenger in AccountTracker to get Preferences state ([#27711](https://github.com/MetaMask/metamask-extension/pull/27711)) -- fix: "Update Network: should update added rpc url for exis..." flaky tests ([#27437](https://github.com/MetaMask/metamask-extension/pull/27437)) -- feat: update copy for 'Default settings' ([#27821](https://github.com/MetaMask/metamask-extension/pull/27821)) -- fix: updated permissions flow copy changes ([#27658](https://github.com/MetaMask/metamask-extension/pull/27658)) -- fix: flaky test `Add account should not affect public address when using secret recovery phrase to recover account with non-zero balance @no-mmi` ([#27834](https://github.com/MetaMask/metamask-extension/pull/27834)) -- fix: hackily wait longer for linea swap approval tx to increase chance of success ([#27810](https://github.com/MetaMask/metamask-extension/pull/27810)) -- fix: flaky test `MultiRpc: should select rpc from settings @no-mmi` ([#27858](https://github.com/MetaMask/metamask-extension/pull/27858)) -- perf: include custom traces in benchmark results ([#27701](https://github.com/MetaMask/metamask-extension/pull/27701)) -- fix: Reset nonce as network is switched ([#27789](https://github.com/MetaMask/metamask-extension/pull/27789)) -- fix: dismiss addToken modal for mmi ([#27855](https://github.com/MetaMask/metamask-extension/pull/27855)) -- fix(multichain): fix eth send flow (from dapp) when a btc account is selected ([#27566](https://github.com/MetaMask/metamask-extension/pull/27566)) -- chore: Add react-beautiful-dnd to deprecated packages list ([#27856](https://github.com/MetaMask/metamask-extension/pull/27856)) -- feat: Create a quality gate for typescript coverage ([#27717](https://github.com/MetaMask/metamask-extension/pull/27717)) -- feat: preferences controller to base controller v2 ([#27398](https://github.com/MetaMask/metamask-extension/pull/27398)) -- revert: use networkClientId to resolve chainId in PPOM Middleware ([#27570](https://github.com/MetaMask/metamask-extension/pull/27570)) -- feat: Added metrics for edit networks and accounts ([#27820](https://github.com/MetaMask/metamask-extension/pull/27820)) -- fix: no connected state for permissions page ([#27660](https://github.com/MetaMask/metamask-extension/pull/27660)) -- feat: remove phishing detection from onboarding Security group ([#27819](https://github.com/MetaMask/metamask-extension/pull/27819)) -- ci: Revert minimum E2E timeout to 20 minutes ([#27827](https://github.com/MetaMask/metamask-extension/pull/27827)) -- fix: disable balance checker for Sepolia in account tracker ([#27763](https://github.com/MetaMask/metamask-extension/pull/27763)) -- ci: Improve validation for `sentry:publish` script ([#26580](https://github.com/MetaMask/metamask-extension/pull/26580)) -- test: Fix Vault Decryptor Page e2e test on develop branch ([#27794](https://github.com/MetaMask/metamask-extension/pull/27794)) -- chore: remove old token details page ([#27774](https://github.com/MetaMask/metamask-extension/pull/27774)) -- chore: remove token list display component ([#27772](https://github.com/MetaMask/metamask-extension/pull/27772)) -- chore: update Trezor Connect to v9.4.0, remove workarounds ([#27112](https://github.com/MetaMask/metamask-extension/pull/27112)) -- test: [POM] Migrate transaction with snap account e2e tests to page object modal ([#27760](https://github.com/MetaMask/metamask-extension/pull/27760)) -- fix(snaps): Restore confirmation switching on routed confirmation ([#27753](https://github.com/MetaMask/metamask-extension/pull/27753)) -- Merge origin/develop into master-sync -- test: Onboarding: Fix vault-decryption-chrome.spec.js ([#27779](https://github.com/MetaMask/metamask-extension/pull/27779)) -- feat: support gas fee flows in standard swaps ([#27612](https://github.com/MetaMask/metamask-extension/pull/27612)) -- feat: Token send heading component ([#27562](https://github.com/MetaMask/metamask-extension/pull/27562)) -- feat: adds the new default settings view to onboarding ([#24562](https://github.com/MetaMask/metamask-extension/pull/24562)) -- chore(3212): remove alert settings ([#27709](https://github.com/MetaMask/metamask-extension/pull/27709)) -- docs: remove outdated Medium link, update "Twitter" to "X" ([#26692](https://github.com/MetaMask/metamask-extension/pull/26692)) -- fix: Replace 'transaction fees' with 'network fees' in the insufficie… ([#27762](https://github.com/MetaMask/metamask-extension/pull/27762)) -- fix: issue with Snap title in Snap Authorship Header ([#27752](https://github.com/MetaMask/metamask-extension/pull/27752)) -- fix: SIWE signature page displays parsed URI instead of domain ([#27754](https://github.com/MetaMask/metamask-extension/pull/27754)) -- fix: updated toasts component and copy ([#27656](https://github.com/MetaMask/metamask-extension/pull/27656)) -- feat: add network picker to AssetPicker ([#26559](https://github.com/MetaMask/metamask-extension/pull/26559)) -- fix(btc): fix jazzicons generations ([#27662](https://github.com/MetaMask/metamask-extension/pull/27662)) -- feat: Release Chain Permissions ([#27561](https://github.com/MetaMask/metamask-extension/pull/27561)) -- feat: upgrade assets-controllers to v38.2.0 ([#27629](https://github.com/MetaMask/metamask-extension/pull/27629)) -- ci: followup to CircleCI Sentry reporting ([#27548](https://github.com/MetaMask/metamask-extension/pull/27548)) -- chore: Master sync ([#27729](https://github.com/MetaMask/metamask-extension/pull/27729)) -- fix(multichain): fix getMultichainCurrentCurrency selector ([#27726](https://github.com/MetaMask/metamask-extension/pull/27726)) -- fix: Limit amount of decimals on spending cap modal ([#27672](https://github.com/MetaMask/metamask-extension/pull/27672)) -- Merge origin/develop into master-sync -- test: [POM] Migrate create snap account e2e tests to page object modal ([#27697](https://github.com/MetaMask/metamask-extension/pull/27697)) -- fix: Prefer token symbol to token name ([#27693](https://github.com/MetaMask/metamask-extension/pull/27693)) -- fix(btc): fetch btc balance right after account creation ([#27628](https://github.com/MetaMask/metamask-extension/pull/27628)) -- fix: UI startup with no Sentry DSN ([#27714](https://github.com/MetaMask/metamask-extension/pull/27714)) -- feat: Sort/Import Tokens in Extension ([#27184](https://github.com/MetaMask/metamask-extension/pull/27184)) -- ci: make git-diff-develop work for PRs from foreign repos ([#27268](https://github.com/MetaMask/metamask-extension/pull/27268)) -- test: Convert json-rpc e2e tests to TypeScript ([#27659](https://github.com/MetaMask/metamask-extension/pull/27659)) -- fix: allow getAddTransactionRequest to pass through other params ([#27117](https://github.com/MetaMask/metamask-extension/pull/27117)) -- perf: add tags to UI startup trace ([#27550](https://github.com/MetaMask/metamask-extension/pull/27550)) -- fix: Disable redirecting Extension users using beta & flask build and dev env to the existing offboarding page ([#27226](https://github.com/MetaMask/metamask-extension/pull/27226)) -- feat(NOTIFY-1193): add profile sync dev menu ([#27666](https://github.com/MetaMask/metamask-extension/pull/27666)) -- refactor: Typescript conversion of log-web3-shim-usage.js ([#23732](https://github.com/MetaMask/metamask-extension/pull/23732)) -- test: removing race condition for asserting inner values (PR-#2) ([#27664](https://github.com/MetaMask/metamask-extension/pull/27664)) -- fix(btc): fix address validation ([#27690](https://github.com/MetaMask/metamask-extension/pull/27690)) -- chore: Update coverage.json ([#27696](https://github.com/MetaMask/metamask-extension/pull/27696)) -- fix: test coverage quality gate ([#27691](https://github.com/MetaMask/metamask-extension/pull/27691)) -- fix: banner alert to render multiple general alerts ([#27339](https://github.com/MetaMask/metamask-extension/pull/27339)) -- refactor: routes constants ([#27078](https://github.com/MetaMask/metamask-extension/pull/27078)) -- fix: Test coverage quality gate ([#27581](https://github.com/MetaMask/metamask-extension/pull/27581)) -- feat: Adding delete metametrics data to security and privacy tab ([#24571](https://github.com/MetaMask/metamask-extension/pull/24571)) -- feat(stx): animations and cosmetic changes to smart transaction status page ([#27650](https://github.com/MetaMask/metamask-extension/pull/27650)) -- build: add lottie-web dependency to extension ([#27632](https://github.com/MetaMask/metamask-extension/pull/27632)) -- fix(btc): do not show percentage for tokens ([#27637](https://github.com/MetaMask/metamask-extension/pull/27637)) -- feat: support Etherscan API keys ([#27611](https://github.com/MetaMask/metamask-extension/pull/27611)) -- feat: change survey timeout time from a week to a day ([#27603](https://github.com/MetaMask/metamask-extension/pull/27603)) -- fix: Design papercuts for redesigned transactions ([#27605](https://github.com/MetaMask/metamask-extension/pull/27605)) -- test: removing race condition for asserting inner values (PR-#1) ([#27606](https://github.com/MetaMask/metamask-extension/pull/27606)) -- test: [POM] Migrate Snap Simple Keyring page and Snap List page to page object modal ([#27327](https://github.com/MetaMask/metamask-extension/pull/27327)) -- fix: fix sentry reading undefined ([#27584](https://github.com/MetaMask/metamask-extension/pull/27584)) -- fix: fix sentry reading null ([#27582](https://github.com/MetaMask/metamask-extension/pull/27582)) -- fix(btc): disable balanceIsCached flag ([#27636](https://github.com/MetaMask/metamask-extension/pull/27636)) -- chore: update accounts related packages ([#27284](https://github.com/MetaMask/metamask-extension/pull/27284)) -- chore: set bridge src network, tokens and top assets ([#26214](https://github.com/MetaMask/metamask-extension/pull/26214)) -- test: [Snaps E2E] add delay to installed snaps test to reduce flaking ([#27521](https://github.com/MetaMask/metamask-extension/pull/27521)) -- chore: set bridge dest network, tokens and top assets ([#26213](https://github.com/MetaMask/metamask-extension/pull/26213)) -- fix: fix reading address from market data ([#27604](https://github.com/MetaMask/metamask-extension/pull/27604)) -- feat: Migrate AccountTrackerController to BaseController v2 ([#27258](https://github.com/MetaMask/metamask-extension/pull/27258)) -- fix: disable transaction data decode if deployment ([#27586](https://github.com/MetaMask/metamask-extension/pull/27586)) -- fix: revert jest collect coverage patterns ([#27583](https://github.com/MetaMask/metamask-extension/pull/27583)) -- fix: add amount row for contract deployment ([#27594](https://github.com/MetaMask/metamask-extension/pull/27594)) -- fix: "Dapp viewed Event @no-mmi is sent when refreshing da..." flaky test ([#27381](https://github.com/MetaMask/metamask-extension/pull/27381)) -- chore: fix deps audit ([#27620](https://github.com/MetaMask/metamask-extension/pull/27620)) -- fix: Max approval and array value spending cap bugs ([#27573](https://github.com/MetaMask/metamask-extension/pull/27573)) -- feat: add power users survey support ([#27361](https://github.com/MetaMask/metamask-extension/pull/27361)) -- fix: Recreate offscreen document if it already exists ([#27596](https://github.com/MetaMask/metamask-extension/pull/27596)) -- fix: flaky test `Block Explorer links to the token tracker in the explorer` ([#27599](https://github.com/MetaMask/metamask-extension/pull/27599)) -- fix(snaps): `Copyable` more button color ([#27600](https://github.com/MetaMask/metamask-extension/pull/27600)) -- fix: flaky test `Import flow allows importing multiple tokens from search` ([#27567](https://github.com/MetaMask/metamask-extension/pull/27567)) -- fix(27428): fix if we type enter anything followed by a \ in settings search ([#27432](https://github.com/MetaMask/metamask-extension/pull/27432)) -- fix: flaky test `Address Book Edit entry in address book` due to race condition with mmi menu ([#27557](https://github.com/MetaMask/metamask-extension/pull/27557)) -- refactor: Typescript conversion of get-provider-state.js ([#23635](https://github.com/MetaMask/metamask-extension/pull/23635)) -- chore: Use "gas_included" event prop ([#27559](https://github.com/MetaMask/metamask-extension/pull/27559)) -- fix: mock locale in unit test ([#27574](https://github.com/MetaMask/metamask-extension/pull/27574)) -- feat: codefence Account Watcher for flask ([#27543](https://github.com/MetaMask/metamask-extension/pull/27543)) -- chore: start upgrade to React Router v6 ([#27185](https://github.com/MetaMask/metamask-extension/pull/27185)) -- fix: AmonHenV2 connection flow incremental permitted chain approval and account address case comparison ([#27518](https://github.com/MetaMask/metamask-extension/pull/27518)) -- fix: flaky test `Backup and Restore should backup the account settings` ([#27565](https://github.com/MetaMask/metamask-extension/pull/27565)) -- fix: Apply flex to Snaps buttons only when containing images and icons ([#27564](https://github.com/MetaMask/metamask-extension/pull/27564)) -- feat: aggregated balance feature ([#27097](https://github.com/MetaMask/metamask-extension/pull/27097)) -- feat: Add redesign integration tests ([#27259](https://github.com/MetaMask/metamask-extension/pull/27259)) -- fix: flaky test `4byte setting does not try to get contract method name from 4byte when the setting is off` ([#27560](https://github.com/MetaMask/metamask-extension/pull/27560)) -- feat: add merge queue ([#26871](https://github.com/MetaMask/metamask-extension/pull/26871)) -- feat: remove squiggle animation from swaps smart transactions ([#27264](https://github.com/MetaMask/metamask-extension/pull/27264)) -- feat: Enable gas included swaps ([#27427](https://github.com/MetaMask/metamask-extension/pull/27427)) -- fix(snaps): Fix custom UI buttons submitting forms ([#27531](https://github.com/MetaMask/metamask-extension/pull/27531)) -- chore: Master sync following v12.3.1 ([#27538](https://github.com/MetaMask/metamask-extension/pull/27538)) -- Merge origin/develop into master-sync -- fix(NOTIFY-1171): account syncing performance and bug fixes ([#27529](https://github.com/MetaMask/metamask-extension/pull/27529)) -- fix: genUnapprovedApproveConfirmation import path ([#27530](https://github.com/MetaMask/metamask-extension/pull/27530)) -- fix(snaps): Keep focus on input if interface re-renders ([#27429](https://github.com/MetaMask/metamask-extension/pull/27429)) -- fix: Allow state updates in Snaps interfaces to state values that are falsy ([#27488](https://github.com/MetaMask/metamask-extension/pull/27488)) -- fix: updated ui for connect and review page ([#27478](https://github.com/MetaMask/metamask-extension/pull/27478)) -- feat: Custom header for wallet initiated confirmations ([#27391](https://github.com/MetaMask/metamask-extension/pull/27391)) -- feat: convert account tracker to typescript ([#27231](https://github.com/MetaMask/metamask-extension/pull/27231)) -- fix: Fix snaps permission connection for `CHAIN_PERMISSIONS` feature flag ([#27459](https://github.com/MetaMask/metamask-extension/pull/27459)) -- fix: flaky test `Navigation Signature - Different signature types initiates multiple signatures and rejects all` ([#27481](https://github.com/MetaMask/metamask-extension/pull/27481)) -- feat: Double Sentry performance trace sample rate ([#27468](https://github.com/MetaMask/metamask-extension/pull/27468)) -- ci: Expand github bot policy update comment to be more actionable ([#27242](https://github.com/MetaMask/metamask-extension/pull/27242)) -- chore: Add `useLedgerConnection` unit tests ([#27358](https://github.com/MetaMask/metamask-extension/pull/27358)) -- ci: Sentry reporting only on develop branch, with Git message overrides ([#27412](https://github.com/MetaMask/metamask-extension/pull/27412)) -- test: Fix flaky permit test ([#27450](https://github.com/MetaMask/metamask-extension/pull/27450)) -- fix: removed closeMenu for ConnectedAccountsMenu ([#27460](https://github.com/MetaMask/metamask-extension/pull/27460)) -- fix(snaps): Set proper text color for secondary button ([#27335](https://github.com/MetaMask/metamask-extension/pull/27335)) -- chore: set bridge selected tokens and amount ([#26212](https://github.com/MetaMask/metamask-extension/pull/26212)) -- fix: flaky test `Add account should not affect public address when using secret recovery phrase to recover account with non-zero balance @no-mmi`aded ([#27420](https://github.com/MetaMask/metamask-extension/pull/27420)) -- fix: flaky test `Responsive UI Send Transaction from responsive window` ([#27417](https://github.com/MetaMask/metamask-extension/pull/27417)) -- fix: flaky test `Request Queuing Dapp 1, Switch Tx -> Dapp 2 Send Tx should queue send tx after switch network confirmation and transaction should target the correct network after switch is confirmed` ([#27352](https://github.com/MetaMask/metamask-extension/pull/27352)) -- fix: Change speed key color ([#27416](https://github.com/MetaMask/metamask-extension/pull/27416)) -- feat: Display setApprovalForAll and revoke setApprovalForAll to users… ([#27401](https://github.com/MetaMask/metamask-extension/pull/27401)) -- fix: "Warning: Invalid argument supplied to oneOfType" ([#27267](https://github.com/MetaMask/metamask-extension/pull/27267)) -- feat: Editing flow ([#26635](https://github.com/MetaMask/metamask-extension/pull/26635)) -- chore: bump profile-sync-controller to 0.9.3 ([#27415](https://github.com/MetaMask/metamask-extension/pull/27415)) -- fix: Remove duplication ([#27421](https://github.com/MetaMask/metamask-extension/pull/27421)) -- fix: Confirm Page test failing in CI/CD ([#27423](https://github.com/MetaMask/metamask-extension/pull/27423)) -- feat: Display approve, increaseAllowance and revoke approval to users… ([#26985](https://github.com/MetaMask/metamask-extension/pull/26985)) -- feat: Add performance metrics for signature requests ([#26967](https://github.com/MetaMask/metamask-extension/pull/26967)) -- fix: Permit DataTree token decimals ([#27328](https://github.com/MetaMask/metamask-extension/pull/27328)) -- fix: alert system and refine SIWE and contract interaction alerts ([#27205](https://github.com/MetaMask/metamask-extension/pull/27205)) -- fix(NOTIFY-1166): rename account sync event names ([#27413](https://github.com/MetaMask/metamask-extension/pull/27413)) -- feat: ERC20 Revoke Allowance ([#26906](https://github.com/MetaMask/metamask-extension/pull/26906)) + ## [12.5.1] ### Changed - Improve accuracy of transaction simulation warnings in some scenarios ([#26845](https://github.com/MetaMask/metamask-extension/pull/26845)) From 2c9ad97c9017a41dbb322957e36279ec4ab597b9 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Thu, 31 Oct 2024 17:36:52 -0230 Subject: [PATCH 22/23] [cherry pick] Fix left aligned fullscreen (#28218) (#28229) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a cherry-pick of #28218 for v12.6.0. Original description: ## **Description** The Home screen was recently updated to make the overview left-aligned. However the fullscreen UI was not considered, and it ended up looking ugly/broken. The fullscreen UI has been updated to be centered, as it was before. The Home screen remains left-aligned in the popup. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28218?quickstart=1) ## **Related issues** Fixes #27593 ## **Manual testing steps** Compare how the Home screen overview looks on the fullscreen UI and the popup. It should be centered on the fullscreen UI, left-aligned on the popup. ## **Screenshots/Recordings** ### **Before** ![Screenshot 2024-10-31 at 11 32 12](https://github.com/user-attachments/assets/989ebd4e-90a5-42ae-a522-f7e4d77f0685) ### **After** ![Screenshot 2024-10-31 at 11 28 35](https://github.com/user-attachments/assets/6802bfab-b462-4168-8536-cabb49aceb53) ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension 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** - [ ] 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/components/app/wallet-overview/index.scss | 8 ++++++++ .../app/wallet-overview/wallet-overview.js | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/ui/components/app/wallet-overview/index.scss b/ui/components/app/wallet-overview/index.scss index 4759af1ffa8c..318c26501097 100644 --- a/ui/components/app/wallet-overview/index.scss +++ b/ui/components/app/wallet-overview/index.scss @@ -9,6 +9,10 @@ flex-direction: column; width: 100%; + &-fullscreen { + align-items: center; + } + &__balance { flex: 1; display: flex; @@ -16,6 +20,10 @@ flex-direction: column; align-items: start; width: 100%; + + .wallet-overview-fullscreen > & { + align-items: center; + } } &__icon_button { diff --git a/ui/components/app/wallet-overview/wallet-overview.js b/ui/components/app/wallet-overview/wallet-overview.js index 213a7b2f2317..04127276acaf 100644 --- a/ui/components/app/wallet-overview/wallet-overview.js +++ b/ui/components/app/wallet-overview/wallet-overview.js @@ -2,9 +2,23 @@ import React from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; +// TODO: Move this function to shared +// eslint-disable-next-line import/no-restricted-paths +import { getEnvironmentType } from '../../../../app/scripts/lib/util'; +import { ENVIRONMENT_TYPE_FULLSCREEN } from '../../../../shared/constants/app'; + const WalletOverview = ({ balance, buttons, className }) => { return ( -
+
{balance}
{buttons}
From f6441023cd31e22f49fe02fe29230f3d064b5603 Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Thu, 31 Oct 2024 21:49:04 +0000 Subject: [PATCH 23/23] fix: cherry-pick: Prevent coercing small spending caps to zero (#28179) (#28183) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cherry-pick: https://github.com/MetaMask/metamask-extension/pull/28179 ## **Description** Previously there was a bug that affected the approve screen. When users had a small spending cap (between 0.001 and 0.0001 or smaller), it was coerced to 0. This was caused by the method `new Intl.NumberFormat(locale).format(spendingCap)` that applied the `1,000` large number formatting, so the fix is to bypass it entirely for values smaller than 1. Additionally, these unformatted small numbers are presented in scientific notation, so we leverage `toNonScientificString(spendingCap)` to prevent that. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28179?quickstart=1) ## **Related issues** Fixes: [#28117](https://github.com/MetaMask/metamask-extension/issues/28117) ## **Manual testing steps** See original bug report. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension 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. ## **Description** [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28183?quickstart=1) ## **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 Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension 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. --- .../use-approve-token-simulation.test.ts | 68 ++++++++++++++++++- .../hooks/use-approve-token-simulation.ts | 14 +++- 2 files changed, 79 insertions(+), 3 deletions(-) diff --git a/ui/pages/confirmations/components/confirm/info/approve/hooks/use-approve-token-simulation.test.ts b/ui/pages/confirmations/components/confirm/info/approve/hooks/use-approve-token-simulation.test.ts index 4173d21910c5..0178e2ffff62 100644 --- a/ui/pages/confirmations/components/confirm/info/approve/hooks/use-approve-token-simulation.test.ts +++ b/ui/pages/confirmations/components/confirm/info/approve/hooks/use-approve-token-simulation.test.ts @@ -65,7 +65,7 @@ describe('useApproveTokenSimulation', () => { expect(result.current).toMatchInlineSnapshot(` { - "formattedSpendingCap": 7, + "formattedSpendingCap": "7", "pending": undefined, "spendingCap": "#7", "value": { @@ -155,4 +155,70 @@ describe('useApproveTokenSimulation', () => { } `); }); + + it('returns correct small decimal number token amount for fungible tokens', async () => { + const useIsNFTMock = jest.fn().mockImplementation(() => ({ isNFT: false })); + + const useDecodedTransactionDataMock = jest.fn().mockImplementation(() => ({ + pending: false, + value: { + data: [ + { + name: 'approve', + params: [ + { + type: 'address', + value: '0x9bc5baF874d2DA8D216aE9f137804184EE5AfEF4', + }, + { + type: 'uint256', + value: 10 ** 5, + }, + ], + }, + ], + source: 'FourByte', + }, + })); + + (useIsNFT as jest.Mock).mockImplementation(useIsNFTMock); + (useDecodedTransactionData as jest.Mock).mockImplementation( + useDecodedTransactionDataMock, + ); + + const transactionMeta = genUnapprovedContractInteractionConfirmation({ + address: CONTRACT_INTERACTION_SENDER_ADDRESS, + }) as TransactionMeta; + + const { result } = renderHookWithProvider( + () => useApproveTokenSimulation(transactionMeta, '18'), + mockState, + ); + + expect(result.current).toMatchInlineSnapshot(` + { + "formattedSpendingCap": "0.0000000000001", + "pending": undefined, + "spendingCap": "0.0000000000001", + "value": { + "data": [ + { + "name": "approve", + "params": [ + { + "type": "address", + "value": "0x9bc5baF874d2DA8D216aE9f137804184EE5AfEF4", + }, + { + "type": "uint256", + "value": 100000, + }, + ], + }, + ], + "source": "FourByte", + }, + } + `); + }); }); diff --git a/ui/pages/confirmations/components/confirm/info/approve/hooks/use-approve-token-simulation.ts b/ui/pages/confirmations/components/confirm/info/approve/hooks/use-approve-token-simulation.ts index 19f26c9c9300..8d938a12c461 100644 --- a/ui/pages/confirmations/components/confirm/info/approve/hooks/use-approve-token-simulation.ts +++ b/ui/pages/confirmations/components/confirm/info/approve/hooks/use-approve-token-simulation.ts @@ -15,6 +15,15 @@ function isSpendingCapUnlimited(decodedSpendingCap: number) { return decodedSpendingCap >= UNLIMITED_THRESHOLD; } +function toNonScientificString(num: number): string { + if (num >= 10e-18) { + return num.toFixed(18).replace(/\.?0+$/u, ''); + } + + // keep in scientific notation + return num.toString(); +} + export const useApproveTokenSimulation = ( transactionMeta: TransactionMeta, decimals: string, @@ -46,8 +55,9 @@ export const useApproveTokenSimulation = ( }, [value, decimals]); const formattedSpendingCap = useMemo(() => { - return isNFT - ? decodedSpendingCap + // formatting coerces small numbers to 0 + return isNFT || decodedSpendingCap < 1 + ? toNonScientificString(decodedSpendingCap) : new Intl.NumberFormat(locale).format(decodedSpendingCap); }, [decodedSpendingCap, isNFT, locale]);