From 978c2b8d2b754f7788468a695791084acea4bced Mon Sep 17 00:00:00 2001 From: Atatakai Date: Wed, 11 Dec 2024 21:50:31 +0400 Subject: [PATCH] feat: hide safe interaction for mode --- .../MainPage/sections/AlertSections/index.tsx | 4 ++- .../AddBackupWalletViaSafePage/index.tsx | 2 +- frontend/components/SettingsPage/index.tsx | 28 ++++++++++++------- frontend/hooks/useFeatureFlag.ts | 5 ++++ 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/frontend/components/MainPage/sections/AlertSections/index.tsx b/frontend/components/MainPage/sections/AlertSections/index.tsx index d9ed1af8..ee694b7a 100644 --- a/frontend/components/MainPage/sections/AlertSections/index.tsx +++ b/frontend/components/MainPage/sections/AlertSections/index.tsx @@ -1,4 +1,5 @@ import { CardSection } from '@/components/styled/CardSection'; +import { useFeatureFlag } from '@/hooks/useFeatureFlag'; import { AddBackupWalletAlert } from './AddBackupWalletAlert'; import { AvoidSuspensionAlert } from './AvoidSuspensionAlert'; @@ -8,10 +9,11 @@ import { NoAvailableSlotsOnTheContract } from './NoAvailableSlotsOnTheContract'; import { UpdateAvailableAlert } from './UpdateAvailableAlert'; export const AlertSections = () => { + const isBackupViaSafeEnabled = useFeatureFlag('backup-via-safe'); return ( - + {isBackupViaSafeEnabled && } diff --git a/frontend/components/Pages/AddBackupWalletViaSafePage/index.tsx b/frontend/components/Pages/AddBackupWalletViaSafePage/index.tsx index 0653eaaa..5d4fe6ad 100644 --- a/frontend/components/Pages/AddBackupWalletViaSafePage/index.tsx +++ b/frontend/components/Pages/AddBackupWalletViaSafePage/index.tsx @@ -19,7 +19,7 @@ const safeChainPrefix = { [EvmChainId.Base]: 'base', [EvmChainId.Optimism]: 'oeth', [EvmChainId.Gnosis]: 'gno', - [EvmChainId.Mode]: 'mode', // TODO: Modius - the above link doesn't have Mode, so the prefix is a guess + [EvmChainId.Mode]: '', // TODO: provide correct prefix once mode is supported on safe }; export const AddBackupWalletViaSafePage = () => { diff --git a/frontend/components/SettingsPage/index.tsx b/frontend/components/SettingsPage/index.tsx index 72e95d31..b903d7f3 100644 --- a/frontend/components/SettingsPage/index.tsx +++ b/frontend/components/SettingsPage/index.tsx @@ -5,6 +5,7 @@ import { useMemo } from 'react'; import { Pages } from '@/enums/Pages'; import { SettingsScreen } from '@/enums/SettingsScreen'; +import { useFeatureFlag } from '@/hooks/useFeatureFlag'; import { useMultisig } from '@/hooks/useMultisig'; import { usePageState } from '@/hooks/usePageState'; import { useServices } from '@/hooks/useServices'; @@ -83,6 +84,8 @@ export const Settings = () => { }; const SettingsMain = () => { + const isBackupViaSafeEnabled = useFeatureFlag('backup-via-safe'); + const { selectedService } = useServices(); const { masterEoa, masterSafes } = useMasterWalletContext(); @@ -148,16 +151,21 @@ const SettingsMain = () => { - {/* Wallet backup */} - - Backup wallet - {walletBackup} - + {/* Wallet backup + If there's no backup address and adding it + via safe is disabled - hide the section + */} + {!isBackupViaSafeEnabled && !masterSafeBackupAddress ? null : ( + + Backup wallet + {walletBackup} + + )} {/* Debug info */} diff --git a/frontend/hooks/useFeatureFlag.ts b/frontend/hooks/useFeatureFlag.ts index 88f52682..7320822c 100644 --- a/frontend/hooks/useFeatureFlag.ts +++ b/frontend/hooks/useFeatureFlag.ts @@ -10,6 +10,7 @@ const FeatureFlagsSchema = z.enum([ 'manage-wallet', 'rewards-streak', 'staking-contract-section', + 'backup-via-safe', ]); type FeatureFlags = z.infer; @@ -29,18 +30,22 @@ const FEATURES_CONFIG = FeaturesConfigSchema.parse({ 'last-transactions': true, 'rewards-streak': true, 'staking-contract-section': true, + 'backup-via-safe': true, }, [AgentType.Memeooorr]: { 'manage-wallet': false, 'last-transactions': false, 'rewards-streak': false, 'staking-contract-section': false, + 'backup-via-safe': true, }, [AgentType.Modius]: { 'manage-wallet': false, 'last-transactions': false, 'rewards-streak': false, 'staking-contract-section': false, + // temporarily hidden until mode is available on safe https://app.safe.global/new-safe/create + 'backup-via-safe': false, }, });