diff --git a/app/actions/security/index.ts b/app/actions/security/index.ts index c62bf08e450..daa6d24fe06 100644 --- a/app/actions/security/index.ts +++ b/app/actions/security/index.ts @@ -3,6 +3,7 @@ import type { Action } from 'redux'; export enum ActionType { SET_ALLOW_LOGIN_WITH_REMEMBER_ME = 'SET_ALLOW_LOGIN_WITH_REMEMBER_ME', + SET_AUTOMATIC_SECURITY_CHECKS = 'SET_AUTOMATIC_SECURITY_CHECKS', } export interface AllowLoginWithRememberMeUpdated @@ -10,7 +11,12 @@ export interface AllowLoginWithRememberMeUpdated enabled: boolean; } -export type Action = AllowLoginWithRememberMeUpdated; +export interface AutomaticSecurityChecks + extends Action { + enabled: boolean; +} + +export type Action = AllowLoginWithRememberMeUpdated | AutomaticSecurityChecks; export const setAllowLoginWithRememberMe = ( enabled: boolean, @@ -18,3 +24,10 @@ export const setAllowLoginWithRememberMe = ( type: ActionType.SET_ALLOW_LOGIN_WITH_REMEMBER_ME, enabled, }); + +export const setAutomaticSecurityChecks = ( + enabled: boolean, +): AutomaticSecurityChecks => ({ + type: ActionType.SET_AUTOMATIC_SECURITY_CHECKS, + enabled, +}); diff --git a/app/actions/security/state.ts b/app/actions/security/state.ts index bf5abaf43e3..78f2fb9a207 100644 --- a/app/actions/security/state.ts +++ b/app/actions/security/state.ts @@ -1,3 +1,4 @@ export interface SecuritySettingsState { allowLoginWithRememberMe: boolean; + automaticSecurityChecks: boolean; } diff --git a/app/components/Views/Settings/SecuritySettings/Sections/AutomaticSecurityChecks.tsx b/app/components/Views/Settings/SecuritySettings/Sections/AutomaticSecurityChecks.tsx new file mode 100644 index 00000000000..171ee84d3ae --- /dev/null +++ b/app/components/Views/Settings/SecuritySettings/Sections/AutomaticSecurityChecks.tsx @@ -0,0 +1,29 @@ +import React, { useCallback } from 'react'; +import { SecurityOptionToggle } from '../../../../UI/SecurityOptionToggle'; +import { strings } from '../../../../../../locales/i18n'; +import { useSelector, useDispatch } from 'react-redux'; +import { setAutomaticSecurityChecks } from '../../../../../actions/security'; + +const AutomaticSecurityChecks = () => { + const dispatch = useDispatch(); + const automaticSecurityChecksState = useSelector( + (state: any) => state.security.automaticSecurityChecks, + ); + + const toggleAutomaticSecurityChecks = useCallback( + (value: boolean) => { + dispatch(setAutomaticSecurityChecks(value)); + }, + [dispatch], + ); + return ( + + ); +}; + +export default React.memo(AutomaticSecurityChecks); diff --git a/app/components/Views/Settings/SecuritySettings/index.js b/app/components/Views/Settings/SecuritySettings/index.js index 976227b30cf..98999929f9e 100644 --- a/app/components/Views/Settings/SecuritySettings/index.js +++ b/app/components/Views/Settings/SecuritySettings/index.js @@ -66,6 +66,7 @@ import { LEARN_MORE_URL } from '../../../../constants/urls'; import DeleteMetaMetricsData from './Sections/DeleteMetaMetricsData'; import DeleteWalletData from './Sections/DeleteWalletData'; import RememberMeOptionSection from './Sections/RememberMeOptionSection'; +import AutomaticSecurityChecks from './Sections/AutomaticSecurityChecks'; const isIos = Device.isIos(); @@ -1151,6 +1152,7 @@ class Settings extends PureComponent { {this.renderApprovalModal()} {this.renderHistoryModal()} {this.isMainnet() && this.renderOpenSeaSettings()} + {__DEV__ ? : null} {this.renderHint()} diff --git a/app/reducers/security/index.ts b/app/reducers/security/index.ts index 7119be56407..e43816d6feb 100644 --- a/app/reducers/security/index.ts +++ b/app/reducers/security/index.ts @@ -4,6 +4,7 @@ import { SecuritySettingsState } from '../../actions/security/state'; const initialState: Readonly = { allowLoginWithRememberMe: false, + automaticSecurityChecks: true, }; const securityReducer = ( @@ -13,8 +14,14 @@ const securityReducer = ( switch (action.type) { case ActionType.SET_ALLOW_LOGIN_WITH_REMEMBER_ME: return { + ...state, allowLoginWithRememberMe: action.enabled, }; + case ActionType.SET_AUTOMATIC_SECURITY_CHECKS: + return { + ...state, + automaticSecurityChecks: action.enabled, + }; default: return state; } diff --git a/locales/languages/en.json b/locales/languages/en.json index 081c96bcc70..20900f39aca 100644 --- a/locales/languages/en.json +++ b/locales/languages/en.json @@ -2161,5 +2161,9 @@ "confirmation_modal": { "cancel_cta": "Cancel", "confirm_cta": "Confirm" + }, + "automatic_security_checks": { + "title": "Automatic security checks", + "description": "Automatically checking for updates may expose your IP address to GitHub servers. This only indicates that your IP address is using MetaMask. No other information or account addresses are exposed." } }