Append answers to contract field 'answers'

This commit is contained in:
James Grugett 2022-02-17 15:53:05 -06:00
parent 72ccb72f8c
commit dfc719fcfe
3 changed files with 5 additions and 0 deletions

View File

@ -1,3 +1,5 @@
import { Answer } from './answer'
export type Contract = {
id: string
slug: string // auto-generated; must be unique
@ -15,6 +17,7 @@ export type Contract = {
outcomeType: 'BINARY' | 'MULTI' | 'FREE_RESPONSE'
multiOutcomes?: string[] // Used for outcomeType 'MULTI'.
answers?: Answer[] // Used for outcomeType 'FREE_RESPONSE'.
mechanism: 'dpm-2'
phantomShares?: { [outcome: string]: number }

View File

@ -72,6 +72,7 @@ const getFreeAnswerProps = (ante: number) => {
pool: { '0': ante },
totalShares: { '0': ante },
totalBets: { '0': ante },
answers: [],
}
}

View File

@ -99,6 +99,7 @@ export const createAnswer = functions.runWith({ minInstances: 1 }).https.onCall(
pool: newPool,
totalShares: newTotalShares,
totalBets: newTotalBets,
answers: [...(contract.answers ?? []), answer],
})
transaction.update(userDoc, { balance: newBalance })