Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronfigueiredo committed Jan 14, 2025
1 parent 02e9563 commit 079f1f0
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 500 deletions.
16 changes: 12 additions & 4 deletions app/scripts/migrations/137.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ describe(`migration #${version}`, () => {
meta: { version: oldVersion },
data: {
PreferencesController: {
redesignedTransactionsEnabled: true,
preferences: {
redesignedTransactionsEnabled: true,
},
},
},
};
const expectedData = {
PreferencesController: {},
PreferencesController: {
preferences: {},
},
};
const newStorage = await migrate(oldStorage);

Expand All @@ -35,12 +39,16 @@ describe(`migration #${version}`, () => {
meta: { version: oldVersion },
data: {
PreferencesController: {
redesignedTransactionsEnabled: false,
preferences: {
redesignedTransactionsEnabled: false,
},
},
},
};
const expectedData = {
PreferencesController: {},
PreferencesController: {
preferences: {},
},
};
const newStorage = await migrate(oldStorage);

Expand Down
9 changes: 6 additions & 3 deletions app/scripts/migrations/137.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { hasProperty } from '@metamask/utils';
import { cloneDeep } from 'lodash';

type VersionedData = {
Expand Down Expand Up @@ -28,7 +29,7 @@ export async function migrate(
return versionedData;
}

function transformState(state: Record<string, unknown>): void {
function transformState(state: Record<string, unknown>) {
const preferencesControllerState = state?.PreferencesController as
| Record<string, unknown>
| undefined;
Expand All @@ -37,8 +38,10 @@ function transformState(state: Record<string, unknown>): void {
| Record<string, unknown>
| undefined;

if (preferences && preferences.redesignedTransactionsEnabled) {
// Existing MetaMask users will have the option off by default
if (
preferences &&
hasProperty(preferences, 'redesignedTransactionsEnabled')
) {
delete preferences.redesignedTransactionsEnabled;
}
}
Loading

0 comments on commit 079f1f0

Please sign in to comment.