Skip to content

Commit

Permalink
feat(suite-native): delete view only feature flag completely
Browse files Browse the repository at this point in the history
- It is no more needed, and by this change it is also removed from persist store.
  • Loading branch information
matejkriz committed May 16, 2024
1 parent b616726 commit 892d0fc
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 42 deletions.
3 changes: 0 additions & 3 deletions suite-native/feature-flags/src/featureFlagsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { isDebugEnv, isDetoxTestBuild, isDevelopOrDebugEnv } from '@suite-native
export const FeatureFlag = {
IsDeviceConnectEnabled: 'isDeviceConnectEnabled',
IsPassphraseEnabled: 'isPassphraseEnabled',
IsViewOnlyEnabled: 'isViewOnlyEnabled',
IsSendEnabled: 'isSendEnabled',
IsRegtestEnabled: 'isRegtestEnabled',
} as const;
Expand All @@ -21,15 +20,13 @@ export type FeatureFlagsRootState = {
export const featureFlagsInitialState: FeatureFlagsState = {
[FeatureFlag.IsDeviceConnectEnabled]: isAndroid() || isDebugEnv(),
[FeatureFlag.IsPassphraseEnabled]: isDebugEnv(),
[FeatureFlag.IsViewOnlyEnabled]: isDebugEnv(),
[FeatureFlag.IsSendEnabled]: isAndroid() && isDevelopOrDebugEnv(),
[FeatureFlag.IsRegtestEnabled]: isDebugEnv() || isDetoxTestBuild(),
};

export const featureFlagsPersistedKeys: Array<keyof FeatureFlagsState> = [
FeatureFlag.IsDeviceConnectEnabled,
FeatureFlag.IsPassphraseEnabled,
FeatureFlag.IsViewOnlyEnabled,
FeatureFlag.IsSendEnabled,
FeatureFlag.IsRegtestEnabled,
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { FeatureFlag as FeatureFlagEnum, useFeatureFlag } from '@suite-native/fe
const featureFlagsTitleMap = {
[FeatureFlagEnum.IsDeviceConnectEnabled]: 'Connect device',
[FeatureFlagEnum.IsPassphraseEnabled]: 'Passphrase',
[FeatureFlagEnum.IsViewOnlyEnabled]: 'View-only',
[FeatureFlagEnum.IsSendEnabled]: 'Send',
[FeatureFlagEnum.IsRegtestEnabled]: 'Regtest',
} as const satisfies Record<FeatureFlagEnum, string>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
selectViewOnlyCancelationTimestamp,
setViewOnlyCancelationTimestamp,
} from '@suite-native/settings';
import { FeatureFlag, useFeatureFlag } from '@suite-native/feature-flags';
import { useToast } from '@suite-native/toasts';

import { DisconnectedTrezorSvg } from '../../../assets/DisconnectedTrezorSvg';
Expand All @@ -40,7 +39,6 @@ const buttonWrapperStyle = prepareNativeStyle(utils => ({
export const EnableViewOnlyBottomSheet = () => {
const dispatch = useDispatch();
const { applyStyle } = useNativeStyles();
const [isViewOnlyModeFeatureEnabled] = useFeatureFlag(FeatureFlag.IsViewOnlyEnabled);
const { isBiometricsInitialSetupFinished } = useIsBiometricsInitialSetupFinished();
const isDeviceReadyToUseAndAuthorized = useSelector(selectIsDeviceReadyToUseAndAuthorized);
const device = useSelector(selectDevice);
Expand Down Expand Up @@ -69,7 +67,6 @@ export const EnableViewOnlyBottomSheet = () => {
// and biometrics initial setup was decided or biometrics is not available

const canBeShowed =
isViewOnlyModeFeatureEnabled &&
!isDeviceRemembered &&
isDeviceReadyToUseAndAuthorized &&
!isPortfolioTrackerDevice &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useNavigation } from '@react-navigation/core';
import { useAtomValue } from 'jotai';

import { FeatureFlag, useFeatureFlag } from '@suite-native/feature-flags';
import {
SettingsStackRoutes,
SettingsStackParamList,
Expand All @@ -16,7 +15,6 @@ import { isDevButtonVisibleAtom } from './ProductionDebug';

export const ApplicationSettings = () => {
const isDevButtonVisible = useAtomValue(isDevButtonVisibleAtom);
const [isViewOnlyFeatureEnabled] = useFeatureFlag(FeatureFlag.IsViewOnlyEnabled);

const navigation =
useNavigation<
Expand Down Expand Up @@ -59,14 +57,12 @@ export const ApplicationSettings = () => {
subtitle="Analytics, Discreet mode, Biometrics"
onPress={() => handleNavigation(SettingsStackRoutes.SettingsPrivacyAndSecurity)}
/>
{isViewOnlyFeatureEnabled && (
<SettingsSectionItem
title="View-only"
iconName="bookmark"
subtitle="Check balances without your Trezor"
onPress={() => handleNavigation(SettingsStackRoutes.SettingsViewOnly)}
/>
)}
<SettingsSectionItem
title="View-only"
iconName="bookmark"
subtitle="Check balances without your Trezor"
onPress={() => handleNavigation(SettingsStackRoutes.SettingsViewOnly)}
/>
</SettingsSection>
);
};
1 change: 0 additions & 1 deletion suite-native/receive/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"@suite-native/device-manager": "workspace:*",
"@suite-native/device-mutex": "workspace:*",
"@suite-native/ethereum-tokens": "workspace:*",
"@suite-native/feature-flags": "workspace:*",
"@suite-native/formatters": "workspace:*",
"@suite-native/helpers": "workspace:*",
"@suite-native/intl": "workspace:*",
Expand Down
10 changes: 1 addition & 9 deletions suite-native/receive/src/components/ReceiveAddressCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
selectIsPortfolioTrackerDevice,
} from '@suite-common/wallet-core';
import { Translation } from '@suite-native/intl';
import { FeatureFlag, useFeatureFlag } from '@suite-native/feature-flags';

import { UnverifiedAddress } from './UnverifiedAddress';

Expand All @@ -33,17 +32,10 @@ export const ReceiveAddressCard = ({
const isPortfolioTrackerDevice = useSelector(selectIsPortfolioTrackerDevice);
const isDeviceInViewOnlyMode = useSelector(selectIsDeviceInViewOnlyMode);

const [isViewOnlyFeatureEnabled] = useFeatureFlag(FeatureFlag.IsViewOnlyEnabled);

const { networkType } = networks[networkSymbol];

const getCardAlertProps = () => {
if (
isReceiveApproved &&
!isPortfolioTrackerDevice &&
!isDeviceInViewOnlyMode &&
!isViewOnlyFeatureEnabled
) {
if (isReceiveApproved && !isPortfolioTrackerDevice && !isDeviceInViewOnlyMode) {
return {
alertTitle: <Translation id="moduleReceive.receiveAddressCard.alert.success" />,
alertVariant: 'success',
Expand Down
5 changes: 1 addition & 4 deletions suite-native/receive/src/components/ShowAddressButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
selectIsDeviceInViewOnlyMode,
selectIsPortfolioTrackerDevice,
} from '@suite-common/wallet-core';
import { FeatureFlag, useFeatureFlag } from '@suite-native/feature-flags';

import { ShowAddressViewOnlyBottomSheet } from './ShowAddressViewOnlyBottomSheet';

Expand All @@ -22,16 +21,14 @@ export const ShowAddressButtons = ({ onShowAddress }: ShowAddressButtonsProps) =

const openLink = useOpenLink();

const [isViewOnlyFeatureEnabled] = useFeatureFlag(FeatureFlag.IsViewOnlyEnabled);

const [isViewOnlyBottomSheetVisible, setIsViewOnlyBottomSheetVisible] = useState(false);

const handleOpenEduLink = () => {
openLink('https://trezor.io/learn/a/verifying-trezor-suite-lite-addresses');
};

const handleShowAddress = () => {
if (isViewOnlyFeatureEnabled && isDeviceInViewOnlyMode) {
if (isDeviceInViewOnlyMode) {
setIsViewOnlyBottomSheetVisible(true);
} else {
onShowAddress();
Expand Down
12 changes: 2 additions & 10 deletions suite-native/receive/src/hooks/useAccountReceiveAddress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { analytics, EventType } from '@suite-native/analytics';
import { requestPrioritizedDeviceAccess } from '@suite-native/device-mutex';
import { useToast } from '@suite-native/toasts';
import { Translation } from '@suite-native/intl';
import { FeatureFlag, useFeatureFlag } from '@suite-native/feature-flags';

export const useAccountReceiveAddress = (accountKey: AccountKey) => {
const dispatch = useDispatch();
Expand All @@ -31,7 +30,6 @@ export const useAccountReceiveAddress = (accountKey: AccountKey) => {
const isPortfolioTrackerDevice = useSelector(selectIsPortfolioTrackerDevice);
const isDeviceInViewOnlyMode = useSelector(selectIsDeviceInViewOnlyMode);
const navigation = useNavigation();
const [isViewOnlyFeatureEnabled] = useFeatureFlag(FeatureFlag.IsViewOnlyEnabled);

const { showToast } = useToast();

Expand Down Expand Up @@ -134,7 +132,7 @@ export const useAccountReceiveAddress = (accountKey: AccountKey) => {
});
setIsReceiveApproved(true);
}
} else if (isDeviceInViewOnlyMode && isViewOnlyFeatureEnabled) {
} else if (isDeviceInViewOnlyMode) {
// If device is remembered,
// no verification should happen and we display the receive address straight away.
setIsUnverifiedAddressRevealed(true);
Expand All @@ -150,13 +148,7 @@ export const useAccountReceiveAddress = (accountKey: AccountKey) => {
setIsUnverifiedAddressRevealed(false);
}
}
}, [
isDeviceInViewOnlyMode,
isPortfolioTrackerDevice,
isViewOnlyFeatureEnabled,
networkSymbol,
verifyAddressOnDevice,
]);
}, [isDeviceInViewOnlyMode, isPortfolioTrackerDevice, networkSymbol, verifyAddressOnDevice]);

return {
address: freshAddress?.address,
Expand Down
1 change: 0 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9803,7 +9803,6 @@ __metadata:
"@suite-native/device-manager": "workspace:*"
"@suite-native/device-mutex": "workspace:*"
"@suite-native/ethereum-tokens": "workspace:*"
"@suite-native/feature-flags": "workspace:*"
"@suite-native/formatters": "workspace:*"
"@suite-native/helpers": "workspace:*"
"@suite-native/intl": "workspace:*"
Expand Down

0 comments on commit 892d0fc

Please sign in to comment.