Skip to content

Commit

Permalink
feat(dataverse): use a dedicated type predicate for cred storage
Browse files Browse the repository at this point in the history
  • Loading branch information
amimart committed Feb 13, 2024
1 parent 1489f95 commit f74aa3b
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions contracts/okp4-dataverse/src/registrar/rdf.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -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",
};
Expand All @@ -29,6 +32,7 @@ impl<'a> TryFrom<&'a DataverseCredential<'a>> for Vec<Triple<'a>> {

fn try_from(credential: &'a DataverseCredential<'a>) -> Result<Self, Self::Error> {
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![
Expand All @@ -48,17 +52,17 @@ impl<'a> TryFrom<&'a DataverseCredential<'a>> for Vec<Triple<'a>> {
},
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 {
Expand Down

0 comments on commit f74aa3b

Please sign in to comment.