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 SES experiment toggle (iOS) #8373

Merged
merged 36 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ccfe2d6
Add react-native-mmkv
leotm Jan 23, 2024
942cb07
MVP
leotm Jan 23, 2024
e6123c7
Only show on iOS
leotm Jan 23, 2024
0f8949e
Update snapshot
leotm Jan 24, 2024
64a694f
Remove stale comment
leotm Jan 24, 2024
cd9f2f4
Update styling
leotm Jan 24, 2024
859dc41
Update header
leotm Jan 24, 2024
9ebe8af
Update content
leotm Jan 24, 2024
f4eb35a
Translate header
leotm Jan 24, 2024
98dc122
Translate description
leotm Jan 24, 2024
75d8c02
Update snapshot
leotm Jan 24, 2024
ea5674c
Replace RN MMKV with RN default-preference
leotm Jan 24, 2024
dd93763
Revert "Replace RN MMKV with RN default-preference"
leotm Jan 24, 2024
5dc2fef
Use Device.isIos fn
leotm Jan 25, 2024
eaa8fe8
Update import
leotm Jan 25, 2024
ec95c3e
Remove stale import
leotm Jan 25, 2024
dd9caf5
Fix Android (Hermes) debug bundle
leotm Jan 25, 2024
57c0080
Add MetaMask copyright notice
leotm Jan 25, 2024
6d1959f
Document SES disabled in debug-mode
leotm Jan 25, 2024
71df5b7
Merge branch 'main' into feat/ses-experimental-setting
leotm Jan 25, 2024
7efb967
Run Yarn deduplicate
leotm Jan 25, 2024
f1fa08a
Add back missing import
leotm Jan 25, 2024
f4d4e97
Merge branch 'main' into feat/ses-experimental-setting
leotm Jan 26, 2024
c65aa5b
Update snapshot
leotm Jan 26, 2024
babb9bb
Update heading
leotm Jan 26, 2024
7625b45
Add SES URL
leotm Jan 26, 2024
11ba12b
Fix SES URL
leotm Jan 26, 2024
e583c8c
Update description
leotm Jan 26, 2024
4786d16
Update description
leotm Jan 26, 2024
5e09337
Update UI
leotm Jan 26, 2024
47a3528
Update UI
leotm Jan 26, 2024
dde9be0
Preserve UI on Android
leotm Jan 26, 2024
205867f
Update React Native core SES comment
leotm Jan 30, 2024
53024b8
Enable SES by default
leotm Jan 30, 2024
3a3a7bf
Merge branch 'main' into feat/ses-experimental-setting
sethkfman Jan 30, 2024
c1f0d24
fix patch issue by moving the error logging to the new portion of patch
sethkfman Jan 30, 2024
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
49 changes: 48 additions & 1 deletion app/components/Views/Settings/ExperimentalSettings/index.tsx
leotm marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { FC, useCallback, useEffect } from 'react';
import React, { FC, useCallback, useEffect, useState } from 'react';
import { ScrollView, Switch, View } from 'react-native';

import { MMKV } from 'react-native-mmkv';
import { strings } from '../../../../../locales/i18n';
import Engine from '../../../../core/Engine';
import { colors as importedColors } from '../../../../styles/common';
Expand All @@ -27,6 +28,8 @@ import Button, {
ButtonWidthTypes,
} from '../../../../component-library/components/Buttons/Button';

const storage = new MMKV(); // id: mmkv.default

