From c7d15f55ce3d8051cb0abe01b8a8915c2142d24d Mon Sep 17 00:00:00 2001 From: Alfetopito Date: Thu, 2 Nov 2023 16:39:53 +0000 Subject: [PATCH 1/2] feat(permit): remove permit related feature flags --- .../hooks/featureFlags/useIsPermitEnabled.ts | 21 ++----------------- .../permit/hooks/useIsTokenPermittable.ts | 2 +- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/apps/cowswap-frontend/src/common/hooks/featureFlags/useIsPermitEnabled.ts b/apps/cowswap-frontend/src/common/hooks/featureFlags/useIsPermitEnabled.ts index 04e42129b7..af12f23fd8 100644 --- a/apps/cowswap-frontend/src/common/hooks/featureFlags/useIsPermitEnabled.ts +++ b/apps/cowswap-frontend/src/common/hooks/featureFlags/useIsPermitEnabled.ts @@ -1,25 +1,8 @@ -import { SupportedChainId } from '@cowprotocol/cow-sdk' import { useIsSmartContractWallet } from '@cowprotocol/wallet' -import { useFeatureFlags } from './useFeatureFlags' - -export function useIsPermitEnabled(chainId: SupportedChainId | undefined): boolean { +export function useIsPermitEnabled(): boolean { const isSmartContractWallet = useIsSmartContractWallet() - const { permitEnabledMainnet, permitEnabledGoerli, permitEnabledGnosis } = useFeatureFlags() // Permit is only available for EOAs - if (isSmartContractWallet) { - return false - } - - switch (chainId) { - case SupportedChainId.MAINNET: - return !!permitEnabledMainnet - case SupportedChainId.GNOSIS_CHAIN: - return !!permitEnabledGnosis - case SupportedChainId.GOERLI: - return !!permitEnabledGoerli - default: - return false - } + return !isSmartContractWallet } diff --git a/apps/cowswap-frontend/src/modules/permit/hooks/useIsTokenPermittable.ts b/apps/cowswap-frontend/src/modules/permit/hooks/useIsTokenPermittable.ts index 834fc2af47..4fa95b0946 100644 --- a/apps/cowswap-frontend/src/modules/permit/hooks/useIsTokenPermittable.ts +++ b/apps/cowswap-frontend/src/modules/permit/hooks/useIsTokenPermittable.ts @@ -43,7 +43,7 @@ export function useIsTokenPermittable( // Avoid building permit info in the first place if order type is not supported const isPermitSupported = !!tradeType && ORDER_TYPE_SUPPORTS_PERMIT[tradeType] - const isPermitEnabled = useIsPermitEnabled(chainId) && isPermitSupported + const isPermitEnabled = useIsPermitEnabled() && isPermitSupported const addPermitInfo = useAddPermitInfo() const permitInfo = usePermitInfo(chainId, isPermitEnabled ? lowerCaseAddress : undefined) From aed609707f6932ce3b696b6a9df2c779d14cbd41 Mon Sep 17 00:00:00 2001 From: Alfetopito Date: Fri, 3 Nov 2023 15:05:32 +0000 Subject: [PATCH 2/2] refactor: remove unecessary variable --- .../src/common/hooks/featureFlags/useIsPermitEnabled.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/cowswap-frontend/src/common/hooks/featureFlags/useIsPermitEnabled.ts b/apps/cowswap-frontend/src/common/hooks/featureFlags/useIsPermitEnabled.ts index af12f23fd8..6f3280b551 100644 --- a/apps/cowswap-frontend/src/common/hooks/featureFlags/useIsPermitEnabled.ts +++ b/apps/cowswap-frontend/src/common/hooks/featureFlags/useIsPermitEnabled.ts @@ -1,8 +1,6 @@ import { useIsSmartContractWallet } from '@cowprotocol/wallet' export function useIsPermitEnabled(): boolean { - const isSmartContractWallet = useIsSmartContractWallet() - // Permit is only available for EOAs - return !isSmartContractWallet + return !useIsSmartContractWallet() }