Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(docs): add and tidy examples #10

Merged
merged 10 commits into from
Dec 27, 2023
Merged
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Are JSON files up to date
name: Check json files
on:
pull_request:
branches:
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Test
on:
pull_request:
branches:
- main

jobs:
check_codebase:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
fetch-depth: 0

- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v3
with:
main-branch-name: 'main'

- name: Install pnpm
uses: pnpm/[email protected]
id: pnpm-install
with:
version: 7
run_install: true

- name: Run tests
run: |
pnpm test
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/security/suites/ed25519-2020/v1"
],
"id": "0xf275c2e31cae9462b6ca923fb5059c164c4b90b67a77e4160e40f7d69546a865",
"type": ["VerifiableCredential"],
"credentialSubject": {
"id": "did:litentry:substrate:0x3a2647fe0ecd1fe0d450fd8650cd8bf3536ecac77b6e8ec2df1b5f5fc9d62931",
"description": "You got the Top Award of community contest.",
"type": "Litentry & Contest Legend",
"assertions": [{ "src": "$is_contest_legend", "op": "==", "dst": "true" }],
"values": [false],
"endpoint": "http://localhost:9933"
},
"issuer": {
"id": "did:litentry:substrate:0xd2ca10cdb1886f99f72273aa502357dfe60b8a16d0e94974c988cf19546facc2",
"name": "Litentry TEE Worker",
"mrenclave": "MsSostcy6BCmtFzk4DGuXxqQsnqXx9EgKCZ6vHLts2p"
},
"issuanceDate": "2023-12-27T17:23:54.057204342+00:00",
"proof": {
"created": "2023-12-27T17:23:54.057701918+00:00",
"type": "Ed25519Signature2020",
"proofPurpose": "assertionMethod",
"proofValue": "45ac723de934358c79826cf2c8f2e92429ee1d59bc7069dc0026bf7116135d519cc9cd88ec4bda6213138686e44e00b7d1bfcbdfe047c4c30412af77bf890808",
"verificationMethod": "0xd2ca10cdb1886f99f72273aa502357dfe60b8a16d0e94974c988cf19546facc2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/security/suites/ed25519-2020/v1"
],
"id": "0xe0dbdfd87b3cc7f7dc1a98b50388f6f4dc1da82425007834f113d1e87d84dc65",
"type": ["VerifiableCredential"],
"credentialSubject": {
"id": "did:litentry:substrate:0x3a2647fe0ecd1fe0d450fd8650cd8bf3536ecac77b6e8ec2df1b5f5fc9d62931",
"description": "You participated in the community contest.",
"type": "Litentry & Contest Participant",
"assertions": [
{ "src": "$is_contest_participant", "op": "==", "dst": "true" }
],
"values": [false],
"endpoint": "http://localhost:9933"
},
"issuer": {
"id": "did:litentry:substrate:0xd2ca10cdb1886f99f72273aa502357dfe60b8a16d0e94974c988cf19546facc2",
"name": "Litentry TEE Worker",
"mrenclave": "MsSostcy6BCmtFzk4DGuXxqQsnqXx9EgKCZ6vHLts2p"
},
"issuanceDate": "2023-12-27T17:25:48.131330048+00:00",
"proof": {
"created": "2023-12-27T17:25:48.131748956+00:00",
"type": "Ed25519Signature2020",
"proofPurpose": "assertionMethod",
"proofValue": "45ac723de934358c79826cf2c8f2e92429ee1d59bc7069dc0026bf7116135d519cc9cd88ec4bda6213138686e44e00b7d1bfcbdfe047c4c30412af77bf890808",
"verificationMethod": "0xd2ca10cdb1886f99f72273aa502357dfe60b8a16d0e94974c988cf19546facc2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/security/suites/ed25519-2020/v1"
],
"id": "0x43e4f8908c32e50a9a08645241a558d57ede2dbfc95a30f9257e844ef441d633",
"type": ["VerifiableCredential"],
"credentialSubject": {
"id": "did:litentry:substrate:0x3a2647fe0ecd1fe0d450fd8650cd8bf3536ecac77b6e8ec2df1b5f5fc9d62931",
"description": "You got the Popularity Award of community contest.",
"type": "Litentry & Popularity Award of Score Contest",
"assertions": [
{ "src": "$is_contest_popularity", "op": "==", "dst": "true" }
],
"values": [false],
"endpoint": "http://localhost:9933"
},
"issuer": {
"id": "did:litentry:substrate:0xd2ca10cdb1886f99f72273aa502357dfe60b8a16d0e94974c988cf19546facc2",
"name": "Litentry TEE Worker",
"mrenclave": "MsSostcy6BCmtFzk4DGuXxqQsnqXx9EgKCZ6vHLts2p"
},
"issuanceDate": "2023-12-27T17:25:00.150406618+00:00",
"proof": {
"created": "2023-12-27T17:25:00.150831108+00:00",
"type": "Ed25519Signature2020",
"proofPurpose": "assertionMethod",
"proofValue": "45ac723de934358c79826cf2c8f2e92429ee1d59bc7069dc0026bf7116135d519cc9cd88ec4bda6213138686e44e00b7d1bfcbdfe047c4c30412af77bf890808",
"verificationMethod": "0xd2ca10cdb1886f99f72273aa502357dfe60b8a16d0e94974c988cf19546facc2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/security/suites/ed25519-2020/v1"
],
"id": "0xc03975489ae1df6e8a202856ac945a306b8a4c5eb5dca75ebe467adbdb6d88a9",
"type": ["VerifiableCredential"],
"credentialSubject": {
"id": "did:litentry:substrate:0x3a2647fe0ecd1fe0d450fd8650cd8bf3536ecac77b6e8ec2df1b5f5fc9d62931",
"description": "Congratulations on your participation in our first quiz in collaboration with our partner, Sora. You have embarked on an exciting educational journey, exploring the world of DeFi & Web3 Identity, we truly appreciate your curiosity and dedication.",
"type": "Litentry & SORA Quiz Attendee",
"assertions": [{ "src": "$is_attendee", "op": "==", "dst": "true" }],
"values": [false],
"endpoint": "http://localhost:9933"
},
"issuer": {
"id": "did:litentry:substrate:0xd2ca10cdb1886f99f72273aa502357dfe60b8a16d0e94974c988cf19546facc2",
"name": "Litentry TEE Worker",
"mrenclave": "MsSostcy6BCmtFzk4DGuXxqQsnqXx9EgKCZ6vHLts2p"
},
"issuanceDate": "2023-12-27T17:27:12.111359985+00:00",
"proof": {
"created": "2023-12-27T17:27:12.111781055+00:00",
"type": "Ed25519Signature2020",
"proofPurpose": "assertionMethod",
"proofValue": "45ac723de934358c79826cf2c8f2e92429ee1d59bc7069dc0026bf7116135d519cc9cd88ec4bda6213138686e44e00b7d1bfcbdfe047c4c30412af77bf890808",
"verificationMethod": "0xd2ca10cdb1886f99f72273aa502357dfe60b8a16d0e94974c988cf19546facc2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/security/suites/ed25519-2020/v1"
],
"id": "0x081cf96c620fcc97d6aeab0df473e5d474db70a4c45877b8b396b63a6f895c6f",
"type": ["VerifiableCredential"],
"credentialSubject": {
"id": "did:litentry:substrate:0x3a2647fe0ecd1fe0d450fd8650cd8bf3536ecac77b6e8ec2df1b5f5fc9d62931",
"description": "Congratulations on winning our first quiz in collaboration with Sora! By emerging as the winner, you have shown your excellent understanding of DeFi along with Web3 identity security and privacy. You are truly a champion in this field!",
"type": "Litentry & SORA Quiz Master",
"assertions": [{ "src": "$is_master", "op": "==", "dst": "true" }],
"values": [false],
"endpoint": "http://localhost:9933"
},
"issuer": {
"id": "did:litentry:substrate:0xd2ca10cdb1886f99f72273aa502357dfe60b8a16d0e94974c988cf19546facc2",
"name": "Litentry TEE Worker",
"mrenclave": "MsSostcy6BCmtFzk4DGuXxqQsnqXx9EgKCZ6vHLts2p"
},
"issuanceDate": "2023-12-27T17:28:12.128591524+00:00",
"proof": {
"created": "2023-12-27T17:28:12.129086512+00:00",
"type": "Ed25519Signature2020",
"proofPurpose": "assertionMethod",
"proofValue": "45ac723de934358c79826cf2c8f2e92429ee1d59bc7069dc0026bf7116135d519cc9cd88ec4bda6213138686e44e00b7d1bfcbdfe047c4c30412af77bf890808",
"verificationMethod": "0xd2ca10cdb1886f99f72273aa502357dfe60b8a16d0e94974c988cf19546facc2"
}
}
File renamed without changes.
31 changes: 31 additions & 0 deletions examples/20-weirdoghostgang-holder/weirdoghostgang-holder.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/security/suites/ed25519-2020/v1"
],
"id": "0xe0c8b1b07a108347df0ce548224ac9e018604f49444d8ac5580bad9cbf752c7b",
"type": ["VerifiableCredential"],
"credentialSubject": {
"id": "did:litentry:substrate:0x52a6c52dc82940a36fefd1474cc0778517bb1a56b7bda0e308b6c19152dd7510",
"description": "You are WeirdoGhostGang NFT holder",
"type": "WeirdoGhostGang Holder",
"assertions": [
{ "src": "$is_weirdo_ghost_gang_holder", "op": "==", "dst": "true" }
],
"values": [false],
"endpoint": "http://localhost:9933"
},
"issuer": {
"id": "did:litentry:substrate:0xd2ca10cdb1886f99f72273aa502357dfe60b8a16d0e94974c988cf19546facc2",
"name": "Litentry TEE Worker",
"mrenclave": "MsSostcy6BCmtFzk4DGuXxqQsnqXx9EgKCZ6vHLts2p"
},
"issuanceDate": "2023-12-27T21:01:54.065425159+00:00",
"proof": {
"created": "2023-12-27T21:01:54.065885623+00:00",
"type": "Ed25519Signature2020",
"proofPurpose": "assertionMethod",
"proofValue": "45ac723de934358c79826cf2c8f2e92429ee1d59bc7069dc0026bf7116135d519cc9cd88ec4bda6213138686e44e00b7d1bfcbdfe047c4c30412af77bf890808",
"verificationMethod": "0xd2ca10cdb1886f99f72273aa502357dfe60b8a16d0e94974c988cf19546facc2"
}
}
29 changes: 29 additions & 0 deletions examples/21-vip3-card-holder/vip3-card-holder-gold.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/security/suites/ed25519-2020/v1"
],
"id": "0x1dfde942fb40aedeb98d89cc2cf68adc8be0f2e23e249aab667ef627f02793c4",
"type": ["VerifiableCredential"],
"credentialSubject": {
"id": "did:litentry:substrate:0x52a6c52dc82940a36fefd1474cc0778517bb1a56b7bda0e308b6c19152dd7510",
"description": "You are VIP3 Gold Card Holder",
"type": "VIP3 Gold Card Holder",
"assertions": [{ "src": "$is_gold_card", "op": "==", "dst": "true" }],
"values": [false],
"endpoint": "http://localhost:9933"
},
"issuer": {
"id": "did:litentry:substrate:0xd2ca10cdb1886f99f72273aa502357dfe60b8a16d0e94974c988cf19546facc2",
"name": "Litentry TEE Worker",
"mrenclave": "MsSostcy6BCmtFzk4DGuXxqQsnqXx9EgKCZ6vHLts2p"
},
"issuanceDate": "2023-12-27T21:08:42.063843376+00:00",
"proof": {
"created": "2023-12-27T21:08:42.064263979+00:00",
"type": "Ed25519Signature2020",
"proofPurpose": "assertionMethod",
"proofValue": "45ac723de934358c79826cf2c8f2e92429ee1d59bc7069dc0026bf7116135d519cc9cd88ec4bda6213138686e44e00b7d1bfcbdfe047c4c30412af77bf890808",
"verificationMethod": "0xd2ca10cdb1886f99f72273aa502357dfe60b8a16d0e94974c988cf19546facc2"
}
}
29 changes: 29 additions & 0 deletions examples/21-vip3-card-holder/vip3-card-holder-silver.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/security/suites/ed25519-2020/v1"
],
"id": "0xc0472e1bc61d39f7db30fcfa4787bc2f22b8a275fd1657b1c83c08dc86ee5e32",
"type": ["VerifiableCredential"],
"credentialSubject": {
"id": "did:litentry:substrate:0x52a6c52dc82940a36fefd1474cc0778517bb1a56b7bda0e308b6c19152dd7510",
"description": "You are VIP3 Silver Card Holder",
"type": "VIP3 Silver Card Holder",
"assertions": [{ "src": "$is_silver_card", "op": "==", "dst": "true" }],
"values": [false],
"endpoint": "http://localhost:9933"
},
"issuer": {
"id": "did:litentry:substrate:0xd2ca10cdb1886f99f72273aa502357dfe60b8a16d0e94974c988cf19546facc2",
"name": "Litentry TEE Worker",
"mrenclave": "MsSostcy6BCmtFzk4DGuXxqQsnqXx9EgKCZ6vHLts2p"
},
"issuanceDate": "2023-12-27T21:09:18.055419161+00:00",
"proof": {
"created": "2023-12-27T21:09:18.055875437+00:00",
"type": "Ed25519Signature2020",
"proofPurpose": "assertionMethod",
"proofValue": "45ac723de934358c79826cf2c8f2e92429ee1d59bc7069dc0026bf7116135d519cc9cd88ec4bda6213138686e44e00b7d1bfcbdfe047c4c30412af77bf890808",
"verificationMethod": "0xd2ca10cdb1886f99f72273aa502357dfe60b8a16d0e94974c988cf19546facc2"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/security/suites/ed25519-2020/v1"
],
"id": "0x18190410b810c986ffe864c6422b13f914e45fc654496e342e1896e3210362a5",
"type": ["VerifiableCredential"],
"credentialSubject": {
"id": "did:litentry:substrate:0x8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48",
"description": "The user has participated in any Polkadot on-chain governance events",
"type": "Polkadot Governance Participation Proof",
"assertions": [
{ "src": "$total_governance_action", "op": ">", "dst": "0" }
],
"values": [false],
"endpoint": "http://localhost:9933"
},
"issuer": {
"id": "did:litentry:substrate:0xd2ca10cdb1886f99f72273aa502357dfe60b8a16d0e94974c988cf19546facc2",
"name": "Litentry TEE Worker",
"mrenclave": "MsSostcy6BCmtFzk4DGuXxqQsnqXx9EgKCZ6vHLts2p"
},
"issuanceDate": "2023-12-27T14:44:36.146050718+00:00",
"proof": {
"created": "2023-12-27T14:44:36.147023625+00:00",
"type": "Ed25519Signature2020",
"proofPurpose": "assertionMethod",
"proofValue": "45ac723de934358c79826cf2c8f2e92429ee1d59bc7069dc0026bf7116135d519cc9cd88ec4bda6213138686e44e00b7d1bfcbdfe047c4c30412af77bf890808",
"verificationMethod": "0xd2ca10cdb1886f99f72273aa502357dfe60b8a16d0e94974c988cf19546facc2"
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "litentry-vc-jsonschema-project",
"version": "0.0.0",
"scripts": {
"generate": "pnpm nx run schemas:generate"
"generate": "nx run schemas:generate",
"test": "nx affected --target=test --plain"
},
"private": true,
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ describe('1-basic-identity-verification/1-0-0', () => {
const validate = ajv.compile(schema);
expect(validate.errors).toBeNull();

const json = JSON.parse(fs.readFileSync('examples/a1/a1.json', 'utf8'));
const json = JSON.parse(
fs.readFileSync('examples/1-basic-identity-verification/a1.json', 'utf8')
);
const valid = validate(json);

if (!valid) console.log(validate.errors);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ajv } from '../ajv';
import { schema } from './1-0-0';

describe('10-account-class-of-year/1-0-0', () => {
it.skip('should work', () => {
it('should work', () => {
const validate = ajv.compile(schema);
expect(validate.errors).toBeNull();

Expand Down
2 changes: 1 addition & 1 deletion packages/schemas/src/lib/10-account-class-of-year/1-0-0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const schema: JSONSchema7 = {
assertion.clause({
src: ['$account_created_year'],
op: ['=='],
dst: undefined, // value is set by the issuer
dst: undefined, // Integer literal or "Invalid"
}),
],
}),
Expand Down
12 changes: 7 additions & 5 deletions packages/schemas/src/lib/11-token-holder/1-0-0.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import * as fs from 'fs';
import { globSync as glob } from 'fast-glob';

import { ajv } from '../ajv';
import { schema } from './1-0-0';

const jsonFiles = glob('examples/11-token-holder/*.json');

const validate = ajv.compile(schema);

describe('11-token-holder/1-0-0', () => {
it.skip('should work', () => {
const validate = ajv.compile(schema);
it.each(jsonFiles)('should work for %s', (example) => {
expect(validate.errors).toBeNull();

const json = JSON.parse(
fs.readFileSync('examples/token-holder/11-token-holder.json', 'utf8')
);
const json = JSON.parse(fs.readFileSync(example, 'utf8'));
const valid = validate(json);

if (!valid) console.log(validate.errors);
Expand Down
Loading
Loading