Skip to content

Commit 8834920

Browse files
authored
feat: CP-12572 add function checking, remove but from testnet (#517)
1 parent c22b6f6 commit 8834920

File tree

2 files changed

+34
-19
lines changed

2 files changed

+34
-19
lines changed

apps/next/src/pages/Portfolio/components/PortfolioHome/components/PortolioDetails/components/PortfolioActionButtons.tsx

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { MdAdd } from 'react-icons/md';
1111
import { useHistory } from 'react-router-dom';
1212

1313
import { getBridgePath, getSendPath, getSwapPath } from '@/config/routes';
14+
import { FunctionNames, useIsFunctionAvailable } from '@core/ui';
1415

1516
const onNotImplementedClick = (e: React.MouseEvent<HTMLButtonElement>) => {
1617
e.preventDefault();
@@ -27,34 +28,48 @@ const ICON_SIZE = 19.2;
2728

2829
export const PortfolioActionButtons = () => {
2930
const { push } = useHistory();
31+
const { checkIsFunctionSupported } = useIsFunctionAvailable();
32+
33+
const isSwapSupported = checkIsFunctionSupported(FunctionNames.SWAP);
34+
const isBuySupported = checkIsFunctionSupported(FunctionNames.BUY);
35+
36+
let delay = 0;
37+
const getDelay = () => (delay += 300);
38+
3039
return (
3140
<Stack direction="row" gap={1} width="100%">
3241
{/* TODO: create the proper animation */}
33-
<Slide direction="left" in timeout={300} easing="ease-out">
42+
<Slide direction="left" in timeout={getDelay()} easing="ease-out">
3443
<SquareButton
3544
variant="extension"
3645
icon={<SendIcon size={ICON_SIZE} />}
3746
label="Send"
3847
onClick={() => push(getSendPath())}
3948
/>
4049
</Slide>
41-
<Slide direction="left" in timeout={600} easing="ease-out">
42-
<SquareButton
43-
variant="extension"
44-
icon={<SwapIcon size={ICON_SIZE} />}
45-
label="Swap"
46-
onClick={() => push(getSwapPath())}
47-
/>
48-
</Slide>
49-
<Slide direction="left" in timeout={900} easing="ease-out">
50-
<SquareButton
51-
variant="extension"
52-
icon={<MdAdd size={ICON_SIZE} />}
53-
label="Buy"
54-
onClick={onNotImplementedClick}
55-
/>
56-
</Slide>
57-
<Slide direction="left" in timeout={1200} easing="ease-out">
50+
51+
{isSwapSupported && (
52+
<Slide direction="left" in timeout={getDelay()} easing="ease-out">
53+
<SquareButton
54+
variant="extension"
55+
icon={<SwapIcon size={ICON_SIZE} />}
56+
label="Swap"
57+
onClick={() => push(getSwapPath())}
58+
/>
59+
</Slide>
60+
)}
61+
62+
{isBuySupported && (
63+
<Slide direction="left" in timeout={getDelay()} easing="ease-out">
64+
<SquareButton
65+
variant="extension"
66+
icon={<MdAdd size={ICON_SIZE} />}
67+
label="Buy"
68+
onClick={onNotImplementedClick}
69+
/>
70+
</Slide>
71+
)}
72+
<Slide direction="left" in timeout={getDelay()} easing="ease-out">
5873
<SquareButton
5974
variant="extension"
6075
icon={<BridgeIcon size={ICON_SIZE} />}

packages/ui/src/hooks/useIsFunctionAvailable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ const enabledFeatures = {
168168
ChainId.ETHEREUM_HOMESTEAD,
169169
ChainId.SOLANA_MAINNET_ID,
170170
],
171-
Buy: [ChainId.AVALANCHE_MAINNET_ID, ChainId.AVALANCHE_TESTNET_ID],
171+
Buy: [ChainId.AVALANCHE_MAINNET_ID],
172172
};
173173

174174
/**

0 commit comments

Comments
 (0)