Removed resolutiontype from contract creation
This commit is contained in:
parent
08ea8a0fe0
commit
41a6ee6056
|
@ -8,7 +8,6 @@ import {
|
||||||
Numeric,
|
Numeric,
|
||||||
outcomeType,
|
outcomeType,
|
||||||
resolution,
|
resolution,
|
||||||
resolutionType,
|
|
||||||
} from './contract'
|
} from './contract'
|
||||||
import { User } from './user'
|
import { User } from './user'
|
||||||
import { parseTags } from './util/parse'
|
import { parseTags } from './util/parse'
|
||||||
|
@ -25,7 +24,6 @@ export function getNewContract(
|
||||||
ante: number,
|
ante: number,
|
||||||
closeTime: number,
|
closeTime: number,
|
||||||
extraTags: string[],
|
extraTags: string[],
|
||||||
resolutionType: resolutionType,
|
|
||||||
automaticResolution: resolution,
|
automaticResolution: resolution,
|
||||||
automaticResolutionTime: number,
|
automaticResolutionTime: number,
|
||||||
|
|
||||||
|
@ -64,7 +62,6 @@ export function getNewContract(
|
||||||
isResolved: false,
|
isResolved: false,
|
||||||
createdTime: Date.now(),
|
createdTime: Date.now(),
|
||||||
closeTime,
|
closeTime,
|
||||||
resolutionType,
|
|
||||||
automaticResolution,
|
automaticResolution,
|
||||||
automaticResolutionTime,
|
automaticResolutionTime,
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,6 @@ import {
|
||||||
MAX_TAG_LENGTH,
|
MAX_TAG_LENGTH,
|
||||||
Numeric,
|
Numeric,
|
||||||
OUTCOME_TYPES,
|
OUTCOME_TYPES,
|
||||||
RESOLUTIONS,
|
|
||||||
RESOLUTION_TYPES
|
|
||||||
} from '../../common/contract'
|
} from '../../common/contract'
|
||||||
import { slugify } from '../../common/util/slugify'
|
import { slugify } from '../../common/util/slugify'
|
||||||
import { randomString } from '../../common/util/random'
|
import { randomString } from '../../common/util/random'
|
||||||
|
@ -43,16 +41,7 @@ const bodySchema = z.object({
|
||||||
'Close time must be in the future.'
|
'Close time must be in the future.'
|
||||||
),
|
),
|
||||||
outcomeType: z.enum(OUTCOME_TYPES),
|
outcomeType: z.enum(OUTCOME_TYPES),
|
||||||
resolutionType: z.enum(RESOLUTION_TYPES),
|
})
|
||||||
automaticResolution: z.enum(RESOLUTIONS),
|
|
||||||
automaticResolutionTime: z.date()
|
|
||||||
}).refine(
|
|
||||||
(data) => data.automaticResolutionTime.getTime() > data.closeTime.getTime(),
|
|
||||||
'Resolution time must be after close time.'
|
|
||||||
).refine(
|
|
||||||
(data) => data.resolutionType === 'MANUAL' && data.automaticResolutionTime,
|
|
||||||
'Time for automatic resolution specified even tho the resolution is \'MANUAL\''
|
|
||||||
)
|
|
||||||
|
|
||||||
const binarySchema = z.object({
|
const binarySchema = z.object({
|
||||||
initialProb: z.number().min(1).max(99),
|
initialProb: z.number().min(1).max(99),
|
||||||
|
@ -64,7 +53,7 @@ const numericSchema = z.object({
|
||||||
})
|
})
|
||||||
|
|
||||||
export const createContract = newEndpoint(['POST'], async (req, [user, _]) => {
|
export const createContract = newEndpoint(['POST'], async (req, [user, _]) => {
|
||||||
const { question, description, tags, closeTime, outcomeType, resolutionType, automaticResolution, automaticResolutionTime } = validate(
|
const { question, description, tags, closeTime, outcomeType } = validate(
|
||||||
bodySchema,
|
bodySchema,
|
||||||
req.body
|
req.body
|
||||||
)
|
)
|
||||||
|
@ -75,9 +64,12 @@ export const createContract = newEndpoint(['POST'], async (req, [user, _]) => {
|
||||||
if (max - min <= 0.01) throw new APIError(400, 'Invalid range.')
|
if (max - min <= 0.01) throw new APIError(400, 'Invalid range.')
|
||||||
}
|
}
|
||||||
if (outcomeType === 'BINARY') {
|
if (outcomeType === 'BINARY') {
|
||||||
;({ initialProb } = validate(binarySchema, req.body)) // leading ; intentional: see abive
|
;({ initialProb } = validate(binarySchema, req.body)) // leading ; intentional: see above
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const automaticResolution = outcomeType == 'BINARY' ? 'MKT' : 'CANCEL'
|
||||||
|
const automaticResolutionTime = closeTime.setDate(closeTime.getDate() + 7)
|
||||||
|
|
||||||
// Uses utc time on server:
|
// Uses utc time on server:
|
||||||
const today = new Date()
|
const today = new Date()
|
||||||
let freeMarketResetTime = today.setUTCHours(16, 0, 0, 0)
|
let freeMarketResetTime = today.setUTCHours(16, 0, 0, 0)
|
||||||
|
@ -117,9 +109,8 @@ export const createContract = newEndpoint(['POST'], async (req, [user, _]) => {
|
||||||
ante,
|
ante,
|
||||||
closeTime.getTime(),
|
closeTime.getTime(),
|
||||||
tags ?? [],
|
tags ?? [],
|
||||||
resolutionType,
|
|
||||||
automaticResolution,
|
automaticResolution,
|
||||||
automaticResolutionTime.getTime(),
|
automaticResolutionTime,
|
||||||
NUMERIC_BUCKET_COUNT,
|
NUMERIC_BUCKET_COUNT,
|
||||||
min ?? 0,
|
min ?? 0,
|
||||||
max ?? 0
|
max ?? 0
|
||||||
|
|
Loading…
Reference in New Issue
Block a user