diff --git a/aries/agents/rust/aries-vcx-agent/src/agent/agent_config.rs b/aries/agents/rust/aries-vcx-agent/src/agent/agent_config.rs index 9d9c73cf01..715982dcf0 100644 --- a/aries/agents/rust/aries-vcx-agent/src/agent/agent_config.rs +++ b/aries/agents/rust/aries-vcx-agent/src/agent/agent_config.rs @@ -1,4 +1,6 @@ -use aries_vcx_core::wallet::indy::{IssuerConfig, WalletConfig}; +use aries_vcx_core::wallet::{ + base_wallet::issuer_config::IssuerConfig, indy::wallet_config::WalletConfig, +}; #[derive(Clone)] pub struct AgentConfig { diff --git a/aries/agents/rust/aries-vcx-agent/src/agent/agent_struct.rs b/aries/agents/rust/aries-vcx-agent/src/agent/agent_struct.rs index 98f4f345e0..9685a20cbb 100644 --- a/aries/agents/rust/aries-vcx-agent/src/agent/agent_struct.rs +++ b/aries/agents/rust/aries-vcx-agent/src/agent/agent_struct.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use aries_vcx_core::{ anoncreds::credx_anoncreds::IndyCredxAnonCreds, ledger::indy_vdr_ledger::{DefaultIndyLedgerRead, DefaultIndyLedgerWrite}, - wallet::indy::IndySdkWallet, + wallet::base_wallet::BaseWallet, }; use crate::{ @@ -22,7 +22,7 @@ pub struct Agent { pub(super) ledger_read: Arc, pub(super) ledger_write: Arc, pub(super) anoncreds: IndyCredxAnonCreds, - pub(super) wallet: Arc, + pub(super) wallet: Arc, pub(super) config: AgentConfig, pub(super) connections: Arc, pub(super) schemas: Arc, @@ -49,7 +49,7 @@ impl Agent { &self.anoncreds } - pub fn wallet(&self) -> &IndySdkWallet { + pub fn wallet(&self) -> &Arc { &self.wallet } diff --git a/aries/agents/rust/aries-vcx-agent/src/agent/init.rs b/aries/agents/rust/aries-vcx-agent/src/agent/init.rs index c693211dec..babf5f1671 100644 --- a/aries/agents/rust/aries-vcx-agent/src/agent/init.rs +++ b/aries/agents/rust/aries-vcx-agent/src/agent/init.rs @@ -11,10 +11,7 @@ use aries_vcx_core::{ self, anoncreds::{base_anoncreds::BaseAnonCreds, credx_anoncreds::IndyCredxAnonCreds}, ledger::indy_vdr_ledger::DefaultIndyLedgerRead, - wallet::indy::{ - wallet::{create_and_open_wallet, wallet_configure_issuer}, - IndySdkWallet, WalletConfig, - }, + wallet::{base_wallet::ManageWallet, indy::wallet_config::WalletConfig}, }; use did_peer::resolver::PeerDidResolver; use did_resolver_registry::ResolverRegistry; @@ -68,13 +65,13 @@ impl Agent { rekey_derivation_method: None, }; - let wallet_handle = create_and_open_wallet(&config_wallet).await.unwrap(); - let config_issuer = wallet_configure_issuer(wallet_handle, &init_config.enterprise_seed) + config_wallet.create_wallet().await.unwrap(); + let wallet = config_wallet.open_wallet().await.unwrap(); + let config_issuer = wallet + .configure_issuer(&init_config.enterprise_seed) .await .unwrap(); - let wallet = Arc::new(IndySdkWallet::new(wallet_handle)); - use aries_vcx_core::ledger::indy_vdr_ledger::{build_ledger_components, VcxPoolConfig}; info!("dev_build_profile_modular >>"); @@ -91,14 +88,14 @@ impl Agent { let ledger_write = Arc::new(ledger_write); anoncreds - .prover_create_link_secret(wallet.as_ref(), DEFAULT_LINK_SECRET_ALIAS) + .prover_create_link_secret(&wallet, DEFAULT_LINK_SECRET_ALIAS) .await .unwrap(); // TODO: This setup should be easier // The default issuer did can't be used - its verkey is not in base58 - TODO: double-check let (public_did, _verkey) = add_new_did( - wallet.as_ref(), + &wallet, ledger_write.as_ref(), &config_issuer.institution_did.parse()?, None, @@ -107,13 +104,7 @@ impl Agent { let endpoint = EndpointDidSov::create() .set_service_endpoint(init_config.service_endpoint.clone()) .set_types(Some(vec![DidSovServiceType::DidCommunication])); - write_endpoint( - wallet.as_ref(), - ledger_write.as_ref(), - &public_did, - &endpoint, - ) - .await?; + write_endpoint(&wallet, ledger_write.as_ref(), &public_did, &endpoint).await?; let did_peer_resolver = PeerDidResolver::new(); let did_sov_resolver: DidSovResolver, DefaultIndyLedgerRead> = diff --git a/aries/agents/rust/aries-vcx-agent/src/services/connection.rs b/aries/agents/rust/aries-vcx-agent/src/services/connection.rs index c956fc75b9..0920859f71 100644 --- a/aries/agents/rust/aries-vcx-agent/src/services/connection.rs +++ b/aries/agents/rust/aries-vcx-agent/src/services/connection.rs @@ -10,7 +10,9 @@ use aries_vcx::{ pairwise_info::PairwiseInfo, Connection, GenericConnection, State, ThinState, }, }; -use aries_vcx_core::{ledger::indy_vdr_ledger::DefaultIndyLedgerRead, wallet::indy::IndySdkWallet}; +use aries_vcx_core::{ + ledger::indy_vdr_ledger::DefaultIndyLedgerRead, wallet::base_wallet::BaseWallet, +}; use url::Url; use crate::{ @@ -23,7 +25,7 @@ pub type ServiceEndpoint = Url; pub struct ServiceConnections { ledger_read: Arc, - wallet: Arc, + wallet: Arc, service_endpoint: ServiceEndpoint, connections: Arc>, } @@ -31,7 +33,7 @@ pub struct ServiceConnections { impl ServiceConnections { pub fn new( ledger_read: Arc, - wallet: Arc, + wallet: Arc, service_endpoint: ServiceEndpoint, ) -> Self { Self { @@ -46,7 +48,7 @@ impl ServiceConnections { &self, pw_info: Option, ) -> AgentResult { - let pw_info = pw_info.unwrap_or(PairwiseInfo::create(self.wallet.as_ref()).await?); + let pw_info = pw_info.unwrap_or(PairwiseInfo::create(&self.wallet).await?); let inviter = Connection::new_inviter("".to_owned(), pw_info) .create_invitation(vec![], self.service_endpoint.clone()); let invite = inviter.get_invitation().clone(); @@ -58,7 +60,7 @@ impl ServiceConnections { } pub async fn receive_invitation(&self, invite: AnyInvitation) -> AgentResult { - let pairwise_info = PairwiseInfo::create(self.wallet.as_ref()).await?; + let pairwise_info = PairwiseInfo::create(&self.wallet).await?; let invitee = Connection::new_invitee("".to_owned(), pairwise_info) .accept_invitation(self.ledger_read.as_ref(), invite) .await?; @@ -75,7 +77,7 @@ impl ServiceConnections { .await?; let request = invitee.get_request().clone(); invitee - .send_message(self.wallet.as_ref(), &request.into(), &VcxHttpClient) + .send_message(&self.wallet, &request.into(), &VcxHttpClient) .await?; self.connections.insert(thread_id, invitee.into())?; Ok(()) @@ -99,12 +101,7 @@ impl ServiceConnections { }?; let inviter = inviter - .handle_request( - self.wallet.as_ref(), - request, - self.service_endpoint.clone(), - vec![], - ) + .handle_request(&self.wallet, request, self.service_endpoint.clone(), vec![]) .await?; self.connections.insert(thread_id, inviter.into())?; @@ -116,7 +113,7 @@ impl ServiceConnections { let inviter: Connection<_, _> = self.connections.get(thread_id)?.try_into()?; let response = inviter.get_connection_response_msg(); inviter - .send_message(self.wallet.as_ref(), &response.into(), &VcxHttpClient) + .send_message(&self.wallet, &response.into(), &VcxHttpClient) .await?; self.connections.insert(thread_id, inviter.into())?; @@ -126,9 +123,7 @@ impl ServiceConnections { pub async fn accept_response(&self, thread_id: &str, response: Response) -> AgentResult<()> { let invitee: Connection<_, _> = self.connections.get(thread_id)?.try_into()?; - let invitee = invitee - .handle_response(self.wallet.as_ref(), response) - .await?; + let invitee = invitee.handle_response(&self.wallet, response).await?; self.connections.insert(thread_id, invitee.into())?; @@ -138,11 +133,7 @@ impl ServiceConnections { pub async fn send_ack(&self, thread_id: &str) -> AgentResult<()> { let invitee: Connection<_, _> = self.connections.get(thread_id)?.try_into()?; invitee - .send_message( - self.wallet.as_ref(), - &invitee.get_ack().into(), - &VcxHttpClient, - ) + .send_message(&self.wallet, &invitee.get_ack().into(), &VcxHttpClient) .await?; self.connections.insert(thread_id, invitee.into())?; diff --git a/aries/agents/rust/aries-vcx-agent/src/services/credential_definition.rs b/aries/agents/rust/aries-vcx-agent/src/services/credential_definition.rs index 4ab02beb09..12a99000d9 100644 --- a/aries/agents/rust/aries-vcx-agent/src/services/credential_definition.rs +++ b/aries/agents/rust/aries-vcx-agent/src/services/credential_definition.rs @@ -4,7 +4,7 @@ use aries_vcx::common::primitives::credential_definition::{CredentialDef, Creden use aries_vcx_core::{ anoncreds::credx_anoncreds::IndyCredxAnonCreds, ledger::indy_vdr_ledger::{DefaultIndyLedgerRead, DefaultIndyLedgerWrite}, - wallet::indy::IndySdkWallet, + wallet::base_wallet::BaseWallet, }; use crate::{ @@ -16,7 +16,7 @@ pub struct ServiceCredentialDefinitions { ledger_read: Arc, ledger_write: Arc, anoncreds: IndyCredxAnonCreds, - wallet: Arc, + wallet: Arc, cred_defs: ObjectCache, } @@ -25,7 +25,7 @@ impl ServiceCredentialDefinitions { ledger_read: Arc, ledger_write: Arc, anoncreds: IndyCredxAnonCreds, - wallet: Arc, + wallet: Arc, ) -> Self { Self { cred_defs: ObjectCache::new("cred-defs"), @@ -38,7 +38,7 @@ impl ServiceCredentialDefinitions { pub async fn create_cred_def(&self, config: CredentialDefConfig) -> AgentResult { let cd = CredentialDef::create( - self.wallet.as_ref(), + &self.wallet, self.ledger_read.as_ref(), &self.anoncreds, "".to_string(), @@ -53,7 +53,7 @@ impl ServiceCredentialDefinitions { let cred_def = self.cred_defs.get(thread_id)?; let cred_def = cred_def .publish_cred_def( - self.wallet.as_ref(), + &self.wallet, self.ledger_read.as_ref(), self.ledger_write.as_ref(), ) diff --git a/aries/agents/rust/aries-vcx-agent/src/services/did_exchange.rs b/aries/agents/rust/aries-vcx-agent/src/services/did_exchange.rs index 40dd0db3e7..2ba6c9afdf 100644 --- a/aries/agents/rust/aries-vcx-agent/src/services/did_exchange.rs +++ b/aries/agents/rust/aries-vcx-agent/src/services/did_exchange.rs @@ -13,7 +13,9 @@ use aries_vcx::{ }, transport::Transport, }; -use aries_vcx_core::{ledger::indy_vdr_ledger::DefaultIndyLedgerRead, wallet::indy::IndySdkWallet}; +use aries_vcx_core::{ + ledger::indy_vdr_ledger::DefaultIndyLedgerRead, wallet::base_wallet::BaseWallet, +}; use did_resolver_registry::ResolverRegistry; use super::connection::ServiceEndpoint; @@ -26,7 +28,7 @@ use crate::{ pub struct ServiceDidExchange { ledger_read: Arc, - wallet: Arc, + wallet: Arc, resolver_registry: Arc, service_endpoint: ServiceEndpoint, did_exchange: Arc>, @@ -36,7 +38,7 @@ pub struct ServiceDidExchange { impl ServiceDidExchange { pub fn new( ledger_read: Arc, - wallet: Arc, + wallet: Arc, resolver_registry: Arc, service_endpoint: ServiceEndpoint, public_did: String, @@ -72,7 +74,7 @@ impl ServiceDidExchange { let ddo_their = requester.their_did_doc(); let ddo_our = requester.our_did_document(); let encryption_envelope = - pairwise_encrypt(ddo_our, ddo_their, self.wallet.as_ref(), &request.into()).await?; + pairwise_encrypt(ddo_our, ddo_their, &self.wallet, &request.into()).await?; VcxHttpClient .send_message(encryption_envelope.0, get_their_endpoint(ddo_their)?) .await?; @@ -101,7 +103,7 @@ impl ServiceDidExchange { let invitation_key = resolve_key_from_invitation(&invitation, &self.resolver_registry).await?; let (responder, response) = GenericDidExchange::handle_request( - self.wallet.as_ref(), + &self.wallet, self.resolver_registry.clone(), request, self.service_endpoint.clone(), @@ -113,7 +115,7 @@ impl ServiceDidExchange { let ddo_their = responder.their_did_doc(); let ddo_our = responder.our_did_document(); let encryption_envelope = - pairwise_encrypt(ddo_our, ddo_their, self.wallet.as_ref(), &response.into()).await?; + pairwise_encrypt(ddo_our, ddo_their, &self.wallet, &response.into()).await?; VcxHttpClient .send_message(encryption_envelope.0, get_their_endpoint(ddo_their)?) .await?; @@ -130,7 +132,7 @@ impl ServiceDidExchange { let ddo_their = requester.their_did_doc(); let ddo_our = requester.our_did_document(); let encryption_envelope = - pairwise_encrypt(ddo_our, ddo_their, self.wallet.as_ref(), &complete.into()).await?; + pairwise_encrypt(ddo_our, ddo_their, &self.wallet, &complete.into()).await?; VcxHttpClient .send_message(encryption_envelope.0, get_their_endpoint(ddo_their)?) .await?; diff --git a/aries/agents/rust/aries-vcx-agent/src/services/holder.rs b/aries/agents/rust/aries-vcx-agent/src/services/holder.rs index 45a80b137b..f92630d9a6 100644 --- a/aries/agents/rust/aries-vcx-agent/src/services/holder.rs +++ b/aries/agents/rust/aries-vcx-agent/src/services/holder.rs @@ -13,7 +13,7 @@ use aries_vcx::{ }; use aries_vcx_core::{ anoncreds::credx_anoncreds::IndyCredxAnonCreds, ledger::indy_vdr_ledger::DefaultIndyLedgerRead, - wallet::indy::IndySdkWallet, + wallet::base_wallet::BaseWallet, }; use crate::{ @@ -41,7 +41,7 @@ impl HolderWrapper { pub struct ServiceCredentialsHolder { ledger_read: Arc, anoncreds: IndyCredxAnonCreds, - wallet: Arc, + wallet: Arc, creds_holder: ObjectCache, service_connections: Arc, } @@ -50,7 +50,7 @@ impl ServiceCredentialsHolder { pub fn new( ledger_read: Arc, anoncreds: IndyCredxAnonCreds, - wallet: Arc, + wallet: Arc, service_connections: Arc, ) -> Self { Self { @@ -78,12 +78,11 @@ impl ServiceCredentialsHolder { propose_credential: ProposeCredentialV1, ) -> AgentResult { let connection = self.service_connections.get_by_id(connection_id)?; - let wallet = self.wallet.as_ref(); let mut holder = Holder::create("")?; holder.set_proposal(propose_credential.clone())?; connection - .send_message(wallet, &propose_credential.into(), &VcxHttpClient) + .send_message(&self.wallet, &propose_credential.into(), &VcxHttpClient) .await?; self.creds_holder.insert( @@ -117,15 +116,19 @@ impl ServiceCredentialsHolder { (None, None) => return Err(AgentError::from_kind(AgentErrorKind::InvalidArguments)), }; let connection = self.service_connections.get_by_id(&connection_id)?; - let wallet = self.wallet.as_ref(); + let pw_did = connection.pairwise_info().pw_did.to_string(); let send_closure: SendClosure = Box::new(|msg: AriesMessage| { - Box::pin(async move { connection.send_message(wallet, &msg, &VcxHttpClient).await }) + Box::pin(async move { + connection + .send_message(&self.wallet, &msg, &VcxHttpClient) + .await + }) }); let msg_response = holder .prepare_credential_request( - self.wallet.as_ref(), + &self.wallet, self.ledger_read.as_ref(), &self.anoncreds, pw_did.parse()?, @@ -146,11 +149,10 @@ impl ServiceCredentialsHolder { let mut holder = self.get_holder(thread_id)?; let connection_id = self.get_connection_id(thread_id)?; let connection = self.service_connections.get_by_id(&connection_id)?; - let wallet = self.wallet.as_ref(); holder .process_credential( - self.wallet.as_ref(), + &self.wallet, self.ledger_read.as_ref(), &self.anoncreds, msg_issue_credential.clone(), @@ -160,9 +162,11 @@ impl ServiceCredentialsHolder { None => {} Some(msg_response) => { let send_closure: SendClosure = Box::new(|msg: AriesMessage| { - Box::pin( - async move { connection.send_message(wallet, &msg, &VcxHttpClient).await }, - ) + Box::pin(async move { + connection + .send_message(&self.wallet, &msg, &VcxHttpClient) + .await + }) }); send_closure(msg_response).await?; } diff --git a/aries/agents/rust/aries-vcx-agent/src/services/issuer.rs b/aries/agents/rust/aries-vcx-agent/src/services/issuer.rs index 54c52f57c2..b1cc2e4500 100644 --- a/aries/agents/rust/aries-vcx-agent/src/services/issuer.rs +++ b/aries/agents/rust/aries-vcx-agent/src/services/issuer.rs @@ -11,7 +11,9 @@ use aries_vcx::{ }, protocols::{issuance::issuer::state_machine::IssuerState, SendClosure}, }; -use aries_vcx_core::{anoncreds::credx_anoncreds::IndyCredxAnonCreds, wallet::indy::IndySdkWallet}; +use aries_vcx_core::{ + anoncreds::credx_anoncreds::IndyCredxAnonCreds, wallet::base_wallet::BaseWallet, +}; use crate::{ error::*, @@ -37,7 +39,7 @@ impl IssuerWrapper { pub struct ServiceCredentialsIssuer { anoncreds: IndyCredxAnonCreds, - wallet: Arc, + wallet: Arc, creds_issuer: ObjectCache, service_connections: Arc, } @@ -45,7 +47,7 @@ pub struct ServiceCredentialsIssuer { impl ServiceCredentialsIssuer { pub fn new( anoncreds: IndyCredxAnonCreds, - wallet: Arc, + wallet: Arc, service_connections: Arc, ) -> Self { Self { @@ -92,13 +94,15 @@ impl ServiceCredentialsIssuer { }; let connection = self.service_connections.get_by_id(&connection_id)?; issuer - .build_credential_offer_msg(self.wallet.as_ref(), &self.anoncreds, offer_info, None) + .build_credential_offer_msg(&self.wallet, &self.anoncreds, offer_info, None) .await?; - let wallet = self.wallet.as_ref(); - let send_closure: SendClosure = Box::new(|msg: AriesMessage| { - Box::pin(async move { connection.send_message(wallet, &msg, &VcxHttpClient).await }) + Box::pin(async move { + connection + .send_message(&self.wallet, &msg, &VcxHttpClient) + .await + }) }); let credential_offer = issuer.get_credential_offer_msg()?; @@ -146,14 +150,16 @@ impl ServiceCredentialsIssuer { } = self.creds_issuer.get(thread_id)?; let connection = self.service_connections.get_by_id(&connection_id)?; - let wallet = self.wallet.as_ref(); - let send_closure: SendClosure = Box::new(|msg: AriesMessage| { - Box::pin(async move { connection.send_message(wallet, &msg, &VcxHttpClient).await }) + Box::pin(async move { + connection + .send_message(&self.wallet, &msg, &VcxHttpClient) + .await + }) }); issuer - .build_credential(self.wallet.as_ref(), &self.anoncreds) + .build_credential(&self.wallet, &self.anoncreds) .await?; match issuer.get_state() { IssuerState::Failed => { diff --git a/aries/agents/rust/aries-vcx-agent/src/services/out_of_band.rs b/aries/agents/rust/aries-vcx-agent/src/services/out_of_band.rs index 39c1925a2d..cf446be35b 100644 --- a/aries/agents/rust/aries-vcx-agent/src/services/out_of_band.rs +++ b/aries/agents/rust/aries-vcx-agent/src/services/out_of_band.rs @@ -18,7 +18,7 @@ use aries_vcx::{ }, protocols::did_exchange::state_machine::generate_keypair, }; -use aries_vcx_core::wallet::indy::IndySdkWallet; +use aries_vcx_core::wallet::base_wallet::BaseWallet; use public_key::KeyType; use uuid::Uuid; @@ -29,13 +29,13 @@ use crate::{ }; pub struct ServiceOutOfBand { - wallet: Arc, + wallet: Arc, service_endpoint: ServiceEndpoint, out_of_band: Arc>, } impl ServiceOutOfBand { - pub fn new(wallet: Arc, service_endpoint: ServiceEndpoint) -> Self { + pub fn new(wallet: Arc, service_endpoint: ServiceEndpoint) -> Self { Self { wallet, service_endpoint, @@ -44,7 +44,7 @@ impl ServiceOutOfBand { } pub async fn create_invitation(&self) -> AgentResult { - let public_key = generate_keypair(self.wallet.as_ref(), KeyType::Ed25519).await?; + let public_key = generate_keypair(&self.wallet, KeyType::Ed25519).await?; let service = { let service_id = Uuid::new_v4().to_string(); ServiceSov::DIDCommV1(ServiceDidCommV1::new( diff --git a/aries/agents/rust/aries-vcx-agent/src/services/prover.rs b/aries/agents/rust/aries-vcx-agent/src/services/prover.rs index 243a957125..c6d965dd74 100644 --- a/aries/agents/rust/aries-vcx-agent/src/services/prover.rs +++ b/aries/agents/rust/aries-vcx-agent/src/services/prover.rs @@ -15,7 +15,7 @@ use aries_vcx::{ }; use aries_vcx_core::{ anoncreds::credx_anoncreds::IndyCredxAnonCreds, ledger::indy_vdr_ledger::DefaultIndyLedgerRead, - wallet::indy::IndySdkWallet, + wallet::base_wallet::BaseWallet, }; use serde_json::Value; @@ -44,7 +44,7 @@ impl ProverWrapper { pub struct ServiceProver { ledger_read: Arc, anoncreds: IndyCredxAnonCreds, - wallet: Arc, + wallet: Arc, provers: ObjectCache, service_connections: Arc, } @@ -53,7 +53,7 @@ impl ServiceProver { pub fn new( ledger_read: Arc, anoncreds: IndyCredxAnonCreds, - wallet: Arc, + wallet: Arc, service_connections: Arc, ) -> Self { Self { @@ -81,7 +81,7 @@ impl ServiceProver { tails_dir: Option<&str>, ) -> AgentResult { let credentials = prover - .retrieve_credentials(self.wallet.as_ref(), &self.anoncreds) + .retrieve_credentials(&self.wallet, &self.anoncreds) .await?; let mut res_credentials = SelectedCredentials::default(); @@ -118,7 +118,7 @@ impl ServiceProver { let connection = self.service_connections.get_by_id(connection_id)?; let mut prover = Prover::create("")?; - let wallet = self.wallet.as_ref(); + let wallet = &self.wallet; let send_closure: SendClosure = Box::new(|msg: AriesMessage| { Box::pin(async move { connection.send_message(wallet, &msg, &VcxHttpClient).await }) @@ -154,7 +154,7 @@ impl ServiceProver { .await?; prover .generate_presentation( - self.wallet.as_ref(), + &self.wallet, self.ledger_read.as_ref(), &self.anoncreds, credentials, @@ -162,7 +162,7 @@ impl ServiceProver { ) .await?; - let wallet = self.wallet.as_ref(); + let wallet = &self.wallet; let send_closure: SendClosure = Box::new(|msg: AriesMessage| { Box::pin(async move { connection.send_message(wallet, &msg, &VcxHttpClient).await }) diff --git a/aries/agents/rust/aries-vcx-agent/src/services/revocation_registry.rs b/aries/agents/rust/aries-vcx-agent/src/services/revocation_registry.rs index c9808e6e90..398d354ccf 100644 --- a/aries/agents/rust/aries-vcx-agent/src/services/revocation_registry.rs +++ b/aries/agents/rust/aries-vcx-agent/src/services/revocation_registry.rs @@ -8,7 +8,7 @@ use aries_vcx::{common::primitives::revocation_registry::RevocationRegistry, did use aries_vcx_core::{ anoncreds::credx_anoncreds::IndyCredxAnonCreds, ledger::indy_vdr_ledger::{DefaultIndyLedgerRead, DefaultIndyLedgerWrite}, - wallet::indy::IndySdkWallet, + wallet::base_wallet::BaseWallet, }; use crate::{ @@ -20,7 +20,7 @@ pub struct ServiceRevocationRegistries { ledger_write: Arc, ledger_read: Arc, anoncreds: IndyCredxAnonCreds, - wallet: Arc, + wallet: Arc, issuer_did: Did, rev_regs: ObjectCache, } @@ -30,7 +30,7 @@ impl ServiceRevocationRegistries { ledger_write: Arc, ledger_read: Arc, anoncreds: IndyCredxAnonCreds, - wallet: Arc, + wallet: Arc, issuer_did: String, ) -> Self { Self { @@ -59,7 +59,7 @@ impl ServiceRevocationRegistries { max_creds: u32, ) -> AgentResult { let rev_reg = RevocationRegistry::create( - self.wallet.as_ref(), + &self.wallet, &self.anoncreds, &self.issuer_did, cred_def_id, @@ -87,11 +87,7 @@ impl ServiceRevocationRegistries { pub async fn publish_rev_reg(&self, thread_id: &str, tails_url: &str) -> AgentResult<()> { let mut rev_reg = self.rev_regs.get(thread_id)?; rev_reg - .publish_revocation_primitives( - self.wallet.as_ref(), - self.ledger_write.as_ref(), - tails_url, - ) + .publish_revocation_primitives(&self.wallet, self.ledger_write.as_ref(), tails_url) .await?; self.rev_regs.insert(thread_id, rev_reg)?; Ok(()) @@ -101,7 +97,7 @@ impl ServiceRevocationRegistries { let rev_reg = self.rev_regs.get(id)?; rev_reg .revoke_credential_local( - self.wallet.as_ref(), + &self.wallet, &self.anoncreds, self.ledger_read.as_ref(), cred_rev_id.parse()?, @@ -114,7 +110,7 @@ impl ServiceRevocationRegistries { let rev_reg = self.rev_regs.get(id)?; rev_reg .publish_local_revocations( - self.wallet.as_ref(), + &self.wallet, &self.anoncreds, self.ledger_write.as_ref(), &self.issuer_did, diff --git a/aries/agents/rust/aries-vcx-agent/src/services/schema.rs b/aries/agents/rust/aries-vcx-agent/src/services/schema.rs index bd4bf4967e..59e9d156d7 100644 --- a/aries/agents/rust/aries-vcx-agent/src/services/schema.rs +++ b/aries/agents/rust/aries-vcx-agent/src/services/schema.rs @@ -7,7 +7,7 @@ use aries_vcx_core::{ base_ledger::AnoncredsLedgerRead, indy_vdr_ledger::{DefaultIndyLedgerRead, DefaultIndyLedgerWrite}, }, - wallet::indy::IndySdkWallet, + wallet::base_wallet::BaseWallet, }; use crate::{ @@ -19,7 +19,7 @@ pub struct ServiceSchemas { ledger_read: Arc, ledger_write: Arc, anoncreds: IndyCredxAnonCreds, - wallet: Arc, + wallet: Arc, issuer_did: Did, schemas: ObjectCache, } @@ -29,7 +29,7 @@ impl ServiceSchemas { ledger_read: Arc, ledger_write: Arc, anoncreds: IndyCredxAnonCreds, - wallet: Arc, + wallet: Arc, issuer_did: String, ) -> Self { Self { @@ -64,7 +64,7 @@ impl ServiceSchemas { pub async fn publish_schema(&self, thread_id: &str) -> AgentResult<()> { let schema = self.schemas.get(thread_id)?; let schema = schema - .publish(self.wallet.as_ref(), self.ledger_write.as_ref()) + .publish(&self.wallet, self.ledger_write.as_ref()) .await?; self.schemas.insert(thread_id, schema)?; Ok(()) diff --git a/aries/agents/rust/aries-vcx-agent/src/services/verifier.rs b/aries/agents/rust/aries-vcx-agent/src/services/verifier.rs index ebb3169f0d..20daeeb496 100644 --- a/aries/agents/rust/aries-vcx-agent/src/services/verifier.rs +++ b/aries/agents/rust/aries-vcx-agent/src/services/verifier.rs @@ -18,7 +18,7 @@ use aries_vcx::{ }; use aries_vcx_core::{ anoncreds::credx_anoncreds::IndyCredxAnonCreds, ledger::indy_vdr_ledger::DefaultIndyLedgerRead, - wallet::indy::IndySdkWallet, + wallet::base_wallet::BaseWallet, }; use super::connection::ServiceConnections; @@ -46,7 +46,7 @@ impl VerifierWrapper { pub struct ServiceVerifier { ledger_read: Arc, anoncreds: IndyCredxAnonCreds, - wallet: Arc, + wallet: Arc, verifiers: ObjectCache, service_connections: Arc, } @@ -55,7 +55,7 @@ impl ServiceVerifier { pub fn new( ledger_read: Arc, anoncreds: IndyCredxAnonCreds, - wallet: Arc, + wallet: Arc, service_connections: Arc, ) -> Self { Self { @@ -80,10 +80,12 @@ impl ServiceVerifier { Verifier::create_from_request("".to_string(), &request)? }; - let wallet = self.wallet.as_ref(); - let send_closure: SendClosure = Box::new(|msg: AriesMessage| { - Box::pin(async move { connection.send_message(wallet, &msg, &VcxHttpClient).await }) + Box::pin(async move { + connection + .send_message(&self.wallet, &msg, &VcxHttpClient) + .await + }) }); let message = verifier.mark_presentation_request_sent()?; @@ -112,10 +114,13 @@ impl ServiceVerifier { connection_id, } = self.verifiers.get(thread_id)?; let connection = self.service_connections.get_by_id(&connection_id)?; - let wallet = self.wallet.as_ref(); let send_closure: SendClosure = Box::new(|msg: AriesMessage| { - Box::pin(async move { connection.send_message(wallet, &msg, &VcxHttpClient).await }) + Box::pin(async move { + connection + .send_message(&self.wallet, &msg, &VcxHttpClient) + .await + }) }); let message = verifier diff --git a/aries/agents/rust/mediator/client-tui/src/lib.rs b/aries/agents/rust/mediator/client-tui/src/lib.rs index 717a8fe9d4..60ad5f6558 100644 --- a/aries/agents/rust/mediator/client-tui/src/lib.rs +++ b/aries/agents/rust/mediator/client-tui/src/lib.rs @@ -1,10 +1,9 @@ -use aries_vcx_core::wallet::base_wallet::BaseWallet; use mediator::{aries_agent::ArcAgent, persistence::MediatorPersistence}; use messages::msg_fields::protocols::out_of_band::invitation::Invitation as OOBInvitation; use serde_json::{json, Value}; pub async fn handle_register( - agent: ArcAgent, + agent: ArcAgent, oob_invite: OOBInvitation, ) -> Result { let mut aries_transport = reqwest::Client::new(); diff --git a/aries/agents/rust/mediator/client-tui/src/tui.rs b/aries/agents/rust/mediator/client-tui/src/tui.rs index 005d6b018c..70de08009a 100644 --- a/aries/agents/rust/mediator/client-tui/src/tui.rs +++ b/aries/agents/rust/mediator/client-tui/src/tui.rs @@ -1,6 +1,5 @@ use std::sync::Arc; -use aries_vcx_core::wallet::base_wallet::BaseWallet; use client_tui::handle_register; use cursive::{ direction::Orientation, @@ -17,19 +16,19 @@ use log::info; use mediator::{aries_agent::Agent, persistence::MediatorPersistence}; use messages::msg_fields::protocols::out_of_band::invitation::Invitation as OOBInvitation; -pub async fn init_tui(agent: Agent) { +pub async fn init_tui(agent: Agent

) { let mut cursive = Cursive::new(); cursive.add_global_callback(Key::Esc, |s| s.quit()); cursive.set_user_data(Arc::new(agent)); let mut main = LinearLayout::horizontal().with_name("main"); - let endpoint_selector = endpoints_ui::(); + let endpoint_selector = endpoints_ui::

(); main.get_mut().add_child(endpoint_selector); cursive.add_layer(main); cursive.run() } -pub fn endpoints_ui() -> Panel { +pub fn endpoints_ui() -> Panel { let mut endpoint_selector = SelectView::new(); // Set available endpoints endpoint_selector.add_item_str("/client/register"); @@ -38,8 +37,8 @@ pub fn endpoints_ui() -> Panel< endpoint_selector.set_on_submit(|s, endpoint: &str| { // Match ui generators for available endpoints let view = match endpoint { - "/client/register" => client_register_ui::(), - "/client/contacts" => contact_selector_ui::(s), + "/client/register" => client_register_ui::

(), + "/client/contacts" => contact_selector_ui::

(s), _ => dummy_ui(), }; // Replace previously exposed ui @@ -52,8 +51,7 @@ pub fn endpoints_ui() -> Panel< make_standard(endpoint_selector, Orientation::Vertical).title("Select endpoint") } -pub fn client_register_ui() -> Panel -{ +pub fn client_register_ui() -> Panel { let input = TextArea::new().with_name("oob_text_area"); let input = ResizedView::new( SizeConstraint::AtLeast(20), @@ -66,7 +64,7 @@ pub fn client_register_ui() -> .unwrap() .set_content(""); }) - .button("Connect", client_register_connect_cb::) + .button("Connect", client_register_connect_cb::

) .title("OOB Invite"); let input = Panel::new(input); @@ -82,9 +80,7 @@ pub fn client_register_ui() -> make_standard(ui, Orientation::Horizontal).title("Register client using Out Of Band Invitation") } -pub fn client_register_connect_cb( - s: &mut Cursive, -) { +pub fn client_register_connect_cb(s: &mut Cursive) { let oob_text_area = s.find_name::