Append answers to contract field 'answers'
This commit is contained in:
parent
72ccb72f8c
commit
dfc719fcfe
|
@ -1,3 +1,5 @@
|
||||||
|
import { Answer } from './answer'
|
||||||
|
|
||||||
export type Contract = {
|
export type Contract = {
|
||||||
id: string
|
id: string
|
||||||
slug: string // auto-generated; must be unique
|
slug: string // auto-generated; must be unique
|
||||||
|
@ -15,6 +17,7 @@ export type Contract = {
|
||||||
|
|
||||||
outcomeType: 'BINARY' | 'MULTI' | 'FREE_RESPONSE'
|
outcomeType: 'BINARY' | 'MULTI' | 'FREE_RESPONSE'
|
||||||
multiOutcomes?: string[] // Used for outcomeType 'MULTI'.
|
multiOutcomes?: string[] // Used for outcomeType 'MULTI'.
|
||||||
|
answers?: Answer[] // Used for outcomeType 'FREE_RESPONSE'.
|
||||||
|
|
||||||
mechanism: 'dpm-2'
|
mechanism: 'dpm-2'
|
||||||
phantomShares?: { [outcome: string]: number }
|
phantomShares?: { [outcome: string]: number }
|
||||||
|
|
|
@ -72,6 +72,7 @@ const getFreeAnswerProps = (ante: number) => {
|
||||||
pool: { '0': ante },
|
pool: { '0': ante },
|
||||||
totalShares: { '0': ante },
|
totalShares: { '0': ante },
|
||||||
totalBets: { '0': ante },
|
totalBets: { '0': ante },
|
||||||
|
answers: [],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,7 @@ export const createAnswer = functions.runWith({ minInstances: 1 }).https.onCall(
|
||||||
pool: newPool,
|
pool: newPool,
|
||||||
totalShares: newTotalShares,
|
totalShares: newTotalShares,
|
||||||
totalBets: newTotalBets,
|
totalBets: newTotalBets,
|
||||||
|
answers: [...(contract.answers ?? []), answer],
|
||||||
})
|
})
|
||||||
transaction.update(userDoc, { balance: newBalance })
|
transaction.update(userDoc, { balance: newBalance })
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user