diff --git a/functions/src/place-bet.ts b/functions/src/place-bet.ts index 11ae425d..497f5dd1 100644 --- a/functions/src/place-bet.ts +++ b/functions/src/place-bet.ts @@ -42,6 +42,10 @@ export const placeBet = functions.runWith({ minInstances: 1 }).https.onCall( return { status: 'error', message: 'Invalid contract' } const contract = contractSnap.data() as Contract + const { closeTime } = contract + if (closeTime && Date.now() > closeTime) + return { status: 'error', message: 'Trading is closed' } + const newBetDoc = firestore .collection(`contracts/${contractId}/bets`) .doc() diff --git a/functions/src/sell-bet.ts b/functions/src/sell-bet.ts index 3d37d3c3..e68df796 100644 --- a/functions/src/sell-bet.ts +++ b/functions/src/sell-bet.ts @@ -33,6 +33,10 @@ export const sellBet = functions.runWith({ minInstances: 1 }).https.onCall( return { status: 'error', message: 'Invalid contract' } const contract = contractSnap.data() as Contract + const { closeTime } = contract + if (closeTime && Date.now() > closeTime) + return { status: 'error', message: 'Trading is closed' } + const betDoc = firestore.doc(`contracts/${contractId}/bets/${betId}`) const betSnap = await transaction.get(betDoc) if (!betSnap.exists) return { status: 'error', message: 'Invalid bet' } diff --git a/web/components/bets-list.tsx b/web/components/bets-list.tsx index b622c58e..4cc376f6 100644 --- a/web/components/bets-list.tsx +++ b/web/components/bets-list.tsx @@ -308,7 +308,8 @@ function BetRow(props: { bet: Bet; contract: Contract; sale?: Bet }) { shares, isSold, } = bet - const { isResolved } = contract + const { isResolved, closeTime } = contract + const isClosed = closeTime && Date.now() > closeTime return ( @@ -333,7 +334,7 @@ function BetRow(props: { bet: Bet; contract: Contract; sale?: Bet }) { )} - {!isResolved && !isSold && ( + {!isResolved && !isClosed && !isSold && (