diff --git a/agents/rust/aries-vcx-agent/src/agent/agent_config.rs b/agents/rust/aries-vcx-agent/src/agent/agent_config.rs index dadb0c8f29..9d9c73cf01 100644 --- a/agents/rust/aries-vcx-agent/src/agent/agent_config.rs +++ b/agents/rust/aries-vcx-agent/src/agent/agent_config.rs @@ -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, pub config_issuer: IssuerConfig, } diff --git a/agents/rust/aries-vcx-agent/src/agent/agent_struct.rs b/agents/rust/aries-vcx-agent/src/agent/agent_struct.rs index 2ec5b3171c..31784f4c81 100644 --- a/agents/rust/aries-vcx-agent/src/agent/agent_struct.rs +++ b/agents/rust/aries-vcx-agent/src/agent/agent_struct.rs @@ -1,17 +1,14 @@ 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)] @@ -19,7 +16,6 @@ pub struct Agent { pub(super) profile: Arc, pub(super) config: AgentConfig, pub(super) connections: Arc, - pub(super) mediated_connections: Option>, pub(super) schemas: Arc, pub(super) cred_defs: Arc, pub(super) rev_regs: Arc, @@ -42,34 +38,10 @@ impl Agent { self.config.config_issuer.institution_did.clone() } - pub fn agency_client(&self) -> AgentResult { - 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 { self.connections.clone() } - pub fn mediated_connections(&self) -> AgentResult> { - self.mediated_connections - .clone() - .ok_or_else(|| AgentError::from_kind(AgentErrorKind::MediatedConnectionServiceUnavailable)) - } - pub fn schemas(&self) -> Arc { self.schemas.clone() } diff --git a/agents/rust/aries-vcx-agent/src/agent/init.rs b/agents/rust/aries-vcx-agent/src/agent/init.rs index e5de359eec..dec64e203b 100644 --- a/agents/rust/aries-vcx-agent/src/agent/init.rs +++ b/agents/rust/aries-vcx-agent/src/agent/init.rs @@ -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; @@ -22,7 +21,6 @@ use crate::{ credential_definition::ServiceCredentialDefinitions, holder::ServiceCredentialsHolder, issuer::ServiceCredentialsIssuer, - mediated_connection::ServiceMediatedConnections, prover::ServiceProver, revocation_registry::ServiceRevocationRegistries, schema::ServiceSchemas, @@ -30,12 +28,6 @@ use crate::{ }, }; -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, @@ -50,7 +42,6 @@ pub struct PoolInitConfig { pub struct InitConfig { pub enterprise_seed: String, pub pool_config: PoolInitConfig, - pub agency_config: Option, pub wallet_config: WalletInitConfig, pub service_endpoint: ServiceEndpoint, } @@ -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, @@ -144,7 +113,6 @@ impl Agent { Ok(Self { profile, connections, - mediated_connections, schemas, cred_defs, rev_regs, @@ -155,7 +123,6 @@ impl Agent { config: AgentConfig { config_wallet, config_issuer, - config_agency_client, }, }) } diff --git a/agents/rust/aries-vcx-agent/src/agent/mod.rs b/agents/rust/aries-vcx-agent/src/agent/mod.rs index 3d01472f22..26c0b66968 100644 --- a/agents/rust/aries-vcx-agent/src/agent/mod.rs +++ b/agents/rust/aries-vcx-agent/src/agent/mod.rs @@ -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}; diff --git a/agents/rust/aries-vcx-agent/src/services/mediated_connection.rs b/agents/rust/aries-vcx-agent/src/services/mediated_connection.rs deleted file mode 100644 index 998dd12ee9..0000000000 --- a/agents/rust/aries-vcx-agent/src/services/mediated_connection.rs +++ /dev/null @@ -1,166 +0,0 @@ -use std::sync::Arc; - -use crate::error::*; -use crate::storage::object_cache::ObjectCache; -use crate::storage::Storage; -use aries_vcx::common::ledger::transactions::into_did_doc; -use aries_vcx::core::profile::profile::Profile; -use aries_vcx::handlers::util::AnyInvitation; -use aries_vcx::messages::msg_fields::protocols::connection::request::Request; -use aries_vcx::messages::msg_fields::protocols::connection::Connection; -use aries_vcx::messages::msg_fields::protocols::cred_issuance::offer_credential::OfferCredential; -use aries_vcx::messages::msg_fields::protocols::cred_issuance::propose_credential::ProposeCredential; -use aries_vcx::messages::msg_fields::protocols::cred_issuance::CredentialIssuance; -use aries_vcx::messages::msg_fields::protocols::present_proof::propose::ProposePresentation; -use aries_vcx::messages::msg_fields::protocols::present_proof::PresentProof; -use aries_vcx::{ - agency_client::{agency_client::AgencyClient, configuration::AgencyClientConfig}, - handlers::connection::mediated_connection::{ConnectionState, MediatedConnection}, -}; -use aries_vcx_core::wallet::agency_client_wallet::ToBaseAgencyClientWallet; - -pub struct ServiceMediatedConnections { - profile: Arc, - config_agency_client: AgencyClientConfig, - mediated_connections: Arc>, -} - -impl ServiceMediatedConnections { - pub fn new(profile: Arc, config_agency_client: AgencyClientConfig) -> Self { - Self { - profile, - config_agency_client, - mediated_connections: Arc::new(ObjectCache::new("mediated-connections")), - } - } - - fn agency_client(&self) -> AgentResult { - AgencyClient::new() - .configure( - self.profile.inject_wallet().to_base_agency_client_wallet(), - &self.config_agency_client, - ) - .map_err(|err| { - AgentError::from_msg( - AgentErrorKind::GenericAriesVcxError, - &format!("Failed to configure agency client: {}", err), - ) - }) - } - - pub async fn create_invitation(&self) -> AgentResult { - let mut connection = - MediatedConnection::create("", &self.profile.inject_wallet(), &self.agency_client()?, true).await?; - connection - .connect(&self.profile.inject_wallet(), &self.agency_client()?, None) - .await?; - let invite = connection - .get_invite_details() - .ok_or_else(|| AgentError::from_kind(AgentErrorKind::InviteDetails))? - .clone(); - self.mediated_connections - .insert(&connection.get_thread_id(), connection)?; - Ok(invite) - } - - pub async fn receive_invitation(&self, invite: AnyInvitation) -> AgentResult { - let ddo = into_did_doc(&self.profile.inject_indy_ledger_read(), &invite).await?; - let connection = MediatedConnection::create_with_invite( - "", - &self.profile.inject_wallet(), - &self.agency_client()?, - invite, - ddo, - true, - ) - .await?; - self.mediated_connections - .insert(&connection.get_thread_id(), connection) - } - - pub async fn send_request(&self, thread_id: &str) -> AgentResult<()> { - let mut connection = self.mediated_connections.get(thread_id)?; - connection - .connect(&self.profile.inject_wallet(), &self.agency_client()?, None) - .await?; - connection - .find_message_and_update_state(&self.profile.inject_wallet(), &self.agency_client()?) - .await?; - self.mediated_connections.insert(thread_id, connection)?; - Ok(()) - } - - pub async fn accept_request(&self, thread_id: &str, request: Request) -> AgentResult<()> { - let mut connection = self.mediated_connections.get(thread_id)?; - connection - .process_request(&self.profile.inject_wallet(), &self.agency_client()?, request) - .await?; - connection.send_response(&self.profile.inject_wallet()).await?; - self.mediated_connections.insert(thread_id, connection)?; - Ok(()) - } - - pub async fn send_ping(&self, thread_id: &str) -> AgentResult<()> { - let mut connection = self.mediated_connections.get(thread_id)?; - connection.send_ping(self.profile.inject_wallet(), None).await?; - self.mediated_connections.insert(thread_id, connection)?; - Ok(()) - } - - pub fn get_state(&self, thread_id: &str) -> AgentResult { - Ok(self.mediated_connections.get(thread_id)?.get_state()) - } - - pub async fn update_state(&self, thread_id: &str) -> AgentResult { - let mut connection = self.mediated_connections.get(thread_id)?; - connection - .find_message_and_update_state(&self.profile.inject_wallet(), &self.agency_client()?) - .await?; - self.mediated_connections.insert(thread_id, connection)?; - Ok(self.mediated_connections.get(thread_id)?.get_state()) - } - - pub fn exists_by_id(&self, thread_id: &str) -> bool { - self.mediated_connections.contains_key(thread_id) - } -} - -macro_rules! get_messages (($msg_type:ty, $a2a_msg:ident, $var:ident, $name:ident) => ( - impl ServiceMediatedConnections { - pub async fn $name(&self, thread_id: &str) -> AgentResult> { - let connection = self.mediated_connections.get(thread_id)?; - let agency_client = self.agency_client()?; - let mut messages = Vec::<$msg_type>::new(); - for (uid, message) in connection.get_messages_noauth(&agency_client).await?.into_iter() { - if let aries_vcx::messages::AriesMessage::$a2a_msg($a2a_msg::$var(message)) = message { - connection - .update_message_status(&uid, &agency_client) - .await - .ok(); - messages.push(message); - } - } - Ok(messages) - } - } -)); - -get_messages!(Request, Connection, Request, get_connection_requests); -get_messages!( - ProposeCredential, - CredentialIssuance, - ProposeCredential, - get_credential_proposals -); -get_messages!( - OfferCredential, - CredentialIssuance, - OfferCredential, - get_credential_offers -); -get_messages!( - ProposePresentation, - PresentProof, - ProposePresentation, - get_proof_proposals -); diff --git a/agents/rust/aries-vcx-agent/src/services/mod.rs b/agents/rust/aries-vcx-agent/src/services/mod.rs index 5aefac1fac..3a88367fd2 100644 --- a/agents/rust/aries-vcx-agent/src/services/mod.rs +++ b/agents/rust/aries-vcx-agent/src/services/mod.rs @@ -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; diff --git a/aries_vcx/src/handlers/connection/mediated_connection.rs b/aries_vcx/src/handlers/connection/mediated_connection.rs index c3cfadefa4..5bf4f8dc35 100644 --- a/aries_vcx/src/handlers/connection/mediated_connection.rs +++ b/aries_vcx/src/handlers/connection/mediated_connection.rs @@ -1114,261 +1114,3 @@ impl From<(SmConnectionState, PairwiseInfo, Option, String, Stri MediatedConnection::from_parts(source_id, thread_id, pairwise_info, cloud_agent_info, state, true) } } - -// #[cfg(test)] -// mod tests { - -// use agency_client::testing::mocking::enable_agency_mocks; - -// use crate::common::test_utils::mock_profile; -// use crate::utils::devsetup::{SetupIndyMocks, SetupMocks}; -// use crate::utils::mockdata::mockdata_mediated_connection::{ -// CONNECTION_SM_INVITEE_COMPLETED, CONNECTION_SM_INVITEE_INVITED, CONNECTION_SM_INVITEE_REQUESTED, -// CONNECTION_SM_INVITER_COMPLETED, -// }; -// use messages::protocols::connection::invite::test_utils::{ -// _pairwise_invitation, _pairwise_invitation_random_id, _public_invitation, _public_invitation_random_id, -// }; -// use messages::protocols::connection::request::unit_tests::_request; -// use messages::protocols::connection::response::test_utils::_signed_response; -// use messages::protocols::discovery::disclose::test_utils::_disclose; -// use messages::protocols::discovery::query::test_utils::_query; - -// use super::*; - -// pub fn _pw_info() -> PairwiseInfo { -// PairwiseInfo { -// pw_did: "FgjjUduQaJnH4HiEVfViTp".to_string(), -// pw_vk: "91E5YBaQVnY2dLbv2mrfFQB1y2wPyYuYVPKziamrZiuS".to_string(), -// } -// } - -// #[tokio::test] -// async fn test_create_with_pairwise_invite() { -// let _setup = SetupMocks::init(); -// let agency_client = AgencyClient::new(); -// enable_agency_mocks(); -// let connection = MediatedConnection::create_with_invite( -// "abc", -// &mock_profile(), -// &agency_client, -// Invitation::Pairwise(_pairwise_invitation()), -// AriesDidDoc::default(), -// true, -// ) -// .await -// .unwrap(); -// assert_eq!(connection.get_state(), ConnectionState::Invitee(InviteeState::Invited)); -// } - -// #[tokio::test] -// async fn test_create_with_public_invite() { -// let _setup = SetupMocks::init(); -// let agency_client = AgencyClient::new(); -// enable_agency_mocks(); -// let connection = MediatedConnection::create_with_invite( -// "abc", -// &mock_profile(), -// &agency_client, -// Invitation::Public(_public_invitation()), -// AriesDidDoc::default(), -// true, -// ) -// .await -// .unwrap(); -// assert_eq!(connection.get_state(), ConnectionState::Invitee(InviteeState::Invited)); -// } - -// #[tokio::test] -// async fn test_connect_sets_correct_thread_id_based_on_invitation_type() { -// let _setup = SetupMocks::init(); -// let agency_client = AgencyClient::new(); -// enable_agency_mocks(); - -// let pub_inv = _public_invitation_random_id(); -// let mut connection = MediatedConnection::create_with_invite( -// "abcd", -// &mock_profile(), -// &agency_client, -// Invitation::Public(pub_inv.clone()), -// AriesDidDoc::default(), -// true, -// ) -// .await -// .unwrap(); -// connection.connect(&mock_profile(), &agency_client, None).await.unwrap(); -// assert_eq!( -// connection.get_state(), -// ConnectionState::Invitee(InviteeState::Requested) -// ); -// assert_ne!(connection.get_thread_id(), pub_inv.id.0); - -// let pw_inv = _pairwise_invitation_random_id(); -// let mut connection = MediatedConnection::create_with_invite( -// "dcba", -// &mock_profile(), -// &agency_client, -// Invitation::Pairwise(pw_inv.clone()), -// AriesDidDoc::default(), -// true, -// ) -// .await -// .unwrap(); -// connection.connect(&mock_profile(), &agency_client, None).await.unwrap(); -// assert_eq!( -// connection.get_state(), -// ConnectionState::Invitee(InviteeState::Requested) -// ); -// assert_eq!(connection.get_thread_id(), pw_inv.id.0); -// } - -// #[tokio::test] -// async fn test_create_with_request() { -// let _setup = SetupMocks::init(); -// let agency_client = AgencyClient::new(); -// enable_agency_mocks(); -// let connection = -// MediatedConnection::create_with_request(&mock_profile(), _request(), _pw_info(), &agency_client) -// .await -// .unwrap(); -// assert_eq!( -// connection.get_state(), -// ConnectionState::Inviter(InviterState::Requested) -// ); -// } - -// #[tokio::test] -// // todo -// async fn test_should_find_messages_to_answer() { -// let _setup = SetupMocks::init(); -// let agency_client = AgencyClient::new(); -// enable_agency_mocks(); -// let connection = -// MediatedConnection::create_with_request(&mock_profile(), _request(), _pw_info(), &agency_client) -// .await -// .unwrap(); -// assert_eq!( -// connection.get_state(), -// ConnectionState::Inviter(InviterState::Requested) -// ); -// } - -// #[tokio::test] -// async fn test_deserialize_connection_inviter_completed() { -// let _setup = SetupMocks::init(); - -// let connection = MediatedConnection::from_string(CONNECTION_SM_INVITER_COMPLETED).unwrap(); -// let _second_string = connection.to_string(); - -// assert_eq!(connection.pairwise_info().pw_did, "2ZHFFhzA2XtTD6hJqzL7ux"); -// assert_eq!( -// connection.pairwise_info().pw_vk, -// "rCw3x5h1jS6gPo7rRrt3EYbXXe5nNjnGbdf1jAwUxuj" -// ); -// assert_eq!( -// connection.cloud_agent_info().unwrap().agent_did, -// "EZrZyu4bfydm4ByNm56kPP" -// ); -// assert_eq!( -// connection.cloud_agent_info().unwrap().agent_vk, -// "8Ps2WosJ9AV1eXPoJKsEJdM3NchPhSyS8qFt6LQUTKv2" -// ); -// assert_eq!( -// connection.get_state(), -// ConnectionState::Inviter(InviterState::Completed) -// ); -// } - -// fn test_deserialize_and_serialize(sm_serialized: &str) { -// let original_object: Value = serde_json::from_str(sm_serialized).unwrap(); -// let connection = MediatedConnection::from_string(sm_serialized).unwrap(); -// let reserialized = connection.to_string().unwrap(); -// let reserialized_object: Value = serde_json::from_str(&reserialized).unwrap(); - -// assert_eq!(original_object, reserialized_object); -// } - -// #[tokio::test] -// async fn test_deserialize_and_serialize_should_produce_the_same_object() { -// let _setup = SetupMocks::init(); - -// test_deserialize_and_serialize(CONNECTION_SM_INVITEE_INVITED); -// test_deserialize_and_serialize(CONNECTION_SM_INVITEE_REQUESTED); -// test_deserialize_and_serialize(CONNECTION_SM_INVITEE_COMPLETED); -// test_deserialize_and_serialize(CONNECTION_SM_INVITER_COMPLETED); -// } - -// fn _dummy_agency_client() -> AgencyClient { -// AgencyClient::new() -// } - -// #[tokio::test] -// async fn test_serialize_deserialize() { -// let _setup = SetupMocks::init(); - -// let connection = MediatedConnection::create( -// "test_serialize_deserialize", -// &mock_profile(), -// &_dummy_agency_client(), -// true, -// ) -// .await -// .unwrap(); -// let first_string = connection.to_string().unwrap(); - -// let connection2 = MediatedConnection::from_string(&first_string).unwrap(); -// let second_string = connection2.to_string().unwrap(); - -// assert_eq!(first_string, second_string); -// } - -// #[tokio::test] -// async fn test_serialize_deserialize_serde() { -// let _setup = SetupMocks::init(); - -// let connection = MediatedConnection::create( -// "test_serialize_deserialize", -// &mock_profile(), -// &_dummy_agency_client(), -// true, -// ) -// .await -// .unwrap(); -// let first_string = serde_json::to_string(&connection).unwrap(); - -// let connection: MediatedConnection = serde_json::from_str(&first_string).unwrap(); -// let second_string = serde_json::to_string(&connection).unwrap(); -// assert_eq!(first_string, second_string); -// } - -// #[tokio::test] -// async fn test_find_message_to_handle_from_completed_state() { -// let _setup = SetupIndyMocks::init(); - -// let connection = MediatedConnection::from_string(CONNECTION_SM_INVITER_COMPLETED).unwrap(); -// // Query -// { -// let messages = map!( -// "key_1".to_string() => A2AMessage::ConnectionRequest(_request()), -// "key_2".to_string() => A2AMessage::ConnectionResponse(_signed_response()), -// "key_3".to_string() => A2AMessage::Query(_query()) -// ); - -// let (uid, message) = connection.find_message_to_handle(messages).unwrap(); -// assert_eq!("key_3", uid); -// assert_match!(A2AMessage::Query(_), message); -// } -// // Disclose -// { -// let messages = map!( -// "key_1".to_string() => A2AMessage::ConnectionRequest(_request()), -// "key_2".to_string() => A2AMessage::ConnectionResponse(_signed_response()), -// "key_3".to_string() => A2AMessage::Disclose(_disclose()) -// ); - -// let (uid, message) = connection.find_message_to_handle(messages).unwrap(); -// assert_eq!("key_3", uid); -// assert_match!(A2AMessage::Disclose(_), message); -// } -// } -// } diff --git a/aries_vcx/src/utils/devsetup.rs b/aries_vcx/src/utils/devsetup.rs index 4611748cae..2e5bb495bb 100644 --- a/aries_vcx/src/utils/devsetup.rs +++ b/aries_vcx/src/utils/devsetup.rs @@ -6,8 +6,6 @@ use std::sync::{Arc, Once}; use chrono::{DateTime, Duration, Utc}; -use agency_client::agency_client::AgencyClient; -use agency_client::configuration::AgentProvisionConfig; use agency_client::testing::mocking::{enable_agency_mocks, AgencyMockDecrypted}; use aries_vcx_core::global::settings::{ disable_indy_mocks as disable_indy_mocks_core, enable_indy_mocks as enable_indy_mocks_core, @@ -15,9 +13,8 @@ use aries_vcx_core::global::settings::{ }; use aries_vcx_core::ledger::base_ledger::{AnoncredsLedgerRead, AnoncredsLedgerWrite, IndyLedgerRead, IndyLedgerWrite}; use aries_vcx_core::ledger::indy::pool::test_utils::{create_testpool_genesis_txn_file, get_temp_file_path}; -use aries_vcx_core::wallet::base_wallet::BaseWallet; use aries_vcx_core::wallet::indy::did_mocks::DidMocks; -use aries_vcx_core::wallet::indy::wallet::{create_and_open_wallet, create_and_store_my_did, wallet_configure_issuer}; +use aries_vcx_core::wallet::indy::wallet::{create_and_open_wallet, create_and_store_my_did}; use aries_vcx_core::wallet::indy::{IndySdkWallet, WalletConfig}; use aries_vcx_core::WalletHandle; @@ -34,7 +31,6 @@ use crate::global::settings::{ use crate::global::settings::{init_issuer_config, reset_config_values_ariesvcx}; use crate::utils::constants::{POOL1_TXN, TRUSTEE_SEED}; use crate::utils::file::write_file; -use crate::utils::provision::provision_cloud_agent; use crate::utils::test_logger::LibvcxDefaultLogger; #[macro_export] @@ -136,39 +132,6 @@ impl Drop for SetupMocks { } } -// todo: we move to libvcx? -pub async fn dev_setup_issuer_wallet_and_agency_client() -> (String, WalletHandle, AgencyClient) { - let enterprise_seed = "000000000000000000000000Trustee1"; - let config_wallet = WalletConfig { - wallet_name: format!("wallet_{}", uuid::Uuid::new_v4()), - wallet_key: settings::DEFAULT_WALLET_KEY.into(), - wallet_key_derivation: settings::WALLET_KDF_RAW.into(), - wallet_type: None, - storage_config: None, - storage_credentials: None, - rekey: None, - rekey_derivation_method: None, - }; - let config_provision_agent = AgentProvisionConfig { - agency_did: AGENCY_DID.to_string(), - agency_verkey: AGENCY_VERKEY.to_string(), - agency_endpoint: AGENCY_ENDPOINT.parse().expect("valid url"), - agent_seed: None, - }; - let wallet_handle = create_and_open_wallet(&config_wallet).await.unwrap(); - let config_issuer = wallet_configure_issuer(wallet_handle, enterprise_seed).await.unwrap(); - init_issuer_config(&config_issuer.institution_did).unwrap(); - let mut agency_client = AgencyClient::new(); - - let wallet: Arc = Arc::new(IndySdkWallet::new(wallet_handle)); - - provision_cloud_agent(&mut agency_client, wallet, &config_provision_agent) - .await - .unwrap(); - - (config_issuer.institution_did, wallet_handle, agency_client) -} - pub async fn dev_setup_wallet_indy(key_seed: &str) -> (String, WalletHandle) { info!("dev_setup_wallet_indy >>"); let config_wallet = WalletConfig { diff --git a/libvcx_core/src/api_vcx/utils/devsetup.rs b/libvcx_core/src/api_vcx/utils/devsetup.rs index 9d1083dbf8..9a61ecf67e 100644 --- a/libvcx_core/src/api_vcx/utils/devsetup.rs +++ b/libvcx_core/src/api_vcx/utils/devsetup.rs @@ -1,17 +1,37 @@ use std::future::Future; -use agency_client::agency_client::AgencyClient; use aries_vcx::aries_vcx_core::ledger::indy::pool::test_utils::{create_testpool_genesis_txn_file, get_temp_file_path}; +use aries_vcx::aries_vcx_core::wallet::indy::wallet::{create_and_open_wallet, wallet_configure_issuer}; +use aries_vcx::aries_vcx_core::wallet::indy::WalletConfig; use aries_vcx::aries_vcx_core::WalletHandle; -use aries_vcx::global::settings::{set_config_value, CONFIG_INSTITUTION_DID, DEFAULT_DID, DEFAULT_GENESIS_PATH}; -use aries_vcx::utils::devsetup::{dev_setup_issuer_wallet_and_agency_client, init_test_logging, reset_global_state}; +use aries_vcx::global::settings::{ + self, init_issuer_config, set_config_value, CONFIG_INSTITUTION_DID, DEFAULT_DID, DEFAULT_GENESIS_PATH, +}; +use aries_vcx::utils::devsetup::{init_test_logging, reset_global_state}; -use crate::api_vcx::api_global::agency_client::{reset_main_agency_client, set_main_agency_client}; use crate::api_vcx::api_global::pool::{close_main_pool, setup_ledger_components, LibvcxLedgerConfig}; use crate::api_vcx::api_global::wallet::{close_main_wallet, setup_wallet}; +async fn dev_setup_issuer_wallet_and_agency_client() -> (String, WalletHandle) { + let enterprise_seed = "000000000000000000000000Trustee1"; + let config_wallet = WalletConfig { + wallet_name: format!("wallet_{}", uuid::Uuid::new_v4()), + wallet_key: settings::DEFAULT_WALLET_KEY.into(), + wallet_key_derivation: settings::WALLET_KDF_RAW.into(), + wallet_type: None, + storage_config: None, + storage_credentials: None, + rekey: None, + rekey_derivation_method: None, + }; + let wallet_handle = create_and_open_wallet(&config_wallet).await.unwrap(); + let config_issuer = wallet_configure_issuer(wallet_handle, enterprise_seed).await.unwrap(); + init_issuer_config(&config_issuer.institution_did).unwrap(); + + (config_issuer.institution_did, wallet_handle) +} + pub struct SetupGlobalsWalletPoolAgency { - pub agency_client: AgencyClient, pub institution_did: String, pub wallet_handle: WalletHandle, } @@ -21,9 +41,8 @@ impl SetupGlobalsWalletPoolAgency { reset_global_state(); init_test_logging(); set_config_value(CONFIG_INSTITUTION_DID, DEFAULT_DID).unwrap(); - let (institution_did, wallet_handle, agency_client) = dev_setup_issuer_wallet_and_agency_client().await; + let (institution_did, wallet_handle) = dev_setup_issuer_wallet_and_agency_client().await; SetupGlobalsWalletPoolAgency { - agency_client, institution_did, wallet_handle, } @@ -39,7 +58,6 @@ impl SetupGlobalsWalletPoolAgency { create_testpool_genesis_txn_file(&genesis_path); setup_wallet(init.wallet_handle).unwrap(); - set_main_agency_client(init.agency_client.clone()); let config = LibvcxLedgerConfig { genesis_path, pool_config: None, @@ -50,9 +68,8 @@ impl SetupGlobalsWalletPoolAgency { f(init).await; - close_main_wallet(); - reset_main_agency_client(); - close_main_pool().await.unwrap(); + close_main_wallet().await.ok(); + close_main_pool().await.ok(); reset_global_state(); }