Skip to content

Commit 2e989e9

Browse files
committed
fix: add test for migration
1 parent 683bbed commit 2e989e9

File tree

10 files changed

+656
-55
lines changed

10 files changed

+656
-55
lines changed

app/components/UI/AssetIcon/index.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const mockInitialState = {
1515
selectedAddress: '0x76cf1CdD1fcC252442b50D6e97207228aA4aefC3',
1616
useTokenDetection: true,
1717
useNftDetection: false,
18-
useMultiRpcMigration: false,
18+
showMultiRpcModal: false,
1919
displayNftMedia: true,
2020
useSafeChainsListValidation: false,
2121
isMultiAccountBalancesEnabled: true,

app/components/Views/MultiRpcModal/MultiRpcModal.test.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ import { backgroundState } from '../../../util/test/initial-root-state';
1212
import { NetworkStatus, RpcEndpointType } from '@metamask/network-controller';
1313
import { CHAIN_IDS } from '@metamask/transaction-controller';
1414

15-
const setUseMultiRpcMigrationSpy = jest.spyOn(
15+
const setShowMultiRpcModalSpy = jest.spyOn(
1616
Engine.context.PreferencesController,
17-
'setUseMultiRpcMigration',
17+
'setShowMultiRpcModal',
1818
);
1919

2020
jest.mock('../../../core/Engine', () => ({
2121
context: {
2222
PreferencesController: {
23-
setUseMultiRpcMigration: jest.fn(),
23+
setShowMultiRpcModal: jest.fn(),
2424
},
2525
},
2626
}));
@@ -30,7 +30,7 @@ const initialState: DeepPartial<RootState> = {
3030
backgroundState: {
3131
...backgroundState,
3232
PreferencesController: {
33-
useMultiRpcMigration: false,
33+
showMultiRpcModal: false,
3434
},
3535
NetworkController: {
3636
selectedNetworkClientId: 'mainnet',
@@ -91,11 +91,11 @@ describe('MultiRpcModal', () => {
9191
expect(toJSON()).toMatchSnapshot();
9292
});
9393

94-
it('calls setUseMultiRpcMigration and trackEvent when clicking on allow button', () => {
94+
it('calls setShowMultiRpcModal and trackEvent when clicking on allow button', () => {
9595
const { getByTestId } = renderComponent(initialState);
9696
const allowButton = getByTestId('allow');
9797

9898
fireEvent.press(allowButton);
99-
expect(setUseMultiRpcMigrationSpy).toHaveBeenCalledWith(true);
99+
expect(setShowMultiRpcModalSpy).toHaveBeenCalledWith(true);
100100
});
101101
});

app/components/Views/MultiRpcModal/MultiRpcModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const MultiRpcModal = () => {
5151

5252
const dismissMultiRpcModalMigration = useCallback(() => {
5353
const { PreferencesController } = Engine.context;
54-
PreferencesController.setUseMultiRpcMigration(false);
54+
PreferencesController.setShowMultiRpcModal(false);
5555
trackEvent(MetaMetricsEvents.MULTI_RPC_MIGRATION_MODAL_ACCEPTED, {
5656
chainId,
5757
});

app/components/Views/Settings/NetworksSettings/NetworkSettings/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2227,7 +2227,9 @@ export class NetworkSettings extends PureComponent {
22272227
await this.onRpcUrlChangeWithName(url, name, type);
22282228
this.closeRpcModal();
22292229
}}
2230-
showButtonIcon={rpcUrl !== url}
2230+
showButtonIcon={
2231+
rpcUrl !== url && type !== RpcEndpointType.Infura
2232+
}
22312233
buttonIcon={IconName.Trash}
22322234
onButtonClick={async () => {
22332235
await this.onRpcUrlDelete(url);

app/components/Views/Wallet/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ import usePrevious from '../../hooks/usePrevious';
8181
import { selectSelectedInternalAccountChecksummedAddress } from '../../../selectors/accountsController';
8282
import { selectAccountBalanceByChainId } from '../../../selectors/accountTrackerController';
8383
import {
84-
selectUseMultiRpcMigration,
84+
selectShowMultiRpcModal,
8585
selectUseNftDetection,
8686
} from '../../../selectors/preferencesController';
8787
import {
@@ -306,7 +306,7 @@ const Wallet = ({
306306

307307
const networkImageSource = useSelector(selectNetworkImageSource);
308308
const useNftDetection = useSelector(selectUseNftDetection);
309-
const useMultiRpcMigration = useSelector(selectUseMultiRpcMigration);
309+
const showMultiRpcModal = useSelector(selectShowMultiRpcModal);
310310
const isNFTAutoDetectionModalViewed = useSelector(
311311
(state: RootState) => state.security.isNFTAutoDetectionModalViewed,
312312
);
@@ -343,15 +343,15 @@ const Wallet = ({
343343
// navigation.navigate(Routes.MODAL.ROOT_MODAL_FLOW, {
344344
// screen: Routes.MODAL.MULTI_RPC_MIGRATION_MODAL,
345345
// });
346-
console.log('useMultiRpcMigration ======', useMultiRpcMigration);
346+
console.log('showMultiRpcModal ======', showMultiRpcModal);
347347

348-
if (useMultiRpcMigration) {
348+
if (showMultiRpcModal) {
349349
navigation.navigate(Routes.MODAL.ROOT_MODAL_FLOW, {
350350
screen: Routes.MODAL.MULTI_RPC_MIGRATION_MODAL,
351351
});
352352
dispatch(setMultiRpcMigrationModalOpen(true));
353353
}
354-
}, [dispatch, useMultiRpcMigration, navigation]);
354+
}, [dispatch, showMultiRpcModal, navigation]);
355355

356356
useEffect(() => {
357357
if (

app/core/Engine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ class Engine {
543543
useNftDetection: true, // set this to true to enable nft detection by default to new users
544544
displayNftMedia: true,
545545
securityAlertsEnabled: true,
546-
useMultiRpcMigration: true,
546+
showMultiRpcModal: true,
547547
...initialState.PreferencesController,
548548
},
549549
});

app/selectors/preferencesController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ export const selectUseNftDetection = createSelector(
1717
preferencesControllerState.useNftDetection,
1818
);
1919

20-
export const selectUseMultiRpcMigration = createSelector(
20+
export const selectShowMultiRpcModal = createSelector(
2121
selectPreferencesControllerState,
2222
(preferencesControllerState: PreferencesState) =>
23-
preferencesControllerState.useMultiRpcMigration,
23+
preferencesControllerState.showMultiRpcModal,
2424
);
2525

2626
export const selectUseTokenDetection = createSelector(

0 commit comments

Comments
 (0)