diff --git a/aries_vcx_core/src/ledger/indy_vdr_ledger.rs b/aries_vcx_core/src/ledger/indy_vdr_ledger.rs index 843280628f..7e5c856b9a 100644 --- a/aries_vcx_core/src/ledger/indy_vdr_ledger.rs +++ b/aries_vcx_core/src/ledger/indy_vdr_ledger.rs @@ -181,6 +181,7 @@ where V: ResponseCacher + Send + Sync, { async fn get_attr(&self, target_did: &str, attr_name: &str) -> VcxCoreResult { + trace!("get_attr >> target_did: {target_did}, attr_name: {attr_name}"); let dest = DidValue::from_str(target_did)?; let request = self.request_builder()? @@ -189,12 +190,14 @@ where } async fn get_nym(&self, did: &str) -> VcxCoreResult { + trace!("get_nym >> did: {did}"); let dest = DidValue::from_str(did)?; let request = self.request_builder()?.build_get_nym_request(None, &dest)?; self.submit_request(None, request).await } async fn get_txn_author_agreement(&self) -> VcxCoreResult> { + trace!("get_txn_author_agreement >>"); let request = self .request_builder()? .build_get_txn_author_agreement_request(None, None)?; @@ -205,11 +208,12 @@ where } async fn get_ledger_txn(&self, seq_no: i32, submitter_did: Option<&str>) -> VcxCoreResult { + trace!("get_ledger_txn >> seq_no: {seq_no}"); let identifier = submitter_did.map(DidValue::from_str).transpose()?; let request = self.request_builder()? .build_get_txn_request(identifier.as_ref(), LedgerType::DOMAIN.to_id(), seq_no)?; - self.submit_request(Some(&seq_no.to_string()), request).await + self.submit_request(None, request).await } } @@ -302,29 +306,38 @@ where V: ResponseCacher + Send + Sync, { async fn get_schema(&self, schema_id: &str, _submitter_did: Option<&str>) -> VcxCoreResult { + trace!("get_schema >> schema_id: {schema_id}"); let request = self .request_builder()? .build_get_schema_request(None, &SchemaId::from_str(schema_id)?)?; - let response = self.submit_request(Some(schema_id), request).await?; + let response = self.submit_request(None, request).await?; let schema = self.response_parser.parse_get_schema_response(&response, None)?; Ok(serde_json::to_string(&schema)?) } async fn get_cred_def(&self, cred_def_id: &str, submitter_did: Option<&str>) -> VcxCoreResult { + trace!("get_cred_def >> cred_def_id: {cred_def_id}"); let identifier = submitter_did.map(DidValue::from_str).transpose()?; let id = CredentialDefinitionId::from_str(cred_def_id)?; let request = self .request_builder()? .build_get_cred_def_request(identifier.as_ref(), &id)?; - let response = self.submit_request(Some(id.as_ref()), request).await?; + // note: Before we try to create credential definition, we are checking if it already + // doesn't exist on the ledger to prevent invalidating the old one. + // When we make the first request, it typically doesn't exist, but we don't want to + // cache such as result. So caching strategy should perhaps only store data in cache + // if ledger response was found / the response is success. + // Therefore parsing should happen prior to caching. + let response = self.submit_request(None, request).await?; let cred_def = self.response_parser.parse_get_cred_def_response(&response, None)?; Ok(serde_json::to_string(&cred_def)?) } async fn get_rev_reg_def_json(&self, rev_reg_id: &str) -> VcxCoreResult { + trace!("get_rev_reg_def_json >> rev_reg_id: {rev_reg_id}"); let id = RevocationRegistryId::from_str(rev_reg_id)?; let request = self.request_builder()?.build_get_revoc_reg_def_request(None, &id)?; - let res = self.submit_request(Some(rev_reg_id), request).await?; + let res = self.submit_request(None, request).await?; let rev_reg_def = self.response_parser.parse_get_revoc_reg_def_response(&res)?; Ok(serde_json::to_string(&rev_reg_def)?) } @@ -335,6 +348,7 @@ where from: Option, to: Option, ) -> VcxCoreResult<(String, String, u64)> { + trace!("get_rev_reg_delta_json >> rev_reg_id: {rev_reg_id}, from: {from:?}, to: {to:?}"); let revoc_reg_def_id = RevocationRegistryId::from_str(rev_reg_id)?; let from = from.map(|x| x as i64); @@ -360,6 +374,7 @@ where } async fn get_rev_reg(&self, rev_reg_id: &str, timestamp: u64) -> VcxCoreResult<(String, String, u64)> { + trace!("get_rev_reg >> rev_reg_id: {rev_reg_id}, timestamp: {timestamp}"); let revoc_reg_def_id = RevocationRegistryId::from_str(rev_reg_id)?; let request = self.request_builder()?.build_get_revoc_reg_request(