Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: clean up ofac #4169

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Footer } from 'components/Footer/Footer'
import { TransactionProvider } from 'contexts/Transaction/TransactionProvider'
import { useHasNftRewards } from 'hooks/JB721Delegate/useHasNftRewards'
import { useIsJuicecrowd } from 'hooks/v2v3/useIsJuiceCrowd'
import { useMemo } from 'react'
import { twMerge } from 'tailwind-merge'
import { BlockedProjectBanner } from './components/BlockedProjectBanner'
import { Cart } from './components/Cart/Cart'
Expand All @@ -21,17 +20,11 @@ import { useProjectPageQueries } from './hooks/useProjectPageQueries'

export const ProjectDashboard = () => {
const { projectPayReceipt } = useProjectPageQueries()

const { value: hasNftRewards } = useHasNftRewards()
const isJuicecrowd = useIsJuicecrowd()
const shouldShowNftCard = useMemo(() => {
// disable juicecrowd nft rewards
if (isJuicecrowd) {
return false
}

return hasNftRewards
}, [hasNftRewards, isJuicecrowd])
// disable juicecrowd nft rewards
const shouldShowNftCard = isJuicecrowd ? false : hasNftRewards

return (
<TransactionProvider>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,19 @@
import { useMemo } from 'react'
import { Button, Tooltip } from 'antd'
import { t, Trans } from '@lingui/macro'

import { Trans } from '@lingui/macro'
import { Button } from 'antd'
import { useCartSummary } from '../hooks/useCartSummary'
import { useProjectIsOFACListed } from '../../../hooks/useProjectIsOFACListed'

export const SummaryPayButton = ({ className }: { className?: string }) => {
const { payProject, walletConnected } = useCartSummary()
const { isAddressListedInOFAC, isLoading: isOFACChecking } =
useProjectIsOFACListed()

const isLoading = useMemo(() => {
return Boolean(walletConnected && isOFACChecking)
}, [walletConnected, isOFACChecking])

const isDisabled = useMemo(() => {
return Boolean(walletConnected && isAddressListedInOFAC)
}, [isAddressListedInOFAC, walletConnected])

return (
<Tooltip
title={t`You can't pay this project because your wallet address failed compliance check.`}
placement="top"
open={isDisabled ? undefined : false}
>
<Button
className={className}
type="primary"
onClick={payProject}
loading={isLoading}
disabled={isDisabled}
>
<span>
{walletConnected ? (
<Trans>Pay project</Trans>
) : (
<Trans>Connect wallet</Trans>
)}
</span>
</Button>
</Tooltip>
<Button className={className} type="primary" onClick={payProject}>
<span>
{walletConnected ? (
<Trans>Pay project</Trans>
) : (
<Trans>Connect wallet</Trans>
)}
</span>
</Button>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ export function NftReward({
hideAttributes,
}: NftRewardProps) {
const [previewVisible, setPreviewVisible] = useState<boolean>(false)

const cart = useProjectCart()
const nftsEnabledForPay = useNftRewardsEnabledForPay()

const { fundingCycleMetadata } = useProjectContext()
const { isAddressListedInOFAC } = useProjectIsOFACListed()
const { isAddressListedInOFAC, isLoading: isOFACLoading } =
useProjectIsOFACListed()

const quantitySelected = useMemo(
() => cart.nftRewards.find(nft => nft.id === rewardTier?.id)?.quantity ?? 0,
Expand Down Expand Up @@ -75,14 +76,15 @@ export function NftReward({
!hasRemainingSupply ||
!nftsEnabledForPay ||
fundingCycleMetadata?.pausePay ||
isAddressListedInOFAC ||
(!isOFACLoading && isAddressListedInOFAC) ||
isJuicecrowdNft
)
}, [
hasRemainingSupply,
nftsEnabledForPay,
fundingCycleMetadata?.pausePay,
isAddressListedInOFAC,
isOFACLoading,
isJuicecrowdNft,
])
const disabledReason = useMemo(() => {
Expand All @@ -92,7 +94,7 @@ export function NftReward({
if (isJuicecrowdNft)
return t`This project's NFTs can only be purchased on juicecrowd.gg.`
if (isAddressListedInOFAC)
return t`NFTs can't be purchased because your wallet address failed compliance check.`
return t`NFTs can't be purchased because your wallet address failed the compliance check.`
}, [
isJuicecrowdNft,
nftsEnabledForPay,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { useMemo } from 'react'

import {
NoSymbolIcon,
QuestionMarkCircleIcon,
Expand All @@ -12,6 +10,7 @@ import { Formik } from 'formik'
import { useV2BlockedProject } from 'hooks/useBlockedProject'
import { useIsJuicecrowd } from 'hooks/v2v3/useIsJuiceCrowd'
import { V2V3CurrencyOption } from 'models/v2v3/currencyOption'
import { useMemo } from 'react'
import { twMerge } from 'tailwind-merge'
import { V2V3_CURRENCY_ETH } from 'utils/v2v3/currency'
import { DisplayCard } from '../ui/DisplayCard'
Expand All @@ -20,7 +19,8 @@ import { TokensPerEth } from './components/TokensPerEth'

export const PayProjectCard = ({ className }: { className?: string }) => {
const isBlockedProject = useV2BlockedProject()
const { isAddressListedInOFAC } = useProjectIsOFACListed()
const { isAddressListedInOFAC, isLoading: isOFACLoading } =
useProjectIsOFACListed()
const { validationSchema, paymentsPaused, addPay } = usePayProjectCard()
const determiningIfProjectCanReceivePayments = paymentsPaused === undefined

Expand All @@ -30,11 +30,12 @@ export const PayProjectCard = ({ className }: { className?: string }) => {
return (
paymentsPaused ||
isBlockedProject ||
isAddressListedInOFAC ||
(!isOFACLoading && isAddressListedInOFAC) ||
isJuicecrowdProject
)
}, [
isAddressListedInOFAC,
isOFACLoading,
paymentsPaused,
isBlockedProject,
isJuicecrowdProject,
Expand All @@ -50,7 +51,7 @@ export const PayProjectCard = ({ className }: { className?: string }) => {

if (isAddressListedInOFAC) {
return {
title: t`You can't pay this project because your wallet address failed compliance check.`,
title: t`You can't pay this project because your wallet address failed the compliance check.`,
open: undefined,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ import { TokensPanel } from '../TokensPanel/TokensPanel'
import { UpdatesPanel } from '../UpdatesPanel/UpdatesPanel'
import { ProjectTab } from '../ui/ProjectTab'

type ProjectTabConfig = {
id: string
name: JSX.Element | string
panel: JSX.Element | string
hideTab?: boolean
}

export const ProjectTabs = ({ className }: { className?: string }) => {
const { projectUpdates } = useContext(ProjectUpdatesContext)
const { projectPageTab, setProjectPageTab } = useProjectPageQueries()
Expand Down Expand Up @@ -65,7 +72,7 @@ export const ProjectTabs = ({ className }: { className?: string }) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [projectPageTab])

const tabs = useMemo(
const tabs: ProjectTabConfig[] = useMemo(
() => [
{ id: 'activity', name: t`Activity`, panel: <ActivityPanel /> },
{ id: 'about', name: t`About`, panel: <AboutPanel /> },
Expand Down
1 change: 1 addition & 0 deletions src/contexts/v2v3/V2V3ProjectMetadataProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default function V2V3ProjectMetadataProvider({
projectId: number
}>) {
const hasMetadata = Boolean(metadata)
console.info('🧃 Server metadata', metadata)

// only load metadata if it hasn't been previously loaded into the prop.
const { data: metadataCid, refetchValue } = useProjectMetadataContent(
Expand Down
5 changes: 4 additions & 1 deletion src/contexts/v2v3/V2V3ProjectOFACProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ export default function V2V3ProjectOFACProvider({
const { userAddress, isConnected } = useWallet()
const { projectMetadata } = useProjectMetadata()

const enabled = projectMetadata?.projectRequiredOFACCheck && isConnected

const { data: isAddressListedInOFAC, isLoading } = useQuery(
['isAddressListedInOFAC', userAddress],
async () => {
if (!(projectMetadata?.projectRequiredOFACCheck && isConnected)) {
if (!enabled) {
return
}

Expand All @@ -46,6 +48,7 @@ export default function V2V3ProjectOFACProvider({
return true
}
},
{ enabled },
)

return (
Expand Down
4 changes: 3 additions & 1 deletion src/hooks/useProjectMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export function useProjectMetadata(uri: string | null | undefined) {
}

const response = await ipfsGet<AnyProjectMetadata>(uri)
return consolidateMetadata(response.data)
const metadata = consolidateMetadata(response.data)
console.info('📗 Project metadata', consolidateMetadata)
return metadata
},
{
enabled: !!uri,
Expand Down
12 changes: 6 additions & 6 deletions src/locales/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -1421,9 +1421,6 @@ msgstr ""
msgid "Collection Symbol"
msgstr ""

msgid "NFTs can't be purchased because your wallet address failed compliance check."
msgstr ""

msgid "Check this to mint {tokenSymbol} ERC-20 to your wallet. Leave unchecked to have the Juicebox protocol internally track your token balance, saving gas on this transaction. You can claim your ERC-20 tokens later."
msgstr ""

Expand Down Expand Up @@ -2234,6 +2231,9 @@ msgstr ""
msgid "Highest paid"
msgstr ""

msgid "You can't pay this project because your wallet address failed the compliance check."
msgstr ""

msgid "Community owned"
msgstr ""

Expand Down Expand Up @@ -2429,9 +2429,6 @@ msgstr ""
msgid "When enabled, fees are held in the project instead of being processed automatically. <0>Learn more.</0>"
msgstr ""

msgid "You can't pay this project because your wallet address failed compliance check."
msgstr ""

msgid "No, keep"
msgstr ""

Expand Down Expand Up @@ -3668,6 +3665,9 @@ msgstr ""
msgid "Select NFTs to redeem"
msgstr ""

msgid "NFTs can't be purchased because your wallet address failed the compliance check."
msgstr ""

msgid "A contract which defines custom behavior which can be used when somebody pays this project or redeems from it. <0>Learn more</0>"
msgstr ""

Expand Down