added type for binary resolution

This commit is contained in:
Milli 2022-06-02 23:35:58 +02:00
parent 6dab3c4e29
commit dfec5ed8fa
4 changed files with 9 additions and 7 deletions

View File

@ -71,7 +71,7 @@ export type Binary = {
outcomeType: 'BINARY'
initialProbability: number
resolutionProbability?: number // Used for BINARY markets resolved to MKT
resolution?: 'YES' | 'NO' | 'MKT' | 'CANCEL'
resolution?: resolution
}
export type FreeResponse = {
@ -91,6 +91,7 @@ export type Numeric = {
}
export type outcomeType = AnyOutcomeType['outcomeType']
export type resolution = 'YES' | 'NO' | 'MKT' | 'CANCEL'
export const OUTCOME_TYPES = ['BINARY', 'FREE_RESPONSE', 'NUMERIC'] as const
export const MAX_QUESTION_LENGTH = 480
export const MAX_DESCRIPTION_LENGTH = 10000

View File

@ -3,13 +3,13 @@ import { ReactNode } from 'react'
import { Answer } from 'common/answer'
import { getProbability } from 'common/calculate'
import { getValueFromBucket } from 'common/calculate-dpm'
import { BinaryContract, Contract, FreeResponseContract } from 'common/contract'
import { BinaryContract, Contract, FreeResponseContract, resolution } from 'common/contract'
import { formatPercent } from 'common/util/format'
import { ClientRender } from './client-render'
export function OutcomeLabel(props: {
contract: Contract
outcome: 'YES' | 'NO' | 'CANCEL' | 'MKT' | string
outcome: resolution | string
truncate: 'short' | 'long' | 'none'
value?: number
}) {

View File

@ -10,7 +10,7 @@ import { resolveMarket } from 'web/lib/firebase/fn-call'
import { ProbabilitySelector } from './probability-selector'
import { DPM_CREATOR_FEE } from 'common/fees'
import { getProbability } from 'common/calculate'
import { BinaryContract } from 'common/contract'
import { BinaryContract, resolution } from 'common/contract'
import { formatMoney } from 'common/util/format'
export function ResolutionPanel(props: {
@ -31,7 +31,7 @@ export function ResolutionPanel(props: {
: `${formatMoney(contract.collectedFees.creatorFee)} in fees`
const [outcome, setOutcome] = useState<
'YES' | 'NO' | 'MKT' | 'CANCEL' | undefined
resolution | undefined
>()
const [prob, setProb] = useState(getProbability(contract) * 100)

View File

@ -3,6 +3,7 @@ import React, { ReactNode } from 'react'
import { formatMoney } from 'common/util/format'
import { Col } from './layout/col'
import { Row } from './layout/row'
import { resolution } from 'common/contract'
export function YesNoSelector(props: {
selected?: 'YES' | 'NO'
@ -65,8 +66,8 @@ export function YesNoSelector(props: {
}
export function YesNoCancelSelector(props: {
selected: 'YES' | 'NO' | 'MKT' | 'CANCEL' | undefined
onSelect: (selected: 'YES' | 'NO' | 'MKT' | 'CANCEL') => void
selected: resolution | undefined
onSelect: (selected: resolution) => void
className?: string
btnClassName?: string
}) {