From 3c8bee1a2ea1207bcebd99370685c04bd57b1a0c Mon Sep 17 00:00:00 2001 From: Salah-Eddine Saakoun Date: Fri, 29 Nov 2024 15:10:31 +0100 Subject: [PATCH 1/7] chore: remove unused usedNetworks AppStateController property --- app/scripts/constants/sentry-state.ts | 1 - .../controllers/app-state-controller.test.ts | 11 ---------- .../controllers/app-state-controller.ts | 20 ------------------- app/scripts/metamask-controller.js | 2 -- test/data/mock-send-state.json | 5 ----- test/e2e/default-fixture.js | 6 ------ test/e2e/fixture-builder.js | 6 ------ ...rs-after-init-opt-in-background-state.json | 1 - .../errors-after-init-opt-in-ui-state.json | 1 - ...s-before-init-opt-in-background-state.json | 6 ------ .../errors-before-init-opt-in-ui-state.json | 6 ------ .../data/integration-init-state.json | 9 --------- .../data/onboarding-completion-route.json | 1 - .../ui/new-network-info/new-network-info.js | 2 -- ui/pages/routes/routes.component.test.js | 8 -------- ui/pages/routes/routes.container.js | 2 -- ui/selectors/selectors.js | 7 ------- ui/store/actions.ts | 4 ---- 18 files changed, 98 deletions(-) diff --git a/app/scripts/constants/sentry-state.ts b/app/scripts/constants/sentry-state.ts index f18fb96d85fd..9823b2ada540 100644 --- a/app/scripts/constants/sentry-state.ts +++ b/app/scripts/constants/sentry-state.ts @@ -90,7 +90,6 @@ export const SENTRY_BACKGROUND_STATE = { termsOfUseLastAgreed: true, timeoutMinutes: true, trezorModel: true, - usedNetworks: true, }, MultichainBalancesController: { balances: false, diff --git a/app/scripts/controllers/app-state-controller.test.ts b/app/scripts/controllers/app-state-controller.test.ts index 4bc1cb63e390..f830e0ee1cdf 100644 --- a/app/scripts/controllers/app-state-controller.test.ts +++ b/app/scripts/controllers/app-state-controller.test.ts @@ -374,17 +374,6 @@ describe('AppStateController', () => { }); }); - describe('setFirstTimeUsedNetwork', () => { - it('updates the array of the first time used networks', () => { - const chainId = '0x1'; - - appStateController.setFirstTimeUsedNetwork(chainId); - expect(appStateController.store.getState().usedNetworks[chainId]).toBe( - true, - ); - }); - }); - describe('setLastInteractedConfirmationInfo', () => { it('sets information about last confirmation user has interacted with', () => { const lastInteractedConfirmationInfo = { diff --git a/app/scripts/controllers/app-state-controller.ts b/app/scripts/controllers/app-state-controller.ts index 605f307ec0e4..c506dc329e94 100644 --- a/app/scripts/controllers/app-state-controller.ts +++ b/app/scripts/controllers/app-state-controller.ts @@ -62,7 +62,6 @@ export type AppStateControllerState = { hadAdvancedGasFeesSetPriorToMigration92_3: boolean; qrHardware: Json; nftsDropdownState: Json; - usedNetworks: Record; surveyLinkLastClickedOrClosed: number | null; signatureSecurityAlertResponses: Record; // States used for displaying the changed network toast @@ -138,7 +137,6 @@ type AppStateControllerInitState = Partial< AppStateControllerState, | 'qrHardware' | 'nftsDropdownState' - | 'usedNetworks' | 'surveyLinkLastClickedOrClosed' | 'signatureSecurityAlertResponses' | 'switchedNetworkDetails' @@ -184,11 +182,6 @@ const getDefaultAppStateControllerState = ( ...initState, qrHardware: {}, nftsDropdownState: {}, - usedNetworks: { - '0x1': true, - '0x5': true, - '0x539': true, - }, surveyLinkLastClickedOrClosed: null, signatureSecurityAlertResponses: {}, switchedNetworkDetails: null, @@ -704,19 +697,6 @@ export class AppStateController extends EventEmitter { }); } - /** - * Updates the array of the first time used networks - * - * @param chainId - */ - setFirstTimeUsedNetwork(chainId: string): void { - const currentState = this.store.getState(); - const { usedNetworks } = currentState; - usedNetworks[chainId] = true; - - this.store.updateState({ usedNetworks }); - } - ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) /** * Set the interactive replacement token with a url and the old refresh token diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index d60d937e1c3c..fcaf9688f734 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -3704,8 +3704,6 @@ export default class MetamaskController extends EventEmitter { appStateController.setShowNetworkBanner.bind(appStateController), updateNftDropDownState: appStateController.updateNftDropDownState.bind(appStateController), - setFirstTimeUsedNetwork: - appStateController.setFirstTimeUsedNetwork.bind(appStateController), setSwitchedNetworkDetails: appStateController.setSwitchedNetworkDetails.bind(appStateController), clearSwitchedNetworkDetails: diff --git a/test/data/mock-send-state.json b/test/data/mock-send-state.json index 73468aca6171..f9c602808719 100644 --- a/test/data/mock-send-state.json +++ b/test/data/mock-send-state.json @@ -140,11 +140,6 @@ "isAccountMenuOpen": false, "isUnlocked": true, "completedOnboarding": true, - "usedNetworks": { - "0x1": true, - "0x5": true, - "0x539": true - }, "showTestnetMessageInDropdown": true, "alertEnabledness": { "unconnectedAccount": true diff --git a/test/e2e/default-fixture.js b/test/e2e/default-fixture.js index c2fba9d63424..a6845e40ec4c 100644 --- a/test/e2e/default-fixture.js +++ b/test/e2e/default-fixture.js @@ -115,12 +115,6 @@ function defaultFixture(inputChainId = CHAIN_IDS.LOCALHOST) { trezorModel: null, newPrivacyPolicyToastClickedOrClosed: true, newPrivacyPolicyToastShownDate: Date.now(), - usedNetworks: { - [CHAIN_IDS.MAINNET]: true, - [CHAIN_IDS.LINEA_MAINNET]: true, - [CHAIN_IDS.GOERLI]: true, - [CHAIN_IDS.LOCALHOST]: true, - }, snapsInstallPrivacyWarningShown: true, }, BridgeController: { diff --git a/test/e2e/fixture-builder.js b/test/e2e/fixture-builder.js index 844c4766db3e..94e515d46ff6 100644 --- a/test/e2e/fixture-builder.js +++ b/test/e2e/fixture-builder.js @@ -40,12 +40,6 @@ function onboardingFixture() { '__FIXTURE_SUBSTITUTION__currentDateInMilliseconds', showTestnetMessageInDropdown: true, trezorModel: null, - usedNetworks: { - [CHAIN_IDS.MAINNET]: true, - [CHAIN_IDS.LINEA_MAINNET]: true, - [CHAIN_IDS.GOERLI]: true, - [CHAIN_IDS.LOCALHOST]: true, - }, }, NetworkController: { ...mockNetworkStateOld({ diff --git a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json index 1df430082f3e..8351032761a7 100644 --- a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json +++ b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json @@ -45,7 +45,6 @@ "nftsDropdownState": {}, "termsOfUseLastAgreed": "number", "qrHardware": {}, - "usedNetworks": { "0x1": true, "0x5": true, "0x539": true }, "snapsInstallPrivacyWarningShown": true, "surveyLinkLastClickedOrClosed": "object", "signatureSecurityAlertResponses": "object", diff --git a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json index 9988234cac2e..5d79ca5964b8 100644 --- a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json +++ b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json @@ -95,7 +95,6 @@ "nftsDropdownState": {}, "termsOfUseLastAgreed": "number", "qrHardware": {}, - "usedNetworks": { "0x1": true, "0x5": true, "0x539": true }, "snapsInstallPrivacyWarningShown": true, "surveyLinkLastClickedOrClosed": "object", "signatureSecurityAlertResponses": "object", diff --git a/test/e2e/tests/metrics/state-snapshots/errors-before-init-opt-in-background-state.json b/test/e2e/tests/metrics/state-snapshots/errors-before-init-opt-in-background-state.json index 07b292d33b3b..1a1009c02c23 100644 --- a/test/e2e/tests/metrics/state-snapshots/errors-before-init-opt-in-background-state.json +++ b/test/e2e/tests/metrics/state-snapshots/errors-before-init-opt-in-background-state.json @@ -42,12 +42,6 @@ "trezorModel": null, "newPrivacyPolicyToastClickedOrClosed": "boolean", "newPrivacyPolicyToastShownDate": "number", - "usedNetworks": { - "0x1": true, - "0xe708": true, - "0x5": true, - "0x539": true - }, "snapsInstallPrivacyWarningShown": true }, "CurrencyController": { diff --git a/test/e2e/tests/metrics/state-snapshots/errors-before-init-opt-in-ui-state.json b/test/e2e/tests/metrics/state-snapshots/errors-before-init-opt-in-ui-state.json index f997b89bcd28..e7fe6fd2a641 100644 --- a/test/e2e/tests/metrics/state-snapshots/errors-before-init-opt-in-ui-state.json +++ b/test/e2e/tests/metrics/state-snapshots/errors-before-init-opt-in-ui-state.json @@ -42,12 +42,6 @@ "trezorModel": null, "newPrivacyPolicyToastClickedOrClosed": "boolean", "newPrivacyPolicyToastShownDate": "number", - "usedNetworks": { - "0x1": true, - "0xe708": true, - "0x5": true, - "0x539": true - }, "snapsInstallPrivacyWarningShown": true }, "BridgeController": { diff --git a/test/integration/data/integration-init-state.json b/test/integration/data/integration-init-state.json index 0c3853035080..ac58306adca8 100644 --- a/test/integration/data/integration-init-state.json +++ b/test/integration/data/integration-init-state.json @@ -2052,15 +2052,6 @@ "useSafeChainsListValidation": true, "useTokenDetection": false, "useTransactionSimulations": true, - "usedNetworks": { - "0xaa36a7": { - "rpcUrl": "https://sepolia.infura.io/v3/dummy_key", - "chainId": "0xaa36a7", - "nickname": "Sepolia Test Network", - "ticker": "ETH", - "blockExplorerUrl": "https://sepolia.etherscan.io" - } - }, "userOperations": {}, "versionFileETag": "W/\"598946a37f16c5b882a0bebbadf4509f\"", "versionInfo": [], diff --git a/test/integration/data/onboarding-completion-route.json b/test/integration/data/onboarding-completion-route.json index b2c19536a138..33d0680ab8a0 100644 --- a/test/integration/data/onboarding-completion-route.json +++ b/test/integration/data/onboarding-completion-route.json @@ -463,7 +463,6 @@ "useSafeChainsListValidation": true, "useTokenDetection": true, "useTransactionSimulations": true, - "usedNetworks": { "0x1": true, "0x5": true, "0x539": true }, "userOperations": {}, "versionFileETag": "", "versionInfo": [], diff --git a/ui/components/ui/new-network-info/new-network-info.js b/ui/components/ui/new-network-info/new-network-info.js index 15a11918afc1..9d4df0ec63ec 100644 --- a/ui/components/ui/new-network-info/new-network-info.js +++ b/ui/components/ui/new-network-info/new-network-info.js @@ -24,7 +24,6 @@ import { getParticipateInMetaMetrics, getDataCollectionForMarketing, } from '../../../selectors'; -import { setFirstTimeUsedNetwork } from '../../../store/actions'; import { PickerNetwork, Text, @@ -56,7 +55,6 @@ export default function NewNetworkInfo() { const onCloseClick = () => { setShowPopup(false); - setFirstTimeUsedNetwork(providerConfig.chainId); }; const checkTokenDetection = useCallback(async () => { diff --git a/ui/pages/routes/routes.component.test.js b/ui/pages/routes/routes.component.test.js index 14490ad6e146..e661099e1aa2 100644 --- a/ui/pages/routes/routes.component.test.js +++ b/ui/pages/routes/routes.component.test.js @@ -225,12 +225,6 @@ describe('Routes Component', () => { }, selectedAccount: account.id, }, - usedNetworks: { - '0x1': true, - '0x5': true, - '0x539': true, - [mockNewlyAddedNetwork.chainId]: false, - }, networkConfigurationsByChainId: { ...mockState.metamask.networkConfigurationsByChainId, [mockNewlyAddedNetwork.chainId]: mockNewlyAddedNetwork, @@ -312,7 +306,6 @@ describe('toast display', () => { announcements: {}, approvalFlows: [], completedOnboarding: true, - usedNetworks: [], pendingApprovals: {}, pendingApprovalCount: 0, preferences: { @@ -341,7 +334,6 @@ describe('toast display', () => { announcements: {}, approvalFlows: [], completedOnboarding: true, - usedNetworks: [], pendingApprovals: {}, pendingApprovalCount: 0, swapsState: { swapsFeatureIsLive: true }, diff --git a/ui/pages/routes/routes.container.js b/ui/pages/routes/routes.container.js index 28f4291ee37c..0342fc2e15d1 100644 --- a/ui/pages/routes/routes.container.js +++ b/ui/pages/routes/routes.container.js @@ -8,7 +8,6 @@ import { } from '../../../shared/modules/selectors/networks'; import { getAllAccountsOnNetworkAreEmpty, - getIsNetworkUsed, getNetworkIdentifier, getPreferences, getTheme, @@ -95,7 +94,6 @@ function mapStateToProps(state) { providerType: getProviderConfig(state).type, theme: getTheme(state), sendStage: getSendStage(state), - isNetworkUsed: getIsNetworkUsed(state), allAccountsOnNetworkAreEmpty: getAllAccountsOnNetworkAreEmpty(state), isTestNet: getIsTestnet(state), showExtensionInFullSizeView: getShowExtensionInFullSizeView(state), diff --git a/ui/selectors/selectors.js b/ui/selectors/selectors.js index 2baaa1a0c931..deb18c1c5309 100644 --- a/ui/selectors/selectors.js +++ b/ui/selectors/selectors.js @@ -2726,13 +2726,6 @@ export function getBlockExplorerLinkText( return blockExplorerLinkText; } -export function getIsNetworkUsed(state) { - const chainId = getCurrentChainId(state); - const { usedNetworks } = state.metamask; - - return Boolean(usedNetworks[chainId]); -} - export function getAllAccountsOnNetworkAreEmpty(state) { const balances = getMetaMaskCachedBalances(state) ?? {}; const hasNoNativeFundsOnAnyAccounts = Object.values(balances).every( diff --git a/ui/store/actions.ts b/ui/store/actions.ts index 2ad3046e9040..14a0f6781628 100644 --- a/ui/store/actions.ts +++ b/ui/store/actions.ts @@ -5202,10 +5202,6 @@ export function setUseTransactionSimulations(val: boolean): void { } } -export function setFirstTimeUsedNetwork(chainId: string) { - return submitRequestToBackground('setFirstTimeUsedNetwork', [chainId]); -} - // QR Hardware Wallets export async function submitQRHardwareCryptoHDKey(cbor: Hex) { await submitRequestToBackground('submitQRHardwareCryptoHDKey', [cbor]); From b36afd2cffcfb9ca3bb2263367059d7036519591 Mon Sep 17 00:00:00 2001 From: Salah-Eddine Saakoun Date: Fri, 29 Nov 2024 16:54:52 +0100 Subject: [PATCH 2/7] fix: add migration script --- app/scripts/migrations/134.test.ts | 56 ++++++++++++++++++++++++++++++ app/scripts/migrations/134.ts | 41 ++++++++++++++++++++++ app/scripts/migrations/index.js | 1 + 3 files changed, 98 insertions(+) create mode 100644 app/scripts/migrations/134.test.ts create mode 100644 app/scripts/migrations/134.ts diff --git a/app/scripts/migrations/134.test.ts b/app/scripts/migrations/134.test.ts new file mode 100644 index 000000000000..44e96acc654c --- /dev/null +++ b/app/scripts/migrations/134.test.ts @@ -0,0 +1,56 @@ +import { migrate, version } from './134'; + +const oldVersion = 133; + +describe(`migration #${version}`, () => { + it('updates the version metadata', async () => { + const oldStorage = { + meta: { version: oldVersion }, + data: {}, + }; + + const newStorage = await migrate(oldStorage); + + expect(newStorage.meta).toStrictEqual({ version }); + }); + + it('Does nothing if `usedNetworks` is not in the AppStateController state', async () => { + const oldState = { + AppStateController: { + timeoutMinutes: 0, + }, + }; + + const transformedState = await migrate({ + meta: { version: oldVersion }, + data: oldState, + }); + + expect(transformedState.data).toStrictEqual(oldState); + }); + + it('Removes `usedNetworks` from the AppStateController state', async () => { + const oldState: { + AppStateController: { + timeoutMinutes: number; + usedNetworks?: Record; + }; + } = { + AppStateController: { + timeoutMinutes: 0, + usedNetworks: { + '0x1': true, + '0x5': true, + '0x539': true, + }, + }, + }; + const transformedState = await migrate({ + meta: { version: oldVersion }, + data: oldState, + }); + + delete oldState.AppStateController.usedNetworks; + expect(transformedState.data).toStrictEqual(oldState); + }); +}); diff --git a/app/scripts/migrations/134.ts b/app/scripts/migrations/134.ts new file mode 100644 index 000000000000..ac2f89b61ac5 --- /dev/null +++ b/app/scripts/migrations/134.ts @@ -0,0 +1,41 @@ +import { hasProperty, isObject } from '@metamask/utils'; +import { cloneDeep } from 'lodash'; + +type VersionedData = { + meta: { version: number }; + data: Record; +}; + +export const version = 134; + +/** + * This migration removes `providerConfig` from the network controller state. + * + * @param originalVersionedData - Versioned MetaMask extension state, exactly what we persist to dist. + * @param originalVersionedData.meta - State metadata. + * @param originalVersionedData.meta.version - The current state version. + * @param originalVersionedData.data - The persisted MetaMask state, keyed by controller. + * @returns Updated versioned MetaMask extension state. + */ +export async function migrate( + originalVersionedData: VersionedData, +): Promise { + const versionedData = cloneDeep(originalVersionedData); + versionedData.meta.version = version; + transformState(versionedData.data); + return versionedData; +} + +function transformState( + state: Record, +): Record { + if ( + hasProperty(state, 'AppStateController') && + isObject(state.AppStateController) && + hasProperty(state.AppStateController, 'usedNetworks') + ) { + console.log('Removing usedNetworks from AppStateController'); + delete state.AppStateController.usedNetworks; + } + return state; +} diff --git a/app/scripts/migrations/index.js b/app/scripts/migrations/index.js index e95a9bf7a9da..887732ad9dbc 100644 --- a/app/scripts/migrations/index.js +++ b/app/scripts/migrations/index.js @@ -154,6 +154,7 @@ const migrations = [ require('./131'), require('./132'), require('./133'), + require('./134'), ]; export default migrations; From 1de82fe5a7efff5cbca954f820440b9170f41bf1 Mon Sep 17 00:00:00 2001 From: Salah-Eddine Saakoun Date: Fri, 29 Nov 2024 17:19:22 +0100 Subject: [PATCH 3/7] fix: remove console log and deep clone state on migration test --- app/scripts/migrations/134.test.ts | 4 ++-- app/scripts/migrations/134.ts | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/scripts/migrations/134.test.ts b/app/scripts/migrations/134.test.ts index 44e96acc654c..bf852e8182d3 100644 --- a/app/scripts/migrations/134.test.ts +++ b/app/scripts/migrations/134.test.ts @@ -23,7 +23,7 @@ describe(`migration #${version}`, () => { const transformedState = await migrate({ meta: { version: oldVersion }, - data: oldState, + data: { ...oldState }, }); expect(transformedState.data).toStrictEqual(oldState); @@ -47,7 +47,7 @@ describe(`migration #${version}`, () => { }; const transformedState = await migrate({ meta: { version: oldVersion }, - data: oldState, + data: { ...oldState }, }); delete oldState.AppStateController.usedNetworks; diff --git a/app/scripts/migrations/134.ts b/app/scripts/migrations/134.ts index ac2f89b61ac5..ef66d71a7419 100644 --- a/app/scripts/migrations/134.ts +++ b/app/scripts/migrations/134.ts @@ -34,7 +34,6 @@ function transformState( isObject(state.AppStateController) && hasProperty(state.AppStateController, 'usedNetworks') ) { - console.log('Removing usedNetworks from AppStateController'); delete state.AppStateController.usedNetworks; } return state; From f7cad9be82a880663420bf55510544031ba13b7b Mon Sep 17 00:00:00 2001 From: Salah-Eddine Saakoun Date: Fri, 29 Nov 2024 17:26:38 +0100 Subject: [PATCH 4/7] fix: restore migration log --- app/scripts/migrations/134.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/app/scripts/migrations/134.ts b/app/scripts/migrations/134.ts index ef66d71a7419..ac2f89b61ac5 100644 --- a/app/scripts/migrations/134.ts +++ b/app/scripts/migrations/134.ts @@ -34,6 +34,7 @@ function transformState( isObject(state.AppStateController) && hasProperty(state.AppStateController, 'usedNetworks') ) { + console.log('Removing usedNetworks from AppStateController'); delete state.AppStateController.usedNetworks; } return state; From e9322d831197a62115959d381a69ca3a98e7a57e Mon Sep 17 00:00:00 2001 From: Salah-Eddine Saakoun Date: Fri, 29 Nov 2024 17:30:18 +0100 Subject: [PATCH 5/7] fix: use cloneDeep --- app/scripts/migrations/134.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/scripts/migrations/134.test.ts b/app/scripts/migrations/134.test.ts index bf852e8182d3..e3736e2fb5b0 100644 --- a/app/scripts/migrations/134.test.ts +++ b/app/scripts/migrations/134.test.ts @@ -1,3 +1,4 @@ +import { cloneDeep } from 'lodash'; import { migrate, version } from './134'; const oldVersion = 133; @@ -23,7 +24,7 @@ describe(`migration #${version}`, () => { const transformedState = await migrate({ meta: { version: oldVersion }, - data: { ...oldState }, + data: cloneDeep(oldState), }); expect(transformedState.data).toStrictEqual(oldState); @@ -47,7 +48,7 @@ describe(`migration #${version}`, () => { }; const transformedState = await migrate({ meta: { version: oldVersion }, - data: { ...oldState }, + data: cloneDeep(oldState), }); delete oldState.AppStateController.usedNetworks; From 27f87c7aa763890388710cb1f285848d4deffb7a Mon Sep 17 00:00:00 2001 From: Salah-Eddine Saakoun Date: Fri, 29 Nov 2024 17:32:45 +0100 Subject: [PATCH 6/7] fix: typo in test jsdoc --- app/scripts/migrations/134.test.ts | 4 ++-- app/scripts/migrations/134.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/scripts/migrations/134.test.ts b/app/scripts/migrations/134.test.ts index e3736e2fb5b0..26dc88cde690 100644 --- a/app/scripts/migrations/134.test.ts +++ b/app/scripts/migrations/134.test.ts @@ -15,7 +15,7 @@ describe(`migration #${version}`, () => { expect(newStorage.meta).toStrictEqual({ version }); }); - it('Does nothing if `usedNetworks` is not in the AppStateController state', async () => { + it('Does nothing if `usedNetworks` is not in the `AppStateController` state', async () => { const oldState = { AppStateController: { timeoutMinutes: 0, @@ -30,7 +30,7 @@ describe(`migration #${version}`, () => { expect(transformedState.data).toStrictEqual(oldState); }); - it('Removes `usedNetworks` from the AppStateController state', async () => { + it('Removes `usedNetworks` from the `AppStateController` state', async () => { const oldState: { AppStateController: { timeoutMinutes: number; diff --git a/app/scripts/migrations/134.ts b/app/scripts/migrations/134.ts index ac2f89b61ac5..e11b2abd9625 100644 --- a/app/scripts/migrations/134.ts +++ b/app/scripts/migrations/134.ts @@ -9,7 +9,7 @@ type VersionedData = { export const version = 134; /** - * This migration removes `providerConfig` from the network controller state. + * This migration removes `usedNetworks` from `AppStateController` state. * * @param originalVersionedData - Versioned MetaMask extension state, exactly what we persist to dist. * @param originalVersionedData.meta - State metadata. From 593e03d989afebc5087ef30150d056a090f8830f Mon Sep 17 00:00:00 2001 From: Salah-Eddine Saakoun Date: Fri, 29 Nov 2024 17:36:18 +0100 Subject: [PATCH 7/7] fix: refactor test logic to be clearer --- app/scripts/migrations/134.test.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/scripts/migrations/134.test.ts b/app/scripts/migrations/134.test.ts index 26dc88cde690..9b3d31db017f 100644 --- a/app/scripts/migrations/134.test.ts +++ b/app/scripts/migrations/134.test.ts @@ -46,12 +46,17 @@ describe(`migration #${version}`, () => { }, }, }; + const expectedState = { + AppStateController: { + timeoutMinutes: 0, + }, + }; + const transformedState = await migrate({ meta: { version: oldVersion }, data: cloneDeep(oldState), }); - delete oldState.AppStateController.usedNetworks; - expect(transformedState.data).toStrictEqual(oldState); + expect(transformedState.data).toStrictEqual(expectedState); }); });