diff --git a/CGPs/cgp-0039.md b/CGPs/cgp-0039.md index 192ef24f..7826c307 100644 --- a/CGPs/cgp-0039.md +++ b/CGPs/cgp-0039.md @@ -3,7 +3,7 @@ cgp: 39 title: Increase Block Target Density date-created: 2021-09-06 author: 'Mariano Cortesi (@mcortesi), Or Neeman (@oneeman)' -discussionts-to: https://forum.celo.org/t/discussion-for-cgp-0039-incre/1333 +discussions-to: https://forum.celo.org/t/discussion-for-cgp-0039-incre/1333 status: EXECUTED date-executed: governance-proposal-id: 39 diff --git a/CGPs/cgp-0087.md b/CGPs/cgp-0087.md index d8ee3b18..90af9101 100644 --- a/CGPs/cgp-0087.md +++ b/CGPs/cgp-0087.md @@ -1,12 +1,11 @@ --- cgp: 87 title: Temperature Check - Celo transition to an Ethereum L2 -date created: 2023-07-21 +date-created: 2023-07-21 author: productmatt discussions-to: https://forum.celo.org/t/clabs-proposal-for-celo-to-transition-to-an-ethereum-l2/6109 status: EXECUTED governance-proposal-id: 116 -type: Temparature Check --- # Abstract diff --git a/CGPs/cgp-0127.md b/CGPs/cgp-0127.md index 1f838470..6a4fa383 100644 --- a/CGPs/cgp-0127.md +++ b/CGPs/cgp-0127.md @@ -4,7 +4,7 @@ title: Enable USDC as Gas Currency date-created: 2024-05-18 author: Martín Volpe (@martinvol), Pavel Hornak (@pahor167) status: PROPOSED -Discussions-to: https://forum.celo.org/t/path-towards-making-usdc-a-gas-currency/7385/2 +discussions-to: https://forum.celo.org/t/path-towards-making-usdc-a-gas-currency/7385/2 governance-proposal-id: 168 date-executed: --- diff --git a/scripts/validate.js b/scripts/validate.js index 12a6fc8c..d2b0af10 100644 --- a/scripts/validate.js +++ b/scripts/validate.js @@ -27,7 +27,7 @@ function validateCGPs() { } } - console.log('Done validating CGPs'); + console.log("Done validating CGPs"); } function validateCgpFolder(pathName) { @@ -39,7 +39,7 @@ function validateCgpFolder(pathName) { } function validateCgpFile(fileName) { - if (fileName === CGP_TEMPLATE_FILENAME) return + if (fileName === CGP_TEMPLATE_FILENAME) return; if (!CGP_FILENAME_REGEX.test(fileName)) { throw new Error(`Invalid CGP filename: ${fileName}`); @@ -85,24 +85,41 @@ const ProposalMetadataStatus = { /** * The schema as used in the CGP front matter */ -const DateString = z.string().regex(/^\d{4}-\d{2}-\d{2}$/) - -export const ProposalMetadataSchema = z.object({ - cgp: z.number().min(1), - title: z.string().min(1), - author: z.string().min(1), - status: z.nativeEnum(ProposalMetadataStatus), - "date-created": DateString.optional().or(z.null()), - "discussions-to": z.string().url().optional().or(z.null()), - "governance-proposal-id": z.number().min(1).optional().or(z.null()), - "date-executed": DateString.optional().or(z.null()), -}); +const DateString = z.string().regex(/^\d{4}-\d{2}-\d{2}$/); + +export const ProposalMetadataSchema = z + .object({ + cgp: z.number().min(1), + title: z.string().min(1), + author: z.string().min(1), + status: z.nativeEnum(ProposalMetadataStatus), + "date-created": DateString.optional().or(z.null()), + "discussions-to": z.string().url().optional().or(z.null()), + "governance-proposal-id": z.number().min(1).optional().or(z.null()), + "date-executed": DateString.optional().or(z.null()), + }) + .strict(); function validateFrontMatter(data, filename) { try { const parsed = ProposalMetadataSchema.parse(data); - parsed["date-created"] && validateDate(parsed["date-created"]) - parsed["date-executed"] && validateDate(parsed["date-executed"]) + const { + status, + "governance-proposal-id": proposalId, + "date-created": dateCreated, + "date-executed": dateExecuted, + } = parsed; + if ( + ![ + ProposalMetadataStatus.DRAFT, + ProposalMetadataStatus.WITHDRAWN, + ].includes(status) && + !proposalId + ) { + throw new Error(`Proposal ID required for non-draft CGPs`); + } + if (dateCreated) validateDate(dateCreated); + if (dateExecuted) validateDate(dateExecuted); } catch (error) { console.error("Error validating front matter", error); throw new Error(`Error validating front matter: ${filename}`); @@ -111,7 +128,7 @@ function validateFrontMatter(data, filename) { function validateDate(value) { const date = new Date(value); - if (date instanceof Date && !isNaN(date.getTime())) return + if (date instanceof Date && !isNaN(date.getTime())) return; throw new Error(`Invalid date: ${value}`); }