Auto resolution date editable
This commit is contained in:
parent
9c6c082de7
commit
727cf5df66
|
@ -28,9 +28,8 @@ export type FullContract<
|
||||||
isResolved: boolean
|
isResolved: boolean
|
||||||
resolutionTime?: number // When the market is resolved
|
resolutionTime?: number // When the market is resolved
|
||||||
resolution?: string
|
resolution?: string
|
||||||
automaticResolution: resolution
|
autoResolution: resolution
|
||||||
automaticResolutionTime?: number
|
autoResolutionTime: number // When the market will be resolved automatically
|
||||||
|
|
||||||
closeEmailsSent?: number
|
closeEmailsSent?: number
|
||||||
|
|
||||||
volume: number
|
volume: number
|
||||||
|
|
|
@ -24,8 +24,8 @@ export function getNewContract(
|
||||||
ante: number,
|
ante: number,
|
||||||
closeTime: number,
|
closeTime: number,
|
||||||
extraTags: string[],
|
extraTags: string[],
|
||||||
automaticResolution: resolution,
|
autoResolution: resolution,
|
||||||
automaticResolutionTime: number,
|
autoResolutionTime: number,
|
||||||
|
|
||||||
// used for numeric markets
|
// used for numeric markets
|
||||||
bucketCount: number,
|
bucketCount: number,
|
||||||
|
@ -62,8 +62,8 @@ export function getNewContract(
|
||||||
isResolved: false,
|
isResolved: false,
|
||||||
createdTime: Date.now(),
|
createdTime: Date.now(),
|
||||||
closeTime,
|
closeTime,
|
||||||
automaticResolution,
|
autoResolution,
|
||||||
automaticResolutionTime,
|
autoResolutionTime,
|
||||||
|
|
||||||
volume: 0,
|
volume: 0,
|
||||||
volume24Hours: 0,
|
volume24Hours: 0,
|
||||||
|
|
|
@ -45,7 +45,7 @@ service cloud.firestore {
|
||||||
match /contracts/{contractId} {
|
match /contracts/{contractId} {
|
||||||
allow read;
|
allow read;
|
||||||
allow update: if request.resource.data.diff(resource.data).affectedKeys()
|
allow update: if request.resource.data.diff(resource.data).affectedKeys()
|
||||||
.hasOnly(['description', 'closeTime', 'tags', 'lowercaseTags']);
|
.hasOnly(['description', 'closeTime', 'tags', 'lowercaseTags', 'autoResolutionTime']);
|
||||||
allow update: if isAdmin();
|
allow update: if isAdmin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,8 +67,8 @@ export const createContract = newEndpoint(['POST'], async (req, [user, _]) => {
|
||||||
;({ initialProb } = validate(binarySchema, req.body)) // leading ; intentional: see above
|
;({ initialProb } = validate(binarySchema, req.body)) // leading ; intentional: see above
|
||||||
}
|
}
|
||||||
|
|
||||||
const automaticResolution = outcomeType == 'BINARY' ? 'MKT' : 'CANCEL'
|
const autoResolution = outcomeType == 'BINARY' ? 'MKT' : 'CANCEL'
|
||||||
const automaticResolutionTime = closeTime.setDate(closeTime.getDate() + 7)
|
const autoResolutionTime = closeTime.setDate(closeTime.getDate() + 7)
|
||||||
|
|
||||||
// Uses utc time on server:
|
// Uses utc time on server:
|
||||||
const today = new Date()
|
const today = new Date()
|
||||||
|
@ -109,8 +109,8 @@ export const createContract = newEndpoint(['POST'], async (req, [user, _]) => {
|
||||||
ante,
|
ante,
|
||||||
closeTime.getTime(),
|
closeTime.getTime(),
|
||||||
tags ?? [],
|
tags ?? [],
|
||||||
automaticResolution,
|
autoResolution,
|
||||||
automaticResolutionTime,
|
autoResolutionTime,
|
||||||
NUMERIC_BUCKET_COUNT,
|
NUMERIC_BUCKET_COUNT,
|
||||||
min ?? 0,
|
min ?? 0,
|
||||||
max ?? 0
|
max ?? 0
|
||||||
|
|
|
@ -109,7 +109,7 @@ export function ContractDetails(props: {
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
}) {
|
}) {
|
||||||
const { contract, bets, isCreator, disabled } = props
|
const { contract, bets, isCreator, disabled } = props
|
||||||
const { closeTime, automaticResolutionTime, creatorName, creatorUsername } = contract
|
const { closeTime, autoResolutionTime, creatorName, creatorUsername } = contract
|
||||||
const { volumeLabel, resolvedDate } = contractMetrics(contract)
|
const { volumeLabel, resolvedDate } = contractMetrics(contract)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -157,7 +157,6 @@ export function ContractDetails(props: {
|
||||||
{/* {' - '}{' '} */}
|
{/* {' - '}{' '} */}
|
||||||
<EditableCloseDate
|
<EditableCloseDate
|
||||||
closeTime={closeTime}
|
closeTime={closeTime}
|
||||||
resolveTime={automaticResolutionTime}
|
|
||||||
contract={contract}
|
contract={contract}
|
||||||
isCreator={isCreator ?? false}
|
isCreator={isCreator ?? false}
|
||||||
/>
|
/>
|
||||||
|
@ -197,11 +196,10 @@ export function contractTextDetails(contract: Contract) {
|
||||||
|
|
||||||
function EditableCloseDate(props: {
|
function EditableCloseDate(props: {
|
||||||
closeTime: number
|
closeTime: number
|
||||||
resolveTime: number | undefined
|
|
||||||
contract: Contract
|
contract: Contract
|
||||||
isCreator: boolean
|
isCreator: boolean
|
||||||
}) {
|
}) {
|
||||||
const { closeTime, resolveTime, contract, isCreator } = props
|
const { closeTime, contract, isCreator } = props
|
||||||
|
|
||||||
const [isEditingCloseTime, setIsEditingCloseTime] = useState(false)
|
const [isEditingCloseTime, setIsEditingCloseTime] = useState(false)
|
||||||
const [closeDate, setCloseDate] = useState(
|
const [closeDate, setCloseDate] = useState(
|
||||||
|
@ -242,30 +240,15 @@ function EditableCloseDate(props: {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<DateTimeTooltip
|
||||||
<DateTimeTooltip
|
text={closeTime > Date.now() ? 'Trading ends:' : 'Trading ended:'}
|
||||||
text={closeTime > Date.now() ? 'Trading ends:' : 'Trading ended:'}
|
time={closeTime}
|
||||||
time={closeTime}
|
>
|
||||||
>
|
{isSameYear
|
||||||
{isSameYear
|
? dayjs(closeTime).format('MMM D')
|
||||||
? dayjs(closeTime).format('MMM D')
|
: dayjs(closeTime).format('MMM D, YYYY')}
|
||||||
: dayjs(closeTime).format('MMM D, YYYY')}
|
{isSameDay && <> ({fromNow(closeTime)})</>}
|
||||||
{isSameDay && <> ({fromNow(closeTime)})</>}
|
</DateTimeTooltip>
|
||||||
</DateTimeTooltip>
|
|
||||||
{resolveTime && (
|
|
||||||
<DateTimeTooltip
|
|
||||||
text={resolveTime > Date.now() ? 'Market resolves as \'MKT\':' : ''}
|
|
||||||
time={resolveTime}
|
|
||||||
>
|
|
||||||
{"/ "}
|
|
||||||
{isSameYear
|
|
||||||
? dayjs(resolveTime).format('MMM D')
|
|
||||||
: dayjs(resolveTime).format('MMM D, YYYY')}
|
|
||||||
{isSameDay && <> ({fromNow(resolveTime)})</>}
|
|
||||||
{": 'MKT'"}
|
|
||||||
</DateTimeTooltip>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{isCreator &&
|
{isCreator &&
|
||||||
|
|
|
@ -30,7 +30,7 @@ export function ContractInfoDialog(props: { contract: Contract; bets: Bet[] }) {
|
||||||
|
|
||||||
const formatTime = (dt: number) => dayjs(dt).format('MMM DD, YYYY hh:mm a z')
|
const formatTime = (dt: number) => dayjs(dt).format('MMM DD, YYYY hh:mm a z')
|
||||||
|
|
||||||
const { createdTime, closeTime, resolutionTime } = contract
|
const { createdTime, closeTime, resolutionTime, autoResolutionTime, autoResolution } = contract
|
||||||
const tradersCount = uniqBy(bets, 'userId').length
|
const tradersCount = uniqBy(bets, 'userId').length
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -81,6 +81,19 @@ export function ContractInfoDialog(props: { contract: Contract; bets: Bet[] }) {
|
||||||
</tr>
|
</tr>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{autoResolutionTime && autoResolution && (
|
||||||
|
<>
|
||||||
|
<tr>
|
||||||
|
<td>Automatic resolution</td>
|
||||||
|
<td>{formatTime(autoResolutionTime)}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Default resolution</td>
|
||||||
|
<td>{autoResolution}</td>
|
||||||
|
</tr>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
{resolutionTime && (
|
{resolutionTime && (
|
||||||
<tr>
|
<tr>
|
||||||
<td>Market resolved</td>
|
<td>Market resolved</td>
|
||||||
|
|
|
@ -42,10 +42,10 @@ export function contractUrl(contract: Contract) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function contractMetrics(contract: Contract) {
|
export function contractMetrics(contract: Contract) {
|
||||||
const { createdTime, resolutionTime, isResolved, automaticResolutionTime } = contract
|
const { createdTime, resolutionTime, isResolved, autoResolutionTime } = contract
|
||||||
|
|
||||||
const createdDate = dayjs(createdTime).format('MMM D')
|
const createdDate = dayjs(createdTime).format('MMM D')
|
||||||
const automaticResolutionDate = dayjs(automaticResolutionTime).format('MMM D')
|
const autoResolutionDate = dayjs(autoResolutionTime).format('MMM D')
|
||||||
|
|
||||||
const resolvedDate = isResolved
|
const resolvedDate = isResolved
|
||||||
? dayjs(resolutionTime).format('MMM D')
|
? dayjs(resolutionTime).format('MMM D')
|
||||||
|
@ -53,7 +53,7 @@ export function contractMetrics(contract: Contract) {
|
||||||
|
|
||||||
const volumeLabel = `${formatMoney(contract.volume)} bet`
|
const volumeLabel = `${formatMoney(contract.volume)} bet`
|
||||||
|
|
||||||
return { volumeLabel, createdDate, automaticResolutionDate, resolvedDate }
|
return { volumeLabel, createdDate, autoResolutionDate, resolvedDate }
|
||||||
}
|
}
|
||||||
|
|
||||||
export function contractPool(contract: Contract) {
|
export function contractPool(contract: Contract) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user