diff --git a/functions/src/scripts/contest/scrape-ea.ts b/functions/src/scripts/contest/scrape-ea.ts new file mode 100644 index 00000000..e29e147d --- /dev/null +++ b/functions/src/scripts/contest/scrape-ea.ts @@ -0,0 +1,54 @@ +// Run with `npx ts-node src/scripts/contest/scrape-ea.ts` +import * as fs from 'fs' +import * as puppeteer from 'puppeteer' +import { CONTEST_DATA } from 'common/contest' + +export function scrapeEA(contestLink: string, fileName: string) { + ;(async () => { + const browser = await puppeteer.launch({ headless: true }) + const page = await browser.newPage() + await page.goto(contestLink) + + let loadMoreButton = await page.$('.LoadMore-root') + + while (loadMoreButton) { + await loadMoreButton.click() + await page.waitForNetworkIdle() + loadMoreButton = await page.$('.LoadMore-root') + } + + /* Run javascript inside the page */ + const data = await page.evaluate(() => { + const list = [] + const items = document.querySelectorAll('.PostsItem2-root') + + for (const item of items) { + let link = + 'https://forum.effectivealtruism.org' + + item?.querySelector('a')?.getAttribute('href') + + list.push({ + title: item?.querySelector('a>span>span')?.innerHTML, + author: item?.querySelector('a.UsersNameDisplay-userName')?.innerHTML, + link: link, + }) + } + + return list + }) + + fs.writeFileSync( + '../web/lib/util/contests/' + fileName + '.json', + JSON.stringify(data, null, 2) + ) + + console.log(data) + await browser.close() + })() +} + +// runs using data from CONTEST_DATA +scrapeEA( + CONTEST_DATA['cause-exploration-prize'].submissionLink, + CONTEST_DATA['cause-exploration-prize'].fileName +) diff --git a/web/lib/util/contests/causeExploration.json b/web/lib/util/contests/causeExploration.json new file mode 100644 index 00000000..f8dafb08 --- /dev/null +++ b/web/lib/util/contests/causeExploration.json @@ -0,0 +1,157 @@ +[ + { + "title": "New cause area: Violence against women and girls", + "author": "Akhil", + "link": "https://forum.effectivealtruism.org/posts/majcwf7i8pW8eMJ3v/new-cause-area-violence-against-women-and-girls" + }, + { + "title": "Open Philanthropy's Cause Exploration Prizes: $120k for written work on global health and wellbeing", + "author": "ChrisSmith", + "link": "https://forum.effectivealtruism.org/posts/iqcph4DbcP4PZGyDB/open-philanthropy-s-cause-exploration-prizes-usd120k-for" + }, + { + "title": "New cause area: training health workers to prevent newborn deaths", + "author": "Marshall", + "link": "https://forum.effectivealtruism.org/posts/B7wohgDDdwPoQAatt/new-cause-area-training-health-workers-to-prevent-newborn" + }, + { + "title": "The Case for Making Professional Degrees Undergraduate Degrees", + "author": "ColdButtonIssues", + "link": "https://forum.effectivealtruism.org/posts/fEMpAcNycbXpp6Ext/the-case-for-making-professional-degrees-undergraduate" + }, + { + "title": "Global Health & Development - Beyond the Streetlight", + "author": "Richard Sedlmayr", + "link": "https://forum.effectivealtruism.org/posts/DXKWHAkihdb6nkKyG/global-health-and-development-beyond-the-streetlight-1" + }, + { + "title": "Cause Exploration Prizes submission: bivalve aquaculture", + "author": "Brian Lui", + "link": "https://forum.effectivealtruism.org/posts/7keuWWMoYY6dMnqys/cause-exploration-prizes-submission-bivalve-aquaculture" + }, + { + "title": "Potential new cause area: Obesity", + "author": "Akhil", + "link": "https://forum.effectivealtruism.org/posts/jhsXxPnKbwzLwrKFq/potential-new-cause-area-obesity" + }, + { + "title": "Energy Access in Sub-Saharan Africa: Open Philanthropy Cause Exploration Prize Submission", + "author": "Tomer_Goloboy", + "link": "https://forum.effectivealtruism.org/posts/ZPjMemurtzeumwcdw/energy-access-in-sub-saharan-africa-open-philanthropy-cause" + }, + { + "title": "Sleep: Open Philanthropy Cause Exploration Prize", + "author": "SuhanKacholia", + "link": "https://forum.effectivealtruism.org/posts/qnDBN3nAXgwyTnrAC/sleep-open-philanthropy-cause-exploration-prize" + }, + { + "title": "Cause Exploration Prizes: Could New Technology Help Solve the Glasses Problem?", + "author": "Open Philanthropy", + "link": "https://forum.effectivealtruism.org/posts/a3vbQCgxTeYNvQBfc/cause-exploration-prizes-could-new-technology-help-solve-the" + }, + { + "title": "Cause Exploration Prizes: Expanding access to infertility services in Low- and Middle-Income Countries (LMICs)", + "author": "Soleine Scotney", + "link": "https://forum.effectivealtruism.org/posts/WAnJw5bhuQwhJiLTm/cause-exploration-prizes-expanding-access-to-infertility" + }, + { + "title": "New Cause Area: Demographic Collapse", + "author": "Malcolm Collins", + "link": "https://forum.effectivealtruism.org/posts/vFfoqL74kmZbydKjp/new-cause-area-demographic-collapse" + }, + { + "title": "Cause area: climate adaptation in low-income countries", + "author": "karthik-t", + "link": "https://forum.effectivealtruism.org/posts/nE827LwrRk5ep3Xao/cause-area-climate-adaptation-in-low-income-countries" + }, + { + "title": "Open Climate Data as a possible cause area, Open Philanthropy", + "author": "Ben Yeoh", + "link": "https://forum.effectivealtruism.org/posts/s9HPpvMHgS5QYEM4C/open-climate-data-as-a-possible-cause-area-open-philanthropy" + }, + { + "title": "One Million Missing Children", + "author": "ColdButtonIssues", + "link": "https://forum.effectivealtruism.org/posts/H5LDwwmdBYBDNXTq4/one-million-missing-children" + }, + { + "title": "Cause Exploration Prizes: Reducing Suffering and Long Term Risk in Common Law Nations via Strategic Case Law Funding", + "author": "Open Philanthropy", + "link": "https://forum.effectivealtruism.org/posts/C6urjnDeKjHGwf2M3/cause-exploration-prizes-reducing-suffering-and-long-term" + }, + { + "title": "NEW GLOBAL POOLS: IMPACT FUNDS ", + "author": "TPogge", + "link": "https://forum.effectivealtruism.org/posts/J8fwT9cZd6x5eED3e/new-global-pools-impact-funds" + }, + { + "title": "Saving lives near the precipice: we're doing it wrong?", + "author": "Samin", + "link": "https://forum.effectivealtruism.org/posts/hz2Q8GgZ28YKLazGb/saving-lives-near-the-precipice-we-re-doing-it-wrong" + }, + { + "title": "A platform for on-demand vaccination", + "author": "George3d6", + "link": "https://forum.effectivealtruism.org/posts/rS2zWRDxw5vZwdQAC/a-platform-for-on-demand-vaccination" + }, + { + "title": "Cause Exploration Prizes: Time-restricted eating (IF) for individual and community health in LMICs ", + "author": "Open Philanthropy", + "link": "https://forum.effectivealtruism.org/posts/RuwCxvJ3xEwQfZevN/cause-exploration-prizes-time-restricted-eating-if-for" + }, + { + "title": "Cause Exploration Prizes: Misinformation Gone Viral: Education As Pandemic Prevention", + "author": "Open Philanthropy", + "link": "https://forum.effectivealtruism.org/posts/Whi5ADu79uJrTpqEt/cause-exploration-prizes-misinformation-gone-viral-education" + }, + { + "title": "Cause Exploration Prizes: Publishing Comprehensive Books Which Make the Case for Effective Corporate Animal Welfare Campaigns via a Writing Contest for Potential Authors", + "author": "Engin Arıkan", + "link": "https://forum.effectivealtruism.org/posts/9sraY9qrwuiKXJjhG/cause-exploration-prizes-publishing-comprehensive-books" + }, + { + "title": "Maritime capability and post-catastrophe resilience.", + "author": "Tom Gardiner", + "link": "https://forum.effectivealtruism.org/posts/nKDBhWFj3vwwFKwGC/maritime-capability-and-post-catastrophe-resilience-1" + }, + { + "title": "Shareholder activism", + "author": "sbehmer", + "link": "https://forum.effectivealtruism.org/posts/fqf4vgCWebTszvHm9/shareholder-activism" + }, + { + "title": "Water, sanitation and hygiene (“WASH”) interventions as a cause area", + "author": "helmetedhornbill", + "link": "https://forum.effectivealtruism.org/posts/WAbjLFkpSoA7FDvTD/water-sanitation-and-hygiene-wash-interventions-as-a-cause" + }, + { + "title": "Doing good is a privilege. This needs to change if we want to do good long-term. ", + "author": "SofiaBalderson", + "link": "https://forum.effectivealtruism.org/posts/gicYG5ymk4pPzrKAd/doing-good-is-a-privilege-this-needs-to-change-if-we-want-to" + }, + { + "title": "Deadline extension (to August 11) for Open Philanthropy's Cause Exploration Prizes", + "author": "ChrisSmith", + "link": "https://forum.effectivealtruism.org/posts/WdMbmLfb7DMMYHvKf/deadline-extension-to-august-11-for-open-philanthropy-s" + }, + { + "title": "Cause: Reducing Judicial Delay in India", + "author": "Vastav Ratra", + "link": "https://forum.effectivealtruism.org/posts/JcYyLfbnbhANCJdbv/cause-reducing-judicial-delay-in-india" + }, + { + "title": "Open Philanthropy Should Fund Further Cause Exploration", + "author": "brb243", + "link": "https://forum.effectivealtruism.org/posts/tvMjgDWptF5MNJtAo/open-philanthropy-should-fund-further-cause-exploration" + }, + { + "title": "Why Genetic Rescue", + "author": "David Lang", + "link": "https://forum.effectivealtruism.org/posts/ebBPcDxtSckRAoJfo/why-genetic-rescue" + }, + { + "title": "Promoting climate considerations within existing high priority areas of work", + "author": "helmetedhornbill", + "link": "https://forum.effectivealtruism.org/posts/pmfyGEa4NozDm2fng/promoting-climate-considerations-within-existing-high" + } +] \ No newline at end of file diff --git a/web/lib/util/contests/ea.json b/web/lib/util/contests/ea.json new file mode 100644 index 00000000..f8dafb08 --- /dev/null +++ b/web/lib/util/contests/ea.json @@ -0,0 +1,157 @@ +[ + { + "title": "New cause area: Violence against women and girls", + "author": "Akhil", + "link": "https://forum.effectivealtruism.org/posts/majcwf7i8pW8eMJ3v/new-cause-area-violence-against-women-and-girls" + }, + { + "title": "Open Philanthropy's Cause Exploration Prizes: $120k for written work on global health and wellbeing", + "author": "ChrisSmith", + "link": "https://forum.effectivealtruism.org/posts/iqcph4DbcP4PZGyDB/open-philanthropy-s-cause-exploration-prizes-usd120k-for" + }, + { + "title": "New cause area: training health workers to prevent newborn deaths", + "author": "Marshall", + "link": "https://forum.effectivealtruism.org/posts/B7wohgDDdwPoQAatt/new-cause-area-training-health-workers-to-prevent-newborn" + }, + { + "title": "The Case for Making Professional Degrees Undergraduate Degrees", + "author": "ColdButtonIssues", + "link": "https://forum.effectivealtruism.org/posts/fEMpAcNycbXpp6Ext/the-case-for-making-professional-degrees-undergraduate" + }, + { + "title": "Global Health & Development - Beyond the Streetlight", + "author": "Richard Sedlmayr", + "link": "https://forum.effectivealtruism.org/posts/DXKWHAkihdb6nkKyG/global-health-and-development-beyond-the-streetlight-1" + }, + { + "title": "Cause Exploration Prizes submission: bivalve aquaculture", + "author": "Brian Lui", + "link": "https://forum.effectivealtruism.org/posts/7keuWWMoYY6dMnqys/cause-exploration-prizes-submission-bivalve-aquaculture" + }, + { + "title": "Potential new cause area: Obesity", + "author": "Akhil", + "link": "https://forum.effectivealtruism.org/posts/jhsXxPnKbwzLwrKFq/potential-new-cause-area-obesity" + }, + { + "title": "Energy Access in Sub-Saharan Africa: Open Philanthropy Cause Exploration Prize Submission", + "author": "Tomer_Goloboy", + "link": "https://forum.effectivealtruism.org/posts/ZPjMemurtzeumwcdw/energy-access-in-sub-saharan-africa-open-philanthropy-cause" + }, + { + "title": "Sleep: Open Philanthropy Cause Exploration Prize", + "author": "SuhanKacholia", + "link": "https://forum.effectivealtruism.org/posts/qnDBN3nAXgwyTnrAC/sleep-open-philanthropy-cause-exploration-prize" + }, + { + "title": "Cause Exploration Prizes: Could New Technology Help Solve the Glasses Problem?", + "author": "Open Philanthropy", + "link": "https://forum.effectivealtruism.org/posts/a3vbQCgxTeYNvQBfc/cause-exploration-prizes-could-new-technology-help-solve-the" + }, + { + "title": "Cause Exploration Prizes: Expanding access to infertility services in Low- and Middle-Income Countries (LMICs)", + "author": "Soleine Scotney", + "link": "https://forum.effectivealtruism.org/posts/WAnJw5bhuQwhJiLTm/cause-exploration-prizes-expanding-access-to-infertility" + }, + { + "title": "New Cause Area: Demographic Collapse", + "author": "Malcolm Collins", + "link": "https://forum.effectivealtruism.org/posts/vFfoqL74kmZbydKjp/new-cause-area-demographic-collapse" + }, + { + "title": "Cause area: climate adaptation in low-income countries", + "author": "karthik-t", + "link": "https://forum.effectivealtruism.org/posts/nE827LwrRk5ep3Xao/cause-area-climate-adaptation-in-low-income-countries" + }, + { + "title": "Open Climate Data as a possible cause area, Open Philanthropy", + "author": "Ben Yeoh", + "link": "https://forum.effectivealtruism.org/posts/s9HPpvMHgS5QYEM4C/open-climate-data-as-a-possible-cause-area-open-philanthropy" + }, + { + "title": "One Million Missing Children", + "author": "ColdButtonIssues", + "link": "https://forum.effectivealtruism.org/posts/H5LDwwmdBYBDNXTq4/one-million-missing-children" + }, + { + "title": "Cause Exploration Prizes: Reducing Suffering and Long Term Risk in Common Law Nations via Strategic Case Law Funding", + "author": "Open Philanthropy", + "link": "https://forum.effectivealtruism.org/posts/C6urjnDeKjHGwf2M3/cause-exploration-prizes-reducing-suffering-and-long-term" + }, + { + "title": "NEW GLOBAL POOLS: IMPACT FUNDS ", + "author": "TPogge", + "link": "https://forum.effectivealtruism.org/posts/J8fwT9cZd6x5eED3e/new-global-pools-impact-funds" + }, + { + "title": "Saving lives near the precipice: we're doing it wrong?", + "author": "Samin", + "link": "https://forum.effectivealtruism.org/posts/hz2Q8GgZ28YKLazGb/saving-lives-near-the-precipice-we-re-doing-it-wrong" + }, + { + "title": "A platform for on-demand vaccination", + "author": "George3d6", + "link": "https://forum.effectivealtruism.org/posts/rS2zWRDxw5vZwdQAC/a-platform-for-on-demand-vaccination" + }, + { + "title": "Cause Exploration Prizes: Time-restricted eating (IF) for individual and community health in LMICs ", + "author": "Open Philanthropy", + "link": "https://forum.effectivealtruism.org/posts/RuwCxvJ3xEwQfZevN/cause-exploration-prizes-time-restricted-eating-if-for" + }, + { + "title": "Cause Exploration Prizes: Misinformation Gone Viral: Education As Pandemic Prevention", + "author": "Open Philanthropy", + "link": "https://forum.effectivealtruism.org/posts/Whi5ADu79uJrTpqEt/cause-exploration-prizes-misinformation-gone-viral-education" + }, + { + "title": "Cause Exploration Prizes: Publishing Comprehensive Books Which Make the Case for Effective Corporate Animal Welfare Campaigns via a Writing Contest for Potential Authors", + "author": "Engin Arıkan", + "link": "https://forum.effectivealtruism.org/posts/9sraY9qrwuiKXJjhG/cause-exploration-prizes-publishing-comprehensive-books" + }, + { + "title": "Maritime capability and post-catastrophe resilience.", + "author": "Tom Gardiner", + "link": "https://forum.effectivealtruism.org/posts/nKDBhWFj3vwwFKwGC/maritime-capability-and-post-catastrophe-resilience-1" + }, + { + "title": "Shareholder activism", + "author": "sbehmer", + "link": "https://forum.effectivealtruism.org/posts/fqf4vgCWebTszvHm9/shareholder-activism" + }, + { + "title": "Water, sanitation and hygiene (“WASH”) interventions as a cause area", + "author": "helmetedhornbill", + "link": "https://forum.effectivealtruism.org/posts/WAbjLFkpSoA7FDvTD/water-sanitation-and-hygiene-wash-interventions-as-a-cause" + }, + { + "title": "Doing good is a privilege. This needs to change if we want to do good long-term. ", + "author": "SofiaBalderson", + "link": "https://forum.effectivealtruism.org/posts/gicYG5ymk4pPzrKAd/doing-good-is-a-privilege-this-needs-to-change-if-we-want-to" + }, + { + "title": "Deadline extension (to August 11) for Open Philanthropy's Cause Exploration Prizes", + "author": "ChrisSmith", + "link": "https://forum.effectivealtruism.org/posts/WdMbmLfb7DMMYHvKf/deadline-extension-to-august-11-for-open-philanthropy-s" + }, + { + "title": "Cause: Reducing Judicial Delay in India", + "author": "Vastav Ratra", + "link": "https://forum.effectivealtruism.org/posts/JcYyLfbnbhANCJdbv/cause-reducing-judicial-delay-in-india" + }, + { + "title": "Open Philanthropy Should Fund Further Cause Exploration", + "author": "brb243", + "link": "https://forum.effectivealtruism.org/posts/tvMjgDWptF5MNJtAo/open-philanthropy-should-fund-further-cause-exploration" + }, + { + "title": "Why Genetic Rescue", + "author": "David Lang", + "link": "https://forum.effectivealtruism.org/posts/ebBPcDxtSckRAoJfo/why-genetic-rescue" + }, + { + "title": "Promoting climate considerations within existing high priority areas of work", + "author": "helmetedhornbill", + "link": "https://forum.effectivealtruism.org/posts/pmfyGEa4NozDm2fng/promoting-climate-considerations-within-existing-high" + } +] \ No newline at end of file diff --git a/web/pages/contest/[contestSlug]/[submissionSlug].tsx b/web/pages/contest/[contestSlug]/[submissionSlug].tsx new file mode 100644 index 00000000..bba785e0 --- /dev/null +++ b/web/pages/contest/[contestSlug]/[submissionSlug].tsx @@ -0,0 +1,293 @@ +import React, { useEffect, useState } from 'react' +import { ArrowLeftIcon } from '@heroicons/react/outline' + +import { useContractWithPreload } from 'web/hooks/use-contract' +import { ContractOverview } from 'web/components/contract/contract-overview' +import { BetPanel } from 'web/components/bet-panel' +import { Col } from 'web/components/layout/col' +import { useUser } from 'web/hooks/use-user' +import { ResolutionPanel } from 'web/components/resolution-panel' +import { Spacer } from 'web/components/layout/spacer' +import { + Contract, + getContractFromSlug, + tradingAllowed, + getBinaryProbPercent, + getContractFromId, +} from 'web/lib/firebase/contracts' +import { SEO } from 'web/components/SEO' +import { Page } from 'web/components/page' +import { Bet, listAllBets } from 'web/lib/firebase/bets' +import { Comment, listAllComments } from 'web/lib/firebase/comments' +import Custom404 from '../../404' +import { AnswersPanel } from 'web/components/answers/answers-panel' +import { fromPropz, usePropz } from 'web/hooks/use-propz' +import { ContractTabs } from 'web/components/contract/contract-tabs' +import { contractTextDetails } from 'web/components/contract/contract-details' +import { useWindowSize } from 'web/hooks/use-window-size' +import Confetti from 'react-confetti' +import { NumericBetPanel } from '../../../components/numeric-bet-panel' +import { NumericResolutionPanel } from '../../../components/numeric-resolution-panel' +import { useIsIframe } from 'web/hooks/use-is-iframe' +import ContractEmbedPage from '../../embed/[username]/[contractSlug]' +import { useBets } from 'web/hooks/use-bets' +import { CPMMBinaryContract } from 'common/contract' +import { AlertBox } from 'web/components/alert-box' +import { useTracking } from 'web/hooks/use-tracking' +import { useTipTxns } from 'web/hooks/use-tip-txns' +import { useLiquidity } from 'web/hooks/use-liquidity' +import { richTextToString } from 'common/util/parse' +import { useSaveReferral } from 'web/hooks/use-save-referral' +import { + ContractLeaderboard, + ContractTopTrades, +} from 'web/components/contract/contract-leaderboard' + +export const getStaticProps = fromPropz(getStaticPropz) +export async function getStaticPropz(props: { + params: { contestSlug: string; submissionSlug: string } +}) { + const { contestSlug, submissionSlug } = props.params + console.log(contestSlug) + const submission = (await getContractFromSlug(submissionSlug)) || null + const submissionId = submission?.id + + const [bets, comments] = await Promise.all([ + submissionId ? listAllBets(submissionId) : [], + submissionId ? listAllComments(submissionId) : [], + ]) + + return { + props: { + submission, + contestSlug, + // Limit the data sent to the client. Client will still load all bets and comments directly. + bets: bets.slice(0, 5000), + comments: comments.slice(0, 1000), + slug: submissionSlug, + }, + + revalidate: 60, // regenerate after a minute + } +} + +export async function getStaticPaths() { + return { paths: [], fallback: 'blocking' } +} + +export default function ContractPage(props: { + submission: Contract | null + contestSlug: string + bets: Bet[] + comments: Comment[] + slug: string + backToHome?: () => void +}) { + props = usePropz(props, getStaticPropz) ?? { + submission: null, + contestSlug: '', + bets: [], + comments: [], + slug: '', + } + + // const inIframe = useIsIframe() + // if (inIframe) { + // return + // } + + const { submission } = props + + if (!submission) { + return + } + + return +} + +export function SubmissionPageContent( + props: Parameters[0] & { submission: Contract } +) { + const { backToHome, comments } = props + + const contract = useContractWithPreload(props.submission) ?? props.submission + + useTracking('view market', { + slug: contract.slug, + contractId: contract.id, + creatorId: contract.creatorId, + }) + + const bets = useBets(contract.id) ?? props.bets + const liquidityProvisions = + useLiquidity(contract.id)?.filter((l) => !l.isAnte && l.amount > 0) ?? [] + // Sort for now to see if bug is fixed. + comments.sort((c1, c2) => c1.createdTime - c2.createdTime) + + const tips = useTipTxns({ contractId: contract.id }) + + const user = useUser() + + const { width, height } = useWindowSize() + + const [showConfetti, setShowConfetti] = useState(false) + + useEffect(() => { + const shouldSeeConfetti = !!( + user && + contract.creatorId === user.id && + Date.now() - contract.createdTime < 10 * 1000 + ) + setShowConfetti(shouldSeeConfetti) + }, [contract, user]) + + const { creatorId, isResolved, question, outcomeType } = contract + + const isCreator = user?.id === creatorId + const isBinary = outcomeType === 'BINARY' + const isPseudoNumeric = outcomeType === 'PSEUDO_NUMERIC' + const isNumeric = outcomeType === 'NUMERIC' + const allowTrade = tradingAllowed(contract) + const allowResolve = !isResolved && isCreator && !!user + const hasSidePanel = + (isBinary || isNumeric || isPseudoNumeric) && (allowTrade || allowResolve) + + const ogCardProps = getOpenGraphProps(contract) + + useSaveReferral(user, { + defaultReferrer: contract.creatorUsername, + contractId: contract.id, + }) + + const rightSidebar = hasSidePanel ? ( + + {allowTrade && + (isNumeric ? ( + + ) : ( + + ))} + {allowResolve && + (isNumeric || isPseudoNumeric ? ( + + ) : ( + + ))} + + ) : null + + return ( + + {showConfetti && ( + + )} + + {ogCardProps && ( + + )} + + + {backToHome && ( + + )} + + + + {isNumeric && ( + + )} + {/* + {(outcomeType === 'FREE_RESPONSE' || + outcomeType === 'MULTIPLE_CHOICE') && ( + <> + + + + + )} */} + + {isNumeric && allowTrade && ( + + )} + + {isResolved && ( + <> +
+ + +
+ + + )} + + + +
+ ) +} + +const getOpenGraphProps = (contract: Contract) => { + const { + resolution, + question, + creatorName, + creatorUsername, + outcomeType, + creatorAvatarUrl, + description: desc, + } = contract + const probPercent = + outcomeType === 'BINARY' ? getBinaryProbPercent(contract) : undefined + + const stringDesc = typeof desc === 'string' ? desc : richTextToString(desc) + + const description = resolution + ? `Resolved ${resolution}. ${stringDesc}` + : probPercent + ? `${probPercent} chance. ${stringDesc}` + : stringDesc + + return { + question, + probability: probPercent, + metadata: contractTextDetails(contract), + creatorName, + creatorUsername, + creatorAvatarUrl, + description, + } +}