diff --git a/common/contract.ts b/common/contract.ts index f60cbb1c..d220da38 100644 --- a/common/contract.ts +++ b/common/contract.ts @@ -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' diff --git a/common/new-contract.ts b/common/new-contract.ts index c84f6f6e..a4617f99 100644 --- a/common/new-contract.ts +++ b/common/new-contract.ts @@ -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', diff --git a/functions/src/create-contract.ts b/functions/src/create-contract.ts index 4c522e99..42021e21 100644 --- a/functions/src/create-contract.ts +++ b/functions/src/create-contract.ts @@ -16,8 +16,8 @@ export const createContract = functions question: string description: string initialProb: number - ante?: number - closeTime?: number + ante: number + closeTime: number }, context ) => { diff --git a/functions/src/scripts/update-contract-tags.ts b/functions/src/scripts/update-contract-tags.ts index 933eee56..72f6b87a 100644 --- a/functions/src/scripts/update-contract-tags.ts +++ b/functions/src/scripts/update-contract-tags.ts @@ -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) } } diff --git a/web/pages/create.tsx b/web/pages/create.tsx index 4cc9b329..f8e76a7f 100644 --- a/web/pages/create.tsx +++ b/web/pages/create.tsx @@ -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') {