Skip to content

Commit 4c2c591

Browse files
authored
feat: rename profile sync to backup and sync (#5686)
## Explanation This PR updates all profile syncing references to backup and sync. This involves state properties name changes, so the clients will need to write migrations when bumping. This is a **breaking** change. Instructions for client migration are basically the test drive PRs below: - ✅ Extension test drive PR: MetaMask/metamask-extension#32572 - ✅ Mobile test drive PR: MetaMask/metamask-mobile#15211 ## References Related to: https://consensyssoftware.atlassian.net/browse/IDENTITY-88 ## Changelog ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs), highlighting breaking changes as necessary - [x] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes
1 parent 261febc commit 4c2c591

File tree

7 files changed

+46
-66
lines changed

7 files changed

+46
-66
lines changed

packages/profile-sync-controller/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Changed
1313

14+
- **BREAKING:** Replace all "Profile Syncing" mentions to "Backup & Sync" ([#5686](https://github.com/MetaMask/core/pull/5686))
15+
- Replaces state properties `isProfileSyncingEnabled` to `isBackupAndSyncEnabled`, and `isProfileSyncingUpdateLoading` to `isBackupAndSyncUpdateLoading`
1416
- **BREAKING:** Bump `@metamask/accounts-controller` peer dependency from `^27.0.0` to `^28.0.0` ([#5763](https://github.com/MetaMask/core/pull/5763))
1517
- **BREAKING:** Bump `@metamask/snaps-controllers` peer dependency from `^9.19.0` to `^11.0.0` ([#5639](https://github.com/MetaMask/core/pull/5639))
1618
- **BREAKING:** Bump `@metamask/providers` peer dependency from `^18.1.1` to `^21.0.0` ([#5639](https://github.com/MetaMask/core/pull/5639))

packages/profile-sync-controller/src/controllers/authentication/AuthenticationController.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export type AuthenticationControllerMessenger = RestrictedMessenger<
104104

105105
/**
106106
* Controller that enables authentication for restricted endpoints.
107-
* Used for Global Profile Syncing and Notifications
107+
* Used for Backup & Sync, Notifications, and other services.
108108
*/
109109
export default class AuthenticationController extends BaseController<
110110
typeof controllerName,

packages/profile-sync-controller/src/controllers/user-storage/UserStorageController.test.ts

+17-39
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('user-storage/user-storage-controller - constructor() tests', () => {
3434
messenger: messengerMocks.messenger,
3535
});
3636

37-
expect(controller.state.isProfileSyncingEnabled).toBe(true);
37+
expect(controller.state.isBackupAndSyncEnabled).toBe(true);
3838
});
3939

4040
it('should call startNetworkSyncing', async () => {
@@ -608,28 +608,6 @@ describe('user-storage/user-storage-controller - getStorageKey() tests', () => {
608608
});
609609
});
610610

611-
describe('user-storage/user-storage-controller - disableProfileSyncing() tests', () => {
612-
const arrangeMocks = async () => {
613-
return {
614-
messengerMocks: mockUserStorageMessenger(),
615-
};
616-
};
617-
618-
it('should disable user storage / profile syncing when called', async () => {
619-
const { messengerMocks } = await arrangeMocks();
620-
const controller = new UserStorageController({
621-
messenger: messengerMocks.messenger,
622-
});
623-
624-
expect(controller.state.isProfileSyncingEnabled).toBe(true);
625-
await controller.setIsBackupAndSyncFeatureEnabled(
626-
BACKUPANDSYNC_FEATURES.main,
627-
false,
628-
);
629-
expect(controller.state.isProfileSyncingEnabled).toBe(false);
630-
});
631-
});
632-
633611
describe('user-storage/user-storage-controller - setIsBackupAndSyncFeatureEnabled tests', () => {
634612
const arrangeMocks = async () => {
635613
return {
@@ -644,21 +622,21 @@ describe('user-storage/user-storage-controller - setIsBackupAndSyncFeatureEnable
644622
const controller = new UserStorageController({
645623
messenger: messengerMocks.messenger,
646624
state: {
647-
isProfileSyncingEnabled: false,
648-
isProfileSyncingUpdateLoading: false,
625+
isBackupAndSyncEnabled: false,
626+
isBackupAndSyncUpdateLoading: false,
649627
isAccountSyncingEnabled: false,
650628
hasAccountSyncingSyncedAtLeastOnce: false,
651629
isAccountSyncingReadyToBeDispatched: false,
652630
isAccountSyncingInProgress: false,
653631
},
654632
});
655633

656-
expect(controller.state.isProfileSyncingEnabled).toBe(false);
634+
expect(controller.state.isBackupAndSyncEnabled).toBe(false);
657635
await controller.setIsBackupAndSyncFeatureEnabled(
658636
BACKUPANDSYNC_FEATURES.main,
659637
true,
660638
);
661-
expect(controller.state.isProfileSyncingEnabled).toBe(true);
639+
expect(controller.state.isBackupAndSyncEnabled).toBe(true);
662640
expect(messengerMocks.mockAuthIsSignedIn).toHaveBeenCalled();
663641
expect(messengerMocks.mockAuthPerformSignIn).toHaveBeenCalled();
664642
});
@@ -670,16 +648,16 @@ describe('user-storage/user-storage-controller - setIsBackupAndSyncFeatureEnable
670648
const controller = new UserStorageController({
671649
messenger: messengerMocks.messenger,
672650
state: {
673-
isProfileSyncingEnabled: false,
674-
isProfileSyncingUpdateLoading: false,
651+
isBackupAndSyncEnabled: false,
652+
isBackupAndSyncUpdateLoading: false,
675653
isAccountSyncingEnabled: false,
676654
hasAccountSyncingSyncedAtLeastOnce: false,
677655
isAccountSyncingReadyToBeDispatched: false,
678656
isAccountSyncingInProgress: false,
679657
},
680658
});
681659

682-
expect(controller.state.isProfileSyncingEnabled).toBe(false);
660+
expect(controller.state.isBackupAndSyncEnabled).toBe(false);
683661
messengerMocks.mockAuthPerformSignIn.mockRejectedValue(new Error('error'));
684662

685663
await expect(
@@ -688,7 +666,7 @@ describe('user-storage/user-storage-controller - setIsBackupAndSyncFeatureEnable
688666
true,
689667
),
690668
).rejects.toThrow('error');
691-
expect(controller.state.isProfileSyncingEnabled).toBe(false);
669+
expect(controller.state.isBackupAndSyncEnabled).toBe(false);
692670
});
693671

694672
it('should not disable backup and sync when disabling account syncing', async () => {
@@ -698,22 +676,22 @@ describe('user-storage/user-storage-controller - setIsBackupAndSyncFeatureEnable
698676
const controller = new UserStorageController({
699677
messenger: messengerMocks.messenger,
700678
state: {
701-
isProfileSyncingEnabled: true,
702-
isProfileSyncingUpdateLoading: false,
679+
isBackupAndSyncEnabled: true,
680+
isBackupAndSyncUpdateLoading: false,
703681
isAccountSyncingEnabled: true,
704682
hasAccountSyncingSyncedAtLeastOnce: false,
705683
isAccountSyncingReadyToBeDispatched: false,
706684
isAccountSyncingInProgress: false,
707685
},
708686
});
709687

710-
expect(controller.state.isProfileSyncingEnabled).toBe(true);
688+
expect(controller.state.isBackupAndSyncEnabled).toBe(true);
711689
await controller.setIsBackupAndSyncFeatureEnabled(
712690
BACKUPANDSYNC_FEATURES.accountSyncing,
713691
false,
714692
);
715693
expect(controller.state.isAccountSyncingEnabled).toBe(false);
716-
expect(controller.state.isProfileSyncingEnabled).toBe(true);
694+
expect(controller.state.isBackupAndSyncEnabled).toBe(true);
717695
});
718696
});
719697

@@ -912,15 +890,15 @@ describe('user-storage/user-storage-controller - error handling edge cases', ()
912890
messenger: messengerMocks.messenger,
913891
state: {
914892
...defaultState,
915-
isProfileSyncingEnabled: false,
893+
isBackupAndSyncEnabled: false,
916894
},
917895
});
918896

919897
await controller.setIsBackupAndSyncFeatureEnabled(
920898
BACKUPANDSYNC_FEATURES.main,
921899
false,
922900
);
923-
expect(controller.state.isProfileSyncingEnabled).toBe(false);
901+
expect(controller.state.isBackupAndSyncEnabled).toBe(false);
924902
});
925903

926904
it('handles enabling backup & sync when already enabled and signed in', async () => {
@@ -931,15 +909,15 @@ describe('user-storage/user-storage-controller - error handling edge cases', ()
931909
messenger: messengerMocks.messenger,
932910
state: {
933911
...defaultState,
934-
isProfileSyncingEnabled: true,
912+
isBackupAndSyncEnabled: true,
935913
},
936914
});
937915

938916
await controller.setIsBackupAndSyncFeatureEnabled(
939917
BACKUPANDSYNC_FEATURES.main,
940918
true,
941919
);
942-
expect(controller.state.isProfileSyncingEnabled).toBe(true);
920+
expect(controller.state.isBackupAndSyncEnabled).toBe(true);
943921
expect(messengerMocks.mockAuthPerformSignIn).not.toHaveBeenCalled();
944922
});
945923
});

packages/profile-sync-controller/src/controllers/user-storage/UserStorageController.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ export type UserStorageControllerState = {
5959
/**
6060
* Condition used by UI and to determine if we can use some of the User Storage methods.
6161
*/
62-
isProfileSyncingEnabled: boolean;
62+
isBackupAndSyncEnabled: boolean;
6363
/**
64-
* Loading state for the profile syncing update
64+
* Loading state for the backup and sync update
6565
*/
66-
isProfileSyncingUpdateLoading: boolean;
66+
isBackupAndSyncUpdateLoading: boolean;
6767
/**
6868
* Condition used by UI to determine if account syncing is enabled.
6969
*/
@@ -89,20 +89,20 @@ export type UserStorageControllerState = {
8989
};
9090

9191
export const defaultState: UserStorageControllerState = {
92-
isProfileSyncingEnabled: true,
93-
isProfileSyncingUpdateLoading: false,
92+
isBackupAndSyncEnabled: true,
93+
isBackupAndSyncUpdateLoading: false,
9494
isAccountSyncingEnabled: true,
9595
hasAccountSyncingSyncedAtLeastOnce: false,
9696
isAccountSyncingReadyToBeDispatched: false,
9797
isAccountSyncingInProgress: false,
9898
};
9999

100100
const metadata: StateMetadata<UserStorageControllerState> = {
101-
isProfileSyncingEnabled: {
101+
isBackupAndSyncEnabled: {
102102
persist: true,
103103
anonymous: true,
104104
},
105-
isProfileSyncingUpdateLoading: {
105+
isBackupAndSyncUpdateLoading: {
106106
persist: false,
107107
anonymous: false,
108108
},
@@ -612,7 +612,7 @@ export default class UserStorageController extends BaseController<
612612
enabled: boolean,
613613
): Promise<void> {
614614
try {
615-
this.#setIsProfileSyncingUpdateLoading(true);
615+
this.#setIsBackupAndSyncUpdateLoading(true);
616616

617617
if (enabled) {
618618
// If any of the features are enabled, we need to ensure the user is signed in
@@ -624,7 +624,7 @@ export default class UserStorageController extends BaseController<
624624

625625
this.update((state) => {
626626
if (feature === BACKUPANDSYNC_FEATURES.main) {
627-
state.isProfileSyncingEnabled = enabled;
627+
state.isBackupAndSyncEnabled = enabled;
628628
}
629629

630630
if (feature === BACKUPANDSYNC_FEATURES.accountSyncing) {
@@ -639,15 +639,15 @@ export default class UserStorageController extends BaseController<
639639
`${controllerName} - failed to ${enabled ? 'enable' : 'disable'} ${feature} - ${errorMessage}`,
640640
);
641641
} finally {
642-
this.#setIsProfileSyncingUpdateLoading(false);
642+
this.#setIsBackupAndSyncUpdateLoading(false);
643643
}
644644
}
645645

646-
#setIsProfileSyncingUpdateLoading(
647-
isProfileSyncingUpdateLoading: boolean,
646+
#setIsBackupAndSyncUpdateLoading(
647+
isBackupAndSyncUpdateLoading: boolean,
648648
): void {
649649
this.update((state) => {
650-
state.isProfileSyncingUpdateLoading = isProfileSyncingUpdateLoading;
650+
state.isBackupAndSyncUpdateLoading = isBackupAndSyncUpdateLoading;
651651
});
652652
}
653653

packages/profile-sync-controller/src/controllers/user-storage/account-syncing/controller-integration.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ import {
2727
import { MOCK_STORAGE_KEY } from '../mocks';
2828

2929
const baseState = {
30-
isProfileSyncingEnabled: true,
30+
isBackupAndSyncEnabled: true,
3131
isAccountSyncingEnabled: true,
32-
isProfileSyncingUpdateLoading: false,
32+
isBackupAndSyncUpdateLoading: false,
3333
hasAccountSyncingSyncedAtLeastOnce: false,
3434
isAccountSyncingReadyToBeDispatched: false,
3535
isAccountSyncingInProgress: false,
@@ -96,7 +96,7 @@ describe('user-storage/account-syncing/controller-integration - syncInternalAcco
9696
it('returns void if UserStorage is not enabled', async () => {
9797
const { controller, messengerMocks, options } = await arrangeMocks({
9898
stateOverrides: {
99-
isProfileSyncingEnabled: false,
99+
isBackupAndSyncEnabled: false,
100100
},
101101
});
102102

@@ -973,7 +973,7 @@ describe('user-storage/account-syncing/controller-integration - saveInternalAcco
973973
it('returns void if UserStorage is not enabled', async () => {
974974
const { options } = await arrangeMocks({
975975
stateOverrides: {
976-
isProfileSyncingEnabled: false,
976+
isBackupAndSyncEnabled: false,
977977
},
978978
});
979979

packages/profile-sync-controller/src/controllers/user-storage/account-syncing/sync-utils.test.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type { AccountSyncingOptions } from './types';
1111
describe('user-storage/account-syncing/sync-utils', () => {
1212
describe('canPerformAccountSyncing', () => {
1313
const arrangeMocks = ({
14-
isProfileSyncingEnabled = true,
14+
isBackupAndSyncEnabled = true,
1515
isAccountSyncingEnabled = true,
1616
isAccountSyncingInProgress = false,
1717
messengerCallControllerAndAction = 'AuthenticationController:isSignedIn',
@@ -29,7 +29,7 @@ describe('user-storage/account-syncing/sync-utils', () => {
2929
}),
3030
getUserStorageControllerInstance: jest.fn().mockReturnValue({
3131
state: {
32-
isProfileSyncingEnabled,
32+
isBackupAndSyncEnabled,
3333
isAccountSyncingEnabled,
3434
isAccountSyncingInProgress,
3535
},
@@ -40,14 +40,14 @@ describe('user-storage/account-syncing/sync-utils', () => {
4040
};
4141

4242
const failureCases = [
43-
['profile syncing is not enabled', { isProfileSyncingEnabled: false }],
43+
['backup and sync is not enabled', { isBackupAndSyncEnabled: false }],
4444
[
45-
'profile syncing is not enabled but account syncing is',
46-
{ isProfileSyncingEnabled: false, isAccountSyncingEnabled: true },
45+
'backup and sync is not enabled but account syncing is',
46+
{ isBackupAndSyncEnabled: false, isAccountSyncingEnabled: true },
4747
],
4848
[
49-
'profile syncing is enabled but not account syncing',
50-
{ isProfileSyncingEnabled: true, isAccountSyncingEnabled: false },
49+
'backup and sync is enabled but not account syncing',
50+
{ isBackupAndSyncEnabled: true, isAccountSyncingEnabled: false },
5151
],
5252
[
5353
'authentication is not enabled',

packages/profile-sync-controller/src/controllers/user-storage/account-syncing/sync-utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function canPerformAccountSyncing(
1616
const { getMessenger, getUserStorageControllerInstance } = options;
1717

1818
const {
19-
isProfileSyncingEnabled,
19+
isBackupAndSyncEnabled,
2020
isAccountSyncingEnabled,
2121
isAccountSyncingInProgress,
2222
} = getUserStorageControllerInstance().state;
@@ -25,7 +25,7 @@ export function canPerformAccountSyncing(
2525
);
2626

2727
if (
28-
!isProfileSyncingEnabled ||
28+
!isBackupAndSyncEnabled ||
2929
!isAccountSyncingEnabled ||
3030
!isAuthEnabled ||
3131
isAccountSyncingInProgress

0 commit comments

Comments
 (0)