Skip to content

Commit

Permalink
fix: Migration 29 isEIP1559Compatible issue cherry pick (#9014)
Browse files Browse the repository at this point in the history
## **Description**
Fixed migration 29 for the 7.19.0
Cherry pick of this
[PR](#9013)
## **Related issues**

Fixes:

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **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**

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

## **Related issues**

Fixes:

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **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.
  • Loading branch information
tommasini authored Mar 21, 2024
1 parent 3c20a67 commit 5ea640f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 51 deletions.
17 changes: 0 additions & 17 deletions app/store/migrations/029.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
40 changes: 6 additions & 34 deletions app/store/migrations/029.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 5ea640f

Please sign in to comment.