From c9acbfb973a622acf47d7e5a2f0813edaa674f75 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Fri, 27 Jan 2023 09:17:47 -0800 Subject: [PATCH 1/7] Use network provider state, instead of CurrencyRateController state, to select 'nativeCurrency' (#17450) * Use network provider state, instead of CurrencyRateController state, select 'nativeCurrency' * Fix unit tests * Lint fix * Only use the network provider ticket for the native currency when useCurrencyRateCheck is false * Fix unit test * Fix tests for real --- test/data/mock-state.json | 3 ++- .../transaction-activity-log.container.test.js | 4 ++++ .../confirm-transaction.duck.test.js | 3 +++ ui/ducks/metamask/metamask.js | 6 +++++- ui/ducks/metamask/metamask.test.js | 16 +++++++++++++++- ui/pages/send/gas-display/gas-display.js | 5 ++--- .../send-content.component.test.js.snap | 10 +++------- 7 files changed, 34 insertions(+), 13 deletions(-) diff --git a/test/data/mock-state.json b/test/data/mock-state.json index c98e05daf..de6a59a83 100644 --- a/test/data/mock-state.json +++ b/test/data/mock-state.json @@ -74,7 +74,8 @@ "network": "5", "provider": { "type": "rpc", - "chainId": "0x5" + "chainId": "0x5", + "ticker": "ETH" }, "keyrings": [ { diff --git a/ui/components/app/transaction-activity-log/transaction-activity-log.container.test.js b/ui/components/app/transaction-activity-log/transaction-activity-log.container.test.js index cb6dbeab0..58c3674f1 100644 --- a/ui/components/app/transaction-activity-log/transaction-activity-log.container.test.js +++ b/ui/components/app/transaction-activity-log/transaction-activity-log.container.test.js @@ -18,6 +18,9 @@ describe('TransactionActivityLog container', () => { conversionRate: 280.45, nativeCurrency: 'ETH', frequentRpcListDetail: [], + provider: { + ticker: 'ETH', + }, }, }; @@ -43,6 +46,7 @@ describe('TransactionActivityLog container', () => { ], provider: { rpcUrl: 'https://customnetwork.com/', + ticker: 'ETH', }, }, }; diff --git a/ui/ducks/confirm-transaction/confirm-transaction.duck.test.js b/ui/ducks/confirm-transaction/confirm-transaction.duck.test.js index 816c544eb..404327af2 100644 --- a/ui/ducks/confirm-transaction/confirm-transaction.duck.test.js +++ b/ui/ducks/confirm-transaction/confirm-transaction.duck.test.js @@ -290,6 +290,9 @@ describe('Confirm Transaction Duck', () => { metamask: { conversionRate: 468.58, currentCurrency: 'usd', + provider: { + ticker: 'ETH', + }, }, confirmTransaction: { ethTransactionAmount: '1', diff --git a/ui/ducks/metamask/metamask.js b/ui/ducks/metamask/metamask.js index d27b68657..3125a135f 100644 --- a/ui/ducks/metamask/metamask.js +++ b/ui/ducks/metamask/metamask.js @@ -10,6 +10,7 @@ import { accountsWithSendEtherInfoSelector, checkNetworkAndAccountSupports1559, getAddressBook, + getUseCurrencyRateCheck, } from '../../selectors'; import { updateTransactionGasFees } from '../../store/actions'; import { setCustomGasLimit, setCustomGasPrice } from '../gas/gas.duck'; @@ -308,7 +309,10 @@ export function getConversionRate(state) { } export function getNativeCurrency(state) { - return state.metamask.nativeCurrency; + const useCurrencyRateCheck = getUseCurrencyRateCheck(state); + return useCurrencyRateCheck + ? state.metamask.nativeCurrency + : state.metamask.provider.ticker; } export function getSendHexDataFeatureFlagState(state) { diff --git a/ui/ducks/metamask/metamask.test.js b/ui/ducks/metamask/metamask.test.js index cdd22052b..820e9f7bd 100644 --- a/ui/ducks/metamask/metamask.test.js +++ b/ui/ducks/metamask/metamask.test.js @@ -40,10 +40,12 @@ describe('MetaMask Reducers', () => { currentBlockGasLimit: '0x4c1878', conversionRate: 1200.88200327, nativeCurrency: 'ETH', + useCurrencyRateCheck: true, network: '5', provider: { type: 'testnet', chainId: '0x5', + ticker: 'TestETH', }, accounts: { '0xfdea65c8e26263f6d9a1b5de9555d2931a33b825': { @@ -308,9 +310,21 @@ describe('MetaMask Reducers', () => { }); describe('getNativeCurrency()', () => { - it('should return the ticker symbol of the selected network', () => { + it('should return nativeCurrency when useCurrencyRateCheck is true', () => { expect(getNativeCurrency(mockState)).toStrictEqual('ETH'); }); + + it('should return the ticker symbol of the selected network when useCurrencyRateCheck is false', () => { + expect( + getNativeCurrency({ + ...mockState, + metamask: { + ...mockState.metamask, + useCurrencyRateCheck: false, + }, + }), + ).toStrictEqual('TestETH'); + }); }); describe('getSendHexDataFeatureFlagState()', () => { diff --git a/ui/pages/send/gas-display/gas-display.js b/ui/pages/send/gas-display/gas-display.js index ff044864b..a719f7f19 100644 --- a/ui/pages/send/gas-display/gas-display.js +++ b/ui/pages/send/gas-display/gas-display.js @@ -67,9 +67,8 @@ export default function GasDisplay({ gasError }) { ); const useCurrencyRateCheck = useSelector(getUseCurrencyRateCheck); const { useNativeCurrencyAsPrimaryCurrency } = useSelector(getPreferences); - const { nativeCurrency, provider, unapprovedTxs } = useSelector( - (state) => state.metamask, - ); + const { provider, unapprovedTxs } = useSelector((state) => state.metamask); + const nativeCurrency = provider.ticker; const { confirmTransaction } = useSelector((state) => state); const { txData } = confirmTransaction; const { txParams = {} } = txData; diff --git a/ui/pages/send/send-content/__snapshots__/send-content.component.test.js.snap b/ui/pages/send/send-content/__snapshots__/send-content.component.test.js.snap index c80d2c7f4..07b2d300f 100644 --- a/ui/pages/send/send-content/__snapshots__/send-content.component.test.js.snap +++ b/ui/pages/send/send-content/__snapshots__/send-content.component.test.js.snap @@ -31,10 +31,8 @@ exports[`SendContent Component render should match snapshot 1`] = `
-
@@ -43,9 +41,7 @@ exports[`SendContent Component render should match snapshot 1`] = ` >
- ETH -
+ />
From 76ebc3318c138246e6e184c25f5c47160b37f05e Mon Sep 17 00:00:00 2001 From: MetaMask Bot Date: Fri, 27 Jan 2023 17:40:38 +0000 Subject: [PATCH 2/7] Version v10.24.2 --- CHANGELOG.md | 7 ++++++- package.json | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dd0763e3..7120480d3 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] +## [10.24.2] +### Uncategorized +- Use network provider state, instead of CurrencyRateController state, to select 'nativeCurrency' ([#17450](https://github.com/MetaMask/metamask-extension/pull/17450)) + ## [10.24.1] ### Added - Ensure app name appears for Taiwanese language speakers in the extension stores ([#17304](https://github.com/MetaMask/metamask-extension/pull/17304)) @@ -3427,7 +3431,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.24.1...HEAD +[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.24.2...HEAD +[10.24.2]: https://github.com/MetaMask/metamask-extension/compare/v10.24.1...v10.24.2 [10.24.1]: https://github.com/MetaMask/metamask-extension/compare/v10.24.0...v10.24.1 [10.24.0]: https://github.com/MetaMask/metamask-extension/compare/v10.23.3...v10.24.0 [10.23.3]: https://github.com/MetaMask/metamask-extension/compare/v10.23.2...v10.23.3 diff --git a/package.json b/package.json index 366ac9999..e7c17375a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "metamask-crx", - "version": "10.24.1", + "version": "10.24.2", "private": true, "repository": { "type": "git", From 5f5b75832f08672973d294ba1b2b74776719a135 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Mon, 23 Jan 2023 10:32:39 -0800 Subject: [PATCH 3/7] Fix cookiejar dependency vulnerability (#17355) --- package.json | 1 + yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index e7c17375a..6b38bc3ee 100644 --- a/package.json +++ b/package.json @@ -90,6 +90,7 @@ "**/redux-devtools-instrument/symbol-observable": "^2.0.3", "**/rxjs/symbol-observable": "^2.0.3", "analytics-node/axios": "^0.21.2", + "cookiejar": "^2.1.4", "ganache-core/lodash": "^4.17.21", "netmask": "^2.0.1", "pubnub/superagent-proxy": "^3.0.0", diff --git a/yarn.lock b/yarn.lock index 6db4230a5..4f379e71e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9228,10 +9228,10 @@ cookie@0.4.0: resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba" integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg== -cookiejar@^2.1.0, cookiejar@^2.1.1: - version "2.1.3" - resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.3.tgz#fc7a6216e408e74414b90230050842dacda75acc" - integrity sha512-JxbCBUdrfr6AQjOXrxoTvAMJO4HBTUIlBzslcJPAz+/KT8yk53fXun51u+RenNYvad/+Vc2DIz5o9UxlCDymFQ== +cookiejar@^2.1.0, cookiejar@^2.1.1, cookiejar@^2.1.4: + version "2.1.4" + resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.4.tgz#ee669c1fea2cf42dc31585469d193fef0d65771b" + integrity sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw== cookies@~0.8.0: version "0.8.0" From 62bca622737ea637213a4085738e9ceb6e705035 Mon Sep 17 00:00:00 2001 From: ryanml Date: Fri, 27 Jan 2023 11:08:25 -0700 Subject: [PATCH 4/7] Updating changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7120480d3..104601148 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ## [10.24.2] -### Uncategorized -- Use network provider state, instead of CurrencyRateController state, to select 'nativeCurrency' ([#17450](https://github.com/MetaMask/metamask-extension/pull/17450)) +### Fixed +- Fix incorrect network information after switching networks when "Show balance and token price checker" is toggled off ([#17450](https://github.com/MetaMask/metamask-extension/pull/17450)) ## [10.24.1] ### Added From 58b5332b67654c8672cf82c0b89975aeb42e1466 Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Thu, 26 Jan 2023 21:09:13 +0530 Subject: [PATCH 5/7] Improving getMemoizedMetadataContractName selector (#17432) --- ui/selectors/selectors.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/selectors/selectors.js b/ui/selectors/selectors.js index 577d32d0e..d8038ccf3 100644 --- a/ui/selectors/selectors.js +++ b/ui/selectors/selectors.js @@ -831,8 +831,9 @@ export const getMemoizedMetadataContractName = createDeepEqualSelector( getTokenList, (_tokenList, address) => address, (tokenList, address) => { + const checksumHexAddress = toChecksumHexAddress(address); const entry = Object.values(tokenList).find((identity) => - isEqualCaseInsensitive(identity.address, toChecksumHexAddress(address)), + isEqualCaseInsensitive(identity.address, checksumHexAddress), ); return entry && entry.name !== '' ? entry.name : ''; }, From a31eccd01ee95ef2733ef493533ddc3f21ad215f Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Mon, 30 Jan 2023 06:23:59 -0330 Subject: [PATCH 6/7] Fix unit tests that were removed on develop in #16862, but broken in master with #17450 --- .../token-input/token-input.component.test.js | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/ui/components/ui/token-input/token-input.component.test.js b/ui/components/ui/token-input/token-input.component.test.js index a7245c54e..b3bc5f0db 100644 --- a/ui/components/ui/token-input/token-input.component.test.js +++ b/ui/components/ui/token-input/token-input.component.test.js @@ -16,6 +16,9 @@ describe('TokenInput Component', () => { metamask: { currentCurrency: 'usd', conversionRate: 231.06, + provider: { + ticker: 'ETH', + }, }, }; const store = configureMockStore()(mockStore); @@ -62,6 +65,9 @@ describe('TokenInput Component', () => { const mockStore = { metamask: { currentCurrency: 'usd', + provider: { + ticker: 'ETH', + }, conversionRate: 231.06, }, }; @@ -106,6 +112,9 @@ describe('TokenInput Component', () => { metamask: { currentCurrency: 'usd', conversionRate: 231.06, + provider: { + ticker: 'ETH', + }, }, }; const store = configureMockStore()(mockStore); @@ -152,6 +161,9 @@ describe('TokenInput Component', () => { metamask: { currentCurrency: 'usd', conversionRate: 231.06, + provider: { + ticker: 'ETH', + }, }, }; const store = configureMockStore()(mockStore); @@ -200,6 +212,9 @@ describe('TokenInput Component', () => { metamask: { currentCurrency: 'usd', conversionRate: 231.06, + provider: { + ticker: 'ETH', + }, }, }; const store = configureMockStore()(mockStore); @@ -262,6 +277,9 @@ describe('TokenInput Component', () => { metamask: { currentCurrency: 'usd', conversionRate: 231.06, + provider: { + ticker: 'ETH', + }, }, }; const store = configureMockStore()(mockStore); @@ -315,6 +333,9 @@ describe('TokenInput Component', () => { metamask: { currentCurrency: 'usd', conversionRate: 231.06, + provider: { + ticker: 'ETH', + }, }, }; const store = configureMockStore()(mockStore); @@ -370,6 +391,9 @@ describe('TokenInput Component', () => { metamask: { currentCurrency: 'usd', conversionRate: 231.06, + provider: { + ticker: 'ETH', + }, }, }; const store = configureMockStore()(mockStore); @@ -425,6 +449,9 @@ describe('TokenInput Component', () => { metamask: { currentCurrency: 'usd', conversionRate: 231.06, + provider: { + ticker: 'ETH', + }, }, }; const store = configureMockStore()(mockStore); @@ -472,6 +499,9 @@ describe('TokenInput Component', () => { metamask: { currentCurrency: 'usd', conversionRate: 231.06, + provider: { + ticker: 'ETH', + }, }, }; const store = configureMockStore()(mockStore); From 665f22d23666f5e6b92f274ccfc9d8f889c0596c Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Mon, 30 Jan 2023 08:55:31 -0330 Subject: [PATCH 7/7] Update changelog for v10.24.2: adding entry for #17432 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 104601148..31f53c974 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [10.24.2] ### Fixed - Fix incorrect network information after switching networks when "Show balance and token price checker" is toggled off ([#17450](https://github.com/MetaMask/metamask-extension/pull/17450)) +- Improve rendering time of signTypedData confirmation screens for large payloads ([#17432](https://github.com/MetaMask/metamask-extension/pull/17432)) ## [10.24.1] ### Added