mirror of
https://github.com/web3privacy/explorer-data.git
synced 2024-10-15 12:06:26 +02:00
Merge pull request #774 from web3privacy/pk/ranks
feat(data): add ranks with conditions
This commit is contained in:
commit
b7883e664e
6 changed files with 279 additions and 24 deletions
|
@ -9,3 +9,5 @@ properties:
|
||||||
pattern: '^[a-z0-9-]+$'
|
pattern: '^[a-z0-9-]+$'
|
||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
|
icon:
|
||||||
|
type: string
|
||||||
|
|
|
@ -25,10 +25,10 @@ properties:
|
||||||
type: string
|
type: string
|
||||||
pattern: '^[A-Z0-9-]+$'
|
pattern: '^[A-Z0-9-]+$'
|
||||||
ecosystem:
|
ecosystem:
|
||||||
anyOf: [{type: array}, {type: string}]
|
type: array
|
||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
pattern: '^[A-Z0-9-]+$'
|
pattern: '^[a-z0-9-]+$'
|
||||||
project_type:
|
project_type:
|
||||||
type: string
|
type: string
|
||||||
description:
|
description:
|
||||||
|
@ -100,19 +100,21 @@ properties:
|
||||||
time:
|
time:
|
||||||
type: string
|
type: string
|
||||||
history:
|
history:
|
||||||
type: object
|
type: array
|
||||||
properties:
|
items:
|
||||||
title:
|
type: object
|
||||||
type: string
|
properties:
|
||||||
event_type:
|
title:
|
||||||
type: string
|
type: string
|
||||||
description:
|
event_type:
|
||||||
type: string
|
type: string
|
||||||
time:
|
description:
|
||||||
type: string
|
type: string
|
||||||
link:
|
time:
|
||||||
type: string
|
type: string
|
||||||
format: uri
|
link:
|
||||||
|
type: string
|
||||||
|
format: uri
|
||||||
sunset:
|
sunset:
|
||||||
type: boolean
|
type: boolean
|
||||||
# LINKS ---------------------------------------------------------------------
|
# LINKS ---------------------------------------------------------------------
|
||||||
|
@ -313,4 +315,9 @@ properties:
|
||||||
testnet:
|
testnet:
|
||||||
type: boolean
|
type: boolean
|
||||||
mainnet:
|
mainnet:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
usecases:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
pattern: '^[a-z0-9-]+$'
|
||||||
|
|
48
schema/rank.yaml
Normal file
48
schema/rank.yaml
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
references:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
field:
|
||||||
|
type: string
|
||||||
|
label:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
positive:
|
||||||
|
type: string
|
||||||
|
negative:
|
||||||
|
type: string
|
||||||
|
condition:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
exists:
|
||||||
|
type: boolean
|
||||||
|
minLength:
|
||||||
|
type: integer
|
||||||
|
regex:
|
||||||
|
type: string
|
||||||
|
equals:
|
||||||
|
oneOf:
|
||||||
|
- type: boolean
|
||||||
|
- type: string
|
||||||
|
- type: integer
|
||||||
|
points:
|
||||||
|
type: integer
|
||||||
|
required:
|
||||||
|
- field
|
||||||
|
- label
|
||||||
|
- condition
|
||||||
|
- points
|
||||||
|
required:
|
||||||
|
- id
|
||||||
|
- name
|
||||||
|
- references
|
||||||
|
additionalProperties: false
|
|
@ -1,12 +1,17 @@
|
||||||
- id: ethereum
|
- id: ethereum
|
||||||
name: Ethereum
|
name: Ethereum
|
||||||
|
icon: https://assets.coingecko.com/coins/images/279/standard/ethereum.png?1696501628
|
||||||
- id: bitcoin
|
- id: bitcoin
|
||||||
name: Bitcoin
|
name: Bitcoin
|
||||||
|
icon: https://assets.coingecko.com/coins/images/1/standard/bitcoin.png?1696501400
|
||||||
- id: solana
|
- id: solana
|
||||||
name: Solana
|
name: Solana
|
||||||
|
icon: https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756
|
||||||
- id: cosmos
|
- id: cosmos
|
||||||
name: Cosmos
|
name: Cosmos
|
||||||
|
icon: https://assets.coingecko.com/coins/images/1481/standard/cosmos_hub.png?1696502525
|
||||||
- id: monero
|
- id: monero
|
||||||
name: Monero
|
name: Monero
|
||||||
|
icon: https://assets.coingecko.com/coins/images/69/standard/monero_logo.png?1696501460
|
||||||
- id: other
|
- id: other
|
||||||
name: Other
|
name: Other
|
||||||
|
|
165
src/ranks.yaml
Normal file
165
src/ranks.yaml
Normal file
|
@ -0,0 +1,165 @@
|
||||||
|
- id: openess
|
||||||
|
name: Openess
|
||||||
|
references:
|
||||||
|
- field: team.teammembers
|
||||||
|
label:
|
||||||
|
name: Team
|
||||||
|
positive: Member
|
||||||
|
negative: Anonymous
|
||||||
|
condition:
|
||||||
|
minLength: 1
|
||||||
|
points: 10
|
||||||
|
- field: links.docs
|
||||||
|
label:
|
||||||
|
name: Documentation
|
||||||
|
positive: Link
|
||||||
|
negative: Not available
|
||||||
|
condition:
|
||||||
|
exists: true
|
||||||
|
points: 10
|
||||||
|
- field: links.github
|
||||||
|
label:
|
||||||
|
name: Github
|
||||||
|
positive: Link
|
||||||
|
negative: Not available
|
||||||
|
condition:
|
||||||
|
exists: true
|
||||||
|
points: 10
|
||||||
|
- field: links.twitter
|
||||||
|
label:
|
||||||
|
name: Twitter
|
||||||
|
positive: Link
|
||||||
|
negative: Not available
|
||||||
|
condition:
|
||||||
|
exists: true
|
||||||
|
points: 1
|
||||||
|
- field: links.telegram
|
||||||
|
label:
|
||||||
|
name: Twitter
|
||||||
|
positive: Link
|
||||||
|
negative: Not available
|
||||||
|
condition:
|
||||||
|
exists: true
|
||||||
|
points: 1
|
||||||
|
- field: links.discord
|
||||||
|
label:
|
||||||
|
name: Discord
|
||||||
|
positive: Link
|
||||||
|
negative: Not available
|
||||||
|
condition:
|
||||||
|
exists: true
|
||||||
|
points: 1
|
||||||
|
- field: links.lens
|
||||||
|
label:
|
||||||
|
name: Lens
|
||||||
|
positive: Link
|
||||||
|
negative: Not available
|
||||||
|
condition:
|
||||||
|
exists: true
|
||||||
|
points: 1
|
||||||
|
- field: links.farcaster
|
||||||
|
label:
|
||||||
|
name: Farcaster
|
||||||
|
positive: Link
|
||||||
|
negative: Not available
|
||||||
|
condition:
|
||||||
|
exists: true
|
||||||
|
points: 1
|
||||||
|
- field: links.whitepaper
|
||||||
|
label:
|
||||||
|
name: Whitepaper
|
||||||
|
positive: Link
|
||||||
|
negative: Not available
|
||||||
|
condition:
|
||||||
|
exists: true
|
||||||
|
points: 10
|
||||||
|
- field: funding.value
|
||||||
|
label:
|
||||||
|
name: Funding
|
||||||
|
positive: Investment
|
||||||
|
negative: Not available
|
||||||
|
condition:
|
||||||
|
exists: true
|
||||||
|
points: 10
|
||||||
|
|
||||||
|
- id: technology
|
||||||
|
name: Technology
|
||||||
|
references:
|
||||||
|
- field: project_status.mainnet
|
||||||
|
label:
|
||||||
|
name: Mainnet
|
||||||
|
positive: Yes
|
||||||
|
negative: No
|
||||||
|
condition:
|
||||||
|
exists: true
|
||||||
|
points: 10
|
||||||
|
- field: blockchain_features.opensource
|
||||||
|
label:
|
||||||
|
name: Open Source
|
||||||
|
positive: Yes
|
||||||
|
negative: No
|
||||||
|
condition:
|
||||||
|
equals: true
|
||||||
|
points: 20
|
||||||
|
- field: blockchain_features.asset_custody_type
|
||||||
|
label:
|
||||||
|
name: Non Custody
|
||||||
|
positive: None
|
||||||
|
negative: Custodial
|
||||||
|
condition:
|
||||||
|
equals: non-custody
|
||||||
|
points: 10
|
||||||
|
- field: blockchain_features.upgradability.enabled
|
||||||
|
label:
|
||||||
|
name: Upgradability
|
||||||
|
positive: Disabled
|
||||||
|
negative: Enabled
|
||||||
|
condition:
|
||||||
|
equals: false
|
||||||
|
points: 10
|
||||||
|
- field: audits
|
||||||
|
label:
|
||||||
|
name: Audits
|
||||||
|
positive: Audit
|
||||||
|
negative: None
|
||||||
|
condition:
|
||||||
|
minLength: 1
|
||||||
|
points: 10
|
||||||
|
|
||||||
|
- id: privacy
|
||||||
|
name: Privacy
|
||||||
|
references:
|
||||||
|
- field: privacy_policy.link
|
||||||
|
label:
|
||||||
|
name: Privacy Policy
|
||||||
|
positive: Link
|
||||||
|
negative: Not available
|
||||||
|
condition:
|
||||||
|
exists: true
|
||||||
|
points: 10
|
||||||
|
- field: traceability.kyc
|
||||||
|
label:
|
||||||
|
name: KYC
|
||||||
|
positive: No
|
||||||
|
negative: Yes
|
||||||
|
condition:
|
||||||
|
equals: false
|
||||||
|
points: 10
|
||||||
|
- field: compliance
|
||||||
|
label:
|
||||||
|
name: Compliance
|
||||||
|
positive: No
|
||||||
|
negative: OFAC
|
||||||
|
condition:
|
||||||
|
equals: true
|
||||||
|
points: 5
|
||||||
|
- field: default_privacy
|
||||||
|
label:
|
||||||
|
name: Default Privacy
|
||||||
|
positive: YES
|
||||||
|
negative: No
|
||||||
|
condition:
|
||||||
|
equals: true
|
||||||
|
points: 10
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import Ajv from "https://esm.sh/ajv@8.8.1?pin=v58";
|
import Ajv from "https://esm.sh/ajv@8.17.1?pin=v58";
|
||||||
import addFormats from "https://esm.sh/ajv-formats@2.1.1";
|
import addFormats from "https://esm.sh/ajv-formats@2.1.1";
|
||||||
|
import { betterAjvErrors } from 'https://esm.sh/@apideck/better-ajv-errors@0.3.6?pin=v58';
|
||||||
import yaml from "npm:js-yaml";
|
import yaml from "npm:js-yaml";
|
||||||
|
|
||||||
import { W3PData } from "./w3pdata.js";
|
import { W3PData } from "./w3pdata.js";
|
||||||
|
@ -7,7 +8,7 @@ import { W3PData } from "./w3pdata.js";
|
||||||
const w3pd = new W3PData();
|
const w3pd = new W3PData();
|
||||||
await w3pd.init();
|
await w3pd.init();
|
||||||
|
|
||||||
const ajv = new Ajv({ strict: false });
|
const ajv = new Ajv({ strict: false, allErrors: true });
|
||||||
addFormats(ajv);
|
addFormats(ajv);
|
||||||
|
|
||||||
async function loadSchemas() {
|
async function loadSchemas() {
|
||||||
|
@ -19,17 +20,44 @@ async function loadSchemas() {
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDeepPropertiesKeys(obj, parentKey = '') {
|
||||||
|
let keys = [];
|
||||||
|
|
||||||
|
if (obj.hasOwnProperty('properties')) {
|
||||||
|
const properties = obj['properties'];
|
||||||
|
|
||||||
|
for (const key in properties) {
|
||||||
|
if (properties.hasOwnProperty(key)) {
|
||||||
|
const newKey = parentKey ? `${parentKey}.${key}` : key;
|
||||||
|
|
||||||
|
if (properties[key].hasOwnProperty('properties')) {
|
||||||
|
keys = keys.concat(getDeepPropertiesKeys(properties[key], newKey));
|
||||||
|
} else {
|
||||||
|
keys.push(newKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
const matrix = {
|
const matrix = {
|
||||||
categories: "category",
|
categories: "category",
|
||||||
projects: "project",
|
projects: "project",
|
||||||
|
assets: "asset",
|
||||||
|
ecosystems: "ecosystem",
|
||||||
|
features: "feature",
|
||||||
|
usecases: "usecase",
|
||||||
|
ranks: "rank",
|
||||||
};
|
};
|
||||||
|
|
||||||
const schemaDir = "./schema";
|
const schemaDir = "./schema";
|
||||||
const schemas = await loadSchemas();
|
const schemas = await loadSchemas();
|
||||||
|
|
||||||
schemas.project.properties.categories.items.enum = w3pd.data.categories.map(
|
schemas.rank.properties.references.items.properties.field.enum = getDeepPropertiesKeys(schemas.project);
|
||||||
(c) => c.id
|
schemas.project.properties.categories.items.enum = w3pd.data.categories.map((c) => c.id);
|
||||||
);
|
schemas.project.properties.usecases.items.enum = w3pd.data.usecases.map((c) => c.id);
|
||||||
|
|
||||||
for (const col of Object.keys(w3pd.data)) {
|
for (const col of Object.keys(w3pd.data)) {
|
||||||
const validator = ajv.compile(schemas[matrix[col]]);
|
const validator = ajv.compile(schemas[matrix[col]]);
|
||||||
|
@ -56,9 +84,9 @@ for (const col of Object.keys(w3pd.data)) {
|
||||||
if (Object.keys(item).length > 1) {
|
if (Object.keys(item).length > 1) {
|
||||||
Deno.test(testName + " (schema)", () => {
|
Deno.test(testName + " (schema)", () => {
|
||||||
if (!validator(item)) {
|
if (!validator(item)) {
|
||||||
// throw validator.errors;
|
const betterErrors = betterAjvErrors({ errors: validator.errors });
|
||||||
// log instead of throwing to proceed building all projects
|
// throw betterErrors;
|
||||||
console.log(validator.errors);
|
console.log(betterErrors);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue