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

Tanya/hide safe #575

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CardSection } from '@/components/styled/CardSection';
import { useFeatureFlag } from '@/hooks/useFeatureFlag';

import { AddBackupWalletAlert } from './AddBackupWalletAlert';
import { AvoidSuspensionAlert } from './AvoidSuspensionAlert';
Expand All @@ -8,10 +9,11 @@ import { NoAvailableSlotsOnTheContract } from './NoAvailableSlotsOnTheContract';
import { UpdateAvailableAlert } from './UpdateAvailableAlert';

export const AlertSections = () => {
const isBackupViaSafeEnabled = useFeatureFlag('backup-via-safe');
return (
<CardSection vertical>
<UpdateAvailableAlert />
<AddBackupWalletAlert />
{isBackupViaSafeEnabled && <AddBackupWalletAlert />}
<NewStakingProgramAlert />
<AvoidSuspensionAlert />
<LowFunds />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down
28 changes: 18 additions & 10 deletions frontend/components/SettingsPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -83,6 +84,8 @@ export const Settings = () => {
};

const SettingsMain = () => {
const isBackupViaSafeEnabled = useFeatureFlag('backup-via-safe');

const { selectedService } = useServices();
const { masterEoa, masterSafes } = useMasterWalletContext();

Expand Down Expand Up @@ -148,16 +151,21 @@ const SettingsMain = () => {
</Flex>
</CardSection>

{/* Wallet backup */}
<CardSection
padding="24px"
borderbottom={masterSafeBackupAddress ? 'true' : 'false'}
vertical
gap={8}
>
<Text strong>Backup wallet</Text>
{walletBackup}
</CardSection>
{/* Wallet backup
If there's no backup address and adding it
via safe is disabled - hide the section
*/}
{!isBackupViaSafeEnabled && !masterSafeBackupAddress ? null : (
Tanya-atatakai marked this conversation as resolved.
Show resolved Hide resolved
<CardSection
padding="24px"
borderbottom={masterSafeBackupAddress ? 'true' : 'false'}
vertical
gap={8}
>
<Text strong>Backup wallet</Text>
{walletBackup}
</CardSection>
)}

{/* Debug info */}
<DebugInfoSection />
Expand Down
5 changes: 5 additions & 0 deletions frontend/hooks/useFeatureFlag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const FeatureFlagsSchema = z.enum([
'manage-wallet',
'rewards-streak',
'staking-contract-section',
'backup-via-safe',
]);
type FeatureFlags = z.infer<typeof FeatureFlagsSchema>;

Expand All @@ -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,
},
});

Expand Down