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 features, enable build with --no-default-features #918

Merged
merged 5 commits into from
Jul 31, 2023
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: 4 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,6 @@ jobs:
run: |
cd did_resolver_sov
cargo check
cargo check --features vdrtools --no-default-features
cargo check --features modular_libs --no-default-features

check-aries-vcx-feature-variants:
runs-on: ubuntu-20.04
Expand All @@ -191,11 +189,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
1 change: 1 addition & 0 deletions Cargo.lock

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

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
2 changes: 1 addition & 1 deletion aries_vcx/src/protocols/connection/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ mod connection_serde_tests {
use crate::protocols::connection::{invitee::InviteeConnection, inviter::InviterConnection, Connection};
use crate::utils::mockdata::profile::mock_ledger::MockLedger;
use crate::utils::mockdata::profile::mock_profile::MockProfile;
use crate::utils::mockdata::profile::mock_wallet::MockWallet;
use aries_vcx_core::ledger::base_ledger::IndyLedgerRead;
use aries_vcx_core::wallet::mock_wallet::MockWallet;
use std::sync::Arc;

impl<'a> From<RefInviteeState<'a>> for InviteeState {
Expand Down
3 changes: 2 additions & 1 deletion aries_vcx/src/utils/mockdata/profile/mock_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ use aries_vcx_core::{
anoncreds::base_anoncreds::BaseAnonCreds,
ledger::base_ledger::{AnoncredsLedgerRead, AnoncredsLedgerWrite, IndyLedgerRead, IndyLedgerWrite},
wallet::base_wallet::BaseWallet,
wallet::mock_wallet::MockWallet,
};

use super::{mock_anoncreds::MockAnoncreds, mock_ledger::MockLedger, mock_wallet::MockWallet};
use super::{mock_anoncreds::MockAnoncreds, mock_ledger::MockLedger};
use crate::core::profile::profile::Profile;
use crate::errors::error::VcxResult;
use async_trait::async_trait;
Expand Down
1 change: 0 additions & 1 deletion aries_vcx/src/utils/mockdata/profile/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub mod mock_anoncreds;
pub mod mock_ledger;
pub mod mock_profile;
pub mod mock_wallet;
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 @@ -2,8 +2,8 @@ use std::sync::Arc;

use agency_client::agency_client::AgencyClient;
use agency_client::configuration::{AgencyClientConfig, AgentProvisionConfig};
use aries_vcx_core::wallet::agency_client_wallet::ToBaseAgencyClientWallet;
use aries_vcx_core::wallet::base_wallet::BaseWallet;
use aries_vcx_core::wallet::indy::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,9 @@ edition = "2021"
[features]
########################## DEP FLAGS ################################
# Feature flag to include the libvdrtools dependency
vdrtools = ["dep:libvdrtools"]
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 All @@ -28,6 +30,7 @@ indy-vdr = { version = "0.3.4", default-features = false, features = ["ffi", "lo
# - update libvdrtools to use =0.3.6 ursa
indy-credx = { git = "https://github.com/anonyome/indy-shared-rs.git", rev = "7342bc624d23ece8845d1a701cd2cdc9cd401bb0", optional = true }
libvdrtools = { path = "../libvdrtools", optional = true }
indy-api-types = { path = "../libvdrtools/indy-api-types" }
Patrik-Stas marked this conversation as resolved.
Show resolved Hide resolved
async-trait = "0.1.68"
futures = { version = "0.3", default-features = false }
serde_json = "1.0.95"
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;
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
#[cfg(feature = "vdrtools")]
use vdrtools::types::{
errors::{IndyError, IndyErrorKind},
ErrorCode,
};
pub use indy_api_types::{errors, ErrorCode};

#[cfg(all(
not(feature = "vdrtools"),
any(feature = "modular_libs", feature = "vdr_proxy_ledger")
))]
use indy_ledger_response_parser::{
errors::{IndyError, IndyErrorKind},
ErrorCode,
use indy_api_types::{
errors::{err_msg, IndyErrorKind, IndyResult, IndyResultExt},
IndyError,
};

use crate::errors::error::{AriesVcxCoreError, AriesVcxCoreErrorKind};
Expand Down
3 changes: 1 addition & 2 deletions aries_vcx_core/src/errors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ pub mod error;
mod mapping_agency_client;
#[cfg(any(feature = "modular_libs", feature = "vdr_proxy_ledger"))]
mod mapping_credx;
mod mapping_indy_api_types;
#[cfg(any(feature = "modular_libs", feature = "vdr_proxy_ledger"))]
mod mapping_indyvdr;
#[cfg(feature = "vdr_proxy_ledger")]
mod mapping_indyvdr_proxy;
mod mapping_others;
#[cfg(any(feature = "vdrtools", feature = "modular_libs", feature = "vdr_proxy_ledger"))]
mod mapping_vdrtools;
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
15 changes: 10 additions & 5 deletions aries_vcx_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,21 @@ extern crate derive_builder;
pub mod anoncreds;
pub mod errors;
pub mod global;
#[cfg(feature = "vdrtools")]
#[cfg(any(
feature = "vdrtools_anoncreds",
feature = "vdrtools_ledger",
feature = "vdrtools_wallet"
))]
pub mod indy;
pub mod ledger;
pub mod utils;
pub mod wallet;

