Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use BaseWallet instead of a specific wallet type #1122

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ jobs:
workspace_clippy:
runs-on: ubuntu-20.04
strategy:
matrix:
wallet: ["vdrtools_wallet", "askar_wallet"]
steps:
- name: "Git checkout"
uses: actions/checkout@v3
Expand All @@ -113,7 +116,7 @@ jobs:
sudo apt-get install -y libsodium-dev libssl-dev libzmq3-dev
sudo snap install --edge --classic just
- name: "Verify clippy across the entire workspace with default features"
run: just clippy-workspace
run: just clippy-workspace ${{ matrix.wallet }}

aries_vcx_clippy:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -392,6 +395,9 @@ jobs:
needs: workflow-setup
if: ${{ needs.workflow-setup.outputs.SKIP_CI != 'true' }}
runs-on: ubuntu-20.04
strategy:
matrix:
wallet: ["vdrtools_wallet", "askar_wallet"]
steps:
- name: "Git checkout"
uses: actions/checkout@v3
Expand All @@ -402,7 +408,7 @@ jobs:
- name: "Install just"
run: sudo snap install --edge --classic just
- name: "Run libvcx_core integration tests"
run: just test-integration-libvcx
run: just test-integration-libvcx ${{ matrix.wallet }}

test-integration-did-crate:
needs: workflow-setup
Expand Down
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions aries/agents/rust/aries-vcx-agent/src/agent/agent_config.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use aries_vcx_core::wallet::indy::{IssuerConfig, WalletConfig};
use aries_vcx_core::wallet::{
base_wallet::issuer_config::IssuerConfig, indy::indy_wallet_config::IndyWalletConfig,
};
use display_as_json::Display;
use serde::Serialize;

#[derive(Clone, Serialize, Display)]
pub struct AgentConfig {
pub config_wallet: WalletConfig,
pub config_wallet: IndyWalletConfig,
pub config_issuer: IssuerConfig,
}
50 changes: 25 additions & 25 deletions aries/agents/rust/aries-vcx-agent/src/agent/agent_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -18,25 +18,25 @@ use crate::{
};

