diff --git a/common/contract.ts b/common/contract.ts index cf4bae0b..f7cd1407 100644 --- a/common/contract.ts +++ b/common/contract.ts @@ -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 diff --git a/web/components/outcome-label.tsx b/web/components/outcome-label.tsx index da8a0e80..eb789faa 100644 --- a/web/components/outcome-label.tsx +++ b/web/components/outcome-label.tsx @@ -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 }) { diff --git a/web/components/resolution-panel.tsx b/web/components/resolution-panel.tsx index fc031b22..6d0319b2 100644 --- a/web/components/resolution-panel.tsx +++ b/web/components/resolution-panel.tsx @@ -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) diff --git a/web/components/yes-no-selector.tsx b/web/components/yes-no-selector.tsx index 25bdaaeb..1a5eabf5 100644 --- a/web/components/yes-no-selector.tsx +++ b/web/components/yes-no-selector.tsx @@ -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 }) {