diff --git a/aries/aries_vcx_anoncreds/src/anoncreds/anoncreds/type_conversion.rs b/aries/aries_vcx_anoncreds/src/anoncreds/anoncreds/type_conversion.rs index 35c0762685..664b717aa3 100644 --- a/aries/aries_vcx_anoncreds/src/anoncreds/anoncreds/type_conversion.rs +++ b/aries/aries_vcx_anoncreds/src/anoncreds/anoncreds/type_conversion.rs @@ -264,9 +264,8 @@ impl Convert for OurRevocationRegistryDefinition { type Error = Box; fn convert(self, (): Self::Args) -> Result { - let issuer_id = self.id.to_string().split(':').next().unwrap().to_string(); Ok(AnoncredsRevocationRegistryDefinition { - issuer_id: AnoncredsIssuerId::new(issuer_id)?, + issuer_id: self.issuer_id.convert(())?, revoc_def_type: self.revoc_def_type.convert(())?, tag: self.tag, cred_def_id: AnoncredsCredentialDefinitionId::new(self.cred_def_id.to_string())?, @@ -288,6 +287,7 @@ impl Convert for AnoncredsRevocationRegistryDefinition { fn convert(self, (rev_reg_def_id,): Self::Args) -> Result { Ok(OurRevocationRegistryDefinition { id: OurRevocationRegistryDefinitionId::new(rev_reg_def_id)?, + issuer_id: self.issuer_id.convert(())?, revoc_def_type: self.revoc_def_type.convert(())?, tag: self.tag, cred_def_id: OurCredentialDefinitionId::new(self.cred_def_id.to_string())?, @@ -492,6 +492,7 @@ impl Convert for HashMap Result { match self { IndyVdrCredentialDefinition::CredentialDefinitionV1(cred_def) => { - if let Some((_method, issuer_id, _sig_type, _schema_id, _tag)) = cred_def.id.parts() - { - Ok(OurCredentialDefinition { - id: OurCredentialDefinitionId::new(cred_def.id.to_string())?, - schema_id: OurSchemaId::new_unchecked(cred_def.schema_id.to_string()), - signature_type: OurSignatureType::CL, - tag: cred_def.tag, - value: OurCredentialDefinitionData { - primary: serde_json::from_value(cred_def.value.primary)?, - revocation: cred_def - .value - .revocation - .map(serde_json::from_value) - .transpose()?, - }, - issuer_id: IssuerId::new(issuer_id.to_string())?, - }) - } else { - todo!() - } + let Some((_method, issuer_id, _sig_type, _schema_id, _tag)) = cred_def.id.parts() + else { + return Err(format!("cred def ID is not valid: {}", cred_def.id).into()); + }; + Ok(OurCredentialDefinition { + id: OurCredentialDefinitionId::new(cred_def.id.to_string())?, + schema_id: OurSchemaId::new_unchecked(cred_def.schema_id.to_string()), + signature_type: OurSignatureType::CL, + tag: cred_def.tag, + value: OurCredentialDefinitionData { + primary: serde_json::from_value(cred_def.value.primary)?, + revocation: cred_def + .value + .revocation + .map(serde_json::from_value) + .transpose()?, + }, + issuer_id: IssuerId::new(issuer_id.to_string())?, + }) } } } @@ -233,8 +232,12 @@ impl Convert for IndyVdrRevocationRegistryDefinition { fn convert(self, (): Self::Args) -> Result { match self { IndyVdrRevocationRegistryDefinition::RevocationRegistryDefinitionV1(rev_reg_def) => { + let Some((issuer_id, _cred_def, _type, _tag)) = rev_reg_def.id.parts() else { + return Err(format!("rev reg id is not valid: {}", rev_reg_def.id).into()); + }; Ok(OurRevocationRegistryDefinition { id: OurRevocationRegistryDefinitionId::new(rev_reg_def.id.to_string())?, + issuer_id: IssuerId::new(issuer_id.to_string())?, revoc_def_type: anoncreds_types::data_types::ledger::rev_reg_def::RegistryType::CL_ACCUM, tag: rev_reg_def.tag, diff --git a/aries/misc/anoncreds_types/src/data_types/ledger/rev_reg_def.rs b/aries/misc/anoncreds_types/src/data_types/ledger/rev_reg_def.rs index 61a25eb3fd..44633e6803 100644 --- a/aries/misc/anoncreds_types/src/data_types/ledger/rev_reg_def.rs +++ b/aries/misc/anoncreds_types/src/data_types/ledger/rev_reg_def.rs @@ -5,7 +5,8 @@ use anoncreds_clsignatures::RevocationKeyPrivate; use crate::{ cl::RevocationKeyPublic, data_types::identifiers::{ - cred_def_id::CredentialDefinitionId, rev_reg_def_id::RevocationRegistryDefinitionId, + cred_def_id::CredentialDefinitionId, issuer_id::IssuerId, + rev_reg_def_id::RevocationRegistryDefinitionId, }, utils::validation::Validatable, }; @@ -51,7 +52,7 @@ pub struct RevocationRegistryDefinitionValuePublicKeys { #[serde(rename_all = "camelCase")] pub struct RevocationRegistryDefinition { pub id: RevocationRegistryDefinitionId, - // pub issuer_id: IssuerId, // This is not on ledger + pub issuer_id: IssuerId, pub revoc_def_type: RegistryType, pub tag: String, pub cred_def_id: CredentialDefinitionId, @@ -61,7 +62,7 @@ pub struct RevocationRegistryDefinition { impl Validatable for RevocationRegistryDefinition { fn validate(&self) -> Result<(), crate::error::Error> { self.cred_def_id.validate()?; - // self.issuer_id.validate()?; + self.issuer_id.validate()?; Ok(()) }