Skip to content

Commit

Permalink
chore: clean up isstaking flag, update profile page (#774)
Browse files Browse the repository at this point in the history
  • Loading branch information
moo-onthelawn authored Jul 8, 2024
1 parent 9801f13 commit 33ff038
Show file tree
Hide file tree
Showing 28 changed files with 141 additions and 856 deletions.
48 changes: 16 additions & 32 deletions public/configs/v1/env.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,7 @@
"CCTPWithdrawalOnly": true,
"CCTPDepositOnly": true,
"isSlTpEnabled": true,
"isSlTpLimitOrdersEnabled": false,
"isStakingEnabled": true
"isSlTpLimitOrdersEnabled": false
}
},
"dydxprotocol-dev-2": {
Expand Down Expand Up @@ -353,8 +352,7 @@
"CCTPWithdrawalOnly": true,
"CCTPDepositOnly": true,
"isSlTpEnabled": true,
"isSlTpLimitOrdersEnabled": false,
"isStakingEnabled": true
"isSlTpLimitOrdersEnabled": false
}
},
"dydxprotocol-dev-3": {
Expand Down Expand Up @@ -393,8 +391,7 @@
"CCTPWithdrawalOnly": true,
"CCTPDepositOnly": true,
"isSlTpEnabled": true,
"isSlTpLimitOrdersEnabled": false,
"isStakingEnabled": true
"isSlTpLimitOrdersEnabled": false
}
},
"dydxprotocol-dev-4": {
Expand Down Expand Up @@ -433,8 +430,7 @@
"CCTPWithdrawalOnly": true,
"CCTPDepositOnly": true,
"isSlTpEnabled": true,
"isSlTpLimitOrdersEnabled": false,
"isStakingEnabled": true
"isSlTpLimitOrdersEnabled": false
}
},
"dydxprotocol-dev-5": {
Expand Down Expand Up @@ -471,8 +467,7 @@
"CCTPWithdrawalOnly": true,
"CCTPDepositOnly": true,
"isSlTpEnabled": true,
"isSlTpLimitOrdersEnabled": false,
"isStakingEnabled": true
"isSlTpLimitOrdersEnabled": false
}
},
"dydxprotocol-staging": {
Expand Down Expand Up @@ -510,8 +505,7 @@
"CCTPWithdrawalOnly": true,
"CCTPDepositOnly": true,
"isSlTpEnabled": true,
"isSlTpLimitOrdersEnabled": false,
"isStakingEnabled": true
"isSlTpLimitOrdersEnabled": false
}
},
"dydxprotocol-staging-forced-update": {
Expand Down Expand Up @@ -561,8 +555,7 @@
"CCTPWithdrawalOnly": true,
"CCTPDepositOnly": true,
"isSlTpEnabled": true,
"isSlTpLimitOrdersEnabled": false,
"isStakingEnabled": true
"isSlTpLimitOrdersEnabled": false
}
},
"dydxprotocol-staging-west": {
Expand Down Expand Up @@ -600,8 +593,7 @@
"CCTPWithdrawalOnly": true,
"CCTPDepositOnly": true,
"isSlTpEnabled": true,
"isSlTpLimitOrdersEnabled": false,
"isStakingEnabled": true
"isSlTpLimitOrdersEnabled": false
}
},
"dydxprotocol-testnet": {
Expand Down Expand Up @@ -647,8 +639,7 @@
"CCTPWithdrawalOnly": true,
"CCTPDepositOnly": true,
"isSlTpEnabled": true,
"isSlTpLimitOrdersEnabled": false,
"isStakingEnabled": true
"isSlTpLimitOrdersEnabled": false
}
},
"dydxprotocol-testnet-dydx": {
Expand Down Expand Up @@ -686,8 +677,7 @@
"CCTPWithdrawalOnly": true,
"CCTPDepositOnly": true,
"isSlTpEnabled": true,
"isSlTpLimitOrdersEnabled": false,
"isStakingEnabled": true
"isSlTpLimitOrdersEnabled": false
}
},
"dydxprotocol-testnet-nodefleet": {
Expand Down Expand Up @@ -726,8 +716,7 @@
"CCTPWithdrawalOnly": true,
"CCTPDepositOnly": true,
"isSlTpEnabled": true,
"isSlTpLimitOrdersEnabled": false,
"isStakingEnabled": true
"isSlTpLimitOrdersEnabled": false
}
},
"dydxprotocol-testnet-kingnodes": {
Expand Down Expand Up @@ -765,8 +754,7 @@
"CCTPWithdrawalOnly": true,
"CCTPDepositOnly": true,
"isSlTpEnabled": true,
"isSlTpLimitOrdersEnabled": false,
"isStakingEnabled": true
"isSlTpLimitOrdersEnabled": false
}
},
"dydxprotocol-testnet-liquify": {
Expand Down Expand Up @@ -805,8 +793,7 @@
"CCTPWithdrawalOnly": true,
"CCTPDepositOnly": true,
"isSlTpEnabled": true,
"isSlTpLimitOrdersEnabled": false,
"isStakingEnabled": true
"isSlTpLimitOrdersEnabled": false
}
},
"dydxprotocol-testnet-polkachu": {
Expand Down Expand Up @@ -845,8 +832,7 @@
"CCTPWithdrawalOnly": true,
"CCTPDepositOnly": true,
"isSlTpEnabled": true,
"isSlTpLimitOrdersEnabled": false,
"isStakingEnabled": true
"isSlTpLimitOrdersEnabled": false
}
},
"dydxprotocol-testnet-bware": {
Expand Down Expand Up @@ -885,8 +871,7 @@
"CCTPWithdrawalOnly": true,
"CCTPDepositOnly": true,
"isSlTpEnabled": true,
"isSlTpLimitOrdersEnabled": false,
"isStakingEnabled": true
"isSlTpLimitOrdersEnabled": false
}
},
"dydxprotocol-mainnet": {
Expand Down Expand Up @@ -925,8 +910,7 @@
"CCTPWithdrawalOnly": true,
"CCTPDepositOnly": true,
"isSlTpEnabled": true,
"isSlTpLimitOrdersEnabled": false,
"isStakingEnabled": true
"isSlTpLimitOrdersEnabled": false
}
}
}
Expand Down
14 changes: 2 additions & 12 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ import { GlobalCommandDialog } from '@/views/dialogs/GlobalCommandDialog';
import { parseLocationHash } from '@/lib/urlUtils';
import { config, configureChainsConfig, privyConfig } from '@/lib/wagmi';

