Skip to content

Commit 2955e78

Browse files
committed
migration 67
1 parent d531309 commit 2955e78

File tree

5 files changed

+433
-10
lines changed

5 files changed

+433
-10
lines changed

app/store/migrations/066.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ describe('migration #66', () => {
391391
// Verify Sentry exception was captured
392392
expect(mockedCaptureException).toHaveBeenCalledWith(
393393
new Error(
394-
'Migration 66: Unknown account type unknown-type, defaulting to EVM namespace',
394+
'Migration 66: Unknown account type unknown-type, defaulting to EVM EOA',
395395
),
396396
);
397397
});

app/store/migrations/066.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ import {
1111
} from '@metamask/keyring-api';
1212
import { captureException } from '@sentry/react-native';
1313

14-
const migrationVersion = 66;
15-
16-
function getScopesForAccountType(accountType: string): string[] {
14+
function getScopesForAccountType(
15+
accountType: string,
16+
migrationNumber: number,
17+
): string[] {
1718
switch (accountType) {
1819
case EthAccountType.Eoa:
1920
case EthAccountType.Erc4337:
@@ -27,7 +28,7 @@ function getScopesForAccountType(accountType: string): string[] {
2728
// Default to EVM namespace for unknown account types
2829
captureException(
2930
new Error(
30-
`Migration ${migrationVersion}: Unknown account type ${accountType}, defaulting to EVM namespace`,
31+
`Migration ${migrationNumber}: Unknown account type ${accountType}, defaulting to EVM EOA`,
3132
),
3233
);
3334
return [EthScope.Eoa];
@@ -45,8 +46,8 @@ function getScopesForAccountType(accountType: string): string[] {
4546
* @param state - The state to migrate
4647
* @returns The migrated state
4748
*/
48-
export default function migrate(state: unknown) {
49-
if (!ensureValidState(state, migrationVersion)) {
49+
export function migration66(state: unknown, migrationNumber: number) {
50+
if (!ensureValidState(state, migrationNumber)) {
5051
return state;
5152
}
5253

@@ -70,7 +71,7 @@ export default function migrate(state: unknown) {
7071
) {
7172
captureException(
7273
new Error(
73-
`Migration ${migrationVersion}: Invalid state structure for AccountsController`,
74+
`Migration ${migrationNumber}: Invalid state structure for AccountsController`,
7475
),
7576
);
7677
return state;
@@ -95,11 +96,21 @@ export default function migrate(state: unknown) {
9596
}
9697

9798
Logger.log(
98-
`Migration ${migrationVersion}: Adding scopes for account type ${account.type}`,
99+
`Migration ${migrationNumber}: Adding scopes for account type ${account.type}`,
99100
);
100101

101-
account.scopes = getScopesForAccountType(account.type as string);
102+
account.scopes = getScopesForAccountType(
103+
account.type as string,
104+
migrationNumber,
105+
);
102106
}
103107

104108
return state;
105109
}
110+
111+
/**
112+
* Migration for adding scopes to accounts in the AccountsController.
113+
*/
114+
export default function migrate(state: unknown) {
115+
return migration66(state, 66);
116+
}

0 commit comments

Comments
 (0)