@@ -52,6 +52,7 @@ import {
5252 isMainNet ,
5353} from '../../../util/networks' ;
5454import {
55+ selectNetworkConfigurations ,
5556 selectProviderConfig ,
5657 selectTicker ,
5758} from '../../../selectors/networkController' ;
@@ -80,8 +81,14 @@ import { RootState } from '../../../reducers';
8081import usePrevious from '../../hooks/usePrevious' ;
8182import { selectSelectedInternalAccountChecksummedAddress } from '../../../selectors/accountsController' ;
8283import { selectAccountBalanceByChainId } from '../../../selectors/accountTrackerController' ;
83- import { selectUseNftDetection } from '../../../selectors/preferencesController' ;
84- import { setNftAutoDetectionModalOpen } from '../../../actions/security' ;
84+ import {
85+ selectShowMultiRpcModal ,
86+ selectUseNftDetection ,
87+ } from '../../../selectors/preferencesController' ;
88+ import {
89+ setNftAutoDetectionModalOpen ,
90+ setMultiRpcMigrationModalOpen ,
91+ } from '../../../actions/security' ;
8592import {
8693 hideNftFetchingLoadingIndicator as hideNftFetchingLoadingIndicatorAction ,
8794 showNftFetchingLoadingIndicator as showNftFetchingLoadingIndicatorAction ,
@@ -96,6 +103,7 @@ import {
96103} from '../../../selectors/notifications' ;
97104import { ButtonVariants } from '../../../component-library/components/Buttons/Button' ;
98105import { useListNotifications } from '../../../util/notifications/hooks/useNotifications' ;
106+ import { isObject } from 'lodash' ;
99107const createStyles = ( { colors, typography } : Theme ) =>
100108 StyleSheet . create ( {
101109 base : {
@@ -167,6 +175,8 @@ const Wallet = ({
167175 const styles = createStyles ( theme ) ;
168176 const { colors } = theme ;
169177 const dispatch = useDispatch ( ) ;
178+ const networkConfigurations = useSelector ( selectNetworkConfigurations ) ;
179+
170180 /**
171181 * Object containing the balance of the current selected account
172182 */
@@ -300,6 +310,7 @@ const Wallet = ({
300310
301311 const networkImageSource = useSelector ( selectNetworkImageSource ) ;
302312 const useNftDetection = useSelector ( selectUseNftDetection ) ;
313+ const showMultiRpcModal = useSelector ( selectShowMultiRpcModal ) ;
303314 const isNFTAutoDetectionModalViewed = useSelector (
304315 ( state : RootState ) => state . security . isNFTAutoDetectionModalViewed ,
305316 ) ;
@@ -316,6 +327,13 @@ const Wallet = ({
316327 } ) ;
317328 } , [ navigate , providerConfig . chainId , trackEvent ] ) ;
318329
330+ const isNetworkDuplicated = Object . values ( networkConfigurations ) . some (
331+ ( networkConfiguration ) =>
332+ isObject ( networkConfiguration ) &&
333+ Array . isArray ( networkConfiguration . rpcEndpoints ) &&
334+ networkConfiguration . rpcEndpoints . length > 1 ,
335+ ) ;
336+
319337 const checkNftAutoDetectionModal = useCallback ( ( ) => {
320338 const isOnMainnet = isMainNet ( providerConfig . chainId ) ;
321339 if ( ! useNftDetection && isOnMainnet && ! isNFTAutoDetectionModalViewed ) {
@@ -332,12 +350,22 @@ const Wallet = ({
332350 useNftDetection ,
333351 ] ) ;
334352
353+ const checkMultiRpcModal = useCallback ( ( ) => {
354+ if ( showMultiRpcModal && isNetworkDuplicated ) {
355+ navigation . navigate ( Routes . MODAL . ROOT_MODAL_FLOW , {
356+ screen : Routes . MODAL . MULTI_RPC_MIGRATION_MODAL ,
357+ } ) ;
358+ dispatch ( setMultiRpcMigrationModalOpen ( true ) ) ;
359+ }
360+ } , [ dispatch , showMultiRpcModal , navigation , isNetworkDuplicated ] ) ;
361+
335362 useEffect ( ( ) => {
336363 if (
337364 currentRouteName === 'Wallet' ||
338365 currentRouteName === 'SecuritySettings'
339366 ) {
340367 checkNftAutoDetectionModal ( ) ;
368+ checkMultiRpcModal ( ) ;
341369 }
342370
343371 async function checkIfNotificationsAreEnabled ( ) {
0 commit comments