Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ src/data/eips.json
.vscode/*
!.vscode/extensions.json
.idea
.zed
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
*.sw?
105 changes: 93 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@types/react": "^19.1.2",
"@types/react-dom": "^19.1.2",
"@vitejs/plugin-react": "^4.4.1",
"ajv": "^8.17.1",
"autoprefixer": "^10.4.21",
"eslint": "^9.25.0",
"eslint-plugin-react-hooks": "^5.2.0",
Expand Down
35 changes: 34 additions & 1 deletion scripts/compile-eips.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import Ajv from 'ajv';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const EIPS_DIR = path.join(__dirname, '../src/data/eips');
const OUTPUT_FILE = path.join(__dirname, '../src/data/eips.json');
const SCHEMA_FILE = path.join(__dirname, 'eip-schema.json');

// Initialize JSON Schema validator
const ajv = new Ajv({ allErrors: true });
const schema = JSON.parse(fs.readFileSync(SCHEMA_FILE, 'utf8'));
const validate = ajv.compile(schema);

/**
* Compiles individual EIP JSON files into a single eips.json file
Expand All @@ -28,20 +35,46 @@ function compileEips() {
process.exit(1);
}

// Read and parse each EIP file
// Read, parse, and validate each EIP file
const eips = [];
const errors = [];

for (const file of files) {
const filePath = path.join(EIPS_DIR, file);
try {
const content = fs.readFileSync(filePath, 'utf8');
const eip = JSON.parse(content);

// Validate against schema
const valid = validate(eip);
if (!valid) {
const errorMessages = validate.errors
.map(err => {
const path = err.instancePath || '/';
const extra = err.params?.additionalProperty
? ` (property: "${err.params.additionalProperty}")`
: '';
return ` - ${path}: ${err.message}${extra}`;
})
.join('\n');
errors.push(`${file}:\n${errorMessages}`);
}

eips.push(eip);
} catch (error) {
console.error(`Error reading/parsing ${file}:`, error.message);
process.exit(1);
}
}

// Report validation errors
if (errors.length > 0) {
console.error('\nSchema validation errors:\n');
console.error(errors.join('\n\n'));
console.error(`\n${errors.length} file(s) failed validation.`);
process.exit(1);
}

// Sort by EIP id
eips.sort((a, b) => a.id - b.id);

Expand Down
120 changes: 120 additions & 0 deletions scripts/eip-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "EIP",
"type": "object",
"required": ["id", "title", "status", "description", "author", "type", "createdDate", "discussionLink", "forkRelationships"],
"additionalProperties": false,
"properties": {
"id": { "type": "integer" },
"title": { "type": "string" },
"status": { "type": "string" },
"description": { "type": "string" },
"author": { "type": "string" },
"type": { "type": "string" },
"category": { "type": "string" },
"createdDate": { "type": "string" },
"discussionLink": { "type": "string" },
"reviewer": { "type": "string" },
"collection": { "type": "string" },
"laymanDescription": { "type": "string" },
"northStars": {
"type": "array",
"items": { "type": "string" }
},
"benefits": {
"type": "array",
"items": { "type": "string" }
},
"tradeoffs": {
"type": "array",
"items": { "type": "string" }
},
"forkRelationships": {
"type": "array",
"items": { "$ref": "#/$defs/ForkRelationship" }
},
"northStarAlignment": { "$ref": "#/$defs/NorthStarAlignment" },
"stakeholderImpacts": { "$ref": "#/$defs/StakeholderImpacts" }
},
"$defs": {
"ForkRelationship": {
"type": "object",
"required": ["forkName", "statusHistory"],
"additionalProperties": false,
"properties": {
"forkName": { "type": "string" },
"statusHistory": {
"type": "array",
"items": { "$ref": "#/$defs/StatusHistoryEntry" }
},
"isHeadliner": { "type": "boolean" },
"wasHeadlinerCandidate": { "type": "boolean" },
"headlinerDiscussionLink": { "type": "string" },
"layer": { "type": "string" },
"champion": { "$ref": "#/$defs/Champion" }
}
},
"StatusHistoryEntry": {
"type": "object",
"required": ["status"],
"additionalProperties": false,
"properties": {
"status": {
"type": "string",
"enum": ["Proposed", "Considered", "Scheduled", "Declined", "Included", "Withdrawn"]
},
"call": {
"type": "string",
"pattern": "^(acdc|acde|acdt)/[0-9]+$"
},
"date": {
"type": "string",
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
}
}
},
"Champion": {
"type": "object",
"required": ["name"],
"additionalProperties": false,
"properties": {
"name": { "type": "string" },
"discord": { "type": "string" },
"telegram": { "type": "string" },
"email": { "type": "string" }
}
},
"NorthStarAlignment": {
"type": "object",
"additionalProperties": false,
"properties": {
"scaleL1": { "$ref": "#/$defs/ImpactDescription" },
"scaleBlobs": { "$ref": "#/$defs/ImpactDescription" },
"improveUX": { "$ref": "#/$defs/ImpactDescription" }
}
},
"ImpactDescription": {
"type": "object",
"required": ["description"],
"additionalProperties": false,
"properties": {
"impact": { "type": "string" },
"description": { "type": "string" }
}
},
"StakeholderImpacts": {
"type": "object",
"additionalProperties": false,
"properties": {
"endUsers": { "$ref": "#/$defs/ImpactDescription" },
"appDevs": { "$ref": "#/$defs/ImpactDescription" },
"walletDevs": { "$ref": "#/$defs/ImpactDescription" },
"toolingInfra": { "$ref": "#/$defs/ImpactDescription" },
"layer2s": { "$ref": "#/$defs/ImpactDescription" },
"stakersNodes": { "$ref": "#/$defs/ImpactDescription" },
"clClients": { "$ref": "#/$defs/ImpactDescription" },
"elClients": { "$ref": "#/$defs/ImpactDescription" }
}
}
}
}
Loading