base validation

This commit is contained in:
tree🌴 2023-10-07 20:48:35 +02:00
parent cb7c59363d
commit 09ee609421
9 changed files with 383 additions and 107 deletions

30
.github/workflows/test.yml vendored Normal file
View file

@ -0,0 +1,30 @@
name: Test
on:
push:
branches:
- main # Set a branch to deploy
pull_request:
jobs:
deploy:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- uses: szenius/set-timezone@v1.0
with:
timezoneLinux: "Europe/Prague"
- name: Test
run: make test

215
dist/bundle.json vendored
View file

@ -409,7 +409,122 @@
"id": "pollen-mobile" "id": "pollen-mobile"
}, },
{ {
"id": "secret-network" "id": "secret-network",
"name": "Secret Network",
"categories": [
"infrastructure"
],
"ecosystem": "Secret",
"token": [
{
"name": "Secret",
"symbol": "SCRT"
}
],
"description": "Chain for private computations",
"project_type": "Infrastructure",
"product_launch_day": "Feb 13, 2020",
"technology": {
"type": "TEE",
"name": "Trusted execution environment",
"features": "privacy, DeFi, NFTs, PaaS"
},
"links": {
"web": "https://scrt.network/",
"twitter": "https://twitter.com/SecretNetwork",
"telegram": "https://t.me/scrtCommunity",
"discord": "https://discord.com/invite/secret-network-360051864110235648",
"blog": "https://scrt.network/blog",
"facebook": null,
"block_explorer": "https://www.mintscan.io/secret",
"whitepaper": "https://scrt.network/graypaper/",
"github": "https://github.com/scrtlabs/SecretNetwork",
"docs": "https://docs.scrt.network/secret-network-documentation/",
"forum": "https://forum.scrt.network/"
},
"blockchain_features": {
"p2p": false,
"encryption": "TEE",
"upgradability": {
"enabled": true,
"type": "governance/fork"
},
"opensource": true,
"viewing_key": true,
"dissapearing_tx": false,
"connected_tx": true,
"reversability_condition": "viewing key, hack",
"data_masking": "Secret Contracts",
"asset_custody_type": "non-custody"
},
"licences": "MIT License",
"privacy_policy": {
"defined": false
},
"team": {
"anonymous": false,
"teammembers": [
{
"name": "Alex Zaidelson",
"role": "SLabs CEO",
"link": "https://twitter.com/azaidelson"
}
],
"company": [
{
"name": "Secret Labs",
"link": "https://www.scrtlabs.com/",
"contacts": "info@scrtlabs.com"
}
]
},
"storage": {
"decentralized": true
},
"tracebility": {
"tracked_data": "user SCRT adress",
"kyc": false,
"sign_in_type_requirments": "wallet"
},
"third_party_dependency": false,
"compliance": false,
"social_trust": "Slabs ( MRSINGER )",
"technical_spof": "Can decrypt",
"history": [
{
"title": "Mainnet",
"event_type": "launch",
"description": "Mainnet",
"time": "Feb 13, 2020",
"link": "https://shadeprotocol.io/blog/shade-protocol-claim-tutorial"
}
],
"client_diversability": [
{
"name": "Keplr",
"link": "https://www.keplr.app/"
},
{
"name": "Starshell",
"link": "https://starshell.net/"
}
],
"default_privacy": false,
"funding": [
{
"name": "Private investors",
"type": "ICO",
"link": "https://icodrops.com/secret-network/",
"value": "236.500.000 $",
"time": "Jul 23, 2020"
}
],
"project_status": {
"live_status": true,
"version": "Mainnet",
"testnet": true,
"mainnet": true
}
}, },
{ {
"id": "mysterium" "id": "mysterium"
@ -478,7 +593,101 @@
"id": "litecash" "id": "litecash"
}, },
{ {
"id": "zcash" "id": "zcash",
"name": "Zcash",
"categories": [
"currency"
],
"ecosystem": "Zcash",
"token": [
{
"name": "Zcash",
"symbol": "ZEC"
}
],
"security": "PoW",
"description": "A simple, secure digital currency that protects your privacy.",
"project_type": "Currency",
"product_launch_day": "Oct 28, 2016",
"technology": {
"type": "zkSNARKs",
"name": "Zero-knowlindge",
"features": "private, currency, payments"
},
"links": {
"web": "https://z.cash/",
"coingecko": "https://www.coingecko.com/en/coins/zcash",
"twitter": "https://twitter.com/zcash",
"telegram": "https://t.me/zcash_community",
"discord": null,
"blog": null,
"facebook": null,
"block_explorer": "https://zcashblockexplorer.com/",
"whitepaper": "https://whitepaper.io/document/645/zcash-whitepaper",
"github": "https://github.com/zcash/zcash",
"docs": "https://zcash.readthedocs.io/en/latest/",
"forum": "https://forum.zcashcommunity.com/"
},
"blockchain_features": {
"p2p": false,
"encryption": "zk-SNARKs",
"upgradability": {
"enabled": true,
"type": "fork"
},
"opensource": true,
"viewing_key": true,
"dissapearing_tx": false,
"frontend_anonymity": "options",
"identity_integration": null,
"connected_tx": false,
"revealed_recipient": false,
"revealed_sender": false,
"revealed_ammount": false,
"reversability_condition": "viewing key, hack",
"data_masking": "Shielded pools",
"asset_custody_type": "non-custody"
},
"licences": null,
"third_party_dependency": false,
"compliance": false,
"social_trust": null,
"technical_spof": null,
"history": [
{
"title": "Mainet",
"event_type": "launch",
"description": "Airdrop",
"time": "Oct 28, 2016",
"link": null
}
],
"wallets": [
{
"name": "Ywallet",
"link": "https://ywallet.app/"
},
{
"name": "Edge Wallet",
"link": "https://z.cash/ecosystem/edge-wallet/"
}
],
"default_privacy": false,
"funding": [
{
"name": null,
"type": null,
"link": null,
"value": null,
"time": null
}
],
"project_status": {
"live_status": true,
"version": "Mainnet",
"testnet": true,
"mainnet": true
}
}, },
{ {
"id": "cog" "id": "cog"
@ -764,7 +973,7 @@
"categories": [ "categories": [
"defi" "defi"
], ],
"ecosystem": "Ethereum", "ecosystem": "Ethereum, Elrond, Polkadot, Avalanche, Near, Flare",
"description": "is a decentralized privacy metaprotocol enabling confidential, trusted transactions and interoperability with DeFi", "description": "is a decentralized privacy metaprotocol enabling confidential, trusted transactions and interoperability with DeFi",
"technology": { "technology": {
"type": "zk" "type": "zk"

View file

@ -1,13 +0,0 @@
type: array
required:
- id
- name
additionalProperties: false
items:
type: object
properties:
id:
type: string
pattern: '^[a-z0-9-]+$'
name:
type: string

11
schema/category.yaml Normal file
View file

@ -0,0 +1,11 @@
type: object
additionalProperties: false
required:
- id
- name
properties:
id:
type: string
pattern: '^[a-z0-9-]+$'
name:
type: string

View file

@ -1,15 +1,18 @@
type: object type: object
additionalProperties: false additionalProperties: false
required: required:
- id
- name - name
- categories - categories
- ecosystem - ecosystem
- token
- description - description
- project_type - project_type
- technology - technology
- links - links
properties: properties:
id:
type: string
pattern: '^[a-z0-9-]+$'
name: name:
type: string type: string
categories: categories:
@ -27,7 +30,7 @@ properties:
symbol: symbol:
type: string type: string
network: network:
type: type: string
contract_address: contract_address:
type: string type: string
required: required:
@ -115,7 +118,7 @@ properties:
encryption: encryption:
type: string type: string
network: network:
type: type: string
upgradability: upgradability:
type: object type: object
properties: properties:
@ -190,7 +193,7 @@ properties:
type: object type: object
properties: properties:
decentralized: decentralized:
type: boolean type: boolean
tracebility: tracebility:
type: object type: object
properties: properties:
@ -221,7 +224,7 @@ properties:
social_trust: social_trust:
type: string type: string
technical_spof: technical_spof:
type: striing type: string
history: history:
type: object type: object
properties: properties:

View file

@ -1,14 +1,14 @@
import { W3PData } from "./w3pdata.js"; import { W3PData } from "./w3pdata.js";
const w3pd = new W3PData() const w3pd = new W3PData();
await w3pd.init() await w3pd.init();
const outputDir = "./dist" const outputDir = "./dist";
try { try {
await Deno.mkdir(outputDir) await Deno.mkdir(outputDir);
} catch {} } catch {}
const bundleFn = `${outputDir}/bundle.json` const bundleFn = `${outputDir}/bundle.json`;
await Deno.writeTextFile(bundleFn, JSON.stringify(w3pd.data, null, 2)) await Deno.writeTextFile(bundleFn, JSON.stringify(w3pd.data, null, 2));
console.log(`Bundle writed: ${bundleFn}`) console.log(`Bundle writed: ${bundleFn}`);

View file

@ -1,56 +1,57 @@
import yaml from 'npm:js-yaml' import yaml from "npm:js-yaml";
function slugify(input) { function slugify(input) {
if (!input) if (!input) {
return ''; return "";
}
// make lower case and trim // make lower case and trim
var slug = input.toLowerCase().trim(); var slug = input.toLowerCase().trim();
// remove accents from charaters // remove accents from charaters
slug = slug.normalize('NFD').replace(/[\u0300-\u036f]/g, '') slug = slug.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
// replace invalid chars with spaces // replace invalid chars with spaces
slug = slug.replace(/[^a-z0-9\s-]/g, ' ').trim(); slug = slug.replace(/[^a-z0-9\s-]/g, " ").trim();
// replace multiple spaces or hyphens with a single hyphen // replace multiple spaces or hyphens with a single hyphen
slug = slug.replace(/[\s-]+/g, '-'); slug = slug.replace(/[\s-]+/g, "-");
return slug; return slug;
} }
const projectDir = "src/projects" const projectDir = "src/projects";
async function genCat (cat) { async function genCat(cat) {
const catDir = `${projectDir}/${cat}` const catDir = `${projectDir}/${cat}`;
const f = await Deno.readTextFile(`${catDir}/src.json`) const f = await Deno.readTextFile(`${catDir}/src.json`);
const src = JSON.parse(f) const src = JSON.parse(f);
for (const p of src.data.Projects) { for (const p of src.data.Projects) {
const id = slugify(p.Project) const id = slugify(p.Project);
const pDir = `${catDir}/${id}` const pDir = `${catDir}/${id}`;
console.log(`${id}:\n -> ${pDir}`) console.log(`${id}:\n -> ${pDir}`);
try { try {
await Deno.mkdir(pDir) await Deno.mkdir(pDir);
} catch {} } catch {}
const out = { const out = {
name: p.Project, name: p.Project,
description: p.Description, description: p.Description,
ecosystem: p.Ecosystem, ecosystem: p.Ecosystem,
links: { links: {
github: p.GitHub, github: p.GitHub,
linkedin: p.TeamLink, linkedin: p.TeamLink,
}, },
team: { team: {
anonymous: p.Team !== "Public" anonymous: p.Team !== "Public",
} },
} };
const yml = yaml.dump(out) const yml = yaml.dump(out);
await Deno.writeTextFile(`${pDir}/index.yaml`, yml) await Deno.writeTextFile(`${pDir}/index.yaml`, yml);
//console.log(id, yml) //console.log(id, yml)
} }
} }
genCat(Deno.args[0]) genCat(Deno.args[0]);

View file

@ -1,6 +1,40 @@
import Ajv from "https://esm.sh/ajv@8.8.1?pin=v58";
import addFormats from "https://esm.sh/ajv-formats@2.1.1";
import yaml from "npm:js-yaml";
import { W3PData } from "./w3pdata.js"; import { W3PData } from "./w3pdata.js";
const w3pd = new W3PData() const w3pd = new W3PData();
await w3pd.init() await w3pd.init();
console.log(w3pd.data) const ajv = new Ajv({ strict: false });
addFormats(ajv);
async function loadSchemas() {
const out = {};
for await (const f of Deno.readDir(schemaDir)) {
const col = f.name.split(".")[0];
out[col] = yaml.load(await Deno.readTextFile(`${schemaDir}/${f.name}`));
}
return out;
}
const matrix = {
categories: "category",
projects: "project",
};
const schemaDir = "./schema";
const schemas = await loadSchemas();
for (const col of Object.keys(w3pd.data)) {
const validator = ajv.compile(schemas[matrix[col]]);
for (const item of w3pd.data[col]) {
Deno.test(`${col}/${item.id}`, () => {
if (!validator(item)) {
throw validator.errors;
}
});
}
}

View file

@ -1,42 +1,43 @@
import yaml from 'npm:js-yaml' import yaml from "npm:js-yaml";
export class W3PData { export class W3PData {
constructor() {
}
constructor () { async init() {
} this.data = await this.load("./src");
}
async init () { async load(dataDir) {
this.data = await this.load("./src") const out = {};
} for await (const f of Deno.readDir(dataDir)) {
if (f.isFile && f.name.match(/\.yaml$/)) {
async load (dataDir) { const name = f.name.split(".")[0];
const out = {} out[name] = await this.loadYaml(`${dataDir}/${f.name}`);
for await (const f of Deno.readDir(dataDir)) { }
if (f.isFile && f.name.match(/\.yaml$/)) { if (f.isDirectory && f.name === "projects") {
const name = f.name.split('.')[0] out.projects = [];
out[name] = await this.loadYaml(`${dataDir}/${f.name}`) const projectsDir = `${dataDir}/${f.name}`;
} for await (const pcd of Deno.readDir(projectsDir)) {
if (f.isDirectory && f.name === 'projects') { const catName = pcd.name;
out.projects = [] const catDir = `${projectsDir}/${pcd.name}`;
const projectsDir = `${dataDir}/${f.name}` for await (const pd of Deno.readDir(catDir)) {
for await (const pcd of Deno.readDir(projectsDir)) { if (!pd.isDirectory) {
const catName = pcd.name continue;
const catDir = `${projectsDir}/${pcd.name}`
for await (const pd of Deno.readDir(catDir)) {
if (!pd.isDirectory) {
continue
}
const pDir = `${catDir}/${pd.name}`
const index = yaml.load(await Deno.readTextFile(`${pDir}/index.yaml`))
out.projects.push(Object.assign({ id: pd.name }, index))
}
}
} }
const pDir = `${catDir}/${pd.name}`;
const index = yaml.load(
await Deno.readTextFile(`${pDir}/index.yaml`),
);
out.projects.push(Object.assign({ id: pd.name }, index));
}
} }
return out }
} }
return out;
}
async loadYaml (f) { async loadYaml(f) {
return yaml.load(await Deno.readTextFile(f)) return yaml.load(await Deno.readTextFile(f));
} }
} }