From 71ce22fa034f822da5c04385cc2fbc8f3f3f6dce Mon Sep 17 00:00:00 2001 From: salimtb Date: Fri, 11 Oct 2024 19:41:37 +0200 Subject: [PATCH 1/2] fix: fix snapshot --- .../__snapshots__/Icon.test.tsx.snap | 125 ------------------ .../__snapshots__/Root.test.tsx.snap | 13 -- 2 files changed, 138 deletions(-) delete mode 100644 app/components/UI/Notification/NotificationMenuItem/__snapshots__/Icon.test.tsx.snap delete mode 100644 app/components/UI/Notification/NotificationMenuItem/__snapshots__/Root.test.tsx.snap diff --git a/app/components/UI/Notification/NotificationMenuItem/__snapshots__/Icon.test.tsx.snap b/app/components/UI/Notification/NotificationMenuItem/__snapshots__/Icon.test.tsx.snap deleted file mode 100644 index ab6ba83caea..00000000000 --- a/app/components/UI/Notification/NotificationMenuItem/__snapshots__/Icon.test.tsx.snap +++ /dev/null @@ -1,125 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`NotificationIcon matches snapshot when icon is provided 1`] = ` -[ - - - - - - - - - - - - , - , -] -`; diff --git a/app/components/UI/Notification/NotificationMenuItem/__snapshots__/Root.test.tsx.snap b/app/components/UI/Notification/NotificationMenuItem/__snapshots__/Root.test.tsx.snap deleted file mode 100644 index 0a3c705f1ec..00000000000 --- a/app/components/UI/Notification/NotificationMenuItem/__snapshots__/Root.test.tsx.snap +++ /dev/null @@ -1,13 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`NotificationRoot matches snapshot 1`] = ` - -`; From 644a5417d6a824d0af9a2d93e56d06e411b87547 Mon Sep 17 00:00:00 2001 From: salimtb Date: Mon, 21 Oct 2024 10:43:09 +0200 Subject: [PATCH 2/2] feat: add new default networks --- app/components/Nav/App/index.js | 44 ++++++ .../__snapshots__/Icon.test.tsx.snap | 125 ++++++++++++++++++ .../__snapshots__/Root.test.tsx.snap | 13 ++ 3 files changed, 182 insertions(+) create mode 100644 app/components/UI/Notification/NotificationMenuItem/__snapshots__/Icon.test.tsx.snap create mode 100644 app/components/UI/Notification/NotificationMenuItem/__snapshots__/Root.test.tsx.snap diff --git a/app/components/Nav/App/index.js b/app/components/Nav/App/index.js index a587ef6c3ae..a4841b9816a 100644 --- a/app/components/Nav/App/index.js +++ b/app/components/Nav/App/index.js @@ -131,6 +131,10 @@ import OptionsSheet from '../../UI/SelectOptionSheet/OptionsSheet'; import FoxLoader from '../../../components/UI/FoxLoader'; import { AppStateEventProcessor } from '../../../core/AppStateEventListener'; import MultiRpcModal from '../../../components/Views/MultiRpcModal/MultiRpcModal'; +import Engine from '../../../core/Engine'; +import { CHAIN_IDS } from '@metamask/transaction-controller'; +import { PopularList } from '../../../util/networks/customNetworks'; +import { RpcEndpointType } from '@metamask/network-controller'; const clearStackNavigatorOptions = { headerShown: false, @@ -528,6 +532,46 @@ const App = (props) => { useEffect(() => { async function startApp() { const existingUser = await StorageWrapper.getItem(EXISTING_USER); + if (!existingUser) { + // List of chainIds to add (as hex strings) + const chainIdsToAdd = [ + CHAIN_IDS.ARBITRUM, + CHAIN_IDS.BASE, + CHAIN_IDS.BSC, + CHAIN_IDS.OPTIMISM, + CHAIN_IDS.POLYGON, + ]; + + // Filter the PopularList to get only the specified networks based on chainId + const selectedNetworks = PopularList.filter((network) => + chainIdsToAdd.includes(network.chainId), + ); + const { NetworkController } = Engine.context; + + // Loop through each selected network and call NetworkController.addNetwork + for (const network of selectedNetworks) { + try { + await NetworkController.addNetwork({ + chainId: network.chainId, + blockExplorerUrls: [network.rpcPrefs.blockExplorerUrl], + defaultRpcEndpointIndex: 0, + defaultBlockExplorerUrlIndex: 0, + name: network.nickname, + nativeCurrency: network.ticker, + rpcEndpoints: [ + { + url: network.rpcUrl, + name: network.nickname, + type: RpcEndpointType.Custom, + }, + ], + }); + } catch (error) { + Logger.error(error); + } + } + } + try { const currentVersion = getVersion(); const savedVersion = await StorageWrapper.getItem(CURRENT_APP_VERSION); diff --git a/app/components/UI/Notification/NotificationMenuItem/__snapshots__/Icon.test.tsx.snap b/app/components/UI/Notification/NotificationMenuItem/__snapshots__/Icon.test.tsx.snap new file mode 100644 index 00000000000..ab6ba83caea --- /dev/null +++ b/app/components/UI/Notification/NotificationMenuItem/__snapshots__/Icon.test.tsx.snap @@ -0,0 +1,125 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`NotificationIcon matches snapshot when icon is provided 1`] = ` +[ + + + + + + + + + + + + , + , +] +`; diff --git a/app/components/UI/Notification/NotificationMenuItem/__snapshots__/Root.test.tsx.snap b/app/components/UI/Notification/NotificationMenuItem/__snapshots__/Root.test.tsx.snap new file mode 100644 index 00000000000..0a3c705f1ec --- /dev/null +++ b/app/components/UI/Notification/NotificationMenuItem/__snapshots__/Root.test.tsx.snap @@ -0,0 +1,13 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`NotificationRoot matches snapshot 1`] = ` + +`;