/**
* Main view for app Experimental Settings
*/
Expand All @@ -38,6 +41,15 @@ const ExperimentalSettings = ({ navigation, route }: Props) => {

const securityAlertsEnabled = useSelector(selectIsSecurityAlertsEnabled);

const [sesEnabled, setSesEnabled] = useState(
storage.getBoolean('is-ses-enabled'),
);

const toggleSesEnabled = () => {
storage.set('is-ses-enabled', !sesEnabled);
setSesEnabled(!sesEnabled);
};

const isFullScreenModal = route?.params?.isFullScreenModal;

const { colors } = useTheme();
Expand Down Expand Up @@ -164,9 +176,44 @@ const ExperimentalSettings = ({ navigation, route }: Props) => {
</>
);

const SesSettings: FC = () => (
<>
<Text
color={TextColor.Default}
variant={TextVariant.HeadingLG}
style={styles.heading}
>
{strings('app_settings.security_heading')}
</Text>
<View style={styles.setting}>
<Text color={TextColor.Default} variant={TextVariant.BodyLGMedium}>
{/* {strings('experimental_settings.security_alerts')} */}
{'JavaScript'}
</Text>
</View>
<View style={styles.switchElement}>
<Text color={TextColor.Default} variant={TextVariant.BodyLGMedium}>
{'SES'}
</Text>
<Switch
value={sesEnabled}
onValueChange={toggleSesEnabled}
trackColor={{
true: colors.primary.default,
false: colors.border.muted,
}}
thumbColor={importedColors.white}
style={styles.switch}
ios_backgroundColor={colors.border.muted}
/>
</View>
</>
);

return (
<ScrollView style={styles.wrapper}>
<WalletConnectSettings />
<SesSettings />
{isBlockaidFeatureEnabled() && <BlockaidSettings />}
</ScrollView>
);
Expand Down
16 changes: 15 additions & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ PODS:
- lottie-react-native (5.1.5):
- lottie-ios (~> 3.4.0)
- React-Core
- MMKV (1.3.2):
- MMKVCore (~> 1.3.2)
- MMKVCore (1.3.2)
- OpenSSL-Universal (1.1.1100)
- Permission-BluetoothPeripheral (3.10.1):
- RNPermissions
Expand Down Expand Up @@ -351,6 +354,9 @@ PODS:
- React
- react-native-launch-arguments (4.0.1):
- React
- react-native-mmkv (2.11.0):
- MMKV (>= 1.2.13)
- React-Core
- react-native-netinfo (6.0.0):
- React-Core
- react-native-randombytes (3.6.1):
Expand Down Expand Up @@ -608,6 +614,7 @@ DEPENDENCIES:
- react-native-gzip (from `../node_modules/react-native-gzip`)
- react-native-in-app-review (from `../node_modules/react-native-in-app-review`)
- react-native-launch-arguments (from `../node_modules/react-native-launch-arguments`)
- react-native-mmkv (from `../node_modules/react-native-mmkv`)
- "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)"
- react-native-randombytes (from `../node_modules/react-native-randombytes`)
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
Expand Down Expand Up @@ -677,6 +684,8 @@ SPEC REPOS:
- GZIP
- GzipSwift
- libevent
- MMKV
- MMKVCore
- OpenSSL-Universal
- Sentry
- SentryPrivate
Expand Down Expand Up @@ -752,6 +761,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-in-app-review"
react-native-launch-arguments:
:path: "../node_modules/react-native-launch-arguments"
react-native-mmkv:
:path: "../node_modules/react-native-mmkv"
react-native-netinfo:
:path: "../node_modules/@react-native-community/netinfo"
react-native-randombytes:
Expand Down Expand Up @@ -855,7 +866,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Base64: cecfb41a004124895a7bcee567a89bae5a89d49b
boost: 57d2868c099736d80fcd648bf211b4431e51a558
boost: 7dcd2de282d72e344012f7d6564d024930a6a440
Branch: 4ac024cb3c29b0ef628048694db3c4cfa679beb0
BVLinearGradient: e3aad03778a456d77928f594a649e96995f1c872
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
Expand All @@ -878,6 +889,8 @@ SPEC CHECKSUMS:
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
lottie-ios: 016449b5d8be0c3dcbcfa0a9988469999cd04c5d
lottie-react-native: 3e722c63015fdb9c27638b0a77969fc412067c18
MMKV: f21593c0af4b3f2a0ceb8f820f28bb639ea22bb7
MMKVCore: 31b4cb83f8266467eef20a35b6d78e409a11060d
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
Permission-BluetoothPeripheral: 247e379c9ecb4b1af2b87f73e4a15a00a5bc0c1f
RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1
Expand Down Expand Up @@ -905,6 +918,7 @@ SPEC CHECKSUMS:
react-native-gzip: c5e87ee9e359f02350e3a2ee52eb35eddc398868
react-native-in-app-review: 23f4f5b9fcd94339dd5d93c6230557f9c67c7dda
react-native-launch-arguments: 4e0fd58e56dcc7f52eedef9dc8eff81eb73ced7a
react-native-mmkv: e97c0c79403fb94577e5d902ab1ebd42b0715b43
react-native-netinfo: e849fc21ca2f4128a5726c801a82fc6f4a6db50d
react-native-randombytes: 421f1c7d48c0af8dbcd471b0324393ebf8fe7846
react-native-safe-area-context: 9e40fb181dac02619414ba1294d6c2a807056ab9
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@
"@metamask/post-message-stream": "7.0.0",
"@metamask/ppom-validator": "^0.18.0",
"@metamask/preferences-controller": "^4.0.0",
"@metamask/react-native-button": "^3.0.0",
"@metamask/scure-bip39": "^2.1.0",
"@metamask/sdk-communication-layer": "^0.12.0",
"@metamask/signature-controller": "4.0.1",
Expand Down Expand Up @@ -295,7 +296,6 @@
"react-native-background-timer": "2.1.1",
"react-native-branch": "^5.6.2",
"react-native-browser-polyfill": "0.1.2",
"@metamask/react-native-button": "^3.0.0",
"react-native-camera": "^3.36.0",
"react-native-confetti": "^0.1.0",
"react-native-confetti-cannon": "^1.5.0",
Expand All @@ -319,6 +319,7 @@
"react-native-level-fs": "3.0.1",
"react-native-linear-gradient": "2.5.6",
"react-native-material-textfield": "0.16.1",
"react-native-mmkv": "^2.11.0",
"react-native-modal": "^12.1.0",
"react-native-os": "^1.2.6",
"react-native-permissions": "^3.7.2",
Expand Down
12 changes: 7 additions & 5 deletions patches/react-native+0.71.15.patch
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
diff --git a/node_modules/react-native/Libraries/Core/InitializeCore.js b/node_modules/react-native/Libraries/Core/InitializeCore.js
index 1379ffd..a991485 100644
index 1379ffd..4763ab2 100644
--- a/node_modules/react-native/Libraries/Core/InitializeCore.js
+++ b/node_modules/react-native/Libraries/Core/InitializeCore.js
@@ -24,26 +24,53 @@
@@ -24,26 +24,55 @@

'use strict';

+const Platform = require('../Utilities/Platform');
+import { MMKV } from 'react-native-mmkv';
leotm marked this conversation as resolved.
Show resolved Hide resolved
leotm marked this conversation as resolved.
Show resolved Hide resolved
+const storage = new MMKV(); // id: mmkv.default
+const isSesEnabled = storage.getBoolean('is-ses-enabled');
+
+const IS_LOCKDOWN_ENABLED = true;
+const Platform = require('../Utilities/Platform');
+
+if (IS_LOCKDOWN_ENABLED && Platform.OS === 'ios' && !global?.HermesInternal && !__DEV__) {
+if (isSesEnabled && Platform.OS === 'ios' && !global?.HermesInternal && !__DEV__) {
+ require('../../../../ses.cjs');
+ /**
+ * Without consoleTaming: 'unsafe' causes:
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22247,6 +22247,11 @@ react-native-material-textfield@0.16.1:
dependencies:
prop-types "^15.5.9"

react-native-mmkv@^2.11.0:
version "2.11.0"
resolved "https://registry.yarnpkg.com/react-native-mmkv/-/react-native-mmkv-2.11.0.tgz#51b9985f6a5c09fe9c16d8c1861cc2901856ace1"
integrity sha512-28PdUHjZJmAw3q+8zJDAAdohnZMpDC7WgRUJxACOMkcmJeqS3u5cKS/lSq2bhf1CvaeIiHYHUWiyatUjMRCDQQ==

react-native-modal-datetime-picker@^14.0.0:
version "14.0.1"
resolved "https://registry.yarnpkg.com/react-native-modal-datetime-picker/-/react-native-modal-datetime-picker-14.0.1.tgz#d9c6df4ff85bf1cfbe108c756dc26dcca4cc5f2f"
Expand Down
Loading