Add lowercaseTags field to contracts. ante / closeTime non-optional in new contract code
This commit is contained in:
parent
7534847e8d
commit
705d5cada7
|
@ -10,6 +10,7 @@ export type Contract = {
|
|||
question: string
|
||||
description: string // More info about what the contract is about
|
||||
tags: string[]
|
||||
lowercaseTags: string[]
|
||||
outcomeType: 'BINARY' // | 'MULTI' | 'interval' | 'date'
|
||||
visibility: 'public' | 'unlisted'
|
||||
|
||||
|
|
|
@ -11,12 +11,15 @@ export function getNewContract(
|
|||
question: string,
|
||||
description: string,
|
||||
initialProb: number,
|
||||
ante?: number,
|
||||
closeTime?: number
|
||||
ante: number,
|
||||
closeTime: number
|
||||
) {
|
||||
const { sharesYes, sharesNo, poolYes, poolNo, phantomYes, phantomNo } =
|
||||
calcStartPool(initialProb, ante)
|
||||
|
||||
const tags = parseTags(`${question} ${description}`)
|
||||
const lowercaseTags = tags.map((tag) => tag.toLowerCase())
|
||||
|
||||
const contract: Contract = {
|
||||
id,
|
||||
slug,
|
||||
|
@ -29,7 +32,8 @@ export function getNewContract(
|
|||
|
||||
question: question.trim(),
|
||||
description: description.trim(),
|
||||
tags: parseTags(`${question} ${description}`),
|
||||
tags,
|
||||
lowercaseTags,
|
||||
visibility: 'public',
|
||||
|
||||
mechanism: 'dpm-2',
|
||||
|
|
|
@ -16,8 +16,8 @@ export const createContract = functions
|
|||
question: string
|
||||
description: string
|
||||
initialProb: number
|
||||
ante?: number
|
||||
closeTime?: number
|
||||
ante: number
|
||||
closeTime: number
|
||||
},
|
||||
context
|
||||
) => {
|
||||
|
|
|
@ -30,6 +30,7 @@ async function updateContractTags() {
|
|||
...parseTags(contract.question + contract.description),
|
||||
...(contract.tags ?? []),
|
||||
])
|
||||
const lowercaseTags = tags.map((tag) => tag.toLowerCase())
|
||||
|
||||
console.log(
|
||||
'Updating tags',
|
||||
|
@ -42,6 +43,7 @@ async function updateContractTags() {
|
|||
|
||||
await contractRef.update({
|
||||
tags,
|
||||
lowercaseTags,
|
||||
} as Partial<Contract>)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ export function NewContract(props: { question: string }) {
|
|||
|
||||
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||
|
||||
const closeTime = dateToMillis(closeDate) || undefined
|
||||
const closeTime = dateToMillis(closeDate)
|
||||
|
||||
const balance = creator?.balance || 0
|
||||
|
||||
|
@ -88,7 +88,7 @@ export function NewContract(props: { question: string }) {
|
|||
ante !== undefined &&
|
||||
ante >= MINIMUM_ANTE &&
|
||||
ante <= balance &&
|
||||
// If set, closeTime must be in the future
|
||||
// closeTime must be in the future
|
||||
closeTime &&
|
||||
closeTime > Date.now()
|
||||
|
||||
|
@ -103,7 +103,7 @@ export function NewContract(props: { question: string }) {
|
|||
description,
|
||||
initialProb,
|
||||
ante,
|
||||
closeTime: closeTime || undefined,
|
||||
closeTime,
|
||||
}).then((r) => r.data || {})
|
||||
|
||||
if (result.status !== 'success') {
|
||||
|
|
Loading…
Reference in New Issue
Block a user