#[cfg(feature = "vdrtools")]
pub use vdrtools::{
PoolHandle, SearchHandle, WalletHandle, INVALID_POOL_HANDLE, INVALID_SEARCH_HANDLE, INVALID_WALLET_HANDLE,
};
#[cfg(feature = "vdrtools_ledger")]
pub use vdrtools::{PoolHandle, INVALID_POOL_HANDLE};

#[cfg(feature = "vdrtools_wallet")]
pub use vdrtools::{SearchHandle, WalletHandle, INVALID_SEARCH_HANDLE, INVALID_WALLET_HANDLE};

#[cfg(feature = "vdr_proxy_ledger")]
pub use indy_vdr_proxy_client::VdrProxyClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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};
Expand Down Expand Up @@ -110,7 +110,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
6 changes: 3 additions & 3 deletions aries_vcx_core/src/wallet/base_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::collections::HashMap;

use async_trait::async_trait;

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

use crate::errors::error::VcxCoreResult;
use crate::utils::async_fn_iterator::AsyncFnIterator;
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: 3 additions & 6 deletions aries_vcx_core/src/wallet/indy/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@ use serde::{Deserialize, Serialize};
use vdrtools::{
types::domain::wallet::{default_key_derivation_method, KeyDerivationMethod},
types::errors::IndyErrorKind,
DidMethod, DidValue, KeyInfo, Locator, MyDidInfo,
DidMethod, DidValue, KeyInfo, Locator, MyDidInfo, WalletHandle,
};

use crate::errors::error::{AriesVcxCoreError, AriesVcxCoreErrorKind, VcxCoreResult};
use crate::global::settings;
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::{secret, utils};

pub async fn open_wallet(wallet_config: &WalletConfig) -> VcxCoreResult<WalletHandle> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use aries_vcx_core::errors::error::{AriesVcxCoreError, AriesVcxCoreErrorKind, VcxCoreResult};
use aries_vcx_core::utils::async_fn_iterator::AsyncFnIterator;
use aries_vcx_core::wallet::base_wallet::BaseWallet;
use std::collections::HashMap;

use async_trait::async_trait;

use crate::errors::error::{AriesVcxCoreError, AriesVcxCoreErrorKind, VcxCoreResult};
use crate::utils::async_fn_iterator::AsyncFnIterator;
use crate::utils::{self};
#[cfg(feature = "vdrtools")]
use aries_vcx_core::WalletHandle;
use std::collections::HashMap;
use crate::wallet::base_wallet::BaseWallet;
#[cfg(feature = "vdrtools_wallet")]
use crate::WalletHandle;

#[derive(Debug)]
pub struct MockWallet;
Expand All @@ -16,7 +17,7 @@ pub struct MockWallet;
#[allow(unused)]
#[async_trait]
impl BaseWallet for MockWallet {
#[cfg(feature = "vdrtools")]
#[cfg(feature = "vdrtools_wallet")]
fn get_wallet_handle(&self) -> WalletHandle {
WalletHandle(1)
}
Expand Down
4 changes: 3 additions & 1 deletion aries_vcx_core/src/wallet/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub mod agency_client_wallet;
pub mod base_wallet;
#[cfg(feature = "vdrtools")]
#[cfg(feature = "vdrtools_wallet")]
pub mod indy;
pub mod mock_wallet;
7 changes: 1 addition & 6 deletions did_resolver_sov/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ name = "did_resolver_sov"
version = "0.1.0"
edition = "2021"

[features]
default = []
vdrtools = ["aries_vcx_core/vdrtools"]
modular_libs = ["aries_vcx_core/modular_libs"]

[dependencies]
did_resolver = { path = "../did_resolver" }
aries_vcx_core = { path = "../aries_vcx_core" }
aries_vcx_core = { path = "../aries_vcx_core", features = ["modular_libs"] }
did_doc_sov = { path = "../did_doc_sov" }
async-trait = "0.1.68"
mockall = "0.11.4"
Expand Down
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
2 changes: 1 addition & 1 deletion libvcx_core/src/api_vcx/api_global/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ use aries_vcx::aries_vcx_core::ledger::base_ledger::{
AnoncredsLedgerRead, AnoncredsLedgerWrite, IndyLedgerRead, IndyLedgerWrite, TxnAuthrAgrmtOptions,
};
use aries_vcx::aries_vcx_core::wallet::indy::IndySdkWallet;
use aries_vcx::aries_vcx_core::wallet::mock_wallet::MockWallet;
use aries_vcx::aries_vcx_core::{wallet::base_wallet::BaseWallet, WalletHandle};
use aries_vcx::core::profile::{profile::Profile, vdrtools_profile::VdrtoolsProfile};
use aries_vcx::errors::error::VcxResult;
use aries_vcx::utils::mockdata::profile::mock_anoncreds::MockAnoncreds;
use aries_vcx::utils::mockdata::profile::mock_ledger::MockLedger;
use aries_vcx::utils::mockdata::profile::mock_wallet::MockWallet;
use aries_vcx::{global::settings::indy_mocks_enabled, utils::mockdata::profile::mock_profile::MockProfile};

pub trait ProfileV2: Send + Sync {
Expand Down