diff --git a/functions/src/accept-challenge.ts b/functions/src/accept-challenge.ts
index 704c5b5c..9b135fe2 100644
--- a/functions/src/accept-challenge.ts
+++ b/functions/src/accept-challenge.ts
@@ -9,8 +9,8 @@ import { removeUndefinedProps } from '../../common/util/object'
import { Acceptance, Challenge } from '../../common/challenge'
import { CandidateBet } from '../../common/new-bet'
import { createChallengeAcceptedNotification } from './create-notification'
-import { noFees } from 'common/fees'
-import { formatMoney, formatPercent } from 'common/util/format'
+import { noFees } from '../../common/fees'
+import { formatMoney, formatPercent } from '../../common/util/format'
const bodySchema = z.object({
contractId: z.string(),
diff --git a/og-image/api/_lib/challenge-template.ts b/og-image/api/_lib/challenge-template.ts
index b09d9ca2..607c4bec 100644
--- a/og-image/api/_lib/challenge-template.ts
+++ b/og-image/api/_lib/challenge-template.ts
@@ -87,12 +87,13 @@ export function getChallengeHtml(parsedReq: ParsedRequest) {
fontSize,
question,
creatorName,
- // creatorUsername,
creatorAvatarUrl,
challengerAmount,
challengerOutcome,
creatorAmount,
creatorOutcome,
+ acceptedName,
+ acceptedAvatarUrl,
} = parsedReq
const MAX_QUESTION_CHARS = 85
const truncatedQuestion =
@@ -100,6 +101,8 @@ export function getChallengeHtml(parsedReq: ParsedRequest) {
? question.slice(0, MAX_QUESTION_CHARS) + '...'
: question
const hideAvatar = creatorAvatarUrl ? '' : 'hidden'
+ const hideAcceptedAvatar = acceptedAvatarUrl ? '' : 'hidden'
+ const accepted = acceptedName !== ''
return `
@@ -131,29 +134,40 @@ export function getChallengeHtml(parsedReq: ParsedRequest) {
/>
+
${'M$' + creatorAmount}
${'on'}
${creatorOutcome}
- ⚔️
+ VS
-
+
-
+
+
+
+

+
+
${'M$' + challengerAmount}
${'on'}
${challengerOutcome}
diff --git a/og-image/api/_lib/parser.ts b/og-image/api/_lib/parser.ts
index bcb38ffc..1a0863bd 100644
--- a/og-image/api/_lib/parser.ts
+++ b/og-image/api/_lib/parser.ts
@@ -26,6 +26,8 @@ export function parseRequest(req: IncomingMessage) {
challengerOutcome,
creatorAmount,
creatorOutcome,
+ acceptedName,
+ acceptedAvatarUrl,
} = query || {}
if (Array.isArray(fontSize)) {
@@ -77,6 +79,8 @@ export function parseRequest(req: IncomingMessage) {
challengerOutcome: getString(challengerOutcome) || '',
creatorAmount: getString(creatorAmount) || '',
creatorOutcome: getString(creatorOutcome) || '',
+ acceptedName: getString(acceptedName) || '',
+ acceptedAvatarUrl: getString(acceptedAvatarUrl) || '',
}
parsedRequest.images = getDefaultImages(parsedRequest.images)
return parsedRequest
diff --git a/og-image/api/_lib/types.ts b/og-image/api/_lib/types.ts
index 565db1b2..3ade016a 100644
--- a/og-image/api/_lib/types.ts
+++ b/og-image/api/_lib/types.ts
@@ -23,4 +23,6 @@ export interface ParsedRequest {
challengerOutcome: string
creatorAmount: string
creatorOutcome: string
+ acceptedName: string
+ acceptedAvatarUrl: string
}
diff --git a/web/components/SEO.tsx b/web/components/SEO.tsx
index b7a5e67d..e5ff9360 100644
--- a/web/components/SEO.tsx
+++ b/web/components/SEO.tsx
@@ -1,5 +1,6 @@
import { ReactNode } from 'react'
import Head from 'next/head'
+import { Challenge } from 'common/challenge'
export type OgCardProps = {
question: string
@@ -10,12 +11,19 @@ export type OgCardProps = {
creatorAvatarUrl?: string
}
-type ChallengeCardProps = {
- challengeAmount: string
- challengeOutcome: string
-}
-
-function buildCardUrl(props: OgCardProps, challengeProps?: ChallengeCardProps) {
+function buildCardUrl(props: OgCardProps, challenge?: Challenge) {
+ const {
+ creatorAmount,
+ acceptances,
+ creatorOutcomeProb,
+ creatorOutcome,
+ yourOutcome,
+ } = challenge || {}
+ const { userName, userAvatarUrl } = acceptances?.[0] ?? {}
+ const challengeAmount =
+ creatorOutcomeProb &&
+ creatorAmount &&
+ Math.round(((1 - creatorOutcomeProb) / creatorOutcomeProb) * creatorAmount)
const probabilityParam =
props.probability === undefined
? ''
@@ -25,8 +33,10 @@ function buildCardUrl(props: OgCardProps, challengeProps?: ChallengeCardProps) {
? ''
: `&creatorAvatarUrl=${encodeURIComponent(props.creatorAvatarUrl ?? '')}`
- const challengeUrlParams = challengeProps
- ? `&challengeAmount=${challengeProps.challengeAmount}&challengeOutcome=${challengeProps.challengeOutcome}`
+ const challengeUrlParams = challenge
+ ? `&creatorAmount=${creatorAmount}&creatorOutcome=${creatorOutcome}` +
+ `&challengerAmount=${challengeAmount}&challengerOutcome=${yourOutcome}` +
+ `&acceptedName=${userName ?? ''}&acceptedAvatarUrl=${userAvatarUrl ?? ''}`
: ''
// URL encode each of the props, then add them as query params
@@ -48,10 +58,9 @@ export function SEO(props: {
url?: string
children?: ReactNode
ogCardProps?: OgCardProps
- challengeCardProps?: ChallengeCardProps
+ challenge?: Challenge
}) {
- const { title, description, url, children, ogCardProps, challengeCardProps } =
- props
+ const { title, description, url, children, ogCardProps, challenge } = props
return (
@@ -83,13 +92,13 @@ export function SEO(props: {
<>
>
diff --git a/web/components/challenges/accept-challenge-button.tsx b/web/components/challenges/accept-challenge-button.tsx
index 11bf03d6..9ae83795 100644
--- a/web/components/challenges/accept-challenge-button.tsx
+++ b/web/components/challenges/accept-challenge-button.tsx
@@ -40,6 +40,8 @@ export function AcceptChallengeButton(props: {
acceptChallenge({
contractId: contract.id,
challengeSlug: challenge.slug,
+ outcomeType: contract.outcomeType,
+ closeTime: contract.closeTime,
})
.then((r) => {
console.log('accepted challenge. Result:', r)
diff --git a/web/pages/challenges/[username]/[contractSlug]/[challengeSlug].tsx b/web/pages/challenges/[username]/[contractSlug]/[challengeSlug].tsx
index c9a43da0..a0bef15b 100644
--- a/web/pages/challenges/[username]/[contractSlug]/[challengeSlug].tsx
+++ b/web/pages/challenges/[username]/[contractSlug]/[challengeSlug].tsx
@@ -117,10 +117,7 @@ export default function ChallengePage(props: {
description={ogCardProps.description}
url={getChallengeUrl(challenge).replace('https://', '')}
ogCardProps={ogCardProps}
- challengeCardProps={{
- challengeOutcome: challenge.creatorOutcome,
- challengeAmount: challenge.creatorAmount + '',
- }}
+ challenge={challenge}
/>
{challenge.acceptances.length >= challenge.maxUses ? (