From 5d11c6fcfb58dd356b1ac53f1ab96dc970cdc1fa Mon Sep 17 00:00:00 2001 From: Klein Petr Date: Thu, 12 Sep 2024 17:36:51 +0200 Subject: [PATCH 01/11] feat(data): add ranks with conditions --- schema/rank.yaml | 37 ++++++++++++++++++++ src/ranks.yaml | 89 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 schema/rank.yaml create mode 100644 src/ranks.yaml diff --git a/schema/rank.yaml b/schema/rank.yaml new file mode 100644 index 00000000..a1d60dc6 --- /dev/null +++ b/schema/rank.yaml @@ -0,0 +1,37 @@ +type: object +properties: + id: + type: string + name: + type: string + references: + type: array + items: + type: object + properties: + field: + type: string + conditions: + type: object + properties: + exists: + type: boolean + minLength: + type: integer + regex: + type: string + equals: + oneOf: + - type: boolean + - type: string + points: + type: integer + required: + - field + - conditions + - points +required: + - id + - name + - references +additionalProperties: false \ No newline at end of file diff --git a/src/ranks.yaml b/src/ranks.yaml new file mode 100644 index 00000000..15e8b353 --- /dev/null +++ b/src/ranks.yaml @@ -0,0 +1,89 @@ +- id: openess + name: Openess + references: + - field: team.teammembers + conditions: + minLength: 1 + points: 10 + - field: links.docs + conditions: + exists: true + points: 10 + - field: links.github + conditions: + exists: true + points: 10 + - field: links.twitter + conditions: + exists: true + points: 1 + - field: links.telegram + conditions: + exists: true + points: 1 + - field: links.discord + conditions: + exists: true + points: 1 + - field: links.lens + conditions: + exists: true + points: 1 + - field: links.farcaster + conditions: + exists: true + points: 1 + - field: links.whitepaper + conditions: + exists: true + points: 10 + - field: team.funding + conditions: + minLength: 1 + points: 10 + +- id: technology + name: Technology + references: + - field: project_status.mainnet + conditions: + exists: true + points: 10 + - field: blockchain_features.opensource + conditions: + equals: true + points: 20 + - field: blockchain_features.asset_custody_type + conditions: + equals: non-custody + points: 10 + - field: blockchain_features.upgradability.enabled + conditions: + equals: false + points: 10 + - field: audits + conditions: + minLength: 1 + points: 10 + +- id: privacy + name: Privacy + references: + - field: privacy_policy.link + conditions: + exists: true + points: 10 + - field: traceability.kyc + conditions: + equals: false + points: 10 + - field: compliance + conditions: + equals: true + points: 5 + - field: default_privacy + conditions: + equals: true + points: 10 + + \ No newline at end of file From d02ca3d1904a78a2009707d3a122a055b4e49cd2 Mon Sep 17 00:00:00 2001 From: Klein Petr Date: Thu, 12 Sep 2024 18:11:39 +0200 Subject: [PATCH 02/11] tests: extend test with new schemas --- utils/test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utils/test.js b/utils/test.js index 4ecd6624..0403d808 100644 --- a/utils/test.js +++ b/utils/test.js @@ -22,6 +22,11 @@ async function loadSchemas() { const matrix = { categories: "category", projects: "project", + assets: "asset", + ecosystems: "ecosystem", + features: "feature", + usecases: "usecase", + ranks: "rank", }; const schemaDir = "./schema"; From 1aee29f4e76ac4b1945fcdc044910e4811a91369 Mon Sep 17 00:00:00 2001 From: Klein Petr Date: Thu, 12 Sep 2024 18:31:48 +0200 Subject: [PATCH 03/11] fix(schema): project history schema --- schema/project.yaml | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/schema/project.yaml b/schema/project.yaml index fc8c53a6..1a5e8d1a 100644 --- a/schema/project.yaml +++ b/schema/project.yaml @@ -100,19 +100,21 @@ properties: time: type: string history: - type: object - properties: - title: - type: string - event_type: - type: string - description: - type: string - time: - type: string - link: - type: string - format: uri + type: array + items: + type: object + properties: + title: + type: string + event_type: + type: string + description: + type: string + time: + type: string + link: + type: string + format: uri sunset: type: boolean # LINKS --------------------------------------------------------------------- From 66cee3680411924c3de49d69d2ae329bf4c89ef8 Mon Sep 17 00:00:00 2001 From: Klein Petr Date: Thu, 12 Sep 2024 18:36:07 +0200 Subject: [PATCH 04/11] feat(schema): update ranks schema, add label --- schema/rank.yaml | 8 +++++-- src/ranks.yaml | 57 ++++++++++++++++++++++++++++++++---------------- 2 files changed, 44 insertions(+), 21 deletions(-) diff --git a/schema/rank.yaml b/schema/rank.yaml index a1d60dc6..e34a9e89 100644 --- a/schema/rank.yaml +++ b/schema/rank.yaml @@ -11,7 +11,9 @@ properties: properties: field: type: string - conditions: + label: + type: string + condition: type: object properties: exists: @@ -24,11 +26,13 @@ properties: oneOf: - type: boolean - type: string + - type: integer points: type: integer required: - field - - conditions + - label + - condition - points required: - id diff --git a/src/ranks.yaml b/src/ranks.yaml index 15e8b353..8656b12d 100644 --- a/src/ranks.yaml +++ b/src/ranks.yaml @@ -2,43 +2,53 @@ name: Openess references: - field: team.teammembers - conditions: + label: Team + condition: minLength: 1 points: 10 - field: links.docs - conditions: + label: Documentation + condition: exists: true points: 10 - field: links.github - conditions: + label: Github + condition: exists: true points: 10 - field: links.twitter - conditions: + label: Twitter + condition: exists: true points: 1 - field: links.telegram - conditions: + label: Telegram + condition: exists: true points: 1 - field: links.discord - conditions: + label: Discord + condition: exists: true points: 1 - field: links.lens - conditions: + label: Lens + condition: exists: true points: 1 - field: links.farcaster - conditions: + label: Farcaster + condition: exists: true points: 1 - field: links.whitepaper - conditions: + label: Whitepaper + condition: exists: true points: 10 - field: team.funding - conditions: + label: Funding + condition: minLength: 1 points: 10 @@ -46,23 +56,28 @@ name: Technology references: - field: project_status.mainnet - conditions: + label: Mainnet + condition: exists: true points: 10 - field: blockchain_features.opensource - conditions: + label: Open Source + condition: equals: true points: 20 - field: blockchain_features.asset_custody_type - conditions: + label: Non Custody + condition: equals: non-custody points: 10 - field: blockchain_features.upgradability.enabled - conditions: + label: Upgradability + condition: equals: false points: 10 - field: audits - conditions: + label: Audits + condition: minLength: 1 points: 10 @@ -70,19 +85,23 @@ name: Privacy references: - field: privacy_policy.link - conditions: + label: Privacy Policy + condition: exists: true points: 10 - field: traceability.kyc - conditions: + label: KYC + condition: equals: false points: 10 - field: compliance - conditions: + label: Compliance + condition: equals: true points: 5 - field: default_privacy - conditions: + label: Default Privacy + condition: equals: true points: 10 From 0359ec2a6b0673709b8e81a108e8d44a1aaa968a Mon Sep 17 00:00:00 2001 From: Daniel Klein Date: Fri, 13 Sep 2024 12:48:25 +0200 Subject: [PATCH 05/11] feat(schema): update ecosystem schema, add icons --- schema/ecosystem.yaml | 2 ++ src/ecosystems.yaml | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/schema/ecosystem.yaml b/schema/ecosystem.yaml index aa85db5d..1ed0ab42 100644 --- a/schema/ecosystem.yaml +++ b/schema/ecosystem.yaml @@ -9,3 +9,5 @@ properties: pattern: '^[a-z0-9-]+$' name: type: string + icon: + type: string diff --git a/src/ecosystems.yaml b/src/ecosystems.yaml index a13f52e3..f43b1015 100644 --- a/src/ecosystems.yaml +++ b/src/ecosystems.yaml @@ -1,12 +1,17 @@ - id: ethereum name: Ethereum + icon: https://assets.coingecko.com/coins/images/279/standard/ethereum.png?1696501628 - id: bitcoin name: Bitcoin + icon: https://assets.coingecko.com/coins/images/1/standard/bitcoin.png?1696501400 - id: solana name: Solana + icon: https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756 - id: cosmos name: Cosmos + icon: https://assets.coingecko.com/coins/images/1481/standard/cosmos_hub.png?1696502525 - id: monero name: Monero + icon: https://assets.coingecko.com/coins/images/69/standard/monero_logo.png?1696501460 - id: other name: Other From 415e9b6ece47d0aacbf902d18875f757c8e4a4bf Mon Sep 17 00:00:00 2001 From: Klein Petr Date: Mon, 16 Sep 2024 19:43:18 +0200 Subject: [PATCH 06/11] fix: rank schema --- src/ranks.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ranks.yaml b/src/ranks.yaml index 8656b12d..3a056c56 100644 --- a/src/ranks.yaml +++ b/src/ranks.yaml @@ -46,10 +46,10 @@ condition: exists: true points: 10 - - field: team.funding + - field: funding.value label: Funding condition: - minLength: 1 + exists: true points: 10 - id: technology From 2cd582717c539fc898c973ef9e56ca92ca6f1f66 Mon Sep 17 00:00:00 2001 From: Klein Petr Date: Mon, 16 Sep 2024 19:43:27 +0200 Subject: [PATCH 07/11] fix: project schema --- schema/project.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/schema/project.yaml b/schema/project.yaml index 1a5e8d1a..f69e48db 100644 --- a/schema/project.yaml +++ b/schema/project.yaml @@ -315,4 +315,9 @@ properties: testnet: type: boolean mainnet: - type: boolean \ No newline at end of file + type: boolean + usecases: + type: array + items: + type: string + pattern: '^[a-z0-9-]+$' \ No newline at end of file From 435304b3c329c5ae1d6eaeaba68859d371b5591f Mon Sep 17 00:00:00 2001 From: Klein Petr Date: Mon, 16 Sep 2024 19:44:53 +0200 Subject: [PATCH 08/11] test: extend schemas with data enums & add betterAvjErrors --- utils/test.js | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/utils/test.js b/utils/test.js index 0403d808..575f6cd2 100644 --- a/utils/test.js +++ b/utils/test.js @@ -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 { betterAjvErrors } from 'https://esm.sh/@apideck/better-ajv-errors@0.3.6?pin=v58'; import yaml from "npm:js-yaml"; import { W3PData } from "./w3pdata.js"; @@ -7,7 +8,7 @@ import { W3PData } from "./w3pdata.js"; const w3pd = new W3PData(); await w3pd.init(); -const ajv = new Ajv({ strict: false }); +const ajv = new Ajv({ strict: false, allErrors: true }); addFormats(ajv); async function loadSchemas() { @@ -19,6 +20,28 @@ async function loadSchemas() { 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 = { categories: "category", projects: "project", @@ -32,9 +55,9 @@ const matrix = { const schemaDir = "./schema"; const schemas = await loadSchemas(); -schemas.project.properties.categories.items.enum = w3pd.data.categories.map( - (c) => c.id -); +schemas.rank.properties.references.items.properties.field.enum = getDeepPropertiesKeys(schemas.project); +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)) { const validator = ajv.compile(schemas[matrix[col]]); @@ -61,9 +84,9 @@ for (const col of Object.keys(w3pd.data)) { if (Object.keys(item).length > 1) { Deno.test(testName + " (schema)", () => { if (!validator(item)) { - // throw validator.errors; - // log instead of throwing to proceed building all projects - console.log(validator.errors); + const betterErrors = betterAjvErrors({ errors: validator.errors }); + throw betterErrors; + console.log(betterErrors); } }); } From bb55177ab15438805b5030015340fae70f5ffc0a Mon Sep 17 00:00:00 2001 From: Daniel Klein Date: Mon, 16 Sep 2024 20:53:05 +0200 Subject: [PATCH 09/11] fix(schema): ecosystem type, add rank positive and negative texts --- schema/project.yaml | 6 +++--- schema/rank.yaml | 6 +++++- src/ranks.yaml | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/schema/project.yaml b/schema/project.yaml index f69e48db..f0ea53e6 100644 --- a/schema/project.yaml +++ b/schema/project.yaml @@ -25,10 +25,10 @@ properties: type: string pattern: '^[A-Z0-9-]+$' ecosystem: - anyOf: [{type: array}, {type: string}] + type: array items: type: string - pattern: '^[A-Z0-9-]+$' + pattern: '^[a-z0-9-]+$' project_type: type: string description: @@ -320,4 +320,4 @@ properties: type: array items: type: string - pattern: '^[a-z0-9-]+$' \ No newline at end of file + pattern: '^[a-z0-9-]+$' diff --git a/schema/rank.yaml b/schema/rank.yaml index e34a9e89..d37c1acc 100644 --- a/schema/rank.yaml +++ b/schema/rank.yaml @@ -13,6 +13,10 @@ properties: type: string label: type: string + positive: + type: string + negative: + type: string condition: type: object properties: @@ -38,4 +42,4 @@ required: - id - name - references -additionalProperties: false \ No newline at end of file +additionalProperties: false diff --git a/src/ranks.yaml b/src/ranks.yaml index 3a056c56..1ec1b4a6 100644 --- a/src/ranks.yaml +++ b/src/ranks.yaml @@ -3,51 +3,71 @@ references: - field: team.teammembers label: Team + positive: 'Member' + negative: 'Anonymous' condition: minLength: 1 points: 10 - field: links.docs label: Documentation + positive: 'Link' + negative: 'Not available' condition: exists: true points: 10 - field: links.github label: Github + positive: 'Link' + negative: 'Not available' condition: exists: true points: 10 - field: links.twitter label: Twitter + positive: 'Link' + negative: 'Not available' condition: exists: true points: 1 - field: links.telegram label: Telegram + positive: 'Link' + negative: 'Not available' condition: exists: true points: 1 - field: links.discord label: Discord + positive: 'Link' + negative: 'Not available' condition: exists: true points: 1 - field: links.lens label: Lens + positive: 'Link' + negative: 'Not available' condition: exists: true points: 1 - field: links.farcaster label: Farcaster + positive: 'Link' + negative: 'Not available' condition: exists: true points: 1 - field: links.whitepaper label: Whitepaper + positive: 'Link' + negative: 'Not available' condition: exists: true points: 10 - field: funding.value label: Funding + positive: 'Investment' + negative: 'Not available' condition: exists: true points: 10 @@ -57,26 +77,36 @@ references: - field: project_status.mainnet label: Mainnet + positive: 'Yes' + negative: 'No' condition: exists: true points: 10 - field: blockchain_features.opensource label: Open Source + positive: 'Yes' + negative: 'No' condition: equals: true points: 20 - field: blockchain_features.asset_custody_type label: Non Custody + positive: 'None' + negative: 'Custodial' condition: equals: non-custody points: 10 - field: blockchain_features.upgradability.enabled label: Upgradability + positive: 'Disabled' + negative: 'Enabled' condition: equals: false points: 10 - field: audits label: Audits + positive: 'Audit' + negative: 'None' condition: minLength: 1 points: 10 @@ -86,21 +116,29 @@ references: - field: privacy_policy.link label: Privacy Policy + positive: 'Link' + negative: 'Not available' condition: exists: true points: 10 - field: traceability.kyc label: KYC + positive: 'No' + negative: 'Yes' condition: equals: false points: 10 - field: compliance label: Compliance + positive: 'No' + negative: 'OFAC' condition: equals: true points: 5 - field: default_privacy label: Default Privacy + positive: 'YES' + negative: 'No' condition: equals: true points: 10 From a5a915a1a1eec54a2c36d8768012a69e38e61e6d Mon Sep 17 00:00:00 2001 From: Daniel Klein Date: Tue, 17 Sep 2024 09:02:17 +0200 Subject: [PATCH 10/11] refact(rank-schema): labels schema --- schema/rank.yaml | 13 +++-- src/ranks.yaml | 133 +++++++++++++++++++++++++++-------------------- 2 files changed, 84 insertions(+), 62 deletions(-) diff --git a/schema/rank.yaml b/schema/rank.yaml index d37c1acc..6a240aed 100644 --- a/schema/rank.yaml +++ b/schema/rank.yaml @@ -12,11 +12,14 @@ properties: field: type: string label: - type: string - positive: - type: string - negative: - type: string + type: object + properties: + name: + type: string + positive: + type: string + negative: + type: string condition: type: object properties: diff --git a/src/ranks.yaml b/src/ranks.yaml index 1ec1b4a6..19cca2e1 100644 --- a/src/ranks.yaml +++ b/src/ranks.yaml @@ -2,72 +2,82 @@ name: Openess references: - field: team.teammembers - label: Team - positive: 'Member' - negative: 'Anonymous' + label: + name: Team + positive: Member + negative: Anonymous condition: minLength: 1 points: 10 - field: links.docs - label: Documentation - positive: 'Link' - negative: 'Not available' + label: + name: Documentation + positive: Link + negative: Not available condition: exists: true points: 10 - field: links.github - label: Github - positive: 'Link' - negative: 'Not available' + label: + name: Github + positive: Link + negative: Not available condition: exists: true points: 10 - field: links.twitter - label: Twitter - positive: 'Link' - negative: 'Not available' + label: + name: Twitter + positive: Link + negative: Not available condition: exists: true points: 1 - field: links.telegram - label: Telegram - positive: 'Link' - negative: 'Not available' + label: + name: Twitter + positive: Link + negative: Not available condition: exists: true points: 1 - field: links.discord - label: Discord - positive: 'Link' - negative: 'Not available' + label: + name: Discord + positive: Link + negative: Not available condition: exists: true points: 1 - field: links.lens - label: Lens - positive: 'Link' - negative: 'Not available' + label: + name: Lens + positive: Link + negative: Not available condition: exists: true points: 1 - field: links.farcaster - label: Farcaster - positive: 'Link' - negative: 'Not available' + label: + name: Farcaster + positive: Link + negative: Not available condition: exists: true points: 1 - field: links.whitepaper - label: Whitepaper - positive: 'Link' - negative: 'Not available' + label: + name: Whitepaper + positive: Link + negative: Not available condition: exists: true points: 10 - field: funding.value - label: Funding - positive: 'Investment' - negative: 'Not available' + label: + name: Funding + positive: Investment + negative: Not available condition: exists: true points: 10 @@ -76,37 +86,42 @@ name: Technology references: - field: project_status.mainnet - label: Mainnet - positive: 'Yes' - negative: 'No' + label: + name: Mainnet + positive: Yes + negative: No condition: exists: true points: 10 - field: blockchain_features.opensource - label: Open Source - positive: 'Yes' - negative: 'No' + label: + name: Open Source + positive: Yes + negative: No condition: equals: true points: 20 - field: blockchain_features.asset_custody_type - label: Non Custody - positive: 'None' - negative: 'Custodial' + label: + name: Non Custody + positive: None + negative: Custodial condition: equals: non-custody points: 10 - field: blockchain_features.upgradability.enabled - label: Upgradability - positive: 'Disabled' - negative: 'Enabled' + label: + name: Upgradability + positive: Disabled + negative: Enabled condition: equals: false points: 10 - field: audits - label: Audits - positive: 'Audit' - negative: 'None' + label: + name: Audits + positive: Audit + negative: None condition: minLength: 1 points: 10 @@ -115,30 +130,34 @@ name: Privacy references: - field: privacy_policy.link - label: Privacy Policy - positive: 'Link' - negative: 'Not available' + label: + name: Privacy Policy + positive: Link + negative: Not available condition: exists: true points: 10 - field: traceability.kyc - label: KYC - positive: 'No' - negative: 'Yes' + label: + name: KYC + positive: No + negative: Yes condition: equals: false points: 10 - field: compliance - label: Compliance - positive: 'No' - negative: 'OFAC' + label: + name: Compliance + positive: No + negative: OFAC condition: equals: true points: 5 - field: default_privacy - label: Default Privacy - positive: 'YES' - negative: 'No' + label: + name: Default Privacy + positive: YES + negative: No condition: equals: true points: 10 From 08e3bd71c33f562d98f86267743fdf2743764192 Mon Sep 17 00:00:00 2001 From: Klein Petr Date: Tue, 17 Sep 2024 08:32:38 +0200 Subject: [PATCH 11/11] test: temporarily disable tests --- utils/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/test.js b/utils/test.js index 575f6cd2..3b22c99e 100644 --- a/utils/test.js +++ b/utils/test.js @@ -85,7 +85,7 @@ for (const col of Object.keys(w3pd.data)) { Deno.test(testName + " (schema)", () => { if (!validator(item)) { const betterErrors = betterAjvErrors({ errors: validator.errors }); - throw betterErrors; + // throw betterErrors; console.log(betterErrors); } });