diff --git a/common/contract.ts b/common/contract.ts index f7cd1407..f75cfa4b 100644 --- a/common/contract.ts +++ b/common/contract.ts @@ -92,6 +92,7 @@ export type Numeric = { export type outcomeType = AnyOutcomeType['outcomeType'] export type resolution = 'YES' | 'NO' | 'MKT' | 'CANCEL' +export const RESOLUTIONS = ['YES', 'NO', 'MKT', 'CANCEL'] as const 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/functions/src/resolve-market.ts b/functions/src/resolve-market.ts index 183a5624..cf8c018f 100644 --- a/functions/src/resolve-market.ts +++ b/functions/src/resolve-market.ts @@ -2,7 +2,7 @@ import * as functions from 'firebase-functions' import * as admin from 'firebase-admin' import { difference, uniq, mapValues, groupBy, sumBy } from 'lodash' -import { Contract } from '../../common/contract' +import { Contract, resolution, RESOLUTIONS } from '../../common/contract' import { User } from '../../common/user' import { Bet } from '../../common/bet' import { getUser, isProd, payUser } from './utils' @@ -21,7 +21,7 @@ export const resolveMarket = functions .https.onCall( async ( data: { - outcome: string + outcome: resolution value?: number contractId: string probabilityInt?: number @@ -42,7 +42,7 @@ export const resolveMarket = functions const { creatorId, outcomeType, closeTime } = contract if (outcomeType === 'BINARY') { - if (!['YES', 'NO', 'MKT', 'CANCEL'].includes(outcome)) + if (!RESOLUTIONS.includes(outcome)) return { status: 'error', message: 'Invalid outcome' } } else if (outcomeType === 'FREE_RESPONSE') { if (