Skip to content

Commit

Permalink
Refactor features, enable build with --no-default-features
Browse files Browse the repository at this point in the history
Signed-off-by: Patrik Stas <[email protected]>
  • Loading branch information
Patrik-Stas committed Jul 28, 2023
1 parent 29cde27 commit f326d49
Show file tree
Hide file tree
Showing 21 changed files with 34 additions and 34 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,11 @@ jobs:
- name: "Verify aries_vcx compiles with different dependency feature variants"
run: |
cd aries_vcx
cargo check
cargo check --no-default-features
cargo check --tests --all-features
cargo check --features vdrtools
cargo check --features modular_libs
cargo check --features vdr_proxy_ledger
cargo check --features vdrtools --no-default-features
cargo check --features modular_libs --no-default-features
cargo check --features vdr_proxy_ledger --no-default-features
##########################################################################################
############################## DOCKER BUILD ##########################################
Expand Down
2 changes: 1 addition & 1 deletion agents/rust/aries-vcx-agent/src/agent/agent_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::sync::Arc;

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use aries_vcx::{
agency_client::{agency_client::AgencyClient, configuration::AgencyClientConfig},
handlers::connection::mediated_connection::{ConnectionState, MediatedConnection},
};
use aries_vcx_core::wallet::indy::agency_client_wallet::ToBaseAgencyClientWallet;
use aries_vcx_core::wallet::agency_client_wallet::ToBaseAgencyClientWallet;

