From 5ea640f8703957c976f70eb5d280f1e4ec7784d5 Mon Sep 17 00:00:00 2001 From: tommasini <46944231+tommasini@users.noreply.github.com> Date: Thu, 21 Mar 2024 09:50:18 +0000 Subject: [PATCH] fix: Migration 29 isEIP1559Compatible issue cherry pick (#9014) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** Fixed migration 29 for the 7.19.0 Cherry pick of this [PR](https://github.com/MetaMask/metamask-mobile/pull/9013) ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've clearly explained what problem this PR is solving and how it is solved. - [ ] I've linked related issues - [ ] I've included manual testing steps - [ ] I've included screenshots/recordings if applicable - [ ] 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. - [ ] I’ve properly set the pull request status: - [ ] In case it's not yet "ready for review", I've set it to "draft". - [ ] In case it's "ready for review", I've changed it from "draft" to "non-draft". ## **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.## **Description** ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've clearly explained what problem this PR is solving and how it is solved. - [ ] I've linked related issues - [ ] I've included manual testing steps - [ ] I've included screenshots/recordings if applicable - [ ] 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. - [ ] I’ve properly set the pull request status: - [ ] In case it's not yet "ready for review", I've set it to "draft". - [ ] In case it's "ready for review", I've changed it from "draft" to "non-draft". ## **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. --- app/store/migrations/029.test.ts | 17 -------------- app/store/migrations/029.ts | 40 +++++--------------------------- 2 files changed, 6 insertions(+), 51 deletions(-) diff --git a/app/store/migrations/029.test.ts b/app/store/migrations/029.test.ts index 1f4bccc73d0..0a64a4eb36b 100644 --- a/app/store/migrations/029.test.ts +++ b/app/store/migrations/029.test.ts @@ -275,23 +275,6 @@ describe('Migration #29', () => { "Migration 29: Invalid NetworkController networkDetails: 'null'", scenario: 'networkDetails is invalid', }, - { - state: merge({}, initialRootState, { - engine: { - backgroundState: { - NetworkController: { - ...initialBackgroundState.NetworkController, - networkDetails: { - isEIP1559Compatible: undefined, - }, - }, - }, - }, - }), - errorMessage: - "Migration 29: Invalid NetworkController networkDetails isEIP1559Compatible: 'undefined'", - scenario: 'networkDetails isEIP1559Compatible is invalid', - }, { state: merge({}, initialRootState, { engine: { diff --git a/app/store/migrations/029.ts b/app/store/migrations/029.ts index 4a33dd35661..7c0fe7aa3c8 100644 --- a/app/store/migrations/029.ts +++ b/app/store/migrations/029.ts @@ -130,43 +130,15 @@ export default async function migrate(stateAsync: unknown) { ); return state; } - - if ( - !hasProperty( - networkControllerState.networkDetails, - 'isEIP1559Compatible', - ) || - networkControllerState.networkDetails.isEIP1559Compatible === null || - networkControllerState.networkDetails.isEIP1559Compatible === undefined - ) { - captureException( - new Error( - `Migration 29: Invalid NetworkController networkDetails isEIP1559Compatible: '${JSON.stringify( - networkControllerState.networkDetails.isEIP1559Compatible, - )}'`, - ), - ); - return state; - } - // Addressing networkDetails property change const isEIP1559Compatible = - networkControllerState.networkDetails.isEIP1559Compatible; - - if (isEIP1559Compatible) { - networkControllerState.networkDetails = { - EIPS: { - 1559: true, - }, - }; - } else { - networkControllerState.networkDetails = { - EIPS: { - 1559: false, - }, - }; - } + !!networkControllerState.networkDetails.isEIP1559Compatible; + networkControllerState.networkDetails = { + EIPS: { + 1559: isEIP1559Compatible, + }, + }; if (isObject(networkControllerState.networkDetails)) { delete networkControllerState.networkDetails.isEIP1559Compatible; }