diff --git a/src/components/common/BlockedAddress/index.tsx b/src/components/common/BlockedAddress/index.tsx
index e4817ea1f3..d083f289fa 100644
--- a/src/components/common/BlockedAddress/index.tsx
+++ b/src/components/common/BlockedAddress/index.tsx
@@ -19,8 +19,7 @@ export const BlockedAddress = ({ address }: { address?: string }): ReactElement
)
diff --git a/src/features/swap/index.tsx b/src/features/swap/index.tsx
index f65dc3f976..54bccd2737 100644
--- a/src/features/swap/index.tsx
+++ b/src/features/swap/index.tsx
@@ -20,10 +20,10 @@ import css from './styles.module.css'
import useSafeInfo from '@/hooks/useSafeInfo'
import useWallet from '@/hooks/wallets/useWallet'
import BlockedAddress from '@/components/common/BlockedAddress'
-import { isBlockedAddress } from '@/services/ofac'
import useSwapConsent from './useSwapConsent'
import Disclaimer from '@/components/common/Disclaimer'
import LegalDisclaimerContent from '@/components/common/LegalDisclaimerContent'
+import { isBlockedAddress } from '@/services/ofac'
import { selectSwapParams, setSwapParams, type SwapState } from './store/swapParamsSlice'
import { setSwapOrder } from '@/store/swapOrderSlice'
@@ -50,11 +50,20 @@ const SwapWidget = ({ sell }: Params) => {
const isSwapFeatureEnabled = useHasFeature(FEATURES.NATIVE_SWAPS)
const swapParams = useAppSelector(selectSwapParams)
const { tradeType } = swapParams
-
const { safeAddress, safeLoading } = useSafeInfo()
+ const [blockedAddress, setBlockedAddress] = useState('')
const wallet = useWallet()
const { isConsentAccepted, onAccept } = useSwapConsent()
+ useEffect(() => {
+ if (isBlockedAddress(safeAddress)) {
+ setBlockedAddress(safeAddress)
+ }
+ if (wallet?.address && isBlockedAddress(wallet.address)) {
+ setBlockedAddress(wallet.address)
+ }
+ }, [safeAddress, wallet?.address])
+
const appData: SafeAppData = useMemo(
() => ({
id: 1,
@@ -127,8 +136,12 @@ const SwapWidget = ({ sell }: Params) => {
{
event: CowEvents.ON_CHANGE_TRADE_PARAMS,
handler: (newTradeParams) => {
- const { orderType: tradeType } = newTradeParams
+ const { orderType: tradeType, recipient } = newTradeParams
dispatch(setSwapParams({ tradeType }))
+
+ if (recipient && isBlockedAddress(recipient)) {
+ setBlockedAddress(recipient)
+ }
},
},
]
@@ -203,11 +216,8 @@ const SwapWidget = ({ sell }: Params) => {
return null
}
- if (isBlockedAddress(safeAddress)) {
- return
- }
- if (wallet?.address && isBlockedAddress(wallet.address)) {
- return
+ if (blockedAddress) {
+ return
}
if (!isConsentAccepted) {