Skip to content

Commit 99ff747

Browse files
committed
feat(account-tree-controller): resolve group names conflicts in b&s operations
1 parent 114aa99 commit 99ff747

File tree

5 files changed

+10
-2
lines changed

5 files changed

+10
-2
lines changed

packages/account-tree-controller/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Changed
1111

12+
- Set the `setAccountGroupName`'s option `autoHandleConflict` to `true` for all backup & sync operations ([#]())
1213
- Add new group naming for non-HD keyring accounts ([#6679](https://github.com/MetaMask/core/pull/6679))
1314
- Hardware-wallet account groups are now named: "Ledger|Trezor|QR|Lattice|OneKey Account N".
1415
- Private key account groups are now named: "Imported Account N".

packages/account-tree-controller/src/backup-and-sync/syncing/group.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ describe('BackupAndSync - Syncing - Group', () => {
278278
expect(mockContext.controller.setAccountGroupName).toHaveBeenCalledWith(
279279
mockLocalGroup.id,
280280
'New Name',
281+
true,
281282
);
282283
}
283284
/* eslint-enable jest/no-conditional-in-test */
@@ -600,6 +601,7 @@ describe('BackupAndSync - Syncing - Group', () => {
600601
expect(testContext.controller.setAccountGroupName).toHaveBeenCalledWith(
601602
mockLocalGroup.id,
602603
testGroupName,
604+
true,
603605
);
604606
});
605607
});

packages/account-tree-controller/src/backup-and-sync/syncing/group.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ async function syncGroupMetadataAndCheckIfPushNeeded(
145145
validateUserStorageValue: (value) =>
146146
UserStorageSyncedWalletGroupSchema.schema.name.schema.value.is(value),
147147
applyLocalUpdate: (name: string) => {
148-
context.controller.setAccountGroupName(localGroup.id, name);
148+
context.controller.setAccountGroupName(localGroup.id, name, true);
149149
},
150150
analytics: {
151151
action: BackupAndSyncAnalyticsEvent.GroupRenamed,

packages/account-tree-controller/src/backup-and-sync/syncing/legacy.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,12 @@ describe('BackupAndSync - Syncing - Legacy', () => {
174174
expect(mockContext.controller.setAccountGroupName).toHaveBeenCalledWith(
175175
'entropy:test-entropy/0',
176176
'Legacy Account 1',
177+
true,
177178
);
178179
expect(mockContext.controller.setAccountGroupName).toHaveBeenCalledWith(
179180
'entropy:test-entropy/1',
180181
'Legacy Account 2',
182+
true,
181183
);
182184
});
183185

@@ -302,14 +304,17 @@ describe('BackupAndSync - Syncing - Legacy', () => {
302304
expect(mockContext.controller.setAccountGroupName).toHaveBeenCalledWith(
303305
'entropy:test-entropy/0',
304306
'Main Account',
307+
true,
305308
);
306309
expect(mockContext.controller.setAccountGroupName).toHaveBeenCalledWith(
307310
'entropy:test-entropy/1',
308311
'Trading Account',
312+
true,
309313
);
310314
expect(mockContext.controller.setAccountGroupName).toHaveBeenCalledWith(
311315
'entropy:test-entropy/2',
312316
'Savings Account',
317+
true,
313318
);
314319

315320
expect(mockContext.emitAnalyticsEventFn).toHaveBeenCalledWith({

packages/account-tree-controller/src/backup-and-sync/syncing/legacy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export const performLegacyAccountSyncing = async (
8888
group.accounts.includes(localAccountId),
8989
);
9090
if (localGroup) {
91-
context.controller.setAccountGroupName(localGroup.id, n);
91+
context.controller.setAccountGroupName(localGroup.id, n, true);
9292

9393
context.emitAnalyticsEventFn({
9494
action: BackupAndSyncAnalyticsEvent.LegacyGroupRenamed,

0 commit comments

Comments
 (0)