44 usePayProjectModal ,
55} from './hooks/usePayProjectModal/usePayProjectModal'
66import { Trans , t } from '@lingui/macro'
7+ import { emitErrorNotification , emitInfoNotification } from 'utils/notifications'
78import { useEffect , useState } from 'react'
89import { useProjectDispatch , useProjectSelector } from '../../redux/hooks'
910
@@ -15,11 +16,11 @@ import Image from 'next/legacy/image'
1516import { JuiceModal } from 'components/modals/JuiceModal'
1617import { MessageSection } from './components/MessageSection'
1718import { ReceiveSection } from './components/ReceiveSection'
18- import { emitInfoNotification } from 'utils/notifications'
1919import { helpPagePath } from 'utils/helpPagePath'
2020import { payRedeemActions } from '../../redux/payRedeemSlice'
2121import { twMerge } from 'tailwind-merge'
2222import { usePayAmounts } from './hooks/usePayAmounts'
23+ import { useProjectIsOFACListed } from 'hooks/useProjectIsOFACListed'
2324import { useSuckers } from 'juice-sdk-react'
2425import { useV4UserNftCredits } from 'packages/v4/contexts/V4UserNftCreditsProvider'
2526import { useWallet } from 'hooks/Wallet'
@@ -44,6 +45,8 @@ export const PayProjectModal: React.FC = () => {
4445 useState < JBChainId > ( defaultChainId )
4546 const dispatch = useProjectDispatch ( )
4647 const { data : suckers } = useSuckers ( )
48+ const { isAddressListedInOFAC, isLoading : isOFACLoading } =
49+ useProjectIsOFACListed ( )
4750
4851 useEffect ( ( ) => {
4952 setSelectedChainId ( defaultChainId )
@@ -70,6 +73,12 @@ export const PayProjectModal: React.FC = () => {
7073 } }
7174 validationSchema = { validationSchema }
7275 onSubmit = { async ( values , actions ) => {
76+ if ( isAddressListedInOFAC ) {
77+ emitErrorNotification (
78+ t `You can't pay this project because your wallet address failed a compliance check set up by the project owner.` ,
79+ )
80+ return
81+ }
7382 const walletConnectedToWrongChain = selectedChainId !== walletChainId
7483 if ( walletConnectedToWrongChain ) {
7584 await changeNetworks ( selectedChainId as JBChainId )
@@ -99,7 +108,7 @@ export const PayProjectModal: React.FC = () => {
99108 buttonPosition = "stretch"
100109 title = { t `Pay ${ projectName } ` }
101110 position = "top"
102- okLoading = { props . isSubmitting || isTransactionPending }
111+ okLoading = { props . isSubmitting || isTransactionPending || isOFACLoading }
103112 okButtonForm = "PayProjectModalForm"
104113 okText = {
105114 walletConnectedToWrongChain
@@ -118,6 +127,7 @@ export const PayProjectModal: React.FC = () => {
118127 setOpen ( false )
119128 setTimeout ( ( ) => props . resetForm ( ) , 300 )
120129 } }
130+ disableOkButton = { Boolean ( isAddressListedInOFAC ) }
121131 >
122132 { isTransactionPending ? (
123133 < div className = "flex h-full w-full flex-col items-center justify-center" >
0 commit comments