Skip to content

Commit

Permalink
Address CR
Browse files Browse the repository at this point in the history
Signed-off-by: Miroslav Kovar <miroslav.kovar@absa.africa>
  • Loading branch information
mirgee committed May 19, 2023
1 parent dd58883 commit 43a5b89
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion aries_vcx/tests/test_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ mod integration_tests {
#[tokio::test]
#[ignore]
async fn test_endorse_transaction() {
SetupProfile::run_indy(|setup| async move {
SetupProfile::run(|setup| async move {
let ledger = Arc::clone(&setup.profile).inject_ledger();
let (author_did, _) = add_new_did(&setup.profile, &setup.institution_did, None).await.unwrap();
let (endorser_did, _) = add_new_did(&setup.profile, &setup.institution_did, Some("ENDORSER"))
Expand Down
8 changes: 4 additions & 4 deletions aries_vcx_core/src/common/ledger/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@ pub struct ReplyDataV1 {
pub result: serde_json::Value,
}

pub fn verify_transaction_can_be_endorsed(transaction_json: &str, did: &str) -> VcxCoreResult<()> {
pub fn verify_transaction_can_be_endorsed(transaction_json: &str, submitter_did: &str) -> VcxCoreResult<()> {
let transaction: Request = serde_json::from_str(transaction_json)
.map_err(|err| AriesVcxCoreError::from_msg(AriesVcxCoreErrorKind::InvalidJson, format!("{err:?}")))?;

let transaction_endorser = transaction.endorser.ok_or(AriesVcxCoreError::from_msg(
let endorser_did = transaction.endorser.ok_or(AriesVcxCoreError::from_msg(
AriesVcxCoreErrorKind::InvalidJson,
"Transaction cannot be endorsed: endorser DID is not set.",
))?;

if transaction_endorser != did {
if endorser_did != submitter_did {
return Err(AriesVcxCoreError::from_msg(
AriesVcxCoreErrorKind::InvalidJson,
format!(
"Transaction cannot be endorsed: transaction endorser DID `{transaction_endorser}` and sender DID `{did}` are different"
"Transaction cannot be endorsed: transaction endorser DID `{endorser_did}` and sender DID `{submitter_did}` are different"
),
));
}
Expand Down
12 changes: 9 additions & 3 deletions aries_vcx_core/src/ledger/indy_vdr_ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,16 @@ where
&self,
schema_json: &str,
submitter_did: &str,
_endorser_did: Option<String>,
endorser_did: Option<String>,
) -> VcxCoreResult<()> {
let request = self._build_schema_request(submitter_did, schema_json)?;
let request = _append_txn_author_agreement_to_request(request).await?;
let mut request = self._build_schema_request(submitter_did, schema_json)?;
request = _append_txn_author_agreement_to_request(request).await?;
if let Some(endorser_did) = endorser_did {
request = PreparedRequest::from_request_json(
self.set_endorser(submitter_did, &request.req_json.to_string(), &endorser_did)
.await?,
)?
}
self._sign_and_submit_request(submitter_did, request).await.map(|_| ())
}

Expand Down

0 comments on commit 43a5b89

Please sign in to comment.