Skip to content

Commit

Permalink
Sync up with latest indy-vdr version
Browse files Browse the repository at this point in the history
Signed-off-by: Patrik Stas <[email protected]>
  • Loading branch information
Patrik-Stas committed Aug 14, 2023
1 parent 952e47f commit 2e54125
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 32 deletions.
11 changes: 9 additions & 2 deletions aries_vcx/src/common/ledger/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ use std::{collections::HashMap, sync::Arc};

use crate::common::ledger::service_didsov::EndpointDidSov;
use crate::handlers::util::AnyInvitation;
use aries_vcx_core::ledger::base_ledger::{IndyLedgerRead, IndyLedgerWrite, IndyRole};
use aries_vcx_core::ledger::base_ledger::{IndyLedgerRead, IndyLedgerWrite};
use aries_vcx_core::ledger::indy_vdr_ledger::{LedgerRole, UpdateRole};
use aries_vcx_core::wallet::base_wallet::BaseWallet;
use serde_json::Value;

Expand Down Expand Up @@ -235,7 +236,13 @@ pub async fn write_endorser_did(
alias: Option<String>,
) -> VcxResult<String> {
let res = indy_ledger_write
.write_did(submitter_did, target_did, target_vk, IndyRole::Endorser, alias)
.write_did(
submitter_did,
target_did,
target_vk,
Some(UpdateRole::Set(LedgerRole::Endorser)),
alias,
)
.await?;
check_response(&res)?;
Ok(res)
Expand Down
7 changes: 3 additions & 4 deletions aries_vcx/src/utils/mockdata/profile/mock_ledger.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use aries_vcx_core::errors::error::{AriesVcxCoreError, AriesVcxCoreErrorKind, VcxCoreResult};
use aries_vcx_core::ledger::base_ledger::{
AnoncredsLedgerRead, AnoncredsLedgerWrite, IndyLedgerRead, IndyLedgerWrite, IndyRole,
};
use aries_vcx_core::ledger::base_ledger::{AnoncredsLedgerRead, AnoncredsLedgerWrite, IndyLedgerRead, IndyLedgerWrite};
use aries_vcx_core::ledger::indy_vdr_ledger::UpdateRole;
use async_trait::async_trait;

use crate::utils;
Expand Down Expand Up @@ -65,7 +64,7 @@ impl IndyLedgerWrite for MockLedger {
submitter_did: &str,
target_did: &str,
target_vk: &str,
role: IndyRole,
role: Option<UpdateRole>,
alias: Option<String>,
) -> VcxCoreResult<String> {
Ok(r#"{"rc":"success"}"#.to_string())
Expand Down
24 changes: 3 additions & 21 deletions aries_vcx_core/src/ledger/base_ledger.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::fmt::Debug;

use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use indy_vdr::ledger::constants::UpdateRole;
use serde::Serialize;

use crate::errors::error::VcxCoreResult;

Expand All @@ -13,25 +14,6 @@ pub trait IndyLedgerRead: Debug + Send + Sync {
async fn get_ledger_txn(&self, seq_no: i32, submitter_did: Option<&str>) -> VcxCoreResult<String>;
}

#[derive(Debug)]
pub enum IndyRole {
Steward,
Trustee,
Endorser,
NetworkMonitor,
}

impl IndyRole {
pub fn as_indyvdr_repr(&self) -> &'static str {
match self {
IndyRole::Steward => "STEWARD",
IndyRole::Trustee => "TRUSTEE",
IndyRole::Endorser => "ENDORSER",
IndyRole::NetworkMonitor => "NETWORK_MONITOR",
}
}
}

#[async_trait]
pub trait IndyLedgerWrite: Debug + Send + Sync {
async fn publish_nym(
Expand All @@ -50,7 +32,7 @@ pub trait IndyLedgerWrite: Debug + Send + Sync {
submitter_did: &str,
target_did: &str,
target_vk: &str,
role: IndyRole,
role: Option<UpdateRole>,
alias: Option<String>,
) -> VcxCoreResult<String>;
}
Expand Down
11 changes: 6 additions & 5 deletions aries_vcx_core/src/ledger/indy_vdr_ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::fmt::{Debug, Formatter};
use std::str::FromStr;
use std::sync::{Arc, RwLock};
use time::OffsetDateTime;
use vdr::ledger::constants::UpdateRole;
pub use vdr::ledger::constants::{LedgerRole, UpdateRole};
use vdr::ledger::requests::cred_def::CredentialDefinitionV1;
use vdr::ledger::requests::rev_reg::{RevocationRegistryDelta, RevocationRegistryDeltaV1};
use vdr::ledger::requests::rev_reg_def::{RegistryType, RevocationRegistryDefinition, RevocationRegistryDefinitionV1};
Expand All @@ -21,7 +21,7 @@ use vdr::utils::did::DidValue;
use vdr::utils::Qualifiable;

use crate::errors::error::{AriesVcxCoreError, AriesVcxCoreErrorKind, VcxCoreResult};
use crate::ledger::base_ledger::{IndyRole, TaaConfigurator, TxnAuthrAgrmtOptions};
use crate::ledger::base_ledger::{TaaConfigurator, TxnAuthrAgrmtOptions};
use crate::ledger::common::verify_transaction_can_be_endorsed;

use super::base_ledger::{AnoncredsLedgerRead, AnoncredsLedgerWrite, IndyLedgerRead, IndyLedgerWrite};
Expand Down Expand Up @@ -326,7 +326,7 @@ where
submitter_did: &str,
target_did: &str,
target_vk: &str,
role: IndyRole,
role: Option<UpdateRole>,
alias: Option<String>,
) -> VcxCoreResult<String> {
debug!("write_did >> submitter_did: {submitter_did}, target_did: {target_did}, target_vk: {target_vk}, role: {role:?}, alias: {alias:?}");
Expand All @@ -337,8 +337,9 @@ where
&dest,
Some(target_vk.into()),
alias,
// todo: this is ugly, but needs to be fixed on indy-vdr side - it should work with enums, not strings
Some(String::from(role.as_indyvdr_repr())),
role,
None,
None,
)?;
let request = self.append_txn_author_agreement_to_request(request).await?;
let response = self.sign_and_submit_request(submitter_did, request).await?;
Expand Down

0 comments on commit 2e54125

Please sign in to comment.