pub struct ServiceMediatedConnections {
profile: Arc<dyn Profile>,
Expand Down
2 changes: 1 addition & 1 deletion aries_vcx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ doctest = false

[features]
default = ["vdrtools"]
vdrtools = ["aries_vcx_core/vdrtools"]
vdrtools = ["aries_vcx_core/vdrtools_anoncreds", "aries_vcx_core/vdrtools_ledger", "aries_vcx_core/vdrtools_wallet"]
# Feature flag to include the 'modular library' dependencies (vdrtools alternatives; indy-vdr, indy-credx)
modular_libs = ["aries_vcx_core/modular_libs"]
# TODO: Remove using "vdrtools" feature flag for vdr_proxy_ledger once IndyCredxAnonCreds
Expand Down
2 changes: 1 addition & 1 deletion aries_vcx/src/handlers/connection/cloud_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use agency_client::agency_client::AgencyClient;
use agency_client::api::downloaded_message::DownloadedMessageEncrypted;
use agency_client::messages::update_message::UIDsByConn;
use agency_client::wallet::base_agency_client_wallet::BaseAgencyClientWallet;
use aries_vcx_core::wallet::indy::agency_client_wallet::ToBaseWallet;
use aries_vcx_core::wallet::agency_client_wallet::ToBaseWallet;
use messages::AriesMessage;

use crate::agency_client::MessageStatusCode;
Expand Down
1 change: 1 addition & 0 deletions aries_vcx/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub mod constants;
pub mod file;
pub mod mockdata;
pub mod openssl;
#[cfg(feature = "vdrtools")]
pub mod provision;
pub mod qualifier;
pub mod random;
Expand Down
2 changes: 1 addition & 1 deletion aries_vcx/src/utils/provision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::Arc;
use agency_client::agency_client::AgencyClient;
use agency_client::configuration::{AgencyClientConfig, AgentProvisionConfig};
use aries_vcx_core::wallet::base_wallet::BaseWallet;
use aries_vcx_core::wallet::indy::agency_client_wallet::ToBaseAgencyClientWallet;
use aries_vcx_core::wallet::agency_client_wallet::ToBaseAgencyClientWallet;

use crate::errors::error::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion aries_vcx/tests/test_agency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mod integration_tests {
use agency_client::MessageStatusCode;
use aries_vcx::global::settings;
use aries_vcx::utils::devsetup::SetupPoolDirectory;
use aries_vcx_core::wallet::indy::agency_client_wallet::ToBaseAgencyClientWallet;
use aries_vcx_core::wallet::agency_client_wallet::ToBaseAgencyClientWallet;
use aries_vcx_core::wallet::indy::wallet::create_and_open_wallet;
use aries_vcx_core::wallet::indy::{IndySdkWallet, WalletConfig};
use messages::msg_fields::protocols::cred_issuance::offer_credential::OfferCredentialDecorators;
Expand Down
2 changes: 1 addition & 1 deletion aries_vcx/tests/utils/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use aries_vcx::{
core::profile::modular_libs_profile::ModularLibsProfile, global::settings::WALLET_KDF_RAW,
utils::devsetup::SetupProfile,
};
use aries_vcx_core::wallet::indy::agency_client_wallet::ToBaseAgencyClientWallet;
use aries_vcx_core::wallet::agency_client_wallet::ToBaseAgencyClientWallet;
use aries_vcx_core::wallet::indy::wallet::create_and_open_wallet;
use aries_vcx_core::wallet::indy::IndySdkWallet;
use aries_vcx_core::wallet::indy::WalletConfig;
Expand Down
5 changes: 4 additions & 1 deletion aries_vcx_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ edition = "2021"
[features]
########################## DEP FLAGS ################################
# Feature flag to include the libvdrtools dependency
vdrtools = ["dep:libvdrtools"]
vdrtools = ["vdrtools_anoncreds", "vdrtools_wallet", "vdrtools_ledger"]
vdrtools_anoncreds = ["dep:libvdrtools"]
vdrtools_wallet = ["dep:libvdrtools"]
vdrtools_ledger = ["dep:libvdrtools"]
# Feature flag to include the 'modular library' dependencies (vdrtools alternatives; indy-vdr, indy-credx)
modular_libs = ["dep:indy-vdr", "dep:indy-credx", "dep:indy-ledger-response-parser", "dep:lru"]
vdr_proxy_ledger = ["modular_libs", "dep:indy-vdr-proxy-client"]
Expand Down
4 changes: 2 additions & 2 deletions aries_vcx_core/src/anoncreds/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub mod base_anoncreds;
#[cfg(any(feature = "modular_libs", feature = "vdr_proxy_ledger"))]
pub mod credx_anoncreds;

#[cfg(feature = "vdrtools")]
#[cfg(feature = "vdrtools_anoncreds")]
pub mod indy;
#[cfg(feature = "vdrtools")]
#[cfg(feature = "vdrtools_anoncreds")]
pub mod indy_anoncreds;
4 changes: 2 additions & 2 deletions aries_vcx_core/src/ledger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ pub mod request_submitter;
#[cfg(any(feature = "modular_libs", feature = "vdr_proxy_ledger"))]
pub mod response_cacher;

#[cfg(feature = "vdrtools")]
#[cfg(feature = "vdrtools_ledger")]
pub mod indy;
#[cfg(feature = "vdrtools")]
#[cfg(feature = "vdrtools_ledger")]
pub mod indy_ledger;

fn map_error_not_found_to_none<T, E>(res: Result<T, E>) -> Result<Option<T>, AriesVcxCoreError>
Expand Down
4 changes: 2 additions & 2 deletions aries_vcx_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ extern crate derive_builder;
pub mod anoncreds;
pub mod errors;
pub mod global;
#[cfg(feature = "vdrtools")]
#[cfg(any(feature = "vdrtools_anoncreds", feature = "vdrtools_ledger"))]
pub mod indy;
pub mod ledger;
pub mod utils;
pub mod wallet;

#[cfg(feature = "vdrtools")]
#[cfg(any(feature = "vdrtools_anoncreds", feature = "vdrtools_ledger"))]
pub use vdrtools::{
PoolHandle, SearchHandle, WalletHandle, INVALID_POOL_HANDLE, INVALID_SEARCH_HANDLE, INVALID_WALLET_HANDLE,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ use async_trait::async_trait;

use agency_client::errors::error::{AgencyClientError, AgencyClientErrorKind, AgencyClientResult};
use agency_client::wallet::base_agency_client_wallet::BaseAgencyClientWallet;
#[cfg(feature = "vdrtools")]
#[cfg(feature = "vdrtools_wallet")]
use vdrtools::WalletHandle;

use crate::errors::error::{AriesVcxCoreError, AriesVcxCoreErrorKind, VcxCoreResult};
use crate::utils::async_fn_iterator::AsyncFnIterator;
use crate::wallet::base_wallet::BaseWallet;


#[derive(Debug)]
pub(crate) struct AgencyClientWallet {
inner: Arc<dyn BaseAgencyClientWallet>,
Expand Down Expand Up @@ -110,7 +111,7 @@ impl BaseWallet for AgencyClientWallet {
Ok(self.inner.unpack_message(msg).await?)
}

#[cfg(feature = "vdrtools")]
#[cfg(feature = "vdrtools_wallet")]
fn get_wallet_handle(&self) -> WalletHandle {
unimplemented!("AgencyClientWallet::get_wallet_handle - this was not expected to be called")
}
Expand Down
4 changes: 2 additions & 2 deletions aries_vcx_core/src/wallet/base_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::HashMap;

use async_trait::async_trait;

#[cfg(feature = "vdrtools")]
#[cfg(feature = "vdrtools_wallet")]
use vdrtools::WalletHandle;

use crate::errors::error::VcxCoreResult;
Expand All @@ -13,7 +13,7 @@ use crate::utils::async_fn_iterator::AsyncFnIterator;
/// see: <https://github.com/hyperledger/indy-sdk/blob/main/libindy/src/api/wallet.rs>
#[async_trait]
pub trait BaseWallet: std::fmt::Debug + Send + Sync {
#[cfg(feature = "vdrtools")]
#[cfg(feature = "vdrtools_wallet")]
fn get_wallet_handle(&self) -> WalletHandle;

// ----- DIDs
Expand Down
1 change: 1 addition & 0 deletions aries_vcx_core/src/wallet/indy/indy_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ impl BaseWallet for IndySdkWallet {
wallet::indy::signing::unpack_message(self.wallet_handle, msg).await
}

#[cfg(feature = "vdrtools_wallet")]
fn get_wallet_handle(&self) -> WalletHandle {
self.wallet_handle
}
Expand Down
3 changes: 1 addition & 2 deletions aries_vcx_core/src/wallet/indy/internal/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::errors::error::VcxCoreResult;
use crate::global::settings;
use crate::{SearchHandle, WalletHandle};
use vdrtools::Locator;
use vdrtools::{Locator, SearchHandle, WalletHandle};

pub(crate) async fn add_wallet_record(
wallet_handle: WalletHandle,
Expand Down
1 change: 0 additions & 1 deletion aries_vcx_core/src/wallet/indy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use crate::{SearchHandle, WalletHandle};

use super::base_wallet::BaseWallet;

pub mod agency_client_wallet;
pub mod did_mocks;
pub mod indy_wallet;
pub mod internal;
Expand Down
9 changes: 2 additions & 7 deletions aries_vcx_core/src/wallet/indy/wallet.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
use serde::{Deserialize, Serialize};

use vdrtools::{
types::domain::wallet::{default_key_derivation_method, KeyDerivationMethod},
types::errors::IndyErrorKind,
DidMethod, DidValue, KeyInfo, Locator, MyDidInfo,
};
use vdrtools::{types::domain::wallet::{default_key_derivation_method, KeyDerivationMethod}, types::errors::IndyErrorKind, DidMethod, DidValue, KeyInfo, Locator, MyDidInfo, WalletHandle};

use crate::wallet::indy::did_mocks::{did_mocks_enabled, DidMocks};
use crate::wallet::indy::{IssuerConfig, RestoreWalletConfigs, WalletConfig};
use crate::SearchHandle;
use crate::{
anoncreds::indy::credentials::holder,
errors::error::{AriesVcxCoreError, AriesVcxCoreErrorKind, VcxCoreResult},
};
use crate::{global::settings, WalletHandle};
use crate::{global::settings};
use crate::{secret, utils};

pub async fn open_wallet(wallet_config: &WalletConfig) -> VcxCoreResult<WalletHandle> {
Expand Down
3 changes: 2 additions & 1 deletion aries_vcx_core/src/wallet/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod base_wallet;
#[cfg(feature = "vdrtools")]
#[cfg(feature = "vdrtools_wallet")]
pub mod indy;
pub mod agency_client_wallet;
2 changes: 1 addition & 1 deletion libvcx_core/src/api_vcx/api_global/agency_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use aries_vcx::agency_client::agency_client::AgencyClient;
use aries_vcx::agency_client::configuration::{AgencyClientConfig, AgentProvisionConfig};
use aries_vcx::agency_client::messages::update_message::UIDsByConn;
use aries_vcx::agency_client::MessageStatusCode;
use aries_vcx::aries_vcx_core::wallet::indy::agency_client_wallet::ToBaseAgencyClientWallet;
use aries_vcx::aries_vcx_core::wallet::agency_client_wallet::ToBaseAgencyClientWallet;

use super::profile::get_main_wallet;

Expand Down

0 comments on commit f326d49

Please sign in to comment.