Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add back account syncing - only e2e for now #12411

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions app/actions/notification/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { getErrorMessage } from '@metamask/utils';

import { notificationsErrors } from '../constants';
import Engine from '../../../core/Engine';
import { Notification, mmStorage, getAllUUIDs } from '../../../util/notifications';
import {
Notification,
mmStorage,
getAllUUIDs,
} from '../../../util/notifications';
import { UserStorage } from '@metamask/notification-services-controller/dist/NotificationServicesController/types/user-storage/index.cjs';

export type MarkAsReadNotificationsParam = Pick<
Expand Down Expand Up @@ -184,6 +188,18 @@ export const syncInternalAccountsWithUserStorage = async () => {
}
};

export const setIsAccountSyncingReadyToBeDispatched = async (
isReady: boolean,
) => {
try {
await Engine.context.UserStorageController.setIsAccountSyncingReadyToBeDispatched(
isReady,
);
} catch (error) {
return getErrorMessage(error);
}
};

/**
* Perform the deletion of the notifications storage key and the creation of on chain triggers to reset the notifications.
*
Expand All @@ -201,7 +217,10 @@ export const performDeleteStorage = async (): Promise<string | undefined> => {
return getErrorMessage(error);
}
};
export const enablePushNotifications = async (userStorage: UserStorage, fcmToken?: string) => {
export const enablePushNotifications = async (
userStorage: UserStorage,
fcmToken?: string,
) => {
try {
const uuids = getAllUUIDs(userStorage);
await Engine.context.NotificationServicesPushController.enablePushNotifications(
Expand All @@ -224,7 +243,9 @@ export const disablePushNotifications = async (userStorage: UserStorage) => {
}
};

export const updateTriggerPushNotifications = async (userStorage: UserStorage) => {
export const updateTriggerPushNotifications = async (
userStorage: UserStorage,
) => {
try {
const uuids = getAllUUIDs(userStorage);
await Engine.context.NotificationServicesPushController.updateTriggerPushNotifications(
Expand Down
5 changes: 0 additions & 5 deletions app/components/UI/ProfileSyncing/ProfileSyncing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import styles from './ProfileSyncing.styles';
import { ProfileSyncingComponentProps } from './ProfileSyncing.types';
import AppConstants from '../../../core/AppConstants';
import { useProfileSyncing } from '../../../util/notifications/hooks/useProfileSyncing';
import { isNotificationsFeatureEnabled } from '../../../util/notifications';

function ProfileSyncingComponent({
handleSwitchToggle,
Expand Down Expand Up @@ -67,9 +66,5 @@ function ProfileSyncingComponent({
export default function ProfileSyncingContainer(
props: Readonly<ProfileSyncingComponentProps>,
) {
if (!isNotificationsFeatureEnabled()) {
return null;
}

return <ProfileSyncingComponent {...props} />;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,92 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ProfileSyncing should render correctly 1`] = `null`;
exports[`ProfileSyncing should render correctly 1`] = `
<View
style={
{
"marginVertical": 16,
}
}
>
<View
style={
{
"alignItems": "center",
"flexDirection": "row",
"justifyContent": "space-between",
"paddingBottom": 8,
}
}
>
<Text
accessibilityRole="text"
style={
{
"color": "#141618",
"fontFamily": "EuclidCircularB-Bold",
"fontSize": 16,
"fontWeight": "700",
"letterSpacing": 0,
"lineHeight": 24,
}
}
>
Profile Sync
</Text>
<RCTSwitch
accessibilityRole="switch"
disabled={true}
onChange={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
onTintColor="#0376c9"
style={
[
{
"height": 31,
"width": 51,
},
{
"backgroundColor": "#bbc0c566",
"borderRadius": 16,
},
]
}
thumbTintColor="#ffffff"
tintColor="#bbc0c566"
value={false}
/>
</View>
<Text
accessibilityRole="text"
style={
{
"color": "#6a737d",
"fontFamily": "EuclidCircularB-Regular",
"fontSize": 14,
"fontWeight": "400",
"letterSpacing": 0,
"lineHeight": 22,
}
}
>
Creates a profile that MetaMask uses to sync some settings among your devices. This is required to get notifications.
<Text
accessibilityRole="text"
onPress={[Function]}
style={
{
"color": "#0376c9",
"fontFamily": "EuclidCircularB-Regular",
"fontSize": 14,
"fontWeight": "400",
"letterSpacing": 0,
"lineHeight": 22,
}
}
>
Learn how we protect your privacy
</Text>
</Text>
</View>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ import AutoDetectNFTSettings from '../../Settings/AutoDetectNFTSettings';
import IPFSGatewaySettings from '../../Settings/IPFSGatewaySettings';
import IncomingTransactionsSettings from '../../Settings/IncomingTransactionsSettings';
import BatchAccountBalanceSettings from '../../Settings/BatchAccountBalanceSettings';
import { isNotificationsFeatureEnabled } from '../../../../util/notifications';
import useCheckNftAutoDetectionModal from '../../../hooks/useCheckNftAutoDetectionModal';
import useCheckMultiRpcModal from '../../../hooks/useCheckMultiRpcModal';

Expand Down Expand Up @@ -593,13 +592,11 @@ const Settings: React.FC = () => {
handleSwitchToggle={toggleBasicFunctionality}
/>
</View>
{isNotificationsFeatureEnabled() && (
<ProfileSyncingComponent
handleSwitchToggle={toggleProfileSyncing}
isBasicFunctionalityEnabled={isBasicFunctionalityEnabled}
isProfileSyncingEnabled={isProfileSyncingEnabled}
/>
)}
<ProfileSyncingComponent
handleSwitchToggle={toggleProfileSyncing}
isBasicFunctionalityEnabled={isBasicFunctionalityEnabled}
isProfileSyncingEnabled={isProfileSyncingEnabled}
/>
<Text
variant={TextVariant.BodyLGMedium}
color={TextColor.Alternative}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,94 @@ exports[`SecuritySettings should render correctly 1`] = `
</Text>
</View>
</View>
<View
style={
{
"marginVertical": 16,
}
}
>
<View
style={
{
"alignItems": "center",
"flexDirection": "row",
"justifyContent": "space-between",
"paddingBottom": 8,
}
}
>
<Text
accessibilityRole="text"
style={
{
"color": "#141618",
"fontFamily": "EuclidCircularB-Bold",
"fontSize": 16,
"fontWeight": "700",
"letterSpacing": 0,
"lineHeight": 24,
}
}
>
Profile Sync
</Text>
<RCTSwitch
accessibilityRole="switch"
disabled={true}
onChange={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
onTintColor="#0376c9"
style={
[
{
"height": 31,
"width": 51,
},
{
"backgroundColor": "#bbc0c566",
"borderRadius": 16,
},
]
}
thumbTintColor="#ffffff"
tintColor="#bbc0c566"
value={false}
/>
</View>
<Text
accessibilityRole="text"
style={
{
"color": "#6a737d",
"fontFamily": "EuclidCircularB-Regular",
"fontSize": 14,
"fontWeight": "400",
"letterSpacing": 0,
"lineHeight": 22,
}
}
>
Creates a profile that MetaMask uses to sync some settings among your devices. This is required to get notifications.
<Text
accessibilityRole="text"
onPress={[Function]}
style={
{
"color": "#0376c9",
"fontFamily": "EuclidCircularB-Regular",
"fontSize": 14,
"fontWeight": "400",
"letterSpacing": 0,
"lineHeight": 22,
}
}
>
Learn how we protect your privacy
</Text>
</Text>
</View>
<Text
accessibilityRole="text"
style={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { useSelector } from 'react-redux';
import renderWithProvider from '../../../../../util/test/renderWithProvider';
import { Snap, SnapStatus } from '@metamask/snaps-utils';
import { SnapId } from '@metamask/snaps-sdk';
import { SemVerVersion } from '@metamask/utils';
import { createMockSnapInternalAccount } from '../../../../../util/test/accountsControllerTestUtils';
import { KEYRING_ACCOUNT_LIST_ITEM } from '../../components/KeyringAccountListItem/KeyringAccountListItem.constants';

Expand Down Expand Up @@ -61,7 +60,7 @@ describe('KeyringSnapRemovalWarning', () => {
snap_manageState: {},
},
manifest: {
version: '1.1.6' as SemVerVersion,
version: '1.1.6' as Snap['manifest']['version'],
description: 'An example of a key management snap for a simple keyring.',
proposedName: mockSnapName,
repository: {
Expand Down Expand Up @@ -93,7 +92,7 @@ describe('KeyringSnapRemovalWarning', () => {
},
status: 'stopped' as SnapStatus,
sourceCode: '',
version: '1.1.6' as SemVerVersion,
version: '1.1.6' as Snap['manifest']['version'],
versionHistory: [
{
version: '1.1.6',
Expand Down Expand Up @@ -273,11 +272,7 @@ describe('KeyringSnapRemovalWarning', () => {
fireEvent.press(continueButton);

await waitFor(() => {
expect(
getByText(
`Failed to remove ${mockSnapName}`,
),
).toBeTruthy();
expect(getByText(`Failed to remove ${mockSnapName}`)).toBeTruthy();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ describe('SnapSettings with keyring snap', () => {
snap_manageState: {},
},
manifest: {
version: '1.1.6' as SemVerVersion,
version: '1.1.6' as Snap['manifest']['version'],
description: 'An example of a key management snap for a simple keyring.',
proposedName: mockSnapName,
repository: {
Expand Down Expand Up @@ -350,7 +350,7 @@ describe('SnapSettings with keyring snap', () => {
},
status: 'stopped' as SnapStatus,
sourceCode: '',
version: '1.1.6' as SemVerVersion,
version: '1.1.6' as Snap['manifest']['version'],
versionHistory: [
{
version: '1.1.6',
Expand Down Expand Up @@ -443,7 +443,6 @@ describe('SnapSettings with keyring snap', () => {
);
fireEvent.press(keyringSnapRemovalWarningContinueButton);


// Step 3: Wait for the warning modal to appear and enter the snap name
await waitFor(() => {
const inputField = getByTestId(KEYRING_SNAP_REMOVAL_WARNING_TEXT_INPUT);
Expand Down
Loading
Loading