Skip to content

Commit

Permalink
fix: re-enable swaps for counterfactual safes
Browse files Browse the repository at this point in the history
CowSwap should now be able to detect once a counterfactual safe is deployed, so we can safely re-enable swaps for counterfactual safes.
  • Loading branch information
compojoom committed May 28, 2024
1 parent ae506ee commit 8626216
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
4 changes: 1 addition & 3 deletions src/components/balances/AssetsTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { TxModalContext } from '@/components/tx-flow'
import { TokenTransferFlow } from '@/components/tx-flow/flows'
import AddFundsCTA from '@/components/common/AddFunds'
import SwapButton from '@/features/swap/components/SwapButton'
import useIsCounterfactualSafe from '@/features/counterfactual/hooks/useIsCounterfactualSafe'

const skeletonCells: EnhancedTableProps['rows'][0]['cells'] = {
asset: {
Expand Down Expand Up @@ -134,8 +133,7 @@ const AssetsTable = ({
const hiddenAssets = useHiddenTokens()
const { balances, loading } = useBalances()
const { setTxFlow } = useContext(TxModalContext)
const isCounterfactualSafe = useIsCounterfactualSafe()
const isSwapFeatureEnabled = useHasFeature(FEATURES.NATIVE_SWAPS) && !isCounterfactualSafe
const isSwapFeatureEnabled = useHasFeature(FEATURES.NATIVE_SWAPS)

const { isAssetSelected, toggleAsset, hidingAsset, hideAsset, cancel, deselectAll, saveChanges } = useHideAssets(() =>
setShowHiddenAssets(false),
Expand Down
13 changes: 2 additions & 11 deletions src/components/sidebar/SidebarNavigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { useCurrentChain } from '@/hooks/useChains'
import { FeatureRoutes, hasFeature } from '@/utils/chains'
import { trackEvent } from '@/services/analytics'
import { SWAP_EVENTS, SWAP_LABELS } from '@/services/analytics/events/swaps'
import useIsCounterfactualSafe from '@/features/counterfactual/hooks/useIsCounterfactualSafe'

const getSubdirectory = (pathname: string): string => {
return pathname.split('/')[1]
Expand All @@ -37,17 +36,9 @@ const Navigation = (): ReactElement => {
const { safe } = useSafeInfo()
const currentSubdirectory = getSubdirectory(router.pathname)
const queueSize = useQueuedTxsLength()
const isCounterFactualSafe = useIsCounterfactualSafe()
const enabledNavItems = useMemo(() => {
return navItems.filter((item) => {
const enabled = isRouteEnabled(item.href, chain)

if (item.href === AppRoutes.swap && isCounterFactualSafe) {
return false
}
return enabled
})
}, [chain, isCounterFactualSafe])
return navItems.filter((item) => isRouteEnabled(item.href, chain))
}, [chain])

const getBadge = (item: NavItem) => {
// Indicate whether the current Safe needs an upgrade
Expand Down
4 changes: 1 addition & 3 deletions src/features/counterfactual/FirstTxFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@ import SafeLogo from '@/public/images/logo-no-text.svg'
import HandymanOutlinedIcon from '@mui/icons-material/HandymanOutlined'
import { useHasFeature } from '@/hooks/useChains'
import { FEATURES } from '@/utils/chains'
import useIsCounterfactualSafe from '@/features/counterfactual/hooks/useIsCounterfactualSafe'

const FirstTxFlow = ({ open, onClose }: { open: boolean; onClose: () => void }) => {
const txBuilder = useTxBuilderApp()
const router = useRouter()
const { setTxFlow } = useContext(TxModalContext)
const supportsRecovery = useIsRecoverySupported()
const [recovery] = useRecovery()
const isCounterfactualSafe = useIsCounterfactualSafe()
const isSwapFeatureEnabled = useHasFeature(FEATURES.NATIVE_SWAPS) && !isCounterfactualSafe
const isSwapFeatureEnabled = useHasFeature(FEATURES.NATIVE_SWAPS)

const handleClick = (onClick: () => void) => {
onClose()
Expand Down

0 comments on commit 8626216

Please sign in to comment.