Skip to content

Commit

Permalink
Remove uniffi boilerplate (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
KendallWeihe authored Sep 5, 2024
1 parent 76cf077 commit 8162595
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 42 deletions.
13 changes: 6 additions & 7 deletions bindings/web5_uniffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ use web5_uniffi_wrapper::{
VerifiableCredentialCreateOptions as VerifiableCredentialCreateOptionsData,
VerifiableCredentialData,
},
verifiable_presentation_1_1::{
VerifiablePresentation,
VerifiablePresentationCreateOptions as VerifiablePresentationCreateOptionsData,
VerifiablePresentationData,
},
verifiable_presentation_1_1::VerifiablePresentation,
},
crypto::{
dsa::{
Expand Down Expand Up @@ -39,8 +35,11 @@ use web5_uniffi_wrapper::{
};

use web5::{
credentials::CredentialSchema as CredentialSchemaData,
credentials::CredentialStatus as CredentialStatusData,
credentials::{
CredentialSchema as CredentialSchemaData, CredentialStatus as CredentialStatusData,
VerifiablePresentation as VerifiablePresentationData,
VerifiablePresentationCreateOptions as VerifiablePresentationCreateOptionsData,
},
crypto::{dsa::Dsa, jwk::Jwk as JwkData},
dids::{
data_model::{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
use crate::{dids::bearer_did::BearerDid, errors::Result};
use std::{sync::Arc, time::SystemTime};
use std::sync::Arc;
use web5::credentials::VerifiablePresentation as InnerVerifiablePresentation;
use web5::credentials::VerifiablePresentationCreateOptions as InnerVerifiablePresentationCreateOptions;

#[derive(Default)]
pub struct VerifiablePresentationCreateOptions {
pub id: Option<String>,
pub context: Option<Vec<String>>,
pub r#type: Option<Vec<String>>,
pub issuance_date: Option<SystemTime>,
pub expiration_date: Option<SystemTime>,
}
use web5::credentials::VerifiablePresentationCreateOptions;

pub struct VerifiablePresentation {
pub inner_vp: InnerVerifiablePresentation,
Expand All @@ -22,22 +13,13 @@ impl VerifiablePresentation {
vc_jwts: Vec<String>,
options: Option<VerifiablePresentationCreateOptions>,
) -> Result<Self> {
let options = options.unwrap_or_default();
let inner_options = InnerVerifiablePresentationCreateOptions {
id: options.id,
context: options.context,
r#type: options.r#type,
issuance_date: options.issuance_date,
expiration_date: options.expiration_date,
};

let inner_vp = InnerVerifiablePresentation::create(holder, vc_jwts, Some(inner_options))?;
let inner_vp = InnerVerifiablePresentation::create(holder, vc_jwts, options)?;

Ok(Self { inner_vp })
}

pub fn get_data(&self) -> Result<VerifiablePresentationData> {
Ok(VerifiablePresentationData {
pub fn get_data(&self) -> Result<InnerVerifiablePresentation> {
Ok(InnerVerifiablePresentation {
context: self.inner_vp.context.clone(),
id: self.inner_vp.id.clone(),
r#type: self.inner_vp.r#type.clone(),
Expand All @@ -63,14 +45,3 @@ impl VerifiablePresentation {
Ok(vp_jwt)
}
}

#[derive(Clone)]
pub struct VerifiablePresentationData {
pub context: Vec<String>,
pub id: String,
pub r#type: Vec<String>,
pub holder: String,
pub issuance_date: SystemTime,
pub expiration_date: Option<SystemTime>,
pub verifiable_credential: Vec<String>,
}
2 changes: 1 addition & 1 deletion web5-spec

0 comments on commit 8162595

Please sign in to comment.