From 0d77c6e8955afc18d90a25040407b03b746587da Mon Sep 17 00:00:00 2001 From: Salim TOUBAL Date: Tue, 12 Nov 2024 12:42:15 +0100 Subject: [PATCH 1/9] fix: fix displayed selected rpc for linea (#12255) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** the displayed selected rpc for linea is not the correct one ## **Related issues** Fixes: #12252 ## **Manual testing steps** 1. Go Network selector 2. add another rpc for linea 3. check the selected rpc on the network selector view ## **Screenshots/Recordings** ### **Before** ### **After** https://github.com/user-attachments/assets/77b16939-5730-4d06-a9a0-e641e8e7f657 ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- .../NetworkSelector/NetworkSelector.test.tsx | 73 +++++++++++++++++++ .../Views/NetworkSelector/NetworkSelector.tsx | 7 +- .../NetworkSelector.test.tsx.snap | 70 ++++++++++++++++-- 3 files changed, 143 insertions(+), 7 deletions(-) diff --git a/app/components/Views/NetworkSelector/NetworkSelector.test.tsx b/app/components/Views/NetworkSelector/NetworkSelector.test.tsx index 077bded6d8c..970634f0db7 100644 --- a/app/components/Views/NetworkSelector/NetworkSelector.test.tsx +++ b/app/components/Views/NetworkSelector/NetworkSelector.test.tsx @@ -86,6 +86,46 @@ const initialState = { mainnet: { status: 'available', EIPS: { '1559': true } }, }, networkConfigurationsByChainId: { + '0x1': { + blockExplorerUrls: [], + chainId: '0x1', + defaultRpcEndpointIndex: 1, + name: 'Ethereum Mainnet', + nativeCurrency: 'ETH', + rpcEndpoints: [ + { + networkClientId: 'mainnet', + type: 'infura', + url: 'https://mainnet.infura.io/v3/{infuraProjectId}', + }, + { + name: 'public', + networkClientId: 'ea57f659-c004-4902-bfca-0c9688a43872', + type: 'custom', + url: 'https://mainnet-rpc.publicnode.com', + }, + ], + }, + '0xe708': { + blockExplorerUrls: [], + chainId: '0xe708', + defaultRpcEndpointIndex: 1, + name: 'Linea', + nativeCurrency: 'ETH', + rpcEndpoints: [ + { + networkClientId: 'linea-mainnet', + type: 'infura', + url: 'https://linea-mainnet.infura.io/v3/{infuraProjectId}', + }, + { + name: 'public', + networkClientId: 'ea57f659-c004-4902-bfca-0c9688a43877', + type: 'custom', + url: 'https://linea-rpc.publicnode.com', + }, + ], + }, '0xa86a': { blockExplorerUrls: ['https://snowtrace.io'], chainId: '0xa86a', @@ -459,4 +499,37 @@ describe('Network Selector', () => { fireEvent(testNetworksSwitch, 'onValueChange', false); expect(setShowTestNetworksSpy).toBeCalledWith(false); }); + + describe('renderLineaMainnet', () => { + it('renders the linea mainnet cell correctly', () => { + (isNetworkUiRedesignEnabled as jest.Mock).mockImplementation(() => true); + const { getByText } = renderComponent(initialState); + const lineaRpcUrl = getByText('https://linea-rpc.publicnode.com'); + const lineaCell = getByText('Linea'); + expect(lineaCell).toBeTruthy(); + expect(lineaRpcUrl).toBeTruthy(); + }); + }); + + describe('renderRpcUrl', () => { + it('renders the RPC URL correctly for avalanche', () => { + (isNetworkUiRedesignEnabled as jest.Mock).mockImplementation(() => true); + const { getByText } = renderComponent(initialState); + const avalancheRpcUrl = getByText('api.avax.network/ext/bc/C'); + const avalancheCell = getByText('Avalanche Mainnet C-Chain'); + expect(avalancheRpcUrl).toBeTruthy(); + expect(avalancheCell).toBeTruthy(); + }); + }); + + describe('renderMainnet', () => { + it('renders the mainnet cell correctly', () => { + (isNetworkUiRedesignEnabled as jest.Mock).mockImplementation(() => true); + const { getByText } = renderComponent(initialState); + const mainnetRpcUrl = getByText('https://mainnet-rpc.publicnode.com'); + const mainnetCell = getByText('Ethereum Mainnet'); + expect(mainnetCell).toBeTruthy(); + expect(mainnetRpcUrl).toBeTruthy(); + }); + }); }); diff --git a/app/components/Views/NetworkSelector/NetworkSelector.tsx b/app/components/Views/NetworkSelector/NetworkSelector.tsx index 9ed751604df..ea36deab166 100644 --- a/app/components/Views/NetworkSelector/NetworkSelector.tsx +++ b/app/components/Views/NetworkSelector/NetworkSelector.tsx @@ -84,7 +84,6 @@ import { isNetworkUiRedesignEnabled } from '../../../util/networks/isNetworkUiRe import { Hex } from '@metamask/utils'; import hideProtocolFromUrl from '../../../util/hideProtocolFromUrl'; import { CHAIN_IDS } from '@metamask/transaction-controller'; -import { LINEA_DEFAULT_RPC_URL } from '../../../constants/urls'; import { useNetworkInfo } from '../../../selectors/selectedNetworkController'; import { NetworkConfiguration } from '@metamask/network-controller'; import Logger from '../../../util/Logger'; @@ -509,6 +508,10 @@ const NetworkSelector = () => { const renderLineaMainnet = () => { const { name: lineaMainnetName, chainId } = Networks['linea-mainnet']; const name = networkConfigurations?.[chainId]?.name ?? lineaMainnetName; + const rpcUrl = + networkConfigurations?.[chainId]?.rpcEndpoints?.[ + networkConfigurations?.[chainId]?.defaultRpcEndpointIndex + ].url; if (isNetworkUiRedesignEnabled() && isNoSearchResults('linea-mainnet')) return null; @@ -529,7 +532,7 @@ const NetworkSelector = () => { onPress={() => onNetworkChange(LINEA_MAINNET)} style={styles.networkCell} buttonIcon={IconName.MoreVertical} - secondaryText={hideKeyFromUrl(LINEA_DEFAULT_RPC_URL)} + secondaryText={hideKeyFromUrl(rpcUrl)} buttonProps={{ onButtonClick: () => { openModal(chainId, false, LINEA_MAINNET, true); diff --git a/app/components/Views/NetworkSelector/__snapshots__/NetworkSelector.test.tsx.snap b/app/components/Views/NetworkSelector/__snapshots__/NetworkSelector.test.tsx.snap index 959570801e2..3773996bbf7 100644 --- a/app/components/Views/NetworkSelector/__snapshots__/NetworkSelector.test.tsx.snap +++ b/app/components/Views/NetworkSelector/__snapshots__/NetworkSelector.test.tsx.snap @@ -560,7 +560,7 @@ exports[`Network Selector renders correctly 1`] = ` } testID="cellbase-avatar-title" > - Ethereum Main Network + Ethereum Mainnet @@ -686,7 +686,7 @@ exports[`Network Selector renders correctly 1`] = ` } testID="cellbase-avatar-title" > - Linea Main Network + Linea @@ -1890,8 +1890,68 @@ exports[`Network Selector renders correctly when network UI redesign is enabled } testID="cellbase-avatar-title" > - Ethereum Main Network + Ethereum Mainnet + + + https://mainnet-rpc.publicnode.com + + + @@ -2080,7 +2140,7 @@ exports[`Network Selector renders correctly when network UI redesign is enabled } testID="cellbase-avatar-title" > - Linea Main Network + Linea - https://linea-mainnet.infura.io/v3 + https://linea-rpc.publicnode.com Date: Tue, 12 Nov 2024 08:58:27 -0500 Subject: [PATCH 2/9] feat(2808): improvements-and-small-features-and-small-fixes-that-still-needed-to-be-added-to-edit-permissions (#12168) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** Adding missing features, small fixes and feedback from design QA. ## **Related issues** Fixes: ## **Manual testing steps** 1. set the feature flag export MM_MULTICHAIN_V1_ENABLED="1" 2. go to the dapp browser and open pancake swap and click Connect in pancake swap 3. change the permissions and check fixes and improvements in the commit names are present ## **Screenshots/Recordings** | Before | After | |--------------|--------------| | Screenshot 2024-04-18 at 3 56 43 PM |Screenshot 2024-04-18 at 3 56 43 PM | ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- .../PermissionsSummary.styles.ts | 4 +- .../PermissionsSummary/PermissionsSummary.tsx | 6 +- .../PermissionsSummary.test.tsx.snap | 20 +- .../UI/Tabs/TabThumbnail/TabThumbnail.tsx | 49 ++-- .../__snapshots__/TabThumbnail.test.tsx.snap | 277 ------------------ .../UI/Tabs/__snapshots__/index.test.tsx.snap | 277 ------------------ .../Views/AccountConnect/AccountConnect.tsx | 1 + .../AccountConnectMultiSelector.styles.ts | 2 +- .../AccountPermissionsConnected.styles.ts | 3 +- .../NetworkConnectMultiSelector.styles.ts | 3 +- sonar-project.properties | 2 +- 11 files changed, 60 insertions(+), 584 deletions(-) diff --git a/app/components/UI/PermissionsSummary/PermissionsSummary.styles.ts b/app/components/UI/PermissionsSummary/PermissionsSummary.styles.ts index 84e03643ab3..3c25f4830a7 100644 --- a/app/components/UI/PermissionsSummary/PermissionsSummary.styles.ts +++ b/app/components/UI/PermissionsSummary/PermissionsSummary.styles.ts @@ -30,6 +30,9 @@ const createStyles = (params: { marginRight: 24, marginLeft: 24, }, + bottomButtonsContainer: { + marginTop: 16, + }, actionButtonsContainer: { flex: 0, flexDirection: 'row', @@ -118,7 +121,6 @@ const createStyles = (params: { walletIcon: { alignSelf: 'flex-start' }, dataIcon: { alignSelf: 'flex-start' }, disconnectAllContainer: { - marginTop: 16, marginHorizontal: 24, flexDirection: 'row', }, diff --git a/app/components/UI/PermissionsSummary/PermissionsSummary.tsx b/app/components/UI/PermissionsSummary/PermissionsSummary.tsx index 715e887d48a..f48936e74ef 100644 --- a/app/components/UI/PermissionsSummary/PermissionsSummary.tsx +++ b/app/components/UI/PermissionsSummary/PermissionsSummary.tsx @@ -389,7 +389,7 @@ const PermissionsSummary = ({ {!isNetworkSwitch && renderAccountPermissionsRequestInfoCard()} {renderNetworkPermissionsRequestInfoCard()} - + {isAlreadyConnected && isDisconnectAllShown && (