Skip to content

Commit

Permalink
Remove agency client from libvcx-core tests and aries-vcx-agent (hype…
Browse files Browse the repository at this point in the history
…rledger#985)

* Remove agency client from libvcx-core tests
* Remove commented mediated connection tests
* Remove mediated connection from aries-vcx-agent

---------

Signed-off-by: Miroslav Kovar <miroslav.kovar@absa.africa>
  • Loading branch information
mirgee authored Sep 19, 2023
1 parent 0907dcc commit b722167
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 540 deletions.
2 changes: 0 additions & 2 deletions agents/rust/aries-vcx-agent/src/agent/agent_config.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use aries_vcx::agency_client::configuration::AgencyClientConfig;
use aries_vcx_core::wallet::indy::{IssuerConfig, WalletConfig};

#[derive(Clone)]
pub struct AgentConfig {
pub config_wallet: WalletConfig,
pub config_agency_client: Option<AgencyClientConfig>,
pub config_issuer: IssuerConfig,
}
32 changes: 2 additions & 30 deletions agents/rust/aries-vcx-agent/src/agent/agent_struct.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
use std::sync::Arc;

use aries_vcx::agency_client::agency_client::AgencyClient;
use aries_vcx::core::profile::profile::Profile;
use aries_vcx_core::wallet::agency_client_wallet::ToBaseAgencyClientWallet;

use crate::agent::agent_config::AgentConfig;

use crate::error::*;
use crate::services::connection::ServiceConnections;
use crate::services::{
credential_definition::ServiceCredentialDefinitions, holder::ServiceCredentialsHolder,
issuer::ServiceCredentialsIssuer, mediated_connection::ServiceMediatedConnections, prover::ServiceProver,
revocation_registry::ServiceRevocationRegistries, schema::ServiceSchemas, verifier::ServiceVerifier,
issuer::ServiceCredentialsIssuer, prover::ServiceProver, revocation_registry::ServiceRevocationRegistries,
schema::ServiceSchemas, verifier::ServiceVerifier,
};

#[derive(Clone)]
pub struct Agent {
pub(super) profile: Arc<dyn Profile>,
pub(super) config: AgentConfig,
pub(super) connections: Arc<ServiceConnections>,
pub(super) mediated_connections: Option<Arc<ServiceMediatedConnections>>,
pub(super) schemas: Arc<ServiceSchemas>,
pub(super) cred_defs: Arc<ServiceCredentialDefinitions>,
pub(super) rev_regs: Arc<ServiceRevocationRegistries>,
Expand All @@ -42,34 +38,10 @@ impl Agent {
self.config.config_issuer.institution_did.clone()
}

pub fn agency_client(&self) -> AgentResult<AgencyClient> {
if let Some(config_agency_client) = &self.config.config_agency_client {
let wallet = self.profile.inject_wallet();
AgencyClient::new()
.configure(wallet.to_base_agency_client_wallet(), config_agency_client)
.map_err(|err| {
AgentError::from_msg(
AgentErrorKind::GenericAriesVcxError,
&format!("Failed to configure agency client: {}", err),
)
})
} else {
Err(AgentError::from_kind(
AgentErrorKind::MediatedConnectionServiceUnavailable,
))
}
}

pub fn connections(&self) -> Arc<ServiceConnections> {
self.connections.clone()
}

pub fn mediated_connections(&self) -> AgentResult<Arc<ServiceMediatedConnections>> {
self.mediated_connections
.clone()
.ok_or_else(|| AgentError::from_kind(AgentErrorKind::MediatedConnectionServiceUnavailable))
}

pub fn schemas(&self) -> Arc<ServiceSchemas> {
self.schemas.clone()
}
Expand Down
33 changes: 0 additions & 33 deletions agents/rust/aries-vcx-agent/src/agent/init.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::sync::Arc;
use std::time::Duration;

use aries_vcx::core::profile::ledger::{build_ledger_components, VcxPoolConfig};
use aries_vcx::global::settings::DEFAULT_LINK_SECRET_ALIAS;
Expand All @@ -22,20 +21,13 @@ use crate::{
credential_definition::ServiceCredentialDefinitions,
holder::ServiceCredentialsHolder,
issuer::ServiceCredentialsIssuer,
mediated_connection::ServiceMediatedConnections,
prover::ServiceProver,
revocation_registry::ServiceRevocationRegistries,
schema::ServiceSchemas,
verifier::ServiceVerifier,
},
};

pub struct AgencyInitConfig {
pub agency_endpoint: Url,
pub agency_did: String,
pub agency_verkey: String,
}

pub struct WalletInitConfig {
pub wallet_name: String,
pub wallet_key: String,
Expand All @@ -50,7 +42,6 @@ pub struct PoolInitConfig {
pub struct InitConfig {
pub enterprise_seed: String,
pub pool_config: PoolInitConfig,
pub agency_config: Option<AgencyInitConfig>,
pub wallet_config: WalletInitConfig,
pub service_endpoint: ServiceEndpoint,
}
Expand Down Expand Up @@ -101,28 +92,6 @@ impl Agent {
.await
.unwrap();

let (mediated_connections, config_agency_client) = if let Some(agency_config) = init_config.agency_config {
let config_provision_agent = AgentProvisionConfig {
agency_did: agency_config.agency_did,
agency_verkey: agency_config.agency_verkey,
agency_endpoint: agency_config.agency_endpoint,
agent_seed: None,
};
let mut agency_client = AgencyClient::new();
let config_agency_client = provision_cloud_agent(&mut agency_client, wallet, &config_provision_agent)
.await
.unwrap();
(
Some(Arc::new(ServiceMediatedConnections::new(
Arc::clone(&profile),
config_agency_client.clone(),
))),
Some(config_agency_client),
)
} else {
(None, None)
};

let connections = Arc::new(ServiceConnections::new(
Arc::clone(&profile),
init_config.service_endpoint,
Expand All @@ -144,7 +113,6 @@ impl Agent {
Ok(Self {
profile,
connections,
mediated_connections,
schemas,
cred_defs,
rev_regs,
Expand All @@ -155,7 +123,6 @@ impl Agent {
config: AgentConfig {
config_wallet,
config_issuer,
config_agency_client,
},
})
}
Expand Down
2 changes: 1 addition & 1 deletion agents/rust/aries-vcx-agent/src/agent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ mod init;

pub use agent_config::AgentConfig;
pub use agent_struct::Agent;
pub use init::{AgencyInitConfig, InitConfig, PoolInitConfig, WalletInitConfig};
pub use init::{InitConfig, PoolInitConfig, WalletInitConfig};
166 changes: 0 additions & 166 deletions agents/rust/aries-vcx-agent/src/services/mediated_connection.rs

This file was deleted.

1 change: 0 additions & 1 deletion agents/rust/aries-vcx-agent/src/services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ pub(crate) mod connection;
pub(crate) mod credential_definition;
pub(crate) mod holder;
pub(crate) mod issuer;
pub(crate) mod mediated_connection;
pub(crate) mod prover;
pub(crate) mod revocation_registry;
pub(crate) mod schema;
Expand Down
Loading

0 comments on commit b722167

Please sign in to comment.