From af6443c13d88bb9f073c3a13483e4a2fd0249361 Mon Sep 17 00:00:00 2001 From: Edgar Khanzadian Date: Mon, 18 Dec 2023 14:35:08 +0400 Subject: [PATCH] fix: only show swaps option on mainnet, closes #4687 --- .../pages/home/components/account-actions.tsx | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/app/pages/home/components/account-actions.tsx b/src/app/pages/home/components/account-actions.tsx index 6d3ac41225c..772ede5f61f 100644 --- a/src/app/pages/home/components/account-actions.tsx +++ b/src/app/pages/home/components/account-actions.tsx @@ -1,12 +1,15 @@ import { useLocation, useNavigate } from 'react-router-dom'; +import { ChainID } from '@stacks/transactions'; import { HomePageSelectors } from '@tests/selectors/home.selectors'; import { Flex, FlexProps } from 'leather-styles/jsx'; import { RouteUrls } from '@shared/route-urls'; +import { whenStacksChainId } from '@app/common/utils'; import { useConfigBitcoinEnabled } from '@app/query/common/remote-config/remote-config.query'; import { useCurrentStacksAccount } from '@app/store/accounts/blockchain/stacks/stacks-account.hooks'; +import { useCurrentNetwork } from '@app/store/networks/networks.selectors'; import { ArrowDownIcon } from '@app/ui/components/icons/arrow-down-icon'; import { PlusIcon } from '@app/ui/components/icons/plus-icon'; import { SwapIcon } from '@app/ui/components/icons/swap-icon'; @@ -19,6 +22,7 @@ export function AccountActions(props: FlexProps) { const location = useLocation(); const isBitcoinEnabled = useConfigBitcoinEnabled(); const stacksAccount = useCurrentStacksAccount(); + const currentNetwork = useCurrentNetwork(); const receivePath = isBitcoinEnabled ? RouteUrls.Receive @@ -42,13 +46,17 @@ export function AccountActions(props: FlexProps) { onClick={() => navigate(RouteUrls.FundChooseCurrency)} /> )} - - } - label="Swap" - onClick={() => navigate(RouteUrls.Swap)} - /> + {whenStacksChainId(currentNetwork.chain.stacks.chainId)({ + [ChainID.Mainnet]: ( + } + label="Swap" + onClick={() => navigate(RouteUrls.Swap)} + /> + ), + [ChainID.Testnet]: null, + })} ); }