From f74aa3b3aecfc4c81ebd2787fe905ae8c1e02a86 Mon Sep 17 00:00:00 2001 From: Arnaud Mimart <33665250+amimart@users.noreply.github.com> Date: Tue, 13 Feb 2024 21:47:05 +0100 Subject: [PATCH] feat(dataverse): use a dedicated type predicate for cred storage --- contracts/okp4-dataverse/src/registrar/rdf.rs | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/contracts/okp4-dataverse/src/registrar/rdf.rs b/contracts/okp4-dataverse/src/registrar/rdf.rs index 159af395..03685cca 100644 --- a/contracts/okp4-dataverse/src/registrar/rdf.rs +++ b/contracts/okp4-dataverse/src/registrar/rdf.rs @@ -1,4 +1,4 @@ -use crate::credential::rdf_marker::{RDF_DATE_TYPE, RDF_TYPE}; +use crate::credential::rdf_marker::RDF_DATE_TYPE; use crate::registrar::credential::DataverseCredential; use crate::ContractError; use cosmwasm_std::{Binary, StdError}; @@ -8,6 +8,9 @@ use rio_api::model::{BlankNode, Literal, NamedNode, Subject, Term, Triple}; pub const VC_SUBMITTER_ADDRESS: NamedNode<'_> = NamedNode { iri: "dataverse:credential#submitterAddress", }; +pub const VC_TYPE: NamedNode<'_> = NamedNode { + iri: "dataverse:credential#type", +}; pub const VC_ISSUER: NamedNode<'_> = NamedNode { iri: "dataverse:credential#issuer", }; @@ -29,6 +32,7 @@ impl<'a> TryFrom<&'a DataverseCredential<'a>> for Vec> { fn try_from(credential: &'a DataverseCredential<'a>) -> Result { let c_subject = Subject::NamedNode(NamedNode { iri: credential.id }); + //todo: use the canon identifier issuer instead and rename all blank nodes let claim_node = BlankNode { id: "c0" }; let mut triples = vec![ @@ -48,17 +52,17 @@ impl<'a> TryFrom<&'a DataverseCredential<'a>> for Vec> { }, Triple { subject: c_subject, - predicate: VC_VALID_FROM, - object: Term::Literal(Literal::Typed { - value: credential.valid_from, - datatype: RDF_DATE_TYPE, + predicate: VC_TYPE, + object: Term::NamedNode(NamedNode { + iri: credential.r#type, }), }, Triple { subject: c_subject, - predicate: RDF_TYPE, - object: Term::NamedNode(NamedNode { - iri: credential.r#type, + predicate: VC_VALID_FROM, + object: Term::Literal(Literal::Typed { + value: credential.valid_from, + datatype: RDF_DATE_TYPE, }), }, Triple {