Skip to content

Commit

Permalink
fix: wrong Date type for start/end ceremony dates expressed in ms
Browse files Browse the repository at this point in the history
  • Loading branch information
0xjei committed Feb 1, 2023
1 parent 1bc5baf commit 655a02e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions packages/actions/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ export type UserDocument = {
* @typedef {Object} CeremonyInputData
* @property {string} title - the title/name of the ceremony.
* @property {string} description - a brief description of the ceremony.
* @property {Date} startDate - the start (opening to contributions) date for the ceremony.
* @property {Date} endDate - the end (closing to contributions) date for the ceremony.
* @property {number} startDate - the start (opening to contributions) date for the ceremony (in ms).
* @property {number} endDate - the end (closing to contributions) date for the ceremony (in ms).
* @property {CeremonyTimeoutType} timeoutMechanismType - the timeout mechanism type used for avoiding blocking contribution behaviours.
* @property {number} penalty - the amount of time expressed in minutes that the blocking contributor has to wait before joining the waiting queue again.
*/
export type CeremonyInputData = {
title: string
description: string
startDate: Date
endDate: Date
startDate: number
endDate: number
timeoutMechanismType: CeremonyTimeoutType
penalty: number
}
Expand Down
16 changes: 8 additions & 8 deletions packages/actions/test/data/samples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ const fakeCeremonyScheduledFixed = generateFakeCeremony({
description: "Short description for Ceremony Scheduled Fixed",
prefix: "ceremony-scheduled-fixed",
penalty: 10, // Penalty in days (amount of time a contributor should wait after timeout).
startDate: new Date(Date.now() + 86400000), // Starts in a day.
endDate: new Date(Date.now() + 86400000 * 2), // Ends in two days.
startDate: Date.now() + 86400000, // Starts in a day.
endDate: Date.now() + 86400000 * 2, // Ends in two days.
state: CeremonyState.SCHEDULED,
type: CeremonyType.PHASE2,
timeoutMechanismType: CeremonyTimeoutType.FIXED,
Expand All @@ -60,8 +60,8 @@ const fakeCeremonyScheduledDynamic = generateFakeCeremony({
description: "Short description for Ceremony Scheduled Dynamic",
prefix: "ceremony-scheduled-dynamic",
penalty: 10, // Penalty in days (amount of time a contributor should wait after timeout).
startDate: new Date(Date.now() + 86400000), // Starts in a day.
endDate: new Date(Date.now() + 86400000 * 2), // Ends in two days.
startDate: Date.now() + 86400000, // Starts in a day.
endDate: Date.now() + 86400000 * 2, // Ends in two days.
state: CeremonyState.SCHEDULED,
type: CeremonyType.PHASE2,
timeoutMechanismType: CeremonyTimeoutType.DYNAMIC,
Expand All @@ -77,8 +77,8 @@ const fakeCeremonyOpenedFixed = generateFakeCeremony({
description: "Short description for Ceremony Opened Fixed",
prefix: "ceremony-opened-fixed",
penalty: 10, // Penalty in days (amount of time a contributor should wait after timeout).
startDate: new Date(Date.now() - 86400000), // Starts in a day.
endDate: new Date(Date.now() + 86400000), // Ends in one day.
startDate: Date.now() - 86400000, // Started a day ago.
endDate: Date.now() + 86400000, // Ends in one day.
state: CeremonyState.OPENED,
type: CeremonyType.PHASE2,
timeoutMechanismType: CeremonyTimeoutType.FIXED,
Expand All @@ -94,8 +94,8 @@ const fakeCeremonyOpenedDynamic = generateFakeCeremony({
description: "Short description for Ceremony Opened Dynamic",
prefix: "ceremony-opened-dynamic",
penalty: 10, // Penalty in days (amount of time a contributor should wait after timeout).
startDate: new Date(Date.now() - 86400000), // Starts in a day.
endDate: new Date(Date.now() + 86400000), // Ends in one day.
startDate: Date.now() - 86400000, // Started a day ago.
endDate: Date.now() + 86400000, // Ends in one day.
state: CeremonyState.OPENED,
type: CeremonyType.PHASE2,
timeoutMechanismType: CeremonyTimeoutType.DYNAMIC,
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/functions/contribute.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as functions from "firebase-functions"
import admin from "firebase-admin"
import dotenv from "dotenv"
import { MsgType } from "types/enums"
import {
commonTerms,
getCircuitsCollectionPath,
Expand All @@ -15,6 +14,7 @@ import {
CeremonyTimeoutType,
TimeoutType
} from "@zkmpc/actions/src/types/enums"
import { MsgType } from "../../types/enums"
import { GENERIC_ERRORS, GENERIC_LOGS, logMsg } from "../lib/logs"
import {
getCeremonyCircuits,
Expand Down
4 changes: 2 additions & 2 deletions packages/phase2cli/src/commands/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ const setup = async () => {
// Display ceremony summary.
let summary = `${`${theme.text.bold(ceremonyInputData.title)}\n${theme.text.italic(ceremonyInputData.description)}`}
\n${`Opening: ${theme.text.bold(
theme.text.underlined(ceremonyInputData.startDate.toUTCString().replace("GMT", "UTC"))
theme.text.underlined(new Date(ceremonyInputData.startDate).toUTCString().replace("GMT", "UTC"))
)}\nEnding: ${theme.text.bold(
theme.text.underlined(ceremonyInputData.endDate.toUTCString().replace("GMT", "UTC"))
theme.text.underlined(new Date(ceremonyInputData.endDate).toUTCString().replace("GMT", "UTC"))
)}`}
\n${theme.text.bold(
ceremonyInputData.timeoutMechanismType === CeremonyTimeoutType.DYNAMIC ? `Dynamic` : `Fixed`
Expand Down

0 comments on commit 655a02e

Please sign in to comment.