import { ComplianceStates } from './constants/compliance';
import { useAnalytics } from './hooks/useAnalytics';
import { useBreakpoints } from './hooks/useBreakpoints';
import { useComplianceState } from './hooks/useComplianceState';
import { useEnvFeatures } from './hooks/useEnvFeatures';
import { useInitializePage } from './hooks/useInitializePage';
import { useShouldShowFooter } from './hooks/useShouldShowFooter';
import { useTokenConfigs } from './hooks/useTokenConfigs';
Expand All @@ -59,7 +56,7 @@ const SettingsPage = lazy(() => import('@/pages/settings/Settings'));
const TradePage = lazy(() => import('@/pages/trade/Trade'));
const TermsOfUsePage = lazy(() => import('@/pages/TermsOfUsePage'));
const PrivacyPolicyPage = lazy(() => import('@/pages/PrivacyPolicyPage'));
const TokenPage = lazy(() => import('@/pages/token/Token'));
const RewardsPage = lazy(() => import('@/pages/token/RewardsPage'));
const VaultsPage = lazy(() => import('@/pages/vaults/Vaults'));

const queryClient = new QueryClient();
Expand All @@ -69,8 +66,6 @@ const Content = () => {
useAnalytics();

const { isTablet, isNotTablet } = useBreakpoints();
const { complianceState } = useComplianceState();
const { isStakingEnabled } = useEnvFeatures();
const { chainTokenLabel } = useTokenConfigs();

const location = useLocation();
Expand All @@ -86,8 +81,6 @@ const Content = () => {

const { dialogAreaRef } = useDialogArea() ?? {};

const showChainTokenPage = complianceState === ComplianceStates.FULL_ACCESS || isStakingEnabled;

return (
<>
<GlobalStyle />
Expand All @@ -107,10 +100,7 @@ const Content = () => {
<Route path={AppRoute.Markets} element={<MarketsPage />} />
</Route>

<Route
path={`/${chainTokenLabel}/*`}
element={showChainTokenPage ? <TokenPage /> : <Navigate to={AppRoute.Markets} />}
/>
<Route path={`/${chainTokenLabel}/*`} element={<RewardsPage />} />

{isTablet && (
<>
Expand Down
7 changes: 0 additions & 7 deletions src/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ export enum HistoryRoute {
Payments = 'payments',
}

// OTE-459: Deprecate this route
export enum TokenRoute {
TradingRewards = 'trading-rewards',
StakingRewards = 'staking-rewards',
Governance = 'governance',
}

export enum MobileSettingsRoute {
Language = 'language',
Notifications = 'notifications',
Expand Down
1 change: 0 additions & 1 deletion src/hooks/useEnvFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export interface EnvironmentFeatures {
CCTPDepositOnly: boolean;
isSlTpEnabled: boolean;
isSlTpLimitOrdersEnabled: boolean;
isStakingEnabled: boolean;
}

export const useEnvFeatures = (): EnvironmentFeatures => {
Expand Down
24 changes: 7 additions & 17 deletions src/hooks/useNotificationTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
TransferNotificationTypes,
type NotificationTypeConfig,
} from '@/constants/notifications';
import { AppRoute, TokenRoute } from '@/constants/routes';
import { AppRoute } from '@/constants/routes';
import { DydxChainAsset } from '@/constants/wallets';

import { useLocalNotifications } from '@/hooks/useLocalNotifications';
Expand Down Expand Up @@ -62,7 +62,6 @@ import { formatSeconds } from '@/lib/timeUtils';
import { useAccounts } from './useAccounts';
import { useApiState } from './useApiState';
import { useComplianceState } from './useComplianceState';
import { useEnvFeatures } from './useEnvFeatures';
import { useQueryChaosLabsIncentives } from './useQueryChaosLabsIncentives';
import { useStringGetter } from './useStringGetter';
import { useTokenConfigs } from './useTokenConfigs';
Expand Down Expand Up @@ -276,7 +275,6 @@ export const notificationTypes: NotificationTypeConfig[] = [
useTrigger: ({ trigger }) => {
const { chainTokenLabel } = useTokenConfigs();
const stringGetter = useStringGetter();
const { isStakingEnabled } = useEnvFeatures();

const incentivesExpirationDate = new Date('2024-07-17T23:59:59');
const conditionalOrdersExpirationDate = new Date('2024-06-01T23:59:59');
Expand Down Expand Up @@ -385,7 +383,7 @@ export const notificationTypes: NotificationTypeConfig[] = [
);
}

if (isStakingEnabled && currentDate <= stakingLiveExpirationDate) {
if (currentDate <= stakingLiveExpirationDate) {
trigger(
ReleaseUpdateNotificationIds.InAppStakingLive,
{
Expand Down Expand Up @@ -449,23 +447,15 @@ export const notificationTypes: NotificationTypeConfig[] = [
},
useNotificationAction: () => {
const { chainTokenLabel } = useTokenConfigs();
const { isStakingEnabled } = useEnvFeatures();

const navigate = useNavigate();

return (notificationId: string) => {
if (notificationId === INCENTIVES_SEASON_NOTIFICATION_ID) {
if (isStakingEnabled) {
navigate(`${chainTokenLabel}`);
} else {
navigate(`${chainTokenLabel}/${TokenRoute.TradingRewards}`);
}
} else if (notificationId === INCENTIVES_DISTRIBUTED_NOTIFICATION_ID) {
if (isStakingEnabled) {
navigate(`${chainTokenLabel}`);
} else {
navigate(`${chainTokenLabel}/${TokenRoute.StakingRewards}`);
}
if (
notificationId === INCENTIVES_SEASON_NOTIFICATION_ID ||
notificationId === INCENTIVES_DISTRIBUTED_NOTIFICATION_ID
) {
navigate(`${chainTokenLabel}`);
}
};
},
Expand Down
8 changes: 1 addition & 7 deletions src/layout/Header/HeaderDesktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ import { Link } from 'react-router-dom';
import styled from 'styled-components';

import { ButtonShape } from '@/constants/buttons';
import { ComplianceStates } from '@/constants/compliance';
import { DialogTypes } from '@/constants/dialogs';
import { STRING_KEYS } from '@/constants/localization';
import { AppRoute } from '@/constants/routes';

import { useComplianceState } from '@/hooks/useComplianceState';
import { useEnvFeatures } from '@/hooks/useEnvFeatures';
import { useStringGetter } from '@/hooks/useStringGetter';
import { useTokenConfigs } from '@/hooks/useTokenConfigs';
import { useURLConfigs } from '@/hooks/useURLConfigs';
Expand Down Expand Up @@ -39,14 +36,11 @@ import { testFlags } from '@/lib/testFlags';

export const HeaderDesktop = () => {
const stringGetter = useStringGetter();
const { isStakingEnabled } = useEnvFeatures();
const { documentation, community, mintscanBase, exchangeStats } = useURLConfigs();
const dispatch = useAppDispatch();
const { chainTokenLabel } = useTokenConfigs();
const { complianceState } = useComplianceState();

const hasSeenLaunchIncentives = useAppSelector(getHasSeenLaunchIncentives);
const showChainTokenPage = complianceState === ComplianceStates.FULL_ACCESS || isStakingEnabled;
const showVaults = testFlags.enableVaults;

const navItems = [
Expand Down Expand Up @@ -78,7 +72,7 @@ export const HeaderDesktop = () => {
),
href: AppRoute.Vaults,
},
showChainTokenPage && {
{
value: chainTokenLabel,
label: chainTokenLabel,
href: `/${chainTokenLabel}`,
Expand Down
Loading

0 comments on commit 33ff038

Please sign in to comment.