From 366ffe67c35e0936b3145ac9a1a3410c704adbb4 Mon Sep 17 00:00:00 2001 From: MetaMask Bot Date: Thu, 20 Apr 2023 23:15:06 +0000 Subject: [PATCH 01/14] Version v10.30.0 --- CHANGELOG.md | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++- package.json | 2 +- 2 files changed, 102 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22e11a337..d8c97e196 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,105 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [10.30.0] +### Uncategorized +- Master sync PR following v10.29.0 ([#18701](https://github.com/MetaMask/metamask-extension/pull/18701)) +- Merge branch 'develop' into master-sync +- Bump coverage targets ([#18702](https://github.com/MetaMask/metamask-extension/pull/18702)) +- Merge branch 'develop' into master-sync +- Recovery phrase chips onboarding unit tests ([#18249](https://github.com/MetaMask/metamask-extension/pull/18249)) +- Onboarding flow switch unit test ([#18251](https://github.com/MetaMask/metamask-extension/pull/18251)) +- Create Password onboarding unit test, test-ids, and snapshot ([#18257](https://github.com/MetaMask/metamask-extension/pull/18257)) +- Review Recovery Phrase onboarding unit test ([#18301](https://github.com/MetaMask/metamask-extension/pull/18301)) +- Update NC setProviderType to clear rpcUrl/nickname ([#18675](https://github.com/MetaMask/metamask-extension/pull/18675)) +- Metametrics onboarding unit test, snapshot ([#18253](https://github.com/MetaMask/metamask-extension/pull/18253)) +- Adding deprecation notice to javascript version of Icon ([#18680](https://github.com/MetaMask/metamask-extension/pull/18680)) +- Creation successful test improvements ([#18256](https://github.com/MetaMask/metamask-extension/pull/18256)) +- Use fake provider for NetworkController unit tests ([#18628](https://github.com/MetaMask/metamask-extension/pull/18628)) +- Remove mobile sync feature ([#18692](https://github.com/MetaMask/metamask-extension/pull/18692)) +- Import srp onboarding unit tests ([#18255](https://github.com/MetaMask/metamask-extension/pull/18255)) +- Add Network Modal onboarding tests ([#18258](https://github.com/MetaMask/metamask-extension/pull/18258)) +- Create New Vault test improvements ([#18259](https://github.com/MetaMask/metamask-extension/pull/18259)) +- Update to component-library readme ([#18501](https://github.com/MetaMask/metamask-extension/pull/18501)) +- Make `upsertNetworkConfiguration` async ([#18606](https://github.com/MetaMask/metamask-extension/pull/18606)) +- 18566 firefox ledger u2f message ([#18570](https://github.com/MetaMask/metamask-extension/pull/18570)) +- Fix/18492/update icon ts app folder ([#18645](https://github.com/MetaMask/metamask-extension/pull/18645)) +- Fix swaps controller: update provider after networkIdStore state update ([#18670](https://github.com/MetaMask/metamask-extension/pull/18670)) +- Master sync following v10.28.2 and v10.28.3 ([#18656](https://github.com/MetaMask/metamask-extension/pull/18656)) +- use `history.replace()` instead of `history.push()` ([#18663](https://github.com/MetaMask/metamask-extension/pull/18663)) +- Feat/18308/ds popover header component ([#18489](https://github.com/MetaMask/metamask-extension/pull/18489)) +- fix(18574): fix new BigNumber() not a number: undefined for setApprovalForAll method ([#18660](https://github.com/MetaMask/metamask-extension/pull/18660)) +- Fix Sentry console logs ([#18539](https://github.com/MetaMask/metamask-extension/pull/18539)) +- removed portfolio icon from eth overview ([#18662](https://github.com/MetaMask/metamask-extension/pull/18662)) +- Merge remote-tracking branch 'origin/develop' into master-sync +- removeNetworkConfiguration validates given ID ([#18650](https://github.com/MetaMask/metamask-extension/pull/18650)) +- UX Multichain: updated ethereum logo icon ([#18528](https://github.com/MetaMask/metamask-extension/pull/18528)) +- Avoid resetting the mock server ([#18661](https://github.com/MetaMask/metamask-extension/pull/18661)) +- Rename migration 83 to 84 and rename migration 84 to 83 ([#18655](https://github.com/MetaMask/metamask-extension/pull/18655)) +- wait for gas estimate to update ([#18658](https://github.com/MetaMask/metamask-extension/pull/18658)) +- knob to control ([#18635](https://github.com/MetaMask/metamask-extension/pull/18635)) +- Update gas limit on token allowance change ([#18524](https://github.com/MetaMask/metamask-extension/pull/18524)) +- Ledger trezor display ([#18637](https://github.com/MetaMask/metamask-extension/pull/18637)) +- Adding documentation for confirmation code cleanup ([#17975](https://github.com/MetaMask/metamask-extension/pull/17975)) +- update Icon to TS version in UI Folder ([#18551](https://github.com/MetaMask/metamask-extension/pull/18551)) +- use network did change instead of state update for assetsContractController ([#18629](https://github.com/MetaMask/metamask-extension/pull/18629)) +- Make `setActiveNetwork` async ([#18605](https://github.com/MetaMask/metamask-extension/pull/18605)) +- Fix approve all warning modal ([#18613](https://github.com/MetaMask/metamask-extension/pull/18613)) +- Overriding gas estimate in the send page even if enough ETH is not available ([#18554](https://github.com/MetaMask/metamask-extension/pull/18554)) +- Pass correct params to fetchEstimatedL1Fee in the swaps controller ([#18634](https://github.com/MetaMask/metamask-extension/pull/18634)) +- fix/18577: Add title back for approving ERC20 token ([#18617](https://github.com/MetaMask/metamask-extension/pull/18617)) +- [FLASK] Redesign `dropdown-tab` ([#18546](https://github.com/MetaMask/metamask-extension/pull/18546)) +- Adopt security provider request from core ([#18520](https://github.com/MetaMask/metamask-extension/pull/18520)) +- Refactor confirm-send-ether into functional component ([#18527](https://github.com/MetaMask/metamask-extension/pull/18527)) +- Fix error in console on rejecting signature request ([#18614](https://github.com/MetaMask/metamask-extension/pull/18614)) +- Make `resetConnection` async ([#18601](https://github.com/MetaMask/metamask-extension/pull/18601)) +- Make `setProviderType` async ([#18604](https://github.com/MetaMask/metamask-extension/pull/18604)) +- update to enum DS Text component ([#18584](https://github.com/MetaMask/metamask-extension/pull/18584)) +- Consolidate network stores ([#18595](https://github.com/MetaMask/metamask-extension/pull/18595)) +- Make network controller internal fields private ([#18607](https://github.com/MetaMask/metamask-extension/pull/18607)) +- [MMI] Added custody-labels and account-list components ([#18197](https://github.com/MetaMask/metamask-extension/pull/18197)) +- New reusable gas-display component ([#17976](https://github.com/MetaMask/metamask-extension/pull/17976)) +- updated onClick of close button to call the same autohide fxn as the NFT import removal ([#18504](https://github.com/MetaMask/metamask-extension/pull/18504)) +- [FLASK] Remove unused snaps code ([#18565](https://github.com/MetaMask/metamask-extension/pull/18565)) +- fix: add metrics event to sign controller ([#18318](https://github.com/MetaMask/metamask-extension/pull/18318)) +- [MMI] moves mmi selectors to institutional folder ([#18542](https://github.com/MetaMask/metamask-extension/pull/18542)) +- Fix issue with requests with empty data being forwarded to opensea ([#18598](https://github.com/MetaMask/metamask-extension/pull/18598)) +- Make `rollbackToPreviousProvider` async ([#18599](https://github.com/MetaMask/metamask-extension/pull/18599)) +- Make `_setProviderConfig` async ([#18600](https://github.com/MetaMask/metamask-extension/pull/18600)) +- Remove the network controller `previousProviderStore` ([#18593](https://github.com/MetaMask/metamask-extension/pull/18593)) +- Disable rate limiting for signature approval requests ([#18594](https://github.com/MetaMask/metamask-extension/pull/18594)) +- Make `_switchNetwork` async ([#18597](https://github.com/MetaMask/metamask-extension/pull/18597)) +- Updating Terms of Use, Adding popover and onboarding flow check ([#18221](https://github.com/MetaMask/metamask-extension/pull/18221)) +- Convert NetworkController net client tests to TS ([#18490](https://github.com/MetaMask/metamask-extension/pull/18490)) +- [MMI] Interactive replacement token modal ([#18523](https://github.com/MetaMask/metamask-extension/pull/18523)) +- [FLASK] Revert changes made to stable permission display (UI design) ([#18470](https://github.com/MetaMask/metamask-extension/pull/18470)) +- test: increase timeout for failing tests ([#18189](https://github.com/MetaMask/metamask-extension/pull/18189)) +- Trigger unlock popup in appStateController using ApprovalController ([#18386](https://github.com/MetaMask/metamask-extension/pull/18386)) +- devdeps: mocha@7.2.0->9.2.2 ([#18195](https://github.com/MetaMask/metamask-extension/pull/18195)) +- Update multichain Icon imports ([#18536](https://github.com/MetaMask/metamask-extension/pull/18536)) +- updated copy Address ([#18557](https://github.com/MetaMask/metamask-extension/pull/18557)) +- UX: Multichain: App header ([#18363](https://github.com/MetaMask/metamask-extension/pull/18363)) +- Disabling network and account changes after the send flow is initiated ([#18086](https://github.com/MetaMask/metamask-extension/pull/18086)) +- deps/security: vm2@3.9.15->3.9.16 ([#18555](https://github.com/MetaMask/metamask-extension/pull/18555)) +- [MMI] 2642 compliance modal component ([#18410](https://github.com/MetaMask/metamask-extension/pull/18410)) +- Refactor eth_getEncryptionPublicKey handling ([#18319](https://github.com/MetaMask/metamask-extension/pull/18319)) +- Convert NetworkController unit tests to TypeScript ([#18476](https://github.com/MetaMask/metamask-extension/pull/18476)) +- update ButtonIcon to TS ([#18448](https://github.com/MetaMask/metamask-extension/pull/18448)) +- Update controllers to include core v42 release ([#18464](https://github.com/MetaMask/metamask-extension/pull/18464)) +- Remove METAMASK_NOTIFIER ([#18437](https://github.com/MetaMask/metamask-extension/pull/18437)) +- Fix e2e test for NFT interactions ([#18540](https://github.com/MetaMask/metamask-extension/pull/18540)) +- Convert NetworkController to TS ([#18358](https://github.com/MetaMask/metamask-extension/pull/18358)) +- Update the gas fee controller from v1 to v3 ([#18466](https://github.com/MetaMask/metamask-extension/pull/18466)) +- Trigger transaction popup using ApprovalController ([#18400](https://github.com/MetaMask/metamask-extension/pull/18400)) +- Fix Unable to determine contract standard error ([#18300](https://github.com/MetaMask/metamask-extension/pull/18300)) +- test: increase jest testTimeout 2500->5500 ([#18480](https://github.com/MetaMask/metamask-extension/pull/18480)) +- initial changes to support controls over knobs in storybook ([#18502](https://github.com/MetaMask/metamask-extension/pull/18502)) +- deps/security: vm2@3.9.11->3.9.15 ([#18512](https://github.com/MetaMask/metamask-extension/pull/18512)) +- Part of 17670: Replace Typography with Text swap-import-token ([#18479](https://github.com/MetaMask/metamask-extension/pull/18479)) +- Update new send icon ([#18411](https://github.com/MetaMask/metamask-extension/pull/18411)) +- Update the announcement controller to v2 ([#18465](https://github.com/MetaMask/metamask-extension/pull/18465)) +- Add more info to Extensions list ([#18391](https://github.com/MetaMask/metamask-extension/pull/18391)) + ## [10.29.0] ### Added - [FLASK] Redesign snaps permission screens ([#18372](https://github.com/MetaMask/metamask-extension/pull/18372)) @@ -3688,7 +3787,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Uncategorized - Added the ability to restore accounts from seed words. -[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.29.0...HEAD +[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.30.0...HEAD +[10.30.0]: https://github.com/MetaMask/metamask-extension/compare/v10.29.0...v10.30.0 [10.29.0]: https://github.com/MetaMask/metamask-extension/compare/v10.28.3...v10.29.0 [10.28.3]: https://github.com/MetaMask/metamask-extension/compare/v10.28.2...v10.28.3 [10.28.2]: https://github.com/MetaMask/metamask-extension/compare/v10.28.1...v10.28.2 diff --git a/package.json b/package.json index 95c969e9e..f12c3c961 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "metamask-crx", - "version": "10.29.0", + "version": "10.30.0", "private": true, "repository": { "type": "git", From f89f96343b06ca934a221df779655e65b1c23fa0 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Wed, 26 Apr 2023 12:26:33 -0230 Subject: [PATCH 02/14] Fix mv3 beta build (#18690) * Build beta with mv3 enabled * Ensure firefox manifest is an mv2 version * Revert "Ensure firefox manifest is an mv2 version" This reverts commit fed74792b0fec33c3a85f2229eb560559d37afe5. * Only create beta builds for the chrome platform * Stop linting firefox for beta --- .circleci/config.yml | 17 ---------------- .circleci/scripts/mozilla-lint-beta.sh | 27 ------------------------- .circleci/scripts/trigger-beta-build.sh | 5 +++-- development/build/index.js | 12 ++++++++++- 4 files changed, 14 insertions(+), 47 deletions(-) delete mode 100755 .circleci/scripts/mozilla-lint-beta.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 68a1c199a..467aabc59 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -143,11 +143,6 @@ workflows: requires: - prep-deps - prep-build - - test-mozilla-lint-beta: - <<: *rc_branch_only - requires: - - prep-deps - - trigger-beta-build - test-mozilla-lint-desktop: filters: branches: @@ -176,7 +171,6 @@ workflows: - validate-source-maps-desktop - validate-source-maps-flask - test-mozilla-lint - - test-mozilla-lint-beta - test-mozilla-lint-desktop - test-mozilla-lint-flask - test-e2e-chrome @@ -1144,17 +1138,6 @@ jobs: name: test:mozilla-lint command: NODE_OPTIONS=--max_old_space_size=3072 yarn mozilla-lint - test-mozilla-lint-beta: - executor: node-browsers - steps: - - checkout - - attach_workspace: - at: . - - run: - name: Lint beta for firefox - command: | - .circleci/scripts/mozilla-lint-beta.sh - test-mozilla-lint-desktop: executor: node-browsers steps: diff --git a/.circleci/scripts/mozilla-lint-beta.sh b/.circleci/scripts/mozilla-lint-beta.sh deleted file mode 100755 index 1096526b7..000000000 --- a/.circleci/scripts/mozilla-lint-beta.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -u -set -o pipefail - -current_commit_msg=$(git show -s --format='%s' HEAD) - -if [[ $current_commit_msg =~ Version[[:space:]](v[[:digit:]]+.[[:digit:]]+.[[:digit:]]+[-]beta.[[:digit:]]) ]] -then - # filter the commit message like Version v10.24.1-beta.1 - printf '%s\n' "Linting beta builds for firefox" - # Move beta build to dist - mv ./dist-beta ./dist - # Move beta zips to builds - mv ./builds-beta ./builds - # test:mozilla-lint - export NODE_OPTIONS='--max_old_space_size=3072' - yarn mozilla-lint -else - printf '%s\n' 'Commit message does not match commit message for beta pattern; skipping linting for firefox' - mkdir dist - mkdir builds - exit 0 -fi - -exit 0 diff --git a/.circleci/scripts/trigger-beta-build.sh b/.circleci/scripts/trigger-beta-build.sh index 77cc8f1c8..34801a476 100755 --- a/.circleci/scripts/trigger-beta-build.sh +++ b/.circleci/scripts/trigger-beta-build.sh @@ -12,8 +12,9 @@ if [[ $current_commit_msg =~ Version[[:space:]](v[[:digit:]]+.[[:digit:]]+.[[:di then # filter the commit message like Version v10.24.1-beta.1 printf '%s\n' "Create a build for $version with beta version $current_commit_msg" - yarn build --build-type beta dist - yarn build --build-type beta prod + export ENABLE_MV3=true + yarn build --build-type beta --platform='chrome' dist + yarn build --build-type beta --platform='chrome' prod else printf '%s\n' 'Commit message does not match commit message for beta pattern; skipping beta automation build' mkdir dist diff --git a/development/build/index.js b/development/build/index.js index a82d9bbd3..dfa5d4652 100755 --- a/development/build/index.js +++ b/development/build/index.js @@ -71,6 +71,7 @@ async function defineAndRunBuildTasks() { shouldLintFenceFiles, skipStats, version, + platform, } = await parseArgv(); // scuttle on production/tests environment only @@ -129,7 +130,7 @@ async function defineAndRunBuildTasks() { ], }); - const browserPlatforms = ['firefox', 'chrome']; + const browserPlatforms = platform ? [platform] : ['firefox', 'chrome']; const browserVersionMap = getBrowserVersionMap(browserPlatforms, version); @@ -311,6 +312,13 @@ testDev: Create an unoptimized, live-reloading build for debugging e2e tests.`, hidden: true, type: 'boolean', }) + .option('platform', { + default: '', + description: + 'Specify a single browser platform to build for. Either `chrome` or `firefox`', + hidden: true, + type: 'string', + }) .check((args) => { if (!Number.isInteger(args.buildVersion)) { throw new Error( @@ -335,6 +343,7 @@ testDev: Create an unoptimized, live-reloading build for debugging e2e tests.`, policyOnly, skipStats, task, + platform, } = argv; // Manually default this to `false` for dev builds only. @@ -365,6 +374,7 @@ testDev: Create an unoptimized, live-reloading build for debugging e2e tests.`, shouldLintFenceFiles, skipStats, version, + platform, }; } From ffc4d6022b65e07f7c515ca765983b136338fe08 Mon Sep 17 00:00:00 2001 From: Thomas Huang Date: Wed, 26 Apr 2023 11:22:56 -0700 Subject: [PATCH 03/14] Update changelog for v10.30.0 (#18812) * [skip e2e] Update changelog for v10.30.0 * Remove MMI change and move terms of use addition to the 'Added' section --------- Co-authored-by: Dan J Miller --- CHANGELOG.md | 110 +++++++-------------------------------------------- 1 file changed, 15 insertions(+), 95 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8c97e196..bbac0646b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,103 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ## [10.30.0] -### Uncategorized -- Master sync PR following v10.29.0 ([#18701](https://github.com/MetaMask/metamask-extension/pull/18701)) -- Merge branch 'develop' into master-sync -- Bump coverage targets ([#18702](https://github.com/MetaMask/metamask-extension/pull/18702)) -- Merge branch 'develop' into master-sync -- Recovery phrase chips onboarding unit tests ([#18249](https://github.com/MetaMask/metamask-extension/pull/18249)) -- Onboarding flow switch unit test ([#18251](https://github.com/MetaMask/metamask-extension/pull/18251)) -- Create Password onboarding unit test, test-ids, and snapshot ([#18257](https://github.com/MetaMask/metamask-extension/pull/18257)) -- Review Recovery Phrase onboarding unit test ([#18301](https://github.com/MetaMask/metamask-extension/pull/18301)) -- Update NC setProviderType to clear rpcUrl/nickname ([#18675](https://github.com/MetaMask/metamask-extension/pull/18675)) -- Metametrics onboarding unit test, snapshot ([#18253](https://github.com/MetaMask/metamask-extension/pull/18253)) -- Adding deprecation notice to javascript version of Icon ([#18680](https://github.com/MetaMask/metamask-extension/pull/18680)) -- Creation successful test improvements ([#18256](https://github.com/MetaMask/metamask-extension/pull/18256)) -- Use fake provider for NetworkController unit tests ([#18628](https://github.com/MetaMask/metamask-extension/pull/18628)) -- Remove mobile sync feature ([#18692](https://github.com/MetaMask/metamask-extension/pull/18692)) -- Import srp onboarding unit tests ([#18255](https://github.com/MetaMask/metamask-extension/pull/18255)) -- Add Network Modal onboarding tests ([#18258](https://github.com/MetaMask/metamask-extension/pull/18258)) -- Create New Vault test improvements ([#18259](https://github.com/MetaMask/metamask-extension/pull/18259)) -- Update to component-library readme ([#18501](https://github.com/MetaMask/metamask-extension/pull/18501)) -- Make `upsertNetworkConfiguration` async ([#18606](https://github.com/MetaMask/metamask-extension/pull/18606)) -- 18566 firefox ledger u2f message ([#18570](https://github.com/MetaMask/metamask-extension/pull/18570)) -- Fix/18492/update icon ts app folder ([#18645](https://github.com/MetaMask/metamask-extension/pull/18645)) -- Fix swaps controller: update provider after networkIdStore state update ([#18670](https://github.com/MetaMask/metamask-extension/pull/18670)) -- Master sync following v10.28.2 and v10.28.3 ([#18656](https://github.com/MetaMask/metamask-extension/pull/18656)) -- use `history.replace()` instead of `history.push()` ([#18663](https://github.com/MetaMask/metamask-extension/pull/18663)) -- Feat/18308/ds popover header component ([#18489](https://github.com/MetaMask/metamask-extension/pull/18489)) -- fix(18574): fix new BigNumber() not a number: undefined for setApprovalForAll method ([#18660](https://github.com/MetaMask/metamask-extension/pull/18660)) -- Fix Sentry console logs ([#18539](https://github.com/MetaMask/metamask-extension/pull/18539)) -- removed portfolio icon from eth overview ([#18662](https://github.com/MetaMask/metamask-extension/pull/18662)) -- Merge remote-tracking branch 'origin/develop' into master-sync -- removeNetworkConfiguration validates given ID ([#18650](https://github.com/MetaMask/metamask-extension/pull/18650)) -- UX Multichain: updated ethereum logo icon ([#18528](https://github.com/MetaMask/metamask-extension/pull/18528)) -- Avoid resetting the mock server ([#18661](https://github.com/MetaMask/metamask-extension/pull/18661)) -- Rename migration 83 to 84 and rename migration 84 to 83 ([#18655](https://github.com/MetaMask/metamask-extension/pull/18655)) -- wait for gas estimate to update ([#18658](https://github.com/MetaMask/metamask-extension/pull/18658)) -- knob to control ([#18635](https://github.com/MetaMask/metamask-extension/pull/18635)) -- Update gas limit on token allowance change ([#18524](https://github.com/MetaMask/metamask-extension/pull/18524)) -- Ledger trezor display ([#18637](https://github.com/MetaMask/metamask-extension/pull/18637)) -- Adding documentation for confirmation code cleanup ([#17975](https://github.com/MetaMask/metamask-extension/pull/17975)) -- update Icon to TS version in UI Folder ([#18551](https://github.com/MetaMask/metamask-extension/pull/18551)) -- use network did change instead of state update for assetsContractController ([#18629](https://github.com/MetaMask/metamask-extension/pull/18629)) -- Make `setActiveNetwork` async ([#18605](https://github.com/MetaMask/metamask-extension/pull/18605)) -- Fix approve all warning modal ([#18613](https://github.com/MetaMask/metamask-extension/pull/18613)) -- Overriding gas estimate in the send page even if enough ETH is not available ([#18554](https://github.com/MetaMask/metamask-extension/pull/18554)) -- Pass correct params to fetchEstimatedL1Fee in the swaps controller ([#18634](https://github.com/MetaMask/metamask-extension/pull/18634)) -- fix/18577: Add title back for approving ERC20 token ([#18617](https://github.com/MetaMask/metamask-extension/pull/18617)) -- [FLASK] Redesign `dropdown-tab` ([#18546](https://github.com/MetaMask/metamask-extension/pull/18546)) -- Adopt security provider request from core ([#18520](https://github.com/MetaMask/metamask-extension/pull/18520)) -- Refactor confirm-send-ether into functional component ([#18527](https://github.com/MetaMask/metamask-extension/pull/18527)) -- Fix error in console on rejecting signature request ([#18614](https://github.com/MetaMask/metamask-extension/pull/18614)) -- Make `resetConnection` async ([#18601](https://github.com/MetaMask/metamask-extension/pull/18601)) -- Make `setProviderType` async ([#18604](https://github.com/MetaMask/metamask-extension/pull/18604)) -- update to enum DS Text component ([#18584](https://github.com/MetaMask/metamask-extension/pull/18584)) -- Consolidate network stores ([#18595](https://github.com/MetaMask/metamask-extension/pull/18595)) -- Make network controller internal fields private ([#18607](https://github.com/MetaMask/metamask-extension/pull/18607)) -- [MMI] Added custody-labels and account-list components ([#18197](https://github.com/MetaMask/metamask-extension/pull/18197)) -- New reusable gas-display component ([#17976](https://github.com/MetaMask/metamask-extension/pull/17976)) -- updated onClick of close button to call the same autohide fxn as the NFT import removal ([#18504](https://github.com/MetaMask/metamask-extension/pull/18504)) -- [FLASK] Remove unused snaps code ([#18565](https://github.com/MetaMask/metamask-extension/pull/18565)) -- fix: add metrics event to sign controller ([#18318](https://github.com/MetaMask/metamask-extension/pull/18318)) -- [MMI] moves mmi selectors to institutional folder ([#18542](https://github.com/MetaMask/metamask-extension/pull/18542)) -- Fix issue with requests with empty data being forwarded to opensea ([#18598](https://github.com/MetaMask/metamask-extension/pull/18598)) -- Make `rollbackToPreviousProvider` async ([#18599](https://github.com/MetaMask/metamask-extension/pull/18599)) -- Make `_setProviderConfig` async ([#18600](https://github.com/MetaMask/metamask-extension/pull/18600)) -- Remove the network controller `previousProviderStore` ([#18593](https://github.com/MetaMask/metamask-extension/pull/18593)) -- Disable rate limiting for signature approval requests ([#18594](https://github.com/MetaMask/metamask-extension/pull/18594)) -- Make `_switchNetwork` async ([#18597](https://github.com/MetaMask/metamask-extension/pull/18597)) +### Added - Updating Terms of Use, Adding popover and onboarding flow check ([#18221](https://github.com/MetaMask/metamask-extension/pull/18221)) -- Convert NetworkController net client tests to TS ([#18490](https://github.com/MetaMask/metamask-extension/pull/18490)) -- [MMI] Interactive replacement token modal ([#18523](https://github.com/MetaMask/metamask-extension/pull/18523)) -- [FLASK] Revert changes made to stable permission display (UI design) ([#18470](https://github.com/MetaMask/metamask-extension/pull/18470)) -- test: increase timeout for failing tests ([#18189](https://github.com/MetaMask/metamask-extension/pull/18189)) -- Trigger unlock popup in appStateController using ApprovalController ([#18386](https://github.com/MetaMask/metamask-extension/pull/18386)) -- devdeps: mocha@7.2.0->9.2.2 ([#18195](https://github.com/MetaMask/metamask-extension/pull/18195)) -- Update multichain Icon imports ([#18536](https://github.com/MetaMask/metamask-extension/pull/18536)) -- updated copy Address ([#18557](https://github.com/MetaMask/metamask-extension/pull/18557)) -- UX: Multichain: App header ([#18363](https://github.com/MetaMask/metamask-extension/pull/18363)) + +### Changed +- Update ethereum logo icon ([#18528](https://github.com/MetaMask/metamask-extension/pull/18528)) +- Update send icon ([#18411](https://github.com/MetaMask/metamask-extension/pull/18411)) - Disabling network and account changes after the send flow is initiated ([#18086](https://github.com/MetaMask/metamask-extension/pull/18086)) -- deps/security: vm2@3.9.15->3.9.16 ([#18555](https://github.com/MetaMask/metamask-extension/pull/18555)) -- [MMI] 2642 compliance modal component ([#18410](https://github.com/MetaMask/metamask-extension/pull/18410)) -- Refactor eth_getEncryptionPublicKey handling ([#18319](https://github.com/MetaMask/metamask-extension/pull/18319)) -- Convert NetworkController unit tests to TypeScript ([#18476](https://github.com/MetaMask/metamask-extension/pull/18476)) -- update ButtonIcon to TS ([#18448](https://github.com/MetaMask/metamask-extension/pull/18448)) -- Update controllers to include core v42 release ([#18464](https://github.com/MetaMask/metamask-extension/pull/18464)) -- Remove METAMASK_NOTIFIER ([#18437](https://github.com/MetaMask/metamask-extension/pull/18437)) -- Fix e2e test for NFT interactions ([#18540](https://github.com/MetaMask/metamask-extension/pull/18540)) -- Convert NetworkController to TS ([#18358](https://github.com/MetaMask/metamask-extension/pull/18358)) -- Update the gas fee controller from v1 to v3 ([#18466](https://github.com/MetaMask/metamask-extension/pull/18466)) -- Trigger transaction popup using ApprovalController ([#18400](https://github.com/MetaMask/metamask-extension/pull/18400)) -- Fix Unable to determine contract standard error ([#18300](https://github.com/MetaMask/metamask-extension/pull/18300)) -- test: increase jest testTimeout 2500->5500 ([#18480](https://github.com/MetaMask/metamask-extension/pull/18480)) -- initial changes to support controls over knobs in storybook ([#18502](https://github.com/MetaMask/metamask-extension/pull/18502)) -- deps/security: vm2@3.9.11->3.9.15 ([#18512](https://github.com/MetaMask/metamask-extension/pull/18512)) -- Part of 17670: Replace Typography with Text swap-import-token ([#18479](https://github.com/MetaMask/metamask-extension/pull/18479)) -- Update new send icon ([#18411](https://github.com/MetaMask/metamask-extension/pull/18411)) -- Update the announcement controller to v2 ([#18465](https://github.com/MetaMask/metamask-extension/pull/18465)) -- Add more info to Extensions list ([#18391](https://github.com/MetaMask/metamask-extension/pull/18391)) +- [FLASK] Redesign `dropdown-tab` ([#18546](https://github.com/MetaMask/metamask-extension/pull/18546)) +- New reusable gas-display component ([#17976](https://github.com/MetaMask/metamask-extension/pull/17976)) +- "Insufficient balance for gas" error no longer prevents from continuing to confirm transaction screen ([#18554](https://github.com/MetaMask/metamask-extension/pull/18554)) + +### Removed +- Remove mobile sync feature ([#18692](https://github.com/MetaMask/metamask-extension/pull/18692)) + +### Fixed +- Fix ability to close "NFT successful import" modal ([#18504](https://github.com/MetaMask/metamask-extension/pull/18504)) +- Fix "Unable to determine contract standard" error ([#18300](https://github.com/MetaMask/metamask-extension/pull/18300)) ## [10.29.0] ### Added From 19257361e52d422e13c1c47b009c922006b6381c Mon Sep 17 00:00:00 2001 From: micaelae <100321200+micaelae@users.noreply.github.com> Date: Thu, 20 Apr 2023 19:27:18 -0700 Subject: [PATCH 04/14] Show Bridge button in TokenOverview component (#18630) * Show Bridge button in TokenOverview component * Hide Swap button in token overview page when network is not supported --- shared/constants/bridge.ts | 43 ++++++ .../app/wallet-overview/eth-overview.js | 7 +- .../app/wallet-overview/eth-overview.test.js | 4 +- ui/components/app/wallet-overview/index.scss | 14 +- .../app/wallet-overview/token-overview.js | 141 ++++++++++-------- .../wallet-overview/token-overview.test.js | 140 ++++++++++++++++- ui/selectors/selectors.js | 14 +- ui/selectors/selectors.test.js | 19 +++ 8 files changed, 314 insertions(+), 68 deletions(-) diff --git a/shared/constants/bridge.ts b/shared/constants/bridge.ts index a70c0a62a..cba071bfb 100644 --- a/shared/constants/bridge.ts +++ b/shared/constants/bridge.ts @@ -8,3 +8,46 @@ export const ALLOWED_BRIDGE_CHAIN_IDS = [ CHAIN_IDS.OPTIMISM, CHAIN_IDS.ARBITRUM, ]; + +export const ALLOWED_BRIDGE_TOKEN_ADDRESSES = { + [CHAIN_IDS.MAINNET]: [ + '0xdac17f958d2ee523a2206206994597c13d831ec7', + '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', + '0x6b175474e89094c44da98b954eedeac495271d0f', + '0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0', + '0x8965349fb649a33a30cbfda057d8ec2c48abe2a2', + ], + [CHAIN_IDS.BSC]: [ + '0x55d398326f99059ff775485246999027b3197955', + '0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d', + '0x1af3f329e8be154074d8769d1ffa4ee058b1dbc3', + '0x2170ed0880ac9a755fd29b2688956bd959f933f8', + '0xcc42724c6683b7e57334c4e856f4c9965ed682bd', + '0x1ce0c2827e2ef14d5c4f29a091d735a204794041', + ], + [CHAIN_IDS.POLYGON]: [ + '0xc2132d05d31c914a87c6611c10748aeb04b58e8f', + '0x2791bca1f2de4661ed88a30c99a7a9449aa84174', + '0x8f3cf7ad23cd3cadbd9735aff958023239c6a063', + '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619', + '0x2c89bbc92bd86f8075d1decc58c7f4e0107f286b', + ], + [CHAIN_IDS.AVALANCHE]: [ + '0xc7198437980c041c805a1edcba50c1ce5db95118', + '0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7', + '0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664', + '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e', + '0xd586e7f844cea2f87f50152665bcbc2c279d8d70', + '0x49d5c2bdffac6ce2bfdb6640f4f80f226bc10bab', + ], + [CHAIN_IDS.OPTIMISM]: [ + '0x94b008aa00579c1307b0ef2c499ad98a8ce58e58', + '0x7f5c764cbc14f9669b88837ca1490cca17c31607', + '0xda10009cbd5d07dd0cecc66161fc93d7c9000da1', + ], + [CHAIN_IDS.ARBITRUM]: [ + '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9', + '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8', + '0xda10009cbd5d07dd0cecc66161fc93d7c9000da1', + ], +}; diff --git a/ui/components/app/wallet-overview/eth-overview.js b/ui/components/app/wallet-overview/eth-overview.js index 6d0dbdeaf..04cace94f 100644 --- a/ui/components/app/wallet-overview/eth-overview.js +++ b/ui/components/app/wallet-overview/eth-overview.js @@ -2,7 +2,7 @@ import React, { useContext } from 'react'; import PropTypes from 'prop-types'; import { useDispatch, useSelector } from 'react-redux'; import classnames from 'classnames'; -import { useHistory } from 'react-router-dom'; +import { useHistory, useLocation } from 'react-router-dom'; import Identicon from '../../ui/identicon'; import { I18nContext } from '../../../contexts/i18n'; @@ -52,6 +52,7 @@ const EthOverview = ({ className }) => { const t = useContext(I18nContext); const trackEvent = useContext(MetaMetricsContext); const history = useHistory(); + const location = useLocation(); const keyring = useSelector(getCurrentKeyring); const usingHardwareWallet = isHardwareKeyring(keyring?.type); const balanceIsCached = useSelector(isBalanceCached); @@ -246,7 +247,9 @@ const EthOverview = ({ className }) => { const portfolioUrl = process.env.PORTFOLIO_URL; const bridgeUrl = `${portfolioUrl}/bridge`; global.platform.openTab({ - url: `${bridgeUrl}?metamaskEntry=ext`, + url: `${bridgeUrl}?metamaskEntry=ext_bridge_button${ + location.pathname.includes('asset') ? '&token=native' : '' + }`, }); trackEvent({ category: MetaMetricsEventCategory.Navigation, diff --git a/ui/components/app/wallet-overview/eth-overview.test.js b/ui/components/app/wallet-overview/eth-overview.test.js index 3d4f459c1..a237e6879 100644 --- a/ui/components/app/wallet-overview/eth-overview.test.js +++ b/ui/components/app/wallet-overview/eth-overview.test.js @@ -181,7 +181,9 @@ describe('EthOverview', () => { await waitFor(() => expect(openTabSpy).toHaveBeenCalledWith({ - url: expect.stringContaining(`/bridge?metamaskEntry=ext`), + url: expect.stringContaining( + '/bridge?metamaskEntry=ext_bridge_button', + ), }), ); }); diff --git a/ui/components/app/wallet-overview/index.scss b/ui/components/app/wallet-overview/index.scss index ae90cfad2..405386fdc 100644 --- a/ui/components/app/wallet-overview/index.scss +++ b/ui/components/app/wallet-overview/index.scss @@ -114,7 +114,14 @@ align-items: center; margin: 16px 0; padding: 0 16px; - max-width: 100%; + max-width: 326px; + } + + &__primary-container { + display: flex; + max-width: inherit; + justify-content: center; + flex-wrap: wrap; } &__primary-balance { @@ -131,6 +138,11 @@ color: var(--color-text-alternative); } + &__portfolio-button { + height: inherit; + padding-inline-start: 16px; + } + &__button:last-of-type { margin-right: 0; } diff --git a/ui/components/app/wallet-overview/token-overview.js b/ui/components/app/wallet-overview/token-overview.js index 7f9ade4b6..ed99cabee 100644 --- a/ui/components/app/wallet-overview/token-overview.js +++ b/ui/components/app/wallet-overview/token-overview.js @@ -4,7 +4,6 @@ import { useDispatch, useSelector } from 'react-redux'; import { useHistory } from 'react-router-dom'; import Identicon from '../../ui/identicon'; -import Tooltip from '../../ui/tooltip'; import CurrencyDisplay from '../../ui/currency-display'; import { I18nContext } from '../../../contexts/i18n'; import { isHardwareKeyring } from '../../../helpers/utils/hardware'; @@ -20,6 +19,7 @@ import { getCurrentKeyring, getIsSwapsChain, getIsBuyableChain, + getIsBridgeToken, } from '../../../selectors'; import IconButton from '../../ui/icon-button'; @@ -35,8 +35,10 @@ import { import { AssetType } from '../../../../shared/constants/transaction'; import useRamps from '../../../hooks/experiences/useRamps'; -import { Icon, IconName } from '../../component-library'; +import { ButtonIcon, Icon, IconName } from '../../component-library'; import { IconColor } from '../../../helpers/constants/design-system'; + +import { BUTTON_ICON_SIZES } from '../../component-library/button-icon/deprecated'; import WalletOverview from './wallet-overview'; const TokenOverview = ({ className, token }) => { @@ -55,7 +57,7 @@ const TokenOverview = ({ className, token }) => { token.symbol, ); const isSwapsChain = useSelector(getIsSwapsChain); - + const isBridgeToken = useSelector(getIsBridgeToken(token.address)); const isBuyableChain = useSelector(getIsBuyableChain); const { openBuyCryptoInPdapp } = useRamps(); @@ -75,11 +77,42 @@ const TokenOverview = ({ className, token }) => { - +
+ + { + const portfolioUrl = process.env.PORTFOLIO_URL; + global.platform.openTab({ + url: `${portfolioUrl}?metamaskEntry=ext`, + }); + trackEvent( + { + category: MetaMetricsEventCategory.Home, + event: MetaMetricsEventName.PortfolioLinkClicked, + properties: { + url: portfolioUrl, + }, + }, + { + contextPropsIntoEventProperties: [ + MetaMetricsContextProp.PageTitle, + ], + }, + ); + }} + /> +
{formattedFiatBalance ? ( { data-testid="eth-overview-send" disabled={token.isERC721} /> - - } - onClick={() => { - if (isSwapsChain) { + {isSwapsChain && ( + + } + onClick={() => { trackEvent({ event: MetaMetricsEventName.NavSwapButtonClicked, category: MetaMetricsEventCategory.Swaps, @@ -179,51 +211,38 @@ const TokenOverview = ({ className, token }) => { } else { history.push(BUILD_QUOTE_ROUTE); } + }} + label={t('swap')} + tooltipRender={null} + /> + )} + {isBridgeToken && ( + } - }} - label={t('swap')} - tooltipRender={ - isSwapsChain - ? null - : (contents) => ( - - {contents} - - ) - } - /> - - } - label={t('portfolio')} - data-testid="home__portfolio-site" - onClick={() => { - const portfolioUrl = process.env.PORTFOLIO_URL; - global.platform.openTab({ - url: `${portfolioUrl}?metamaskEntry=ext`, - }); - trackEvent( - { - category: MetaMetricsEventCategory.Home, - event: MetaMetricsEventName.PortfolioLinkClicked, + label={t('bridge')} + onClick={() => { + const portfolioUrl = process.env.PORTFOLIO_URL; + + const bridgeUrl = `${portfolioUrl}/bridge`; + global.platform.openTab({ + url: `${bridgeUrl}?metamaskEntry=ext_bridge_button&token=${token.address}`, + }); + trackEvent({ + category: MetaMetricsEventCategory.Navigation, + event: MetaMetricsEventName.BridgeLinkClicked, properties: { - url: portfolioUrl, + location: 'Token Overview', + text: 'Bridge', }, - }, - { - contextPropsIntoEventProperties: [ - MetaMetricsContextProp.PageTitle, - ], - }, - ); - }} - /> + }); + }} + tooltipRender={null} + /> + )} } className={className} diff --git a/ui/components/app/wallet-overview/token-overview.test.js b/ui/components/app/wallet-overview/token-overview.test.js index 9b2769181..707b02921 100644 --- a/ui/components/app/wallet-overview/token-overview.test.js +++ b/ui/components/app/wallet-overview/token-overview.test.js @@ -23,6 +23,7 @@ jest.mock('../../../../shared/constants/network', () => ({ }, }, })); +let openTabSpy; describe('TokenOverview', () => { const mockStore = { @@ -68,6 +69,11 @@ describe('TokenOverview', () => { openTab: jest.fn(), }, }); + openTabSpy = jest.spyOn(global.platform, 'openTab'); + }); + + beforeEach(() => { + openTabSpy.mockClear(); }); const token = { @@ -209,8 +215,6 @@ describe('TokenOverview', () => { mockedStoreWithBuyableChainId, ); - const openTabSpy = jest.spyOn(global.platform, 'openTab'); - const { queryByTestId } = renderWithProvider( , mockedStore, @@ -228,5 +232,137 @@ describe('TokenOverview', () => { }), ); }); + + it('should always show the Portfolio button', () => { + const mockToken = { + name: 'test', + isERC721: false, + address: '0x7ceb23fd6bc0add59e62ac25578270cff1B9f619', + symbol: 'test', + }; + const { queryByTestId } = renderWithProvider( + , + store, + ); + const portfolioButton = queryByTestId('home__portfolio-site'); + expect(portfolioButton).toBeInTheDocument(); + }); + + it('should open the Portfolio URI when clicking on Portfolio button', async () => { + const mockToken = { + name: 'test', + isERC721: false, + address: '0x7ceb23fd6bc0add59e62ac25578270cff1B9f619', + symbol: 'test', + }; + const { queryByTestId } = renderWithProvider( + , + store, + ); + + const portfolioButton = queryByTestId('home__portfolio-site'); + + expect(portfolioButton).toBeInTheDocument(); + expect(portfolioButton).not.toBeDisabled(); + + fireEvent.click(portfolioButton); + expect(openTabSpy).toHaveBeenCalledTimes(1); + + await waitFor(() => + expect(openTabSpy).toHaveBeenCalledWith({ + url: expect.stringContaining(`?metamaskEntry=ext`), + }), + ); + }); + + it('should show the Bridge button if chain id and token are supported', async () => { + const mockToken = { + name: 'test', + isERC721: false, + address: '0x7ceb23fd6bc0add59e62ac25578270cff1B9f619', + symbol: 'test', + }; + + const mockedStoreWithBridgeableChainId = { + metamask: { + ...mockStore.metamask, + provider: { type: 'test', chainId: CHAIN_IDS.POLYGON }, + }, + }; + const mockedStore = configureMockStore([thunk])( + mockedStoreWithBridgeableChainId, + ); + + const { queryByTestId } = renderWithProvider( + , + mockedStore, + ); + const bridgeButton = queryByTestId('token-overview-bridge'); + expect(bridgeButton).toBeInTheDocument(); + expect(bridgeButton).not.toBeDisabled(); + + fireEvent.click(bridgeButton); + expect(openTabSpy).toHaveBeenCalledTimes(1); + + await waitFor(() => + expect(openTabSpy).toHaveBeenCalledWith({ + url: expect.stringContaining( + '/bridge?metamaskEntry=ext_bridge_button&token=0x7ceb23fd6bc0add59e62ac25578270cff1B9f619', + ), + }), + ); + }); + + it('should not show the Bridge button if chain id is not supported', async () => { + const mockToken = { + name: 'test', + isERC721: false, + address: '0x7ceb23fd6bc0add59e62ac25578270cff1B9f619', + symbol: 'test', + }; + + const mockedStoreWithBridgeableChainId = { + metamask: { + ...mockStore.metamask, + provider: { type: 'test', chainId: CHAIN_IDS.FANTOM }, + }, + }; + const mockedStore = configureMockStore([thunk])( + mockedStoreWithBridgeableChainId, + ); + + const { queryByTestId } = renderWithProvider( + , + mockedStore, + ); + const bridgeButton = queryByTestId('token-overview-bridge'); + expect(bridgeButton).not.toBeInTheDocument(); + }); + + it('should not show the Bridge button if token is not supported', async () => { + const mockToken = { + name: 'test', + isERC721: false, + address: '0x7ceb23fd6bc0add59e62ac25578270cff1B9f620', + symbol: 'test', + }; + + const mockedStoreWithBridgeableChainId = { + metamask: { + ...mockStore.metamask, + provider: { type: 'test', chainId: CHAIN_IDS.POLYGON }, + }, + }; + const mockedStore = configureMockStore([thunk])( + mockedStoreWithBridgeableChainId, + ); + + const { queryByTestId } = renderWithProvider( + , + mockedStore, + ); + const bridgeButton = queryByTestId('token-overview-bridge'); + expect(bridgeButton).not.toBeInTheDocument(); + }); }); }); diff --git a/ui/selectors/selectors.js b/ui/selectors/selectors.js index ec606c02e..b99f0bd7c 100644 --- a/ui/selectors/selectors.js +++ b/ui/selectors/selectors.js @@ -46,7 +46,10 @@ import { ALLOWED_DEV_SWAPS_CHAIN_IDS, } from '../../shared/constants/swaps'; -import { ALLOWED_BRIDGE_CHAIN_IDS } from '../../shared/constants/bridge'; +import { + ALLOWED_BRIDGE_CHAIN_IDS, + ALLOWED_BRIDGE_TOKEN_ADDRESSES, +} from '../../shared/constants/bridge'; import { shortenAddress, @@ -747,6 +750,15 @@ export function getIsBridgeChain(state) { return ALLOWED_BRIDGE_CHAIN_IDS.includes(chainId); } +export const getIsBridgeToken = (tokenAddress) => (state) => { + const chainId = getCurrentChainId(state); + const isBridgeChain = getIsBridgeChain(state); + return ( + isBridgeChain && + ALLOWED_BRIDGE_TOKEN_ADDRESSES[chainId].includes(tokenAddress.toLowerCase()) + ); +}; + export function getIsBuyableChain(state) { const chainId = getCurrentChainId(state); return Object.keys(BUYABLE_CHAINS_MAP).includes(chainId); diff --git a/ui/selectors/selectors.test.js b/ui/selectors/selectors.test.js index edd495ec8..af59b8931 100644 --- a/ui/selectors/selectors.test.js +++ b/ui/selectors/selectors.test.js @@ -450,4 +450,23 @@ describe('Selectors', () => { const isFantomSupported = selectors.getIsBridgeChain(mockState); expect(isFantomSupported).toBeFalsy(); }); + + it('#getIsBridgeToken', () => { + mockState.metamask.provider.chainId = '0xa'; + const isOptimismTokenSupported = selectors.getIsBridgeToken( + '0x94B008aa00579c1307b0ef2c499ad98a8ce58e58', + )(mockState); + expect(isOptimismTokenSupported).toBeTruthy(); + + const isOptimismUnknownTokenSupported = selectors.getIsBridgeToken( + '0x94B008aa00579c1307b0ef2c499ad98a8ce58e60', + )(mockState); + expect(isOptimismUnknownTokenSupported).toBeFalsy(); + + mockState.metamask.provider.chainId = '0xfa'; + const isFantomTokenSupported = selectors.getIsBridgeToken( + '0x94B008aa00579c1307b0ef2c499ad98a8ce58e58', + )(mockState); + expect(isFantomTokenSupported).toBeFalsy(); + }); }); From 0a9c6023dcf2a258460cab22e7d702ec7479c00d Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Fri, 21 Apr 2023 11:17:38 +0530 Subject: [PATCH 05/14] Fixing issue with gasLimit in transaction being 0 (#18682) --- app/scripts/controllers/transactions/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index ce5e85d0d..be61a789a 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -802,8 +802,8 @@ export default class TransactionController extends EventEmitter { this.txStateManager.getTransactionWithActionId(actionId); if (existingTxMeta) { this.emit('newUnapprovedTx', existingTxMeta); - this._requestApproval(existingTxMeta); existingTxMeta = await this.addTransactionGasDefaults(existingTxMeta); + this._requestApproval(existingTxMeta); return existingTxMeta; } } @@ -875,9 +875,9 @@ export default class TransactionController extends EventEmitter { this.addTransaction(txMeta); this.emit('newUnapprovedTx', txMeta); - this._requestApproval(txMeta); txMeta = await this.addTransactionGasDefaults(txMeta); + this._requestApproval(txMeta); return txMeta; } From 1626f22704f5c6e43d8c243755adaa3f845f0b43 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Fri, 21 Apr 2023 12:03:46 -0230 Subject: [PATCH 06/14] Update outdated browser versions (#18721) The range of browsers considered to be outdated has been updated to match our latest browser support policy, which is ~2 years on Chrome, and the most recent end-of-life extended support release on Firefox. Comments have been added to help explain how these versions were chosen as well. --- ui/helpers/constants/common.ts | 12 ++++++++---- ui/helpers/utils/util.test.js | 16 ++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ui/helpers/constants/common.ts b/ui/helpers/constants/common.ts index 62e8077b8..db2491f53 100644 --- a/ui/helpers/constants/common.ts +++ b/ui/helpers/constants/common.ts @@ -20,8 +20,12 @@ export const SUPPORT_REQUEST_LINK = _supportRequestLink; export const CONTRACT_ADDRESS_LINK = _contractAddressLink; export const PASSWORD_MIN_LENGTH = 8; export const OUTDATED_BROWSER_VERSIONS = { - chrome: '<80', - edge: '<80', - firefox: '<78', - opera: '<67', + // Chrome and Edge should match the latest Chrome version released ~2 years ago + chrome: '<90', + edge: '<90', + // Firefox should match the most recent end-of-life extended support release + firefox: '<91', + // Opera should be set to the equivalent of the Chrome version set + // See https://en.wikipedia.org/wiki/History_of_the_Opera_web_browser + opera: '<76', }; diff --git a/ui/helpers/utils/util.test.js b/ui/helpers/utils/util.test.js index 535c4e843..8b23a1ea1 100644 --- a/ui/helpers/utils/util.test.js +++ b/ui/helpers/utils/util.test.js @@ -204,56 +204,56 @@ describe('util', () => { }); it('should return false when given a modern chrome browser', () => { const browser = Bowser.getParser( - 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.2623.112 Safari/537.36', + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.2623.112 Safari/537.36', ); const result = util.getIsBrowserDeprecated(browser); expect(result).toStrictEqual(false); }); it('should return true when given an outdated chrome browser', () => { const browser = Bowser.getParser( - 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.2623.112 Safari/537.36', + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.2623.112 Safari/537.36', ); const result = util.getIsBrowserDeprecated(browser); expect(result).toStrictEqual(true); }); it('should return false when given a modern firefox browser', () => { const browser = Bowser.getParser( - 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0', + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/91.0', ); const result = util.getIsBrowserDeprecated(browser); expect(result).toStrictEqual(false); }); it('should return true when given an outdated firefox browser', () => { const browser = Bowser.getParser( - 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0', + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/90.0', ); const result = util.getIsBrowserDeprecated(browser); expect(result).toStrictEqual(true); }); it('should return false when given a modern opera browser', () => { const browser = Bowser.getParser( - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_16_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.3578.98 Safari/537.36 OPR/68.0.3135.47', + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_16_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.3578.98 Safari/537.36 OPR/76.0.3135.47', ); const result = util.getIsBrowserDeprecated(browser); expect(result).toStrictEqual(false); }); it('should return true when given an outdated opera browser', () => { const browser = Bowser.getParser( - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_16_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36 OPR/58.0.3135.47', + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_16_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.3578.98 Safari/537.36 OPR/58.0.3135.47', ); const result = util.getIsBrowserDeprecated(browser); expect(result).toStrictEqual(true); }); it('should return false when given a modern edge browser', () => { const browser = Bowser.getParser( - 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.3578.98 Safari/537.36 Edg/81.0.416.68', + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.3578.98 Safari/537.36 Edg/90.0.416.68', ); const result = util.getIsBrowserDeprecated(browser); expect(result).toStrictEqual(false); }); it('should return true when given an outdated edge browser', () => { const browser = Bowser.getParser( - 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36 Edge/71.0.416.68', + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.3578.98 Safari/537.36 Edge/89.0.416.68', ); const result = util.getIsBrowserDeprecated(browser); expect(result).toStrictEqual(true); From ca0a4bec3b37d5c1cab877697ac46d9677a0cb86 Mon Sep 17 00:00:00 2001 From: Bernardo Garces Chapero Date: Thu, 27 Apr 2023 12:39:37 +0200 Subject: [PATCH 07/14] Return state when calling EncryptionPublicKeyController.cancelEncryptionPublicKey (#18845) * returns state * adds unit test --- app/scripts/controllers/encryption-public-key.test.ts | 9 +++++++++ app/scripts/controllers/encryption-public-key.ts | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/scripts/controllers/encryption-public-key.test.ts b/app/scripts/controllers/encryption-public-key.test.ts index cc5b61cc1..cb5581831 100644 --- a/app/scripts/controllers/encryption-public-key.test.ts +++ b/app/scripts/controllers/encryption-public-key.test.ts @@ -352,6 +352,15 @@ describe('EncryptionPublicKeyController', () => { 'Cancel', ); }); + + it('returns current state', async () => { + getStateMock.mockReturnValueOnce(stateMock); + expect( + await encryptionPublicKeyController.cancelEncryptionPublicKey( + messageIdMock, + ), + ).toEqual(stateMock); + }); }); describe('message manager events', () => { diff --git a/app/scripts/controllers/encryption-public-key.ts b/app/scripts/controllers/encryption-public-key.ts index f4cb5e25e..de710c501 100644 --- a/app/scripts/controllers/encryption-public-key.ts +++ b/app/scripts/controllers/encryption-public-key.ts @@ -275,7 +275,7 @@ export default class EncryptionPublicKeyController extends BaseControllerV2< * @param msgId - The id of the message to cancel. */ cancelEncryptionPublicKey(msgId: string) { - this._cancelAbstractMessage(this._encryptionPublicKeyManager, msgId); + return this._cancelAbstractMessage(this._encryptionPublicKeyManager, msgId); } /** From b758165c1b0fc6ccc5de93979b6f485ab43aa92e Mon Sep 17 00:00:00 2001 From: Victorien Gauch <85494462+VGau@users.noreply.github.com> Date: Fri, 28 Apr 2023 14:34:10 +0200 Subject: [PATCH 08/14] =?UTF-8?q?fix(18709):=20fix=20error=20when=20switch?= =?UTF-8?q?ing=20to=20linea=20testnet=20using=20wallet=5Fsw=E2=80=A6=20(#1?= =?UTF-8?q?8710)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(18709): fix error when switching to linea testnet using wallet_switchEthereumChain * fix: update condition to get network config --- .../handlers/switch-ethereum-chain.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/scripts/lib/rpc-method-middleware/handlers/switch-ethereum-chain.js b/app/scripts/lib/rpc-method-middleware/handlers/switch-ethereum-chain.js index faeded072..4755a2c3d 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/switch-ethereum-chain.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/switch-ethereum-chain.js @@ -6,7 +6,7 @@ import { NETWORK_TO_NAME_MAP, CHAIN_ID_TO_RPC_URL_MAP, CURRENCY_SYMBOLS, - NETWORK_TYPES, + BUILT_IN_INFURA_NETWORKS, } from '../../../../../shared/constants/network'; import { isPrefixedFormattedHexString, @@ -27,7 +27,11 @@ const switchEthereumChain = { export default switchEthereumChain; function findExistingNetwork(chainId, findNetworkConfigurationBy) { - if (chainId in CHAIN_ID_TO_TYPE_MAP) { + if ( + Object.values(BUILT_IN_INFURA_NETWORKS) + .map(({ chainId: id }) => id) + .includes(chainId) + ) { return { chainId, ticker: CURRENCY_SYMBOLS.ETH, @@ -109,9 +113,9 @@ async function switchEthereumChainHandler( requestData, }); if ( - chainId in CHAIN_ID_TO_TYPE_MAP && - approvedRequestData.type !== NETWORK_TYPES.LOCALHOST && - approvedRequestData.type !== NETWORK_TYPES.LINEA_TESTNET + Object.values(BUILT_IN_INFURA_NETWORKS) + .map(({ chainId: id }) => id) + .includes(chainId) ) { await setProviderType(approvedRequestData.type); } else { From ece1e482003557964407eb0d785e43ec615aca53 Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Fri, 28 Apr 2023 22:59:36 +0530 Subject: [PATCH 09/14] Consistent message for third party requests across screens (#18873) --- app/_locales/en/messages.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index bd64bcf17..018eeb575 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -831,10 +831,10 @@ "message": "NFT contract" }, "contractRequestingAccess": { - "message": "Contract requesting access" + "message": "Third party requesting access" }, "contractRequestingSignature": { - "message": "Contract requesting signature" + "message": "Third party requesting signature" }, "contractRequestingSpendingCap": { "message": "Third party requesting spending cap" From 02b537c0c152970019daaae97f105c07453419f7 Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Wed, 26 Apr 2023 05:43:38 +0530 Subject: [PATCH 10/14] Enable editing L2 gas on optimism (#18217) --- app/_locales/de/messages.json | 3 - app/_locales/el/messages.json | 3 - app/_locales/en/messages.json | 6 +- app/_locales/es/messages.json | 3 - app/_locales/fr/messages.json | 3 - app/_locales/hi/messages.json | 3 - app/_locales/id/messages.json | 3 - app/_locales/ja/messages.json | 3 - app/_locales/ko/messages.json | 3 - app/_locales/pt/messages.json | 3 - app/_locales/ru/messages.json | 3 - app/_locales/tl/messages.json | 3 - app/_locales/tr/messages.json | 3 - app/_locales/vi/messages.json | 3 - app/_locales/zh_CN/messages.json | 3 - .../advanced-gas-controls.component.js | 8 -- .../advanced-gas-inputs.component.js | 9 -- .../advanced-gas-inputs.container.js | 9 +- .../approve-content-card.js | 47 +++++--- .../confirm-legacy-gas-display.js | 37 ++++++ .../confirm-legacy-gas-display.test.js | 112 ++++++++++++------ .../multi-layer-fee-message.test.js.snap | 98 +++++++++++++++ .../multi-layer-fee-message.js | 74 +++++++----- .../multi-layer-fee-message.test.js | 46 +++++++ .../confirm-approve-content.component.js | 32 ++++- ui/pages/confirm-approve/confirm-approve.js | 9 ++ .../confirm-transaction-base.component.js | 16 +-- .../confirm-transaction-base.container.js | 2 - .../confirm-transaction-base.test.js | 14 ++- .../confirm-token-transaction-switch.js | 3 + .../send-content/send-content.component.js | 4 +- .../send-content/send-content.container.js | 2 + ui/pages/token-allowance/token-allowance.js | 7 ++ ui/selectors/selectors.js | 6 +- 34 files changed, 407 insertions(+), 176 deletions(-) create mode 100644 ui/components/app/multilayer-fee-message/__snapshots__/multi-layer-fee-message.test.js.snap create mode 100644 ui/components/app/multilayer-fee-message/multi-layer-fee-message.test.js diff --git a/app/_locales/de/messages.json b/app/_locales/de/messages.json index 88153ba68..2980e9ccb 100644 --- a/app/_locales/de/messages.json +++ b/app/_locales/de/messages.json @@ -1432,9 +1432,6 @@ "message": "Diese Gasgebühr wurde von $1 vorgeschlagen. Dies kann ein Problem mit Ihrer Transaktion verursachen. Bei Fragen wenden Sie sich bitte an $1.", "description": "$1 represents the Dapp's origin" }, - "gasFee": { - "message": "Gasgebühr" - }, "gasLimit": { "message": "Gaslimit" }, diff --git a/app/_locales/el/messages.json b/app/_locales/el/messages.json index c3aa83b1f..f0836e464 100644 --- a/app/_locales/el/messages.json +++ b/app/_locales/el/messages.json @@ -1432,9 +1432,6 @@ "message": "Αυτό το τέλος συναλλαγής έχει προταθεί από το $1. Η παράκαμψη μπορεί να προκαλέσει πρόβλημα με τη συναλλαγή σας. Εάν έχετε απορίες, επικοινωνήστε με $1.", "description": "$1 represents the Dapp's origin" }, - "gasFee": { - "message": "Τέλη Συναλλαγής" - }, "gasLimit": { "message": "Όριο τέλους συναλλαγής" }, diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 018eeb575..cc1f96a56 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -1552,9 +1552,6 @@ "message": "This gas fee has been suggested by $1. Overriding this may cause a problem with your transaction. Please reach out to $1 if you have questions.", "description": "$1 represents the Dapp's origin" }, - "gasFee": { - "message": "Gas fee" - }, "gasLimit": { "message": "Gas limit" }, @@ -1960,6 +1957,9 @@ "lastSold": { "message": "Last sold" }, + "layer1Fees": { + "message": "Layer 1 fees" + }, "learnCancelSpeeedup": { "message": "Learn how to $1", "description": "$1 is link to cancel or speed up transactions" diff --git a/app/_locales/es/messages.json b/app/_locales/es/messages.json index 05ea8c314..bf0aab118 100644 --- a/app/_locales/es/messages.json +++ b/app/_locales/es/messages.json @@ -1432,9 +1432,6 @@ "message": "Esta tarifa de gas ha sido sugerida por $1. Anularla puede causar un problema con su transacción. Comuníquese con $1 si tiene preguntas.", "description": "$1 represents the Dapp's origin" }, - "gasFee": { - "message": "Cuota de gas" - }, "gasLimit": { "message": "Límite de gas" }, diff --git a/app/_locales/fr/messages.json b/app/_locales/fr/messages.json index 23da974ab..1d2319533 100644 --- a/app/_locales/fr/messages.json +++ b/app/_locales/fr/messages.json @@ -1432,9 +1432,6 @@ "message": "Ce prix de carburant a été suggéré par $1. Si vous n’en tenez pas compte, vous risquez de rencontrer des difficultés lors de votre transaction. Veuillez contacter $1 pour toute question.", "description": "$1 represents the Dapp's origin" }, - "gasFee": { - "message": "Frais de transaction" - }, "gasLimit": { "message": "Montant maximal des frais de transaction" }, diff --git a/app/_locales/hi/messages.json b/app/_locales/hi/messages.json index 2299802ba..05c32e878 100644 --- a/app/_locales/hi/messages.json +++ b/app/_locales/hi/messages.json @@ -1432,9 +1432,6 @@ "message": "यह गैस शुल्क $1 द्वारा सुझाया गया है। इसे ओवरराइड करने से आपके लेन-देन में समस्या हो सकती है। यदि आपके पास कोई सवाल हैं तो कृपया $1 तक पहुंचें।", "description": "$1 represents the Dapp's origin" }, - "gasFee": { - "message": "गैस शुल्क" - }, "gasLimit": { "message": "गैस की सीमा" }, diff --git a/app/_locales/id/messages.json b/app/_locales/id/messages.json index 7fe302c56..5153bebde 100644 --- a/app/_locales/id/messages.json +++ b/app/_locales/id/messages.json @@ -1432,9 +1432,6 @@ "message": "Biaya gas ini telah disarankan oleh $1. Pengabaian dapat menyebabkan masalah pada transaksi Anda. Hubungi $1 jika ada pertanyaan.", "description": "$1 represents the Dapp's origin" }, - "gasFee": { - "message": "Biaya gas" - }, "gasLimit": { "message": "Batas gas" }, diff --git a/app/_locales/ja/messages.json b/app/_locales/ja/messages.json index 30667b7df..285805237 100644 --- a/app/_locales/ja/messages.json +++ b/app/_locales/ja/messages.json @@ -1432,9 +1432,6 @@ "message": "このガス代は$1により提案されています。これを上書きすると、トランザクションに問題が発生する可能性があります。ご質問がございましたら、$1までお問い合わせください。", "description": "$1 represents the Dapp's origin" }, - "gasFee": { - "message": "ガス代" - }, "gasLimit": { "message": "ガスリミット" }, diff --git a/app/_locales/ko/messages.json b/app/_locales/ko/messages.json index 65c96401b..fe2d20dc6 100644 --- a/app/_locales/ko/messages.json +++ b/app/_locales/ko/messages.json @@ -1432,9 +1432,6 @@ "message": "$1에서 이 가스 요금을 제안했습니다. 이를 무시하면 거래에 문제가 발생할 수 있습니다. 질문이 있는 경우 $1에 문의하세요.", "description": "$1 represents the Dapp's origin" }, - "gasFee": { - "message": "가스 수수료" - }, "gasLimit": { "message": "가스 한도" }, diff --git a/app/_locales/pt/messages.json b/app/_locales/pt/messages.json index 7db95bf79..fac9a765a 100644 --- a/app/_locales/pt/messages.json +++ b/app/_locales/pt/messages.json @@ -1432,9 +1432,6 @@ "message": "Essa taxa de gás foi sugerida por $1. Sua substituição pode causar um problema com a sua transação. Entre em contato com $1 se tiver perguntas.", "description": "$1 represents the Dapp's origin" }, - "gasFee": { - "message": "Taxa de gás" - }, "gasLimit": { "message": "Limite de gás" }, diff --git a/app/_locales/ru/messages.json b/app/_locales/ru/messages.json index 026e36730..d332888b5 100644 --- a/app/_locales/ru/messages.json +++ b/app/_locales/ru/messages.json @@ -1432,9 +1432,6 @@ "message": "Эта плата за газ была предложена $1. Ее переопредление может вызвать проблемы с вашей транзакцией. При наличии вопросов обратитесь к $1.", "description": "$1 represents the Dapp's origin" }, - "gasFee": { - "message": "Плата за газ" - }, "gasLimit": { "message": "Лимит газа" }, diff --git a/app/_locales/tl/messages.json b/app/_locales/tl/messages.json index 4d2957f89..33fef9c73 100644 --- a/app/_locales/tl/messages.json +++ b/app/_locales/tl/messages.json @@ -1432,9 +1432,6 @@ "message": "Ang gas fee na ito ay iminungkahi ng $1. Ang pag-override dito ay maaaring magdulot ng problema sa iyong transaksyon. Mangyaring makipag-ugnayan sa $1 kung mayroon kang mga tanong.", "description": "$1 represents the Dapp's origin" }, - "gasFee": { - "message": "Bayarin sa Gas" - }, "gasLimit": { "message": "Limitasyon sa Gas" }, diff --git a/app/_locales/tr/messages.json b/app/_locales/tr/messages.json index f4d61422f..ef089de79 100644 --- a/app/_locales/tr/messages.json +++ b/app/_locales/tr/messages.json @@ -1432,9 +1432,6 @@ "message": "Bu gaz ücreti $1 tarafından önerilmiştir. Bu değerin başka bir değerle değiştirilmesi işleminizle ilgili bir soruna neden olabilir. Sorularınız olursa lütfen $1 ile iletişime geçin.", "description": "$1 represents the Dapp's origin" }, - "gasFee": { - "message": "Gaz ücreti" - }, "gasLimit": { "message": "Gaz limiti" }, diff --git a/app/_locales/vi/messages.json b/app/_locales/vi/messages.json index 7bb1339a6..4ce8446bd 100644 --- a/app/_locales/vi/messages.json +++ b/app/_locales/vi/messages.json @@ -1432,9 +1432,6 @@ "message": "Phí gas này đã được gợi ý bởi $1. Việc sửa đổi có thể khiến giao dịch của bạn gặp sự cố. Vui lòng liên hệ với $1 nếu bạn có câu hỏi.", "description": "$1 represents the Dapp's origin" }, - "gasFee": { - "message": "Phí gas" - }, "gasLimit": { "message": "Giới hạn gas" }, diff --git a/app/_locales/zh_CN/messages.json b/app/_locales/zh_CN/messages.json index dc186ebf1..c7463ae0c 100644 --- a/app/_locales/zh_CN/messages.json +++ b/app/_locales/zh_CN/messages.json @@ -1432,9 +1432,6 @@ "message": "这笔燃料费是由 $1 建议的。忽略它可能会导致您的交易出现问题。如果您有疑问,请联系 $1。", "description": "$1 represents the Dapp's origin" }, - "gasFee": { - "message": "燃料费" - }, "gasLimit": { "message": "燃料上限" }, diff --git a/ui/components/app/advanced-gas-controls/advanced-gas-controls.component.js b/ui/components/app/advanced-gas-controls/advanced-gas-controls.component.js index 547d0dced..8068a41e9 100644 --- a/ui/components/app/advanced-gas-controls/advanced-gas-controls.component.js +++ b/ui/components/app/advanced-gas-controls/advanced-gas-controls.component.js @@ -1,11 +1,9 @@ import React, { useContext } from 'react'; import PropTypes from 'prop-types'; -import { useSelector } from 'react-redux'; import { I18nContext } from '../../../contexts/i18n'; import FormField from '../../ui/form-field'; import { getGasFormErrorText } from '../../../helpers/constants/gas'; -import { getNetworkSupportsSettingGasFees } from '../../../selectors'; export default function AdvancedGasControls({ onManualChange, @@ -18,10 +16,6 @@ export default function AdvancedGasControls({ }) { const t = useContext(I18nContext); - const networkSupportsSettingGasFees = useSelector( - getNetworkSupportsSettingGasFees, - ); - return (
<> @@ -58,7 +51,6 @@ export default function AdvancedGasControls({ ? getGasFormErrorText(gasErrors.gasPrice, t) : null } - disabled={!networkSupportsSettingGasFees} />
diff --git a/ui/components/app/advanced-gas-inputs/advanced-gas-inputs.component.js b/ui/components/app/advanced-gas-inputs/advanced-gas-inputs.component.js index a6841767a..cda7f4d73 100644 --- a/ui/components/app/advanced-gas-inputs/advanced-gas-inputs.component.js +++ b/ui/components/app/advanced-gas-inputs/advanced-gas-inputs.component.js @@ -20,12 +20,10 @@ export default class AdvancedGasInputs extends Component { customGasLimitMessage: PropTypes.string, minimumGasLimit: PropTypes.number, customPriceIsExcessive: PropTypes.bool, - networkSupportsSettingGasFees: PropTypes.bool, }; static defaultProps = { customPriceIsExcessive: false, - networkSupportsSettingGasFees: true, }; constructor(props) { @@ -203,14 +201,9 @@ export default class AdvancedGasInputs extends Component { customGasLimitMessage, minimumGasLimit, customPriceIsExcessive, - networkSupportsSettingGasFees, } = this.props; const { gasPrice, gasLimit } = this.state; - if (!networkSupportsSettingGasFees) { - return null; - } - const { errorText: gasPriceErrorText, errorType: gasPriceErrorType } = this.gasPriceError({ insufficientBalance, @@ -253,7 +246,6 @@ export default class AdvancedGasInputs extends Component { onChange: this.onChangeGasPrice, errorComponent: gasPriceErrorComponent, errorType: gasPriceErrorType, - disabled: !networkSupportsSettingGasFees, })} {this.renderGasInput({ label: this.context.t('gasLimit'), @@ -264,7 +256,6 @@ export default class AdvancedGasInputs extends Component { errorComponent: gasLimitErrorComponent, customMessageComponent: gasLimitCustomMessageComponent, errorType: gasLimitErrorType, - disabled: !networkSupportsSettingGasFees, })} ); diff --git a/ui/components/app/advanced-gas-inputs/advanced-gas-inputs.container.js b/ui/components/app/advanced-gas-inputs/advanced-gas-inputs.container.js index dc2b09a17..4736de011 100644 --- a/ui/components/app/advanced-gas-inputs/advanced-gas-inputs.container.js +++ b/ui/components/app/advanced-gas-inputs/advanced-gas-inputs.container.js @@ -1,5 +1,4 @@ import { connect } from 'react-redux'; -import { getNetworkSupportsSettingGasFees } from '../../../selectors/selectors'; import { MIN_GAS_LIMIT_DEC } from '../../../pages/send/send.constants'; import { decGWEIToHexWEI, @@ -20,12 +19,6 @@ function convertMinimumGasLimitForInputs(minimumGasLimit = MIN_GAS_LIMIT_DEC) { return parseInt(minimumGasLimit, 10); } -function mapStateToProps(state) { - return { - networkSupportsSettingGasFees: getNetworkSupportsSettingGasFees(state), - }; -} - function mergeProps(stateProps, dispatchProps, ownProps) { const { customGasPrice, @@ -47,4 +40,4 @@ function mergeProps(stateProps, dispatchProps, ownProps) { }; } -export default connect(mapStateToProps, null, mergeProps)(AdvancedGasInputs); +export default connect(undefined, null, mergeProps)(AdvancedGasInputs); diff --git a/ui/components/app/approve-content-card/approve-content-card.js b/ui/components/app/approve-content-card/approve-content-card.js index bc5665209..8f188b9ba 100644 --- a/ui/components/app/approve-content-card/approve-content-card.js +++ b/ui/components/app/approve-content-card/approve-content-card.js @@ -1,6 +1,8 @@ import React, { useContext } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; +import { useSelector } from 'react-redux'; + import Box from '../../ui/box/box'; import Button from '../../ui/button'; import EditGasFeeButton from '../edit-gas-fee-button/edit-gas-fee-button'; @@ -16,10 +18,14 @@ import { TextColor, TextVariant, } from '../../../helpers/constants/design-system'; +import { PRIMARY, SECONDARY } from '../../../helpers/constants/common'; import { I18nContext } from '../../../contexts/i18n'; +import { getPreferences } from '../../../selectors'; import { ConfirmGasDisplay } from '../confirm-gas-display'; import MultiLayerFeeMessage from '../multilayer-fee-message/multi-layer-fee-message'; import { formatCurrency } from '../../../helpers/utils/confirm-tx.util'; +import TransactionDetailItem from '../transaction-detail-item/transaction-detail-item.component'; +import UserPreferencedCurrencyDisplay from '../user-preferenced-currency-display'; export default function ApproveContentCard({ showHeader = true, @@ -37,6 +43,7 @@ export default function ApproveContentCard({ ethTransactionTotal, nativeCurrency, fullTxData, + hexMinimumTransactionFee, hexTransactionTotal, fiatTransactionTotal, currentCurrency, @@ -48,6 +55,7 @@ export default function ApproveContentCard({ useCurrencyRateCheck, }) { const t = useContext(I18nContext); + const { useNativeCurrencyAsPrimaryCurrency } = useSelector(getPreferences); return ( - - - {t('transactionDetailLayer2GasHeading')} - {`${ethTransactionTotal} ${nativeCurrency}`} - - + + } + detailText={ + + } + noBold + flexWidthValues + /> process.env.IN_TEST ? null : ; @@ -32,8 +35,10 @@ const ConfirmLegacyGasDisplay = () => { // state selectors const isMainnet = useSelector(getIsMainnet); + const isMultiLayerFeeNetwork = useSelector(getIsMultiLayerFeeNetwork); const useCurrencyRateCheck = useSelector(getUseCurrencyRateCheck); const { useNativeCurrencyAsPrimaryCurrency } = useSelector(getPreferences); + const nativeCurrency = useSelector(getNativeCurrency); const unapprovedTxs = useSelector(getUnapprovedTransactions); const { transactionData } = useDraftTransactionGasValues(); const txData = useSelector((state) => txDataSelector(state)); @@ -45,6 +50,38 @@ const ConfirmLegacyGasDisplay = () => { (state) => transactionFeeSelector(state, transaction), ); + if (isMultiLayerFeeNetwork) { + return [ + + } + detailText={ + + } + noBold + flexWidthValues + />, + , + ]; + } + return ( { - const store = configureStore({ - ...mockState, - ...contextProps, - metamask: { - ...mockState.metamask, - accounts: { - [mockState.metamask.selectedAddress]: { - address: mockState.metamask.selectedAddress, - balance: '0x1F4', - }, - }, - unapprovedTxs: { - 8393540981007587: { - ...mockState.metamask.unapprovedTxs[8393540981007587], - txParams: { - from: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc', - to: '0xc42edfcc21ed14dda456aa0756c153f7985d8813', - value: '0x0', - gas: '0x5208', - gasPrice: '0x3b9aca00', - type: '0x0', - }, - }, - }, - preferences: { - useNativeCurrencyAsPrimaryCurrency: true, +const mmState = { + ...mockState, + metamask: { + ...mockState.metamask, + accounts: { + [mockState.metamask.selectedAddress]: { + address: mockState.metamask.selectedAddress, + balance: '0x1F4', }, }, - confirmTransaction: { - txData: { - id: 8393540981007587, - status: 'unapproved', - chainId: '0x5', + unapprovedTxs: { + 8393540981007587: { + ...mockState.metamask.unapprovedTxs[8393540981007587], txParams: { from: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc', to: '0xc42edfcc21ed14dda456aa0756c153f7985d8813', @@ -51,7 +31,29 @@ const render = ({ contextProps } = {}) => { }, }, }, - }); + preferences: { + useNativeCurrencyAsPrimaryCurrency: true, + }, + }, + confirmTransaction: { + txData: { + id: 8393540981007587, + status: 'unapproved', + chainId: '0x5', + txParams: { + from: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc', + to: '0xc42edfcc21ed14dda456aa0756c153f7985d8813', + value: '0x0', + gas: '0x5208', + gasPrice: '0x3b9aca00', + type: '0x0', + }, + }, + }, +}; + +const render = ({ contextProps, state = mmState } = {}) => { + const store = configureStore({ ...state, ...contextProps }); return renderWithProvider(, store); }; @@ -107,4 +109,48 @@ describe('ConfirmLegacyGasDisplay', () => { expect(screen.queryAllByTitle('0.000021 ETH').length).toBeGreaterThan(0); }); }); + + it('should contain L1 L2 fee details for optimism', async () => { + mmState.metamask.provider.chainId = CHAIN_IDS.OPTIMISM; + mmState.confirmTransaction.txData.chainId = CHAIN_IDS.OPTIMISM; + const state = { + metamask: { + ...mmState.metamask, + provider: { + ...mmState.metamask.provider, + chainId: CHAIN_IDS.OPTIMISM, + }, + }, + confirmTransaction: { + ...mmState.confirmTransaction, + txData: { + ...mmState.confirmTransaction.txData, + chainId: CHAIN_IDS.OPTIMISM, + }, + }, + }; + render( + { + send: { + currentTransactionUUID: '1d40b578-6184-4607-8513-762c24d0a19b', + draftTransactions: { + '1d40b578-6184-4607-8513-762c24d0a19b': { + gas: { + error: null, + gasLimit: '0x5208', + gasPrice: '0x3b9aca00', + gasTotal: '0x157c9fbb9a000', + wasManuallyEdited: false, + }, + }, + }, + }, + }, + state, + ); + await waitFor(() => { + expect(screen.queryByText('Layer 1 fees')).toBeInTheDocument(); + expect(screen.queryByText('Layer 2 gas fee')).toBeInTheDocument(); + }); + }); }); diff --git a/ui/components/app/multilayer-fee-message/__snapshots__/multi-layer-fee-message.test.js.snap b/ui/components/app/multilayer-fee-message/__snapshots__/multi-layer-fee-message.test.js.snap new file mode 100644 index 000000000..523ee6cdb --- /dev/null +++ b/ui/components/app/multilayer-fee-message/__snapshots__/multi-layer-fee-message.test.js.snap @@ -0,0 +1,98 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Multi layer fee message should match snapshot 1`] = ` +
+
+
+
+
+ Layer 1 fees +
+
+
+ Unknown +
+
+ Unknown +
+
+
+
+
+
+
+
+
+
+
+ Total +
+
+
+
+ + + $0.56 + +
+
+
+ 0.001000021000 ETH +
+
+
+
+
+ Amount + fees +
+
+
+
+
+
+`; diff --git a/ui/components/app/multilayer-fee-message/multi-layer-fee-message.js b/ui/components/app/multilayer-fee-message/multi-layer-fee-message.js index 60eb8c3c3..d14507215 100644 --- a/ui/components/app/multilayer-fee-message/multi-layer-fee-message.js +++ b/ui/components/app/multilayer-fee-message/multi-layer-fee-message.js @@ -17,36 +17,17 @@ export default function MultilayerFeeMessage({ plainStyle, }) { const t = useContext(I18nContext); - const [fetchedLayer1Total, setLayer1Total] = useState(null); - let layer1Total = 'unknown'; - let layer1TotalBN; - - if (fetchedLayer1Total !== null) { - layer1TotalBN = new Numeric(fetchedLayer1Total, 16, EtherDenomination.WEI); - layer1Total = `${layer1TotalBN - .toDenomination(EtherDenomination.ETH) - .toFixed(12)} ${nativeCurrency}`; - } - - const feeTotal = sumHexes(layer2fee || '0x0', fetchedLayer1Total || '0x0'); - - const totalInWeiHex = sumHexes( - feeTotal || '0x0', - transaction.txParams.value || '0x0', - ); - - const totalBN = new Numeric(totalInWeiHex, 16, EtherDenomination.WEI); - const totalInEth = `${totalBN - .toDenomination(EtherDenomination.ETH) - .toFixed(12)} ${nativeCurrency}`; useEffect(() => { + if (!transaction?.txParams) { + return; + } const getEstimatedL1Fee = async () => { try { const result = await fetchEstimatedL1Fee( - transaction.chainId, - transaction.txParams, + transaction?.chainId, + transaction, ); setLayer1Total(result); } catch (e) { @@ -57,15 +38,44 @@ export default function MultilayerFeeMessage({ getEstimatedL1Fee(); }, [transaction]); - const feeTotalInFiat = ( - + if (!transaction?.txParams) { + return null; + } + + let layer1Total = t('unknown'); + let feeTotalInFiat = t('unknown'); + + if (fetchedLayer1Total !== null) { + const layer1TotalBN = new Numeric( + fetchedLayer1Total, + 16, + EtherDenomination.WEI, + ); + layer1Total = `${layer1TotalBN + .toDenomination(EtherDenomination.ETH) + .toFixed(12)} ${nativeCurrency}`; + + feeTotalInFiat = ( + + ); + } + + const totalInWeiHex = sumHexes( + layer2fee || '0x0', + fetchedLayer1Total || '0x0', + transaction?.txParams?.value || '0x0', ); + const totalBN = new Numeric(totalInWeiHex, 16, EtherDenomination.WEI); + const totalInEth = `${totalBN + .toDenomination(EtherDenomination.ETH) + .toFixed(12)} ${nativeCurrency}`; + const totalInFiat = ( '0x5'); + +describe('Multi layer fee message', () => { + const store = configureStore(mockState); + + it('should match snapshot', () => { + const { container } = renderWithProvider( + , + store, + ); + expect(container).toMatchSnapshot(); + }); + + it('should containe fee values', () => { + const { getByText } = renderWithProvider( + , + store, + ); + expect(getByText('Layer 1 fees')).toBeInTheDocument(); + expect(getByText('Amount + fees')).toBeInTheDocument(); + expect(getByText('0.001000021000 ETH')).toBeInTheDocument(); + }); +}); diff --git a/ui/pages/confirm-approve/confirm-approve-content/confirm-approve-content.component.js b/ui/pages/confirm-approve/confirm-approve-content/confirm-approve-content.component.js index 1ea32fab3..06bffa89a 100644 --- a/ui/pages/confirm-approve/confirm-approve-content/confirm-approve-content.component.js +++ b/ui/pages/confirm-approve/confirm-approve-content/confirm-approve-content.component.js @@ -33,6 +33,9 @@ import { } from '../../../components/component-library/icon/deprecated'; import { ButtonIcon } from '../../../components/component-library/button-icon/deprecated'; import { Text } from '../../../components/component-library'; +import TransactionDetailItem from '../../../components/app/transaction-detail-item/transaction-detail-item.component'; +import UserPreferencedCurrencyDisplay from '../../../components/app/user-preferenced-currency-display'; +import { PRIMARY, SECONDARY } from '../../../helpers/constants/common'; import { ConfirmGasDisplay } from '../../../components/app/confirm-gas-display'; export default class ConfirmApproveContent extends Component { @@ -65,6 +68,7 @@ export default class ConfirmApproveContent extends Component { rpcPrefs: PropTypes.object, isContract: PropTypes.bool, hexTransactionTotal: PropTypes.string, + hexMinimumTransactionFee: PropTypes.string, isMultiLayerFeeNetwork: PropTypes.bool, supportsEIP1559: PropTypes.bool, assetName: PropTypes.string, @@ -77,6 +81,7 @@ export default class ConfirmApproveContent extends Component { setUserAcknowledgedGasMissing: PropTypes.func, renderSimulationFailureWarning: PropTypes.bool, useCurrencyRateCheck: PropTypes.bool, + useNativeCurrencyAsPrimaryCurrency: PropTypes.bool, }; state = { @@ -157,12 +162,14 @@ export default class ConfirmApproveContent extends Component { ethTransactionTotal, fiatTransactionTotal, hexTransactionTotal, + hexMinimumTransactionFee, txData, isMultiLayerFeeNetwork, supportsEIP1559, userAcknowledgedGasMissing, renderSimulationFailureWarning, useCurrencyRateCheck, + useNativeCurrencyAsPrimaryCurrency, } = this.props; if ( !isMultiLayerFeeNetwork && @@ -179,10 +186,27 @@ export default class ConfirmApproveContent extends Component {
{isMultiLayerFeeNetwork ? (
-
- {t('transactionDetailLayer2GasHeading')} - {`${ethTransactionTotal} ${nativeCurrency}`} -
+ + } + detailText={ + + } + noBold + flexWidthValues + /> {showCustomizeGasPopover && !supportsEIP1559 && ( this.handleEditGas() + renderSimulationFailureWarning ? null : () => this.handleEditGas() } rows={[ renderSimulationFailureWarning && simulationFailureWarning(), - !renderSimulationFailureWarning && !isMultiLayerFeeNetwork && ( + !renderSimulationFailureWarning && ( ), - !renderSimulationFailureWarning && isMultiLayerFeeNetwork && ( - - ), !isMultiLayerFeeNetwork && ( { const { hexTransactionAmount, - hexMinimumTransactionFee, hexMaximumTransactionFee, hexTransactionTotal, gasEstimationObject, @@ -206,7 +205,6 @@ const mapStateToProps = (state, ownProps) => { toName, toNickname, hexTransactionAmount, - hexMinimumTransactionFee, hexMaximumTransactionFee, hexTransactionTotal, txData: fullTxData, diff --git a/ui/pages/confirm-transaction-base/confirm-transaction-base.test.js b/ui/pages/confirm-transaction-base/confirm-transaction-base.test.js index ae33ad632..30d699486 100644 --- a/ui/pages/confirm-transaction-base/confirm-transaction-base.test.js +++ b/ui/pages/confirm-transaction-base/confirm-transaction-base.test.js @@ -146,12 +146,24 @@ const baseStore = { }; describe('Confirm Transaction Base', () => { - const store = configureMockStore(middleware)(baseStore); it('should match snapshot', () => { + const store = configureMockStore(middleware)(baseStore); const { container } = renderWithProvider( , store, ); expect(container).toMatchSnapshot(); }); + + it('should contain L1 L2 fee details for optimism', () => { + baseStore.metamask.provider.chainId = CHAIN_IDS.OPTIMISM; + baseStore.confirmTransaction.txData.chainId = CHAIN_IDS.OPTIMISM; + const store = configureMockStore(middleware)(baseStore); + const { getByText } = renderWithProvider( + , + store, + ); + expect(getByText('Layer 1 fees')).toBeInTheDocument(); + expect(getByText('Layer 2 gas fee')).toBeInTheDocument(); + }); }); diff --git a/ui/pages/confirm-transaction/confirm-token-transaction-switch.js b/ui/pages/confirm-transaction/confirm-token-transaction-switch.js index 8b0bd17e1..e04b7c404 100644 --- a/ui/pages/confirm-transaction/confirm-token-transaction-switch.js +++ b/ui/pages/confirm-transaction/confirm-token-transaction-switch.js @@ -46,6 +46,7 @@ export default function ConfirmTokenTransactionSwitch({ transaction }) { fiatTransactionTotal, hexTransactionTotal, hexMaximumTransactionFee, + hexMinimumTransactionFee, } = useSelector((state) => transactionFeeSelector(state, transaction)); return ( @@ -70,6 +71,7 @@ export default function ConfirmTokenTransactionSwitch({ transaction }) { ethTransactionTotal={ethTransactionTotal} fiatTransactionTotal={fiatTransactionTotal} hexTransactionTotal={hexTransactionTotal} + hexMinimumTransactionFee={hexMinimumTransactionFee} /> )} /> @@ -94,6 +96,7 @@ export default function ConfirmTokenTransactionSwitch({ transaction }) { ethTransactionTotal={ethTransactionTotal} fiatTransactionTotal={fiatTransactionTotal} hexTransactionTotal={hexTransactionTotal} + hexMinimumTransactionFee={hexMinimumTransactionFee} /> )} /> diff --git a/ui/pages/send/send-content/send-content.component.js b/ui/pages/send/send-content/send-content.component.js index b57b59a51..d358a6c87 100644 --- a/ui/pages/send/send-content/send-content.component.js +++ b/ui/pages/send/send-content/send-content.component.js @@ -34,6 +34,7 @@ export default class SendContent extends Component { recipient: PropTypes.object, acknowledgeRecipientWarning: PropTypes.func, recipientWarningAcknowledged: PropTypes.bool, + isMultiLayerFeeNetwork: PropTypes.bool, }; render() { @@ -48,6 +49,7 @@ export default class SendContent extends Component { assetError, recipient, recipientWarningAcknowledged, + isMultiLayerFeeNetwork, } = this.props; let gasError; @@ -80,7 +82,7 @@ export default class SendContent extends Component { {networkOrAccountNotSupports1559 ? : null} {showHexData ? : null} - + {!isMultiLayerFeeNetwork && }
); diff --git a/ui/pages/send/send-content/send-content.container.js b/ui/pages/send/send-content/send-content.container.js index e9d3f6f02..6bf19dea3 100644 --- a/ui/pages/send/send-content/send-content.container.js +++ b/ui/pages/send/send-content/send-content.container.js @@ -3,6 +3,7 @@ import { getIsEthGasPriceFetched, getNoGasPriceFetched, checkNetworkOrAccountNotSupports1559, + getIsMultiLayerFeeNetwork, } from '../../../selectors'; import { getIsBalanceInsufficient, @@ -29,6 +30,7 @@ function mapStateToProps(state) { assetError: getAssetError(state), recipient, recipientWarningAcknowledged, + isMultiLayerFeeNetwork: getIsMultiLayerFeeNetwork(state), }; } diff --git a/ui/pages/token-allowance/token-allowance.js b/ui/pages/token-allowance/token-allowance.js index 10cc6ced0..ffebfb795 100644 --- a/ui/pages/token-allowance/token-allowance.js +++ b/ui/pages/token-allowance/token-allowance.js @@ -81,6 +81,7 @@ export default function TokenAllowance({ ethTransactionTotal, fiatTransactionTotal, hexTransactionTotal, + hexMinimumTransactionFee, txData, isMultiLayerFeeNetwork, supportsEIP1559, @@ -463,6 +464,7 @@ export default function TokenAllowance({ userAcknowledgedGasMissing={userAcknowledgedGasMissing} renderSimulationFailureWarning={renderSimulationFailureWarning} hexTransactionTotal={hexTransactionTotal} + hexMinimumTransactionFee={hexMinimumTransactionFee} fiatTransactionTotal={fiatTransactionTotal} currentCurrency={currentCurrency} useCurrencyRateCheck={useCurrencyRateCheck} @@ -514,6 +516,7 @@ export default function TokenAllowance({ isApprovalOrRejection={isApprovalOrRejection} data={customTxParamsData || data} useCurrencyRateCheck={useCurrencyRateCheck} + hexMinimumTransactionFee={hexMinimumTransactionFee} /> @@ -595,6 +598,10 @@ TokenAllowance.propTypes = { * Total sum of the transaction converted to hex value */ hexTransactionTotal: PropTypes.string, + /** + * Minimum transaction fee converted to hex value + */ + hexMinimumTransactionFee: PropTypes.string, /** * Current transaction */ diff --git a/ui/selectors/selectors.js b/ui/selectors/selectors.js index b99f0bd7c..cb1d0c70e 100644 --- a/ui/selectors/selectors.js +++ b/ui/selectors/selectors.js @@ -839,7 +839,7 @@ export const getFullTxData = createDeepEqualSelector( (txData, transaction, customTxParamsData) => { let fullTxData = { ...txData, ...transaction }; if (transaction && transaction.simulationFails) { - txData.simulationFails = transaction.simulationFails; + fullTxData.simulationFails = { ...transaction.simulationFails }; } if (customTxParamsData) { fullTxData = { @@ -1215,10 +1215,6 @@ export function getIsOptimism(state) { ); } -export function getNetworkSupportsSettingGasFees(state) { - return !getIsOptimism(state); -} - export function getIsMultiLayerFeeNetwork(state) { return getIsOptimism(state); } From e1295e489ba4959bc2c332a95277de3b8d1c6495 Mon Sep 17 00:00:00 2001 From: OGPoyraz Date: Wed, 3 May 2023 13:07:03 +0200 Subject: [PATCH 11/14] fix: prevent cancel and speedup transactions to call accept approval (#18846) --- app/scripts/controllers/transactions/index.js | 16 ++++++++++++---- .../controllers/transactions/index.test.js | 3 +++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index be61a789a..5b393963c 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -1248,7 +1248,9 @@ export default class TransactionController extends EventEmitter { } this.addTransaction(newTxMeta); - await this.approveTransaction(newTxMeta.id, actionId); + await this.approveTransaction(newTxMeta.id, actionId, { + hasApprovalRequest: false, + }); return newTxMeta; } @@ -1306,7 +1308,9 @@ export default class TransactionController extends EventEmitter { } this.addTransaction(newTxMeta); - await this.approveTransaction(newTxMeta.id, actionId); + await this.approveTransaction(newTxMeta.id, actionId, { + hasApprovalRequest: false, + }); return newTxMeta; } @@ -1345,8 +1349,10 @@ export default class TransactionController extends EventEmitter { * * @param {number} txId - the tx's Id * @param {string} actionId - actionId passed from UI + * @param opts - options object + * @param opts.hasApprovalRequest - whether the transaction has an approval request */ - async approveTransaction(txId, actionId) { + async approveTransaction(txId, actionId, { hasApprovalRequest = true } = {}) { // TODO: Move this safety out of this function. // Since this transaction is async, // we need to keep track of what is currently being signed, @@ -1361,7 +1367,9 @@ export default class TransactionController extends EventEmitter { try { // approve this.txStateManager.setTxStatusApproved(txId); - this._acceptApproval(txMeta); + if (hasApprovalRequest) { + this._acceptApproval(txMeta); + } // get next nonce const fromAddress = txMeta.txParams.from; // wait for a nonce diff --git a/app/scripts/controllers/transactions/index.test.js b/app/scripts/controllers/transactions/index.test.js index 601b1fb88..3767572b7 100644 --- a/app/scripts/controllers/transactions/index.test.js +++ b/app/scripts/controllers/transactions/index.test.js @@ -608,6 +608,8 @@ describe('Transaction Controller', function () { cancelTxMeta.id, ); assert.deepEqual(cancelTxMeta, memTxMeta); + // One for the initial addUnapprovedTransaction, one for the approval + assert.equal(messengerMock.call.callCount, 2); }); it('should add only 1 cancel transaction when called twice with same actionId', async function () { @@ -1385,6 +1387,7 @@ describe('Transaction Controller', function () { type: TransactionType.retry, }, ); + assert.equal(messengerMock.call.callCount, 0); }); it('should call this.approveTransaction with the id of the returned tx', async function () { From e3a7f910955464c5486b3f55843ff078ace070a7 Mon Sep 17 00:00:00 2001 From: MetaMask Bot Date: Fri, 5 May 2023 10:39:44 +0000 Subject: [PATCH 12/14] Version v10.30.1 --- CHANGELOG.md | 11 ++++++++++- package.json | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbac0646b..ba6d58620 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [10.30.1] +### Uncategorized +- Version v10.29.1 +- Version v10.30.0 +- Merge branch 'develop' into master-sync +- Merge branch 'develop' into master-sync +- Merge remote-tracking branch 'origin/develop' into master-sync + ## [10.30.0] ### Added - Updating Terms of Use, Adding popover and onboarding flow check ([#18221](https://github.com/MetaMask/metamask-extension/pull/18221)) @@ -3707,7 +3715,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Uncategorized - Added the ability to restore accounts from seed words. -[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.30.0...HEAD +[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.30.1...HEAD +[10.30.1]: https://github.com/MetaMask/metamask-extension/compare/v10.30.0...v10.30.1 [10.30.0]: https://github.com/MetaMask/metamask-extension/compare/v10.29.0...v10.30.0 [10.29.0]: https://github.com/MetaMask/metamask-extension/compare/v10.28.3...v10.29.0 [10.28.3]: https://github.com/MetaMask/metamask-extension/compare/v10.28.2...v10.28.3 diff --git a/package.json b/package.json index f12c3c961..365642414 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "metamask-crx", - "version": "10.30.0", + "version": "10.30.1", "private": true, "repository": { "type": "git", From e4e9f3c7ac90d3a1e382d598d5e9647d8b772a30 Mon Sep 17 00:00:00 2001 From: Frederik Bolding Date: Thu, 4 May 2023 19:09:37 +0200 Subject: [PATCH 13/14] [FLASK] Disable RPC test (#19011) * Disable RPC test * Fix lint --- test/e2e/snaps/test-snap-rpc.spec.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/e2e/snaps/test-snap-rpc.spec.js b/test/e2e/snaps/test-snap-rpc.spec.js index 3505a6c85..9135801c3 100644 --- a/test/e2e/snaps/test-snap-rpc.spec.js +++ b/test/e2e/snaps/test-snap-rpc.spec.js @@ -3,7 +3,10 @@ const FixtureBuilder = require('../fixture-builder'); const { TEST_SNAPS_WEBSITE_URL } = require('./enums'); describe('Test Snap RPC', function () { - it('can use the cross-snap RPC endowment and produce a public key', async function () { + // Disabled for now due to a bug. + // TODO: Re-enable when fixed. + // eslint-disable-next-line mocha/no-skipped-tests + it.skip('can use the cross-snap RPC endowment and produce a public key', async function () { const ganacheOptions = { accounts: [ { From 18b80df0438f7c8b9fc32dea83534fb3345690b2 Mon Sep 17 00:00:00 2001 From: Dan Miller Date: Fri, 5 May 2023 08:23:24 -0230 Subject: [PATCH 14/14] Update changelog for v10.30.1 --- CHANGELOG.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba6d58620..ff018c396 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,12 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ## [10.30.1] -### Uncategorized -- Version v10.29.1 -- Version v10.30.0 -- Merge branch 'develop' into master-sync -- Merge branch 'develop' into master-sync -- Merge remote-tracking branch 'origin/develop' into master-sync +### Fixed +- Disable Flask RPC test to fix failing build ([#19011](https://github.com/MetaMask/metamask-extension/pull/19011)) ## [10.30.0] ### Added