From a76ae4a9d3956abb35cdef09c71beb388fc0f73b Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Wed, 20 Mar 2024 17:14:39 -0230 Subject: [PATCH 1/4] v11.12.4 --- CHANGELOG.md | 7 ++++++- package.json | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8a819529166..6d6d191fc49d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [11.12.4] +### Fixed +- Ensure native network balance is visible in home screen balance display ([#23614](https://github.com/MetaMask/metamask-extension/pull/23614)) + ## [11.12.3] ### Fixed - [MMI] Fixes an error related with a missing code fence, when the MMI build didn't have the blockaid feature ([#23516](https://github.com/MetaMask/metamask-extension/pull/23516)) @@ -4507,7 +4511,8 @@ Update styles and spacing on the critical error page ([#20350](https://github.c ### Uncategorized - Added the ability to restore accounts from seed words. -[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v11.12.3...HEAD +[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v11.12.4...HEAD +[11.12.4]: https://github.com/MetaMask/metamask-extension/compare/v11.12.3...v11.12.4 [11.12.3]: https://github.com/MetaMask/metamask-extension/compare/v11.12.2...v11.12.3 [11.12.2]: https://github.com/MetaMask/metamask-extension/compare/v11.12.1...v11.12.2 [11.12.1]: https://github.com/MetaMask/metamask-extension/compare/v11.12.0...v11.12.1 diff --git a/package.json b/package.json index 2524da7ba8b7..dee4ac170e3e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "metamask-crx", - "version": "11.12.3", + "version": "11.12.4", "private": true, "repository": { "type": "git", From 177ec59564bb3ee3ea85e42a8430057cf54befb8 Mon Sep 17 00:00:00 2001 From: Brian Bergeron Date: Wed, 20 Mar 2024 13:37:25 -0700 Subject: [PATCH 2/4] fix: revert aggregated fiat balance on home page (#23614) (#23617) cherry picking https://github.com/MetaMask/metamask-extension/pull/23614 Not a clean cherry pick, handled conflicts in 3 files. --------- Co-authored-by: Dan J Miller --- test/e2e/helpers.js | 9 +--- test/e2e/tests/account-token-list.spec.js | 2 +- test/e2e/tests/contract-interactions.spec.js | 9 ++-- test/e2e/tests/incremental-security.spec.js | 8 +-- test/e2e/tests/localization.spec.js | 2 +- test/e2e/tests/lock-account.spec.js | 2 +- test/e2e/tests/metamask-responsive-ui.spec.js | 4 +- test/e2e/tests/migrate-old-vault.spec.js | 2 +- test/e2e/tests/send-eth.spec.js | 16 +++--- .../app/wallet-overview/eth-overview.js | 49 +++++++------------ .../app/wallet-overview/eth-overview.test.js | 4 +- 11 files changed, 42 insertions(+), 65 deletions(-) diff --git a/test/e2e/helpers.js b/test/e2e/helpers.js index 210790844a50..dcc693b4a855 100644 --- a/test/e2e/helpers.js +++ b/test/e2e/helpers.js @@ -808,16 +808,11 @@ const TEST_SEED_PHRASE_TWO = // Usually happens when onboarded to make sure the state is retrieved from metamaskState properly, or after txn is made const locateAccountBalanceDOM = async (driver, ganacheServer) => { - const balance = (await ganacheServer.getFiatBalance()).toLocaleString( - undefined, - { - minimumFractionDigits: 2, - }, - ); + const balance = await ganacheServer.getBalance(); await driver.findElement({ css: '[data-testid="eth-overview__primary-currency"]', - text: `$ ${balance} USD`, + text: `${balance} ETH`, }); }; diff --git a/test/e2e/tests/account-token-list.spec.js b/test/e2e/tests/account-token-list.spec.js index c92e1217de4f..f0f08ae8fcdb 100644 --- a/test/e2e/tests/account-token-list.spec.js +++ b/test/e2e/tests/account-token-list.spec.js @@ -65,7 +65,7 @@ describe('Settings', function () { const tokenListAmount = await driver.findElement( '.eth-overview__primary-container', ); - assert.equal(await tokenListAmount.getText(), '$42,500.00\nUSD'); + assert.equal(await tokenListAmount.getText(), '25\nETH'); await driver.clickElement('[data-testid="account-menu-icon"]'); const accountTokenValue = await driver.waitForSelector( '.multichain-account-list-item .multichain-account-list-item__asset', diff --git a/test/e2e/tests/contract-interactions.spec.js b/test/e2e/tests/contract-interactions.spec.js index 3f87e112a21e..d59ece2d97ed 100644 --- a/test/e2e/tests/contract-interactions.spec.js +++ b/test/e2e/tests/contract-interactions.spec.js @@ -1,4 +1,3 @@ -const { strict: assert } = require('assert'); const { defaultGanacheOptions, withFixtures, @@ -6,6 +5,7 @@ const { unlockWallet, largeDelayMs, WINDOW_TITLES, + locateAccountBalanceDOM, } = require('../helpers'); const { SMART_CONTRACTS } = require('../seeder/smart-contracts'); @@ -25,7 +25,7 @@ describe('Deploy contract and call contract methods', function () { smartContract, title: this.test.fullTitle(), }, - async ({ driver, contractRegistry }) => { + async ({ driver, contractRegistry, ganacheServer }) => { const contractAddress = await contractRegistry.getContractAddress( smartContract, ); @@ -87,10 +87,7 @@ describe('Deploy contract and call contract methods', function () { await driver.switchToWindowWithTitle( WINDOW_TITLES.ExtensionInFullScreenView, ); - const balance = await driver.findElement( - '[data-testid="eth-overview__primary-currency"]', - ); - assert.equal(await balance.getText(), '$37,399.05\nUSD'); + await locateAccountBalanceDOM(driver, ganacheServer); }, ); }); diff --git a/test/e2e/tests/incremental-security.spec.js b/test/e2e/tests/incremental-security.spec.js index 7c231c622f92..0bc9f33f5cdc 100644 --- a/test/e2e/tests/incremental-security.spec.js +++ b/test/e2e/tests/incremental-security.spec.js @@ -112,10 +112,10 @@ describe('Incremental Security', function () { // should have the correct amount of eth let currencyDisplay = await driver.waitForSelector({ css: '.currency-display-component__text', - text: '$1,700.00', + text: '1', }); let balance = await currencyDisplay.getText(); - assert.strictEqual(balance, '$1,700.00'); + assert.strictEqual(balance, '1'); // backs up the Secret Recovery Phrase // should show a backup reminder @@ -163,11 +163,11 @@ describe('Incremental Security', function () { // should have the correct amount of eth currencyDisplay = await driver.waitForSelector({ css: '.currency-display-component__text', - text: '$1,700.00', + text: '1', }); balance = await currencyDisplay.getText(); - assert.strictEqual(balance, '$1,700.00'); + assert.strictEqual(balance, '1'); // should not show a backup reminder await driver.assertElementNotPresent('.backup-notification'); diff --git a/test/e2e/tests/localization.spec.js b/test/e2e/tests/localization.spec.js index 6c0e0295f097..7c8c35d3d169 100644 --- a/test/e2e/tests/localization.spec.js +++ b/test/e2e/tests/localization.spec.js @@ -27,7 +27,7 @@ describe('Localization', function () { await unlockWallet(driver); const secondaryBalance = await driver.findElement( - '[data-testid="eth-overview__primary-currency"]', + '[data-testid="eth-overview__secondary-currency"]', ); const secondaryBalanceText = await secondaryBalance.getText(); const [fiatAmount, fiatUnit] = secondaryBalanceText diff --git a/test/e2e/tests/lock-account.spec.js b/test/e2e/tests/lock-account.spec.js index 9ef084b17a7c..a4d23ab7838f 100644 --- a/test/e2e/tests/lock-account.spec.js +++ b/test/e2e/tests/lock-account.spec.js @@ -30,7 +30,7 @@ describe('Lock and unlock', function () { const walletBalance = await driver.findElement( '.eth-overview__primary-balance', ); - assert.equal(await walletBalance.getText(), '$42,500.00\nUSD'); + assert.equal(/^25\s*ETH$/u.test(await walletBalance.getText()), true); }, ); }); diff --git a/test/e2e/tests/metamask-responsive-ui.spec.js b/test/e2e/tests/metamask-responsive-ui.spec.js index c9aa4667bc1d..033b1611ca7b 100644 --- a/test/e2e/tests/metamask-responsive-ui.spec.js +++ b/test/e2e/tests/metamask-responsive-ui.spec.js @@ -74,9 +74,9 @@ describe('MetaMask Responsive UI', function () { await driver.waitForElementNotPresent('.loading-overlay__spinner'); // assert balance const balance = await driver.findElement( - '.eth-overview__primary-container', + '[data-testid="eth-overview__primary-currency"]', ); - assert.equal(await balance.getText(), '$0.00\nUSD'); + assert.ok(/^0\sETH$/u.test(await balance.getText())); }, ); }); diff --git a/test/e2e/tests/migrate-old-vault.spec.js b/test/e2e/tests/migrate-old-vault.spec.js index 82b6c846b2d9..93bd07010bbe 100644 --- a/test/e2e/tests/migrate-old-vault.spec.js +++ b/test/e2e/tests/migrate-old-vault.spec.js @@ -32,7 +32,7 @@ describe('Migrate vault with old encryption', function () { const walletBalance = await driver.findElement( '.eth-overview__primary-balance', ); - assert.equal(await walletBalance.getText(), '$42,500.00\nUSD'); + assert.equal(/^25\s*ETH$/u.test(await walletBalance.getText()), true); }, ); }); diff --git a/test/e2e/tests/send-eth.spec.js b/test/e2e/tests/send-eth.spec.js index 8d8d86bd873d..32b649bfd0d2 100644 --- a/test/e2e/tests/send-eth.spec.js +++ b/test/e2e/tests/send-eth.spec.js @@ -190,7 +190,7 @@ describe('Send ETH', function () { const balance = await driver.findElement( '[data-testid="eth-overview__primary-currency"]', ); - assert.equal(await balance.getText(), '$42,496.38\nUSD'); + assert.ok(/^[\d.]+\sETH$/u.test(await balance.getText())); await driver.clickElement('[data-testid="home__activity-tab"]'); await driver.findElement( @@ -215,12 +215,13 @@ describe('Send ETH', function () { return; } await unlockWallet(driver); + + await driver.assertElementNotPresent('.loading-overlay__spinner'); const balance = await driver.findElement( '[data-testid="eth-overview__primary-currency"]', ); - await driver.isElementPresent('.loading-overlay__spinner'); - await driver.waitForElementNotPresent('.loading-overlay__spinner'); - assert.equal(await balance.getText(), '$42,500.00\nUSD'); + assert.ok(/^[\d.]+\sETH$/u.test(await balance.getText())); + await openActionMenuAndStartSendFlow(driver); // choose to scan via QR code await driver.clickElement('[data-testid="ens-qr-scan-button"]'); @@ -419,13 +420,12 @@ describe('Send ETH', function () { }, async ({ driver }) => { await unlockWallet(driver); + + await driver.assertElementNotPresent('.loading-overlay__spinner'); const balance = await driver.findElement( '[data-testid="eth-overview__primary-currency"]', ); - - await driver.isElementPresent('.loading-overlay__spinner'); - await driver.waitForElementNotPresent('.loading-overlay__spinner'); - assert.equal(await balance.getText(), '$42,500.00\nUSD'); + assert.ok(/^[\d.]+\sETH$/u.test(await balance.getText())); await openActionMenuAndStartSendFlow(driver); if (process.env.MULTICHAIN) { diff --git a/ui/components/app/wallet-overview/eth-overview.js b/ui/components/app/wallet-overview/eth-overview.js index dece08d61f14..ebe77325a386 100644 --- a/ui/components/app/wallet-overview/eth-overview.js +++ b/ui/components/app/wallet-overview/eth-overview.js @@ -27,14 +27,11 @@ import UserPreferencedCurrencyDisplay from '../user-preferenced-currency-display import { PRIMARY, SECONDARY } from '../../../helpers/constants/common'; import { isBalanceCached, + getShouldShowFiat, getIsSwapsChain, getCurrentChainId, getPreferences, - getSelectedAddress, - getShouldHideZeroBalanceTokens, - getCurrentNetwork, getSelectedAccountCachedBalance, - getShowFiatInTestnets, ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) getSwapsDefaultToken, getCurrentKeyring, @@ -65,11 +62,9 @@ import { IconColor } from '../../../helpers/constants/design-system'; import useRamps from '../../../hooks/experiences/useRamps'; import { getPortfolioUrl } from '../../../helpers/utils/portfolio'; ///: END:ONLY_INCLUDE_IF -import { useAccountTotalFiatBalance } from '../../../hooks/useAccountTotalFiatBalance'; import { useIsOriginalNativeTokenSymbol } from '../../../hooks/useIsOriginalNativeTokenSymbol'; import { getProviderConfig } from '../../../ducks/metamask/metamask'; import { showPrimaryCurrency } from '../../../../shared/modules/currency-display.utils'; -import { TEST_NETWORKS } from '../../../../shared/constants/network'; import WalletOverview from './wallet-overview'; const EthOverview = ({ className, showAddress }) => { @@ -87,10 +82,10 @@ const EthOverview = ({ className, showAddress }) => { const defaultSwapsToken = useSelector(getSwapsDefaultToken); ///: END:ONLY_INCLUDE_IF const balanceIsCached = useSelector(isBalanceCached); + const showFiat = useSelector(getShouldShowFiat); const { useNativeCurrencyAsPrimaryCurrency } = useSelector(getPreferences); const chainId = useSelector(getCurrentChainId); const { ticker, type } = useSelector(getProviderConfig); - const currentNetwork = useSelector(getCurrentNetwork); const balance = useSelector(getSelectedAccountCachedBalance); const isOriginalNativeSymbol = useIsOriginalNativeTokenSymbol( chainId, @@ -98,25 +93,6 @@ const EthOverview = ({ className, showAddress }) => { type, ); - // Total fiat balance - const selectedAddress = useSelector(getSelectedAddress); - const shouldHideZeroBalanceTokens = useSelector( - getShouldHideZeroBalanceTokens, - ); - const { totalWeiBalance } = useAccountTotalFiatBalance( - selectedAddress, - shouldHideZeroBalanceTokens, - ); - const showFiatInTestnets = useSelector(getShowFiatInTestnets); - const showFiat = - TEST_NETWORKS.includes(currentNetwork?.nickname) && !showFiatInTestnets; - - let balanceToUse = totalWeiBalance; - - if (showFiat) { - balanceToUse = balance; - } - const isSwapsChain = useSelector(getIsSwapsChain); ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) @@ -186,14 +162,14 @@ const EthOverview = ({ className, showAddress }) => { >
- {balanceToUse ? ( + {balance ? ( { ? PRIMARY : SECONDARY } - showFiat={ - !showFiat || - !TEST_NETWORKS.includes(currentNetwork?.nickname) - } ethNumberOfDecimals={4} hideTitle /> @@ -219,6 +191,19 @@ const EthOverview = ({ className, showAddress }) => { * ) : null}
+ {showFiat && isOriginalNativeSymbol && balance && ( + + )}
} diff --git a/ui/components/app/wallet-overview/eth-overview.test.js b/ui/components/app/wallet-overview/eth-overview.test.js index 2b0bc7935eb0..959a38678677 100644 --- a/ui/components/app/wallet-overview/eth-overview.test.js +++ b/ui/components/app/wallet-overview/eth-overview.test.js @@ -171,7 +171,7 @@ describe('EthOverview', () => { const primaryBalance = queryByTestId(ETH_OVERVIEW_PRIMARY_CURRENCY); expect(primaryBalance).toBeInTheDocument(); - expect(primaryBalance).toHaveTextContent('$0.00USD'); + expect(primaryBalance).toHaveTextContent('<0.000001ETH'); expect(queryByText('*')).not.toBeInTheDocument(); }); @@ -202,7 +202,7 @@ describe('EthOverview', () => { const primaryBalance = queryByTestId(ETH_OVERVIEW_PRIMARY_CURRENCY); expect(primaryBalance).toBeInTheDocument(); - expect(primaryBalance).toHaveTextContent('$0.02USD'); + expect(primaryBalance).toHaveTextContent('0.0104ETH'); expect(queryByText('*')).toBeInTheDocument(); }); From 6b1e892d7b565581c80115de2d863c49e4d3cfd0 Mon Sep 17 00:00:00 2001 From: Brian Bergeron Date: Wed, 20 Mar 2024 14:41:15 -0700 Subject: [PATCH 3/4] fix: test for v11.12.4 release (#23619) Fix test for v11.12.4 release --- test/e2e/tests/send-eth.spec.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/e2e/tests/send-eth.spec.js b/test/e2e/tests/send-eth.spec.js index 32b649bfd0d2..aeb9a1995720 100644 --- a/test/e2e/tests/send-eth.spec.js +++ b/test/e2e/tests/send-eth.spec.js @@ -216,10 +216,11 @@ describe('Send ETH', function () { } await unlockWallet(driver); - await driver.assertElementNotPresent('.loading-overlay__spinner'); const balance = await driver.findElement( '[data-testid="eth-overview__primary-currency"]', ); + await driver.isElementPresent('.loading-overlay__spinner'); + await driver.waitForElementNotPresent('.loading-overlay__spinner'); assert.ok(/^[\d.]+\sETH$/u.test(await balance.getText())); await openActionMenuAndStartSendFlow(driver); @@ -421,10 +422,11 @@ describe('Send ETH', function () { async ({ driver }) => { await unlockWallet(driver); - await driver.assertElementNotPresent('.loading-overlay__spinner'); const balance = await driver.findElement( '[data-testid="eth-overview__primary-currency"]', ); + await driver.isElementPresent('.loading-overlay__spinner'); + await driver.waitForElementNotPresent('.loading-overlay__spinner'); assert.ok(/^[\d.]+\sETH$/u.test(await balance.getText())); await openActionMenuAndStartSendFlow(driver); From cda3bdd5348847c870daae5d4599de22265817c2 Mon Sep 17 00:00:00 2001 From: Bowen Sanders Date: Wed, 20 Mar 2024 14:51:02 -0700 Subject: [PATCH 4/4] fix: fix typo in snap install rejected metric (#23618) ## **Description** Fixes a typo in the name for the `SnapInstallRejected` MetaMetrics event. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/23618?quickstart=1) --- shared/constants/metametrics.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/constants/metametrics.ts b/shared/constants/metametrics.ts index 397fa0472039..4a02b88d461c 100644 --- a/shared/constants/metametrics.ts +++ b/shared/constants/metametrics.ts @@ -662,7 +662,7 @@ export enum MetaMetricsEventName { ///: BEGIN:ONLY_INCLUDE_IF(snaps) SnapInstallStarted = 'Snap Install Started', SnapInstallFailed = 'Snap Install Failed', - SnapInstallRejected = 'Snap Update Rejected', + SnapInstallRejected = 'Snap Install Rejected', SnapInstalled = 'Snap Installed', SnapUninstalled = 'Snap Uninstalled', SnapUpdateStarted = 'Snap Update Started',