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

Dev blocked projects and block Metakeys copy-cat #4067

Merged
merged 2 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions src/components/ProjectDashboard/ProjectDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Footer } from 'components/Footer'
import { TransactionProvider } from 'contexts/Transaction/TransactionProvider'
import { useHasNftRewards } from 'hooks/JB721Delegate/useHasNftRewards'
import { twMerge } from 'tailwind-merge'
import { BlockedProjectBanner } from './components/BlockedProjectBanner'
import { Cart } from './components/Cart'
import { CoverPhoto } from './components/CoverPhoto'
import { CurrentBalanceCard } from './components/CurrentBalanceCard'
Expand Down Expand Up @@ -35,6 +36,7 @@ export const ProjectDashboard = () => {
<div className="flex w-full justify-center md:px-6">
<div className="flex w-full max-w-6xl flex-col">
<ProjectHeader className="mt-12 px-4 md:mt-4 md:px-0" />
<BlockedProjectBanner className="mt-10" />
<div
className={twMerge(
'mt-10 flex w-full flex-col gap-4 px-4 md:flex-row md:px-0',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Trans } from '@lingui/macro'
import Banner from 'components/Banner'
import ExternalLink from 'components/ExternalLink'
import { useBlockedProject } from 'hooks/useBlockedProject'

export function BlockedProjectBanner({ className }: { className?: string }) {
const isBlockedProject = useBlockedProject()
if (!isBlockedProject) return null

const delistingPolicyLink =
'https://github.com/peeldao/proposals/pull/42/files'
const discordLink = 'https://discord.gg/wFTh4QnDzk'

return (
<div className={className}>
<Banner
title={<Trans>Delisted project</Trans>}
body={
<Trans>
This project has been <strong>delisted</strong> for breaching our{' '}
<ExternalLink href={delistingPolicyLink}>policy</ExternalLink>.{' '}
<ExternalLink href={discordLink}>Get in touch</ExternalLink>.
</Trans>
}
variant="warning"
/>
</div>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Trans, t } from '@lingui/macro'
import { Button, Tooltip } from 'antd'
import { usePayProjectCard } from 'components/ProjectDashboard/hooks'
import { Formik } from 'formik'
import { useBlockedProject } from 'hooks/useBlockedProject'
import { V2V3CurrencyOption } from 'models/v2v3/currencyOption'
import { twMerge } from 'tailwind-merge'
import { V2V3_CURRENCY_ETH } from 'utils/v2v3/currency'
Expand All @@ -14,6 +15,8 @@ import { PayInput } from './components/PayInput'
import { TokensPerEth } from './components/TokensPerEth'

export const PayProjectCard = ({ className }: { className?: string }) => {
const isBlockedProject = useBlockedProject()

const { validationSchema, paymentsPaused, addPay } = usePayProjectCard()
const determiningIfProjectCanReceivePayments = paymentsPaused === undefined

Expand Down Expand Up @@ -74,7 +77,7 @@ export const PayProjectCard = ({ className }: { className?: string }) => {
>
<Button
loading={determiningIfProjectCanReceivePayments}
disabled={paymentsPaused}
disabled={paymentsPaused || isBlockedProject}
htmlType="submit"
className="h-12 text-base"
style={{ height: '48px' }}
Expand Down
4 changes: 4 additions & 0 deletions src/constants/blocklist.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// List of delisted projects
export const BLOCKED_PROJECT_IDS = [
'564', //copycat of 563
Copy link
Contributor

@peripheralist peripheralist Sep 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll want these to be project ids (e.g. "2-564"), not projectIds (otherwise this would block a v1 project 564). we also want it to be specific to mainnet

Copy link
Contributor

@peripheralist peripheralist Sep 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or, we could copy the pattern used for archived projects (storing V2ArchivedProjectIdsByNetwork that are all pv == 2), but we need to add the pv == 2 statement in the filter. archived project lists are network-specific

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image image

]
11 changes: 11 additions & 0 deletions src/hooks/useBlockedProject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { BLOCKED_PROJECT_IDS } from 'constants/blocklist'
import { ProjectMetadataContext } from 'contexts/shared/ProjectMetadataContext'
import { useContext } from 'react'

export const useBlockedProject = () => {
const { projectId } = useContext(ProjectMetadataContext)
const isBlockedProject = projectId
? BLOCKED_PROJECT_IDS.includes(projectId?.toString())
: false
return isBlockedProject
}
13 changes: 11 additions & 2 deletions src/hooks/useProjects.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios from 'axios'
import { BLOCKED_PROJECT_IDS } from 'constants/blocklist'
import { BigNumber } from 'ethers'
import { DBProject, DBProjectQueryOpts, DBProjectRow } from 'models/dbProject'
import { Json } from 'models/json'
Expand Down Expand Up @@ -68,7 +69,13 @@ export function useDBProjectsInfiniteQuery(
pageSize,
})}`,
)
.then(res => (res.data ? res.data.map(parseDBProject) : []))
.then(res =>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds filters to "all" (same as the "new" query) and "trending" projects queries

res.data
? res.data
.map(parseDBProject)
.filter(project => !BLOCKED_PROJECT_IDS.includes(project.id))
: [],
)
},
{
staleTime: DEFAULT_STALE_TIME,
Expand All @@ -93,7 +100,9 @@ export function useTrendingProjects(count: number) {
'/api/projects/trending?count=' + count,
)

return res.data.map(parseDBProjectJson)
return res.data
.map(parseDBProjectJson)
.filter(project => !BLOCKED_PROJECT_IDS.includes(project.id))
})
}

Expand Down
6 changes: 6 additions & 0 deletions src/locales/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -1484,6 +1484,9 @@ msgstr ""
msgid "Custom strategy"
msgstr ""

msgid "Delisted project"
msgstr ""

msgid "If you use the default governance option (no governance), the voting weight will still be accessible on the blockchain for use in Snapshot strategies or any other desired purpose."
msgstr ""

Expand Down Expand Up @@ -3932,6 +3935,9 @@ msgstr ""
msgid "Duration"
msgstr ""

msgid "This project has been <0>delisted</0> for breaching our <1>policy</1>. <2>Get in touch</2>."
msgstr ""

msgid "Supporters will be sent to this page if they click the button on your pop-up. You can preview this below."
msgstr ""

Expand Down
Loading