Skip to content

Commit

Permalink
fix(onboarding): Disable non CCTP withdrawals with featureflag (#450)
Browse files Browse the repository at this point in the history
* fix(onboarding): Disable non CCTP withdrawals with featureflag

* fix condition
  • Loading branch information
rosepuppy authored Apr 16, 2024
1 parent 7dd087c commit 9477f99
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 51 deletions.
42 changes: 28 additions & 14 deletions public/configs/env.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@
},
"featureFlags": {
"reduceOnlySupported": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-dev-2": {
Expand Down Expand Up @@ -214,7 +215,8 @@
},
"featureFlags": {
"reduceOnlySupported": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-dev-4": {
Expand Down Expand Up @@ -301,7 +303,8 @@
},
"featureFlags": {
"reduceOnlySupported": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-dev-5": {
Expand Down Expand Up @@ -387,7 +390,8 @@
},
"featureFlags": {
"reduceOnlySupported": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-staging": {
Expand Down Expand Up @@ -475,7 +479,8 @@
},
"featureFlags": {
"reduceOnlySupported": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-staging-forced-update": {
Expand Down Expand Up @@ -561,7 +566,8 @@
},
"featureFlags": {
"reduceOnlySupported": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-staging-west": {
Expand Down Expand Up @@ -649,7 +655,8 @@
},
"featureFlags": {
"reduceOnlySupported": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-testnet": {
Expand Down Expand Up @@ -741,7 +748,8 @@
},
"featureFlags": {
"reduceOnlySupported": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-testnet-dydx": {
Expand Down Expand Up @@ -830,7 +838,8 @@
},
"featureFlags": {
"reduceOnlySupported": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-testnet-nodefleet": {
Expand Down Expand Up @@ -919,7 +928,8 @@
},
"featureFlags": {
"reduceOnlySupported": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-testnet-kingnodes": {
Expand Down Expand Up @@ -1008,7 +1018,8 @@
},
"featureFlags": {
"reduceOnlySupported": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-testnet-liquify": {
Expand Down Expand Up @@ -1097,7 +1108,8 @@
},
"featureFlags": {
"reduceOnlySupported": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-testnet-polkachu": {
Expand Down Expand Up @@ -1177,7 +1189,8 @@
},
"featureFlags": {
"reduceOnlySupported": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-testnet-bware": {
Expand Down Expand Up @@ -1266,7 +1279,8 @@
},
"featureFlags": {
"reduceOnlySupported": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-mainnet": {
Expand Down
45 changes: 30 additions & 15 deletions public/configs/v1/env.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@
"reduceOnlySupported": true,
"usePessimisticCollateralCheck": false,
"useOptimisticCollateralCheck": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-dev-2": {
Expand Down Expand Up @@ -298,7 +299,8 @@
"reduceOnlySupported": true,
"usePessimisticCollateralCheck": false,
"useOptimisticCollateralCheck": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-dev-4": {
Expand Down Expand Up @@ -327,7 +329,8 @@
"reduceOnlySupported": true,
"usePessimisticCollateralCheck": false,
"useOptimisticCollateralCheck": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-dev-5": {
Expand Down Expand Up @@ -355,7 +358,8 @@
"reduceOnlySupported": true,
"usePessimisticCollateralCheck": false,
"useOptimisticCollateralCheck": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-staging": {
Expand Down Expand Up @@ -384,7 +388,8 @@
"reduceOnlySupported": true,
"usePessimisticCollateralCheck": false,
"useOptimisticCollateralCheck": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-staging-forced-update": {
Expand Down Expand Up @@ -420,7 +425,8 @@
"reduceOnlySupported": true,
"usePessimisticCollateralCheck": false,
"useOptimisticCollateralCheck": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-staging-west": {
Expand Down Expand Up @@ -449,7 +455,8 @@
"reduceOnlySupported": true,
"usePessimisticCollateralCheck": false,
"useOptimisticCollateralCheck": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-testnet": {
Expand Down Expand Up @@ -482,7 +489,8 @@
"reduceOnlySupported": true,
"usePessimisticCollateralCheck": false,
"useOptimisticCollateralCheck": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-testnet-dydx": {
Expand Down Expand Up @@ -510,7 +518,8 @@
"featureFlags": {
"reduceOnlySupported": true,
"usePessimisticCollateralCheck": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-testnet-nodefleet": {
Expand Down Expand Up @@ -539,7 +548,8 @@
"reduceOnlySupported": true,
"usePessimisticCollateralCheck": false,
"useOptimisticCollateralCheck": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-testnet-kingnodes": {
Expand Down Expand Up @@ -567,7 +577,8 @@
"featureFlags": {
"reduceOnlySupported": true,
"usePessimisticCollateralCheck": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-testnet-liquify": {
Expand Down Expand Up @@ -596,7 +607,8 @@
"reduceOnlySupported": true,
"usePessimisticCollateralCheck": false,
"useOptimisticCollateralCheck": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-testnet-polkachu": {
Expand Down Expand Up @@ -625,7 +637,8 @@
"reduceOnlySupported": true,
"usePessimisticCollateralCheck": false,
"useOptimisticCollateralCheck": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-testnet-bware": {
Expand Down Expand Up @@ -654,7 +667,8 @@
"reduceOnlySupported": true,
"usePessimisticCollateralCheck": false,
"useOptimisticCollateralCheck": true,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
},
"dydxprotocol-mainnet": {
Expand Down Expand Up @@ -683,7 +697,8 @@
"reduceOnlySupported": true,
"usePessimisticCollateralCheck": true,
"useOptimisticCollateralCheck": false,
"withdrawalSafetyEnabled": true
"withdrawalSafetyEnabled": true,
"CCTPWithdrawalOnly": true
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/components/SearchSelectMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { Popover, TriggerType } from '@/components/Popover';
import { WithDetailsReceipt } from '@/components/WithDetailsReceipt';
import { WithLabel } from '@/components/WithLabel';

import cctpTokens from '../../public/configs/cctp.json';

type ElementProps = {
asChild?: boolean;
children: ReactNode;
Expand All @@ -34,6 +36,12 @@ type StyleProps = {

export type SearchSelectMenuProps = ElementProps & StyleProps;

type TokenInfo = {
chainId: string;
tokenAddress: string;
name: string;
};

export const SearchSelectMenu = ({
asChild,
children,
Expand All @@ -54,6 +62,15 @@ export const SearchSelectMenu = ({
ref: searchSelectMenuRef,
});

const cctpChainsById = cctpTokens.reduce((acc, token) => {
// Check if the key for this chainId already exists
if (!acc[token.chainId]) {
acc[token.chainId] = []; // Initialize it with an empty array if not existing
}
acc[token.chainId].push(token); // Push the current token into the corresponding array
return acc;
}, {} as Record<string, TokenInfo[]>);

const Trigger = asChild ? (
children
) : (
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useEnvFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getSelectedNetwork } from '@/state/appSelectors';
export interface EnvironmentFeatures {
reduceOnlySupported: boolean;
withdrawalSafetyEnabled: boolean;
CCTPWithdrawalOnly: boolean;
}

export const useEnvFeatures = (): EnvironmentFeatures => {
Expand Down
6 changes: 4 additions & 2 deletions src/hooks/useNotificationTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,13 @@ export const notificationTypes: NotificationTypeConfig[] = [
ReleaseUpdateNotificationIds.IncentivesS4,
{
icon: <AssetIcon symbol={chainTokenLabel} />,
title: stringGetter({ key: 'NOTIFICATIONS.INCENTIVES_SEASON_BEGUN.TITLE' }),
title: stringGetter({
key: 'NOTIFICATIONS.INCENTIVES_SEASON_BEGUN.TITLE',
params: { SEASON_NUMBER: '4' },
}),
body: stringGetter({
key: 'NOTIFICATIONS.INCENTIVES_SEASON_BEGUN.BODY',
params: {
SEASON_NUMBER: '4',
PREV_SEASON_NUMBER: '2',
DYDX_AMOUNT: '16',
USDC_AMOUNT: '50',
Expand Down
Loading

0 comments on commit 9477f99

Please sign in to comment.