Skip to content

Commit

Permalink
use environment var to determine if to show blockaid or not
Browse files Browse the repository at this point in the history
Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com>
  • Loading branch information
segun committed Aug 3, 2023
1 parent 0ab1b33 commit f5367fb
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ExperimentalSettings should render blockaid togggle button 1`] = `
exports[`ExperimentalSettings should render blockaid toggle button 1`] = `
Array [
<RCTScrollView
style={
Expand Down
14 changes: 10 additions & 4 deletions app/components/Views/Settings/ExperimentalSettings/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from 'react';
import { render } from '@testing-library/react-native';
import { Provider } from 'react-redux';
import { ThemeContext, mockTheme } from '../../../../util/theme';
import configureMockStore from 'redux-mock-store';

import { render } from '@testing-library/react-native';

import initialBackgroundState from '../../../../util/test/initial-background-state.json';
import ExperimentalSettings from '.';
import { mockTheme, ThemeContext } from '../../../../util/theme';
import ExperimentalSettings from './';
import SECURITY_ALERTS_TOGGLE_TEST_ID from './constants';

const mockStore = configureMockStore();
Expand All @@ -25,6 +27,10 @@ jest.mock('@react-navigation/native', () => ({
createNavigatorFactory: () => ({}),
}));

jest.mock('../../../../util/blockaid', () => ({
showBlockaidUI: jest.fn().mockReturnValue(true),
}));

const store = mockStore(initialState);

const setOptions = jest.fn();
Expand All @@ -47,7 +53,7 @@ describe('ExperimentalSettings', () => {
expect(wrapper).toMatchSnapshot();
});

it('should render blockaid togggle button', async () => {
it('should render blockaid toggle button', async () => {
const wrapper = render(
<Provider store={store}>
<ThemeContext.Provider value={mockTheme}>
Expand Down
6 changes: 4 additions & 2 deletions app/components/Views/Settings/ExperimentalSettings/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import React, { FC, useCallback, useEffect } from 'react';
import { ScrollView, StyleSheet, Switch, Text, View } from 'react-native';
import { useDispatch, useSelector } from 'react-redux';

import { strings } from '../../../../../locales/i18n';
import { setSecurityAlertsEnabled } from '../../../../actions/experimental';
import {
fontStyles,
colors as importedColors,
fontStyles,
} from '../../../../styles/common';
import { useTheme } from '../../../../util/theme';
import { getNavigationOptionsTitle } from '../../../UI/Navbar';
import StyledButton from '../../../UI/StyledButton';
import SECURITY_ALERTS_TOGGLE_TEST_ID from './constants';
import { showBlockaidUI } from '../../../../util/blockaid';

const createStyles = (colors: any) =>
StyleSheet.create({
Expand Down Expand Up @@ -197,7 +199,7 @@ const ExperimentalSettings = ({ navigation, route }: Props) => {
return (
<ScrollView style={styles.wrapper}>
<WalletConnectSettings />
<BlockaidSettings />
{showBlockaidUI() && <BlockaidSettings />}
</ScrollView>
);
};
Expand Down
3 changes: 3 additions & 0 deletions app/util/blockaid/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// eslint-disable-next-line import/prefer-default-export
export const showBlockaidUI = () =>
process.env.MM_BLOCKAID_UI_ENABLED === 'true';
6 changes: 3 additions & 3 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -828,11 +828,11 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/yoga"

SPEC CHECKSUMS:
boost: a7c83b31436843459a1961bfd74b96033dc77234
boost: 57d2868c099736d80fcd648bf211b4431e51a558
Branch: 4ac024cb3c29b0ef628048694db3c4cfa679beb0
BVLinearGradient: e3aad03778a456d77928f594a649e96995f1c872
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
FBLazyVector: a83ceaa8a8581003a623facdb3c44f6d4f342ac5
FBReactNativeSpec: 85eee79837cb797ab6176f0243a2b40511c09158
Flipper: 26fc4b7382499f1281eb8cb921e5c3ad6de91fe0
Expand All @@ -845,7 +845,7 @@ SPEC CHECKSUMS:
Flipper-RSocket: d9d9ade67cbecf6ac10730304bf5607266dd2541
FlipperKit: cbdee19bdd4e7f05472a66ce290f1b729ba3cb86
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: 5337263514dd6f09803962437687240c5dc39aa4
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
JitsiWebRTC: f441eb0e2d67f0588bf24e21c5162e97342714fb
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
lottie-ios: 016449b5d8be0c3dcbcfa0a9988469999cd04c5d
Expand Down

0 comments on commit f5367fb

Please sign in to comment.