#[derive(Clone)]
pub struct Agent {
pub struct Agent<T> {
pub(super) ledger_read: Arc<DefaultIndyLedgerRead>,
pub(super) ledger_write: Arc<DefaultIndyLedgerWrite>,
pub(super) anoncreds: IndyCredxAnonCreds,
pub(super) wallet: Arc<IndySdkWallet>,
pub(super) wallet: Arc<T>,
pub(super) config: AgentConfig,
pub(super) connections: Arc<ServiceConnections>,
pub(super) schemas: Arc<ServiceSchemas>,
pub(super) cred_defs: Arc<ServiceCredentialDefinitions>,
pub(super) rev_regs: Arc<ServiceRevocationRegistries>,
pub(super) holder: Arc<ServiceCredentialsHolder>,
pub(super) issuer: Arc<ServiceCredentialsIssuer>,
pub(super) verifier: Arc<ServiceVerifier>,
pub(super) prover: Arc<ServiceProver>,
pub(super) out_of_band: Arc<ServiceOutOfBand>,
pub(super) did_exchange: Arc<ServiceDidExchange>,
pub(super) connections: Arc<ServiceConnections<T>>,
pub(super) schemas: Arc<ServiceSchemas<T>>,
pub(super) cred_defs: Arc<ServiceCredentialDefinitions<T>>,
pub(super) rev_regs: Arc<ServiceRevocationRegistries<T>>,
pub(super) holder: Arc<ServiceCredentialsHolder<T>>,
pub(super) issuer: Arc<ServiceCredentialsIssuer<T>>,
pub(super) verifier: Arc<ServiceVerifier<T>>,
pub(super) prover: Arc<ServiceProver<T>>,
pub(super) out_of_band: Arc<ServiceOutOfBand<T>>,
pub(super) did_exchange: Arc<ServiceDidExchange<T>>,
}

impl Agent {
impl<T: BaseWallet> Agent<T> {
pub fn ledger_read(&self) -> &DefaultIndyLedgerRead {
&self.ledger_read
}
Expand All @@ -49,7 +49,7 @@ impl Agent {
&self.anoncreds
}

pub fn wallet(&self) -> &IndySdkWallet {
pub fn wallet(&self) -> &Arc<T> {
&self.wallet
}

Expand All @@ -61,43 +61,43 @@ impl Agent {
self.config.config_issuer.institution_did.clone()
}

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

pub fn out_of_band(&self) -> Arc<ServiceOutOfBand> {
pub fn out_of_band(&self) -> Arc<ServiceOutOfBand<T>> {
self.out_of_band.clone()
}

pub fn did_exchange(&self) -> Arc<ServiceDidExchange> {
pub fn did_exchange(&self) -> Arc<ServiceDidExchange<T>> {
self.did_exchange.clone()
}

pub fn schemas(&self) -> Arc<ServiceSchemas> {
pub fn schemas(&self) -> Arc<ServiceSchemas<T>> {
self.schemas.clone()
}

pub fn cred_defs(&self) -> Arc<ServiceCredentialDefinitions> {
pub fn cred_defs(&self) -> Arc<ServiceCredentialDefinitions<T>> {
self.cred_defs.clone()
}

pub fn rev_regs(&self) -> Arc<ServiceRevocationRegistries> {
pub fn rev_regs(&self) -> Arc<ServiceRevocationRegistries<T>> {
self.rev_regs.clone()
}

pub fn issuer(&self) -> Arc<ServiceCredentialsIssuer> {
pub fn issuer(&self) -> Arc<ServiceCredentialsIssuer<T>> {
self.issuer.clone()
}

pub fn holder(&self) -> Arc<ServiceCredentialsHolder> {
pub fn holder(&self) -> Arc<ServiceCredentialsHolder<T>> {
self.holder.clone()
}

pub fn verifier(&self) -> Arc<ServiceVerifier> {
pub fn verifier(&self) -> Arc<ServiceVerifier<T>> {
self.verifier.clone()
}

pub fn prover(&self) -> Arc<ServiceProver> {
pub fn prover(&self) -> Arc<ServiceProver<T>> {
self.prover.clone()
}

Expand Down
18 changes: 9 additions & 9 deletions aries/agents/rust/aries-vcx-agent/src/agent/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ 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::{BaseWallet, ManageWallet},
indy::{indy_wallet_config::IndyWalletConfig, IndySdkWallet},
},
};
use did_peer::resolver::PeerDidResolver;
Expand Down Expand Up @@ -59,9 +59,9 @@ pub struct InitConfig {
pub service_endpoint: ServiceEndpoint,
}

impl Agent {
impl Agent<IndySdkWallet> {
pub async fn initialize(init_config: InitConfig) -> AgentResult<Self> {
let config_wallet = WalletConfig {
let config_wallet = IndyWalletConfig {
wallet_name: init_config.wallet_config.wallet_name,
wallet_key: init_config.wallet_config.wallet_key,
wallet_key_derivation: init_config.wallet_config.wallet_kdf,
Expand All @@ -72,13 +72,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 = Arc::new(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 >>");
Expand Down
12 changes: 7 additions & 5 deletions aries/agents/rust/aries-vcx-agent/src/services/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -21,17 +23,17 @@ use crate::{

pub type ServiceEndpoint = Url;

pub struct ServiceConnections {
pub struct ServiceConnections<T> {
ledger_read: Arc<DefaultIndyLedgerRead>,
wallet: Arc<IndySdkWallet>,
wallet: Arc<T>,
service_endpoint: ServiceEndpoint,
connections: Arc<ObjectCache<GenericConnection>>,
}

impl ServiceConnections {
impl<T: BaseWallet> ServiceConnections<T> {
pub fn new(
ledger_read: Arc<DefaultIndyLedgerRead>,
wallet: Arc<IndySdkWallet>,
wallet: Arc<T>,
service_endpoint: ServiceEndpoint,
) -> Self {
Self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ use aries_vcx::{common::primitives::credential_definition::CredentialDef, did_pa
use aries_vcx_core::{
anoncreds::credx_anoncreds::IndyCredxAnonCreds,
ledger::indy_vdr_ledger::{DefaultIndyLedgerRead, DefaultIndyLedgerWrite},
wallet::indy::IndySdkWallet,
wallet::base_wallet::BaseWallet,
};

use crate::{
error::*,
storage::{object_cache::ObjectCache, Storage},
};

pub struct ServiceCredentialDefinitions {
pub struct ServiceCredentialDefinitions<T> {
ledger_read: Arc<DefaultIndyLedgerRead>,
ledger_write: Arc<DefaultIndyLedgerWrite>,
anoncreds: IndyCredxAnonCreds,
wallet: Arc<IndySdkWallet>,
wallet: Arc<T>,
cred_defs: ObjectCache<CredentialDef>,
}

impl ServiceCredentialDefinitions {
impl<T: BaseWallet> ServiceCredentialDefinitions<T> {
pub fn new(
ledger_read: Arc<DefaultIndyLedgerRead>,
ledger_write: Arc<DefaultIndyLedgerWrite>,
anoncreds: IndyCredxAnonCreds,
wallet: Arc<IndySdkWallet>,
wallet: Arc<T>,
) -> Self {
Self {
cred_defs: ObjectCache::new("cred-defs"),
Expand Down
12 changes: 7 additions & 5 deletions aries/agents/rust/aries-vcx-agent/src/services/did_exchange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,19 +26,19 @@ use crate::{
AgentError, AgentErrorKind, AgentResult,
};

pub struct ServiceDidExchange {
pub struct ServiceDidExchange<T> {
ledger_read: Arc<DefaultIndyLedgerRead>,
wallet: Arc<IndySdkWallet>,
wallet: Arc<T>,
resolver_registry: Arc<ResolverRegistry>,
service_endpoint: ServiceEndpoint,
did_exchange: Arc<ObjectCache<GenericDidExchange>>,
public_did: String,
}

impl ServiceDidExchange {
impl<T: BaseWallet> ServiceDidExchange<T> {
pub fn new(
ledger_read: Arc<DefaultIndyLedgerRead>,
wallet: Arc<IndySdkWallet>,
wallet: Arc<T>,
resolver_registry: Arc<ResolverRegistry>,
service_endpoint: ServiceEndpoint,
public_did: String,
Expand Down
Loading
Loading