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

Separate core into a standalone crate #798

Merged
merged 38 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
30f1483
Remove dependency on aries-vcx in plugins
mirgee Apr 8, 2023
5b3d13f
Separate plugins into a crate
mirgee Apr 8, 2023
011fd32
Use BaseAnoncreds from aries_vcx_core
mirgee Apr 10, 2023
3ff388a
Use BaseWallet from aries_vcx_core
mirgee Apr 10, 2023
bb98634
Use IndyWallet from aries_vcx_core
mirgee Apr 10, 2023
656574d
Use IndyAnoncreds, CredxAnoncreds from aries_vcx_core
mirgee Apr 10, 2023
aae3ee4
Use BaseLedger from aries_vcx_core
mirgee Apr 10, 2023
85d418c
Use IndyLedger, IndyVdrLedger from aries_vcx_core
mirgee Apr 10, 2023
a25d1c9
Prune indy aries_vcx module
mirgee Apr 10, 2023
9934412
Remove holder and wallet from indy module
mirgee Apr 10, 2023
9a6cef3
Remove remainder of indy dir from aries_vcx
mirgee Apr 10, 2023
053683a
aries_vcx, aries_vcx core builds with all features
mirgee Apr 11, 2023
c58164b
aries-vcx-agent compiles
mirgee Apr 11, 2023
c262e52
libvcx_core + tests compile
mirgee Apr 11, 2023
6087327
Export newtype wallet handle from aries_vcx_core
mirgee Apr 11, 2023
eda5d3d
aries_vcx + tests compile
mirgee Apr 11, 2023
434af97
libvcx_core + tests compile
mirgee Apr 11, 2023
47b48f5
Decide to reexport aries_vcx_core from aries_vcx
mirgee Apr 11, 2023
5cb12e5
Workspace compiles
mirgee Apr 11, 2023
b025ecd
Use internal pool handle in aries_vcx_core
mirgee Apr 11, 2023
405fda6
Workspace compiles
mirgee Apr 11, 2023
a465261
workspace compiles, no reexports
mirgee Apr 11, 2023
69feacc
Merge branch 'main' into refactor/seperate-plugins
mirgee Apr 12, 2023
e0b9e3a
Unit tests passing
mirgee Apr 12, 2023
c7ca1cb
Merge branch 'main' into refactor/seperate-plugins
mirgee Apr 12, 2023
3767993
Fix some test
mirgee Apr 12, 2023
7f56cc6
Remove some stuff
mirgee Apr 12, 2023
a699292
Trigger CI rerun
Patrik-Stas Apr 13, 2023
cabf885
Fix CI caching
Patrik-Stas Apr 13, 2023
156fd62
Use additional cache key for shared library build jobs
Patrik-Stas Apr 13, 2023
f914881
Fix nodejs unit tests (setting up mock mode)
Patrik-Stas Apr 13, 2023
3003ad6
Fix ci syntax
Patrik-Stas Apr 13, 2023
866fe82
Bump CI rust version to 1.65.0
Patrik-Stas Apr 13, 2023
76529cc
Fix formatting
Patrik-Stas Apr 13, 2023
56b541e
Fix compile errs
Patrik-Stas Apr 13, 2023
0dc0309
Fix code formatting
Patrik-Stas Apr 13, 2023
eb925f1
Fix aries-vcx-core build in non-test environment
Patrik-Stas Apr 13, 2023
b99839d
Fix hashing in CI
Patrik-Stas Apr 13, 2023
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
1,041 changes: 621 additions & 420 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ members = [
"diddoc",
"agents/rust/aries-vcx-agent",
"wrappers/vcx-napi-rs",
"aries_vcx_core",
"uniffi_aries_vcx/core"
]

Expand Down
1 change: 1 addition & 0 deletions agents/rust/aries-vcx-agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition.workspace = true
[dependencies]
serde = "1.0.145"
aries-vcx = { path = "../../../aries_vcx" }
aries_vcx_core = { path = "../../../aries_vcx_core" }
async-trait = "0.1.64"
derive_builder = "0.11.2"
serde_json = "1.0.85"
Expand Down
6 changes: 2 additions & 4 deletions agents/rust/aries-vcx-agent/src/agent/agent_config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use aries_vcx::{
agency_client::configuration::AgencyClientConfig,
indy::wallet::{IssuerConfig, WalletConfig},
};
use aries_vcx::agency_client::configuration::AgencyClientConfig;
use aries_vcx_core::indy::wallet::{IssuerConfig, WalletConfig};

#[derive(Clone)]
pub struct AgentConfig {
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::plugins::wallet::agency_client_wallet::ToBaseAgencyClientWallet;
use aries_vcx_core::wallet::agency_client_wallet::ToBaseAgencyClientWallet;

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

Expand Down
10 changes: 5 additions & 5 deletions agents/rust/aries-vcx-agent/src/agent/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use aries_vcx::{
agency_client::{agency_client::AgencyClient, configuration::AgentProvisionConfig},
core::profile::{profile::Profile, vdrtools_profile::VdrtoolsProfile},
global::settings::init_issuer_config,
indy::{
ledger::pool::{create_pool_ledger_config, open_pool_ledger, PoolConfigBuilder},
wallet::{create_wallet_with_master_secret, open_wallet, wallet_configure_issuer, WalletConfig},
},
utils::provision::provision_cloud_agent,
};
use aries_vcx_core::indy::{
ledger::pool::{create_pool_ledger_config, open_pool_ledger, PoolConfigBuilder},
wallet::{create_wallet_with_master_secret, open_wallet, wallet_configure_issuer, WalletConfig},
};

use crate::{
agent::{agent_config::AgentConfig, agent_struct::Agent},
Expand Down Expand Up @@ -86,7 +86,7 @@ impl Agent {
.await
.unwrap();

let indy_profile = VdrtoolsProfile::new(wallet_handle, pool_handle);
let indy_profile = VdrtoolsProfile::new(wallet_handle, aries_vcx_core::PoolHandle(pool_handle));
let profile: Arc<dyn Profile> = Arc::new(indy_profile);
let wallet = profile.inject_wallet();

Expand Down
10 changes: 10 additions & 0 deletions agents/rust/aries-vcx-agent/src/error/convertors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::convert::From;

use aries_vcx::errors::error::{AriesVcxError, AriesVcxErrorKind};
use aries_vcx_core::errors::error::AriesVcxCoreError;

use crate::error::*;

Expand All @@ -23,3 +24,12 @@ impl From<serde_json::Error> for AgentError {
AgentError { message, kind }
}
}

// TODO
impl From<AriesVcxCoreError> for AgentError {
fn from(err: AriesVcxCoreError) -> Self {
let kind = AgentErrorKind::GenericAriesVcxError;
let message = format!("AriesVcxCore Error; err: {:?}", err.to_string());
AgentError { message, kind }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ use aries_vcx::messages::protocols::connection::request::Request;
use aries_vcx::messages::protocols::issuance::credential_offer::CredentialOffer;
use aries_vcx::messages::protocols::issuance::credential_proposal::CredentialProposal;
use aries_vcx::messages::protocols::proof_presentation::presentation_proposal::PresentationProposal;
use aries_vcx::plugins::wallet::agency_client_wallet::ToBaseAgencyClientWallet;
use aries_vcx::{
agency_client::{agency_client::AgencyClient, configuration::AgencyClientConfig},
handlers::connection::mediated_connection::{ConnectionState, MediatedConnection},
messages::a2a::A2AMessage,
};
use aries_vcx_core::wallet::agency_client_wallet::ToBaseAgencyClientWallet;

pub struct ServiceMediatedConnections {
profile: Arc<dyn Profile>,
Expand Down
26 changes: 4 additions & 22 deletions aries_vcx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@ path = "src/lib.rs"
doctest = false

[features]
# By default, vdrtools is enabled to allow aries_vcx usage with vdrtools-based wallets/anoncreds/ledgers
default = ["vdrtools"]
########################## DEP FLAGS ################################
# Feature flag to include the libvdrtools dependency
vdrtools = ["dep:libvdrtools"]
vdrtools = ["aries_vcx_core/vdrtools"]
# Feature flag to include the 'modular library' dependencies (vdrtools alternatives; indy-vdr, indy-credx)
modular_libs = ["dep:indy-vdr", "dep:indy-credx"]
modular_libs = ["aries_vcx_core/modular_libs"]
########################## TEST FLAGS ###############################
# Feature flag for base requirments for running tests underneath the `test_utils` flag (most tests).
# Both `vdrtools` and `modular_libs` are transitively enabled, so they can be used for tests (including interop tests).
test_utils = [ "messages/test_utils", "vdrtools", "modular_libs" ]
test_utils = [ "messages/test_utils", "aries_vcx_core/test_utils", "vdrtools", "modular_libs" ]
# Feature flag for categorising tests which require a ledger to be running
pool_tests = [ "test_utils" ]
# Feature flag for categorising tests which require a ledger and messaging agency to be running
Expand Down Expand Up @@ -53,22 +50,6 @@ serde_derive = "1.0.97"
regex = "1.1.0"
base64 = "0.10"
openssl = { version = "0.10.48" }
libvdrtools = { path = "../libvdrtools", optional = true }
# vdrtools alternatives ----
indy-vdr = { version = "0.3.4", default-features = false, features = ["ffi", "log"], optional = true }
# PATCH (TO MONITOR IN FUTURE): The following patch changes the `indy-data-types` (within indy-shared-rs) to depend on
# `ursa "0.3.6"` rather than `ursa "=0.3.6"`. Currently, `libvdrtools` depends on `ursa "0.3.7"`, which causes a mismatch of
# `indy-utils` versions, which causes some types within credx to fail. Details about the issue can be found here: https://github.com/hyperledger/indy-shared-rs/issues/20
# `indy-data-types` depends on `ursa =0.3.6` due to a 'broken cl feature', see commmit: https://github.com/hyperledger/indy-shared-rs/commit/2403eed6449a3b5e347697b215a732fc33c014c0
# however using ursa 0.3.7 does not seem to affect our usage of indy-credx currently. More testing would be ideal.
# various combinations of indy-vdr and indy-credx have been tried to resolve the dependency mismatches, however this patch appears
# to be the only quick solution.
# Potential resolutions:
# - wait for ursa 0.3.8+ to resolve the CL issue and update indy-shared-rs,
# - monitor anoncred-rs (which will replace indy-credx) as the fix will likely go in here,
# - monitor the issue for other fixes from the maintainers: https://github.com/hyperledger/indy-shared-rs/issues/20
# - update libvdrtools to use =0.3.6 ursa
indy-credx = { git = "https://github.com/anonyome/indy-shared-rs.git", rev = "7342bc624d23ece8845d1a701cd2cdc9cd401bb0", optional = true }
# ----------------------
futures = { version = "0.3", default-features = false }
uuid = { version = "0.8", default-features = false, features = ["v4"] }
Expand All @@ -78,6 +59,7 @@ agency_client = { path = "../agency_client" }
derive_builder = "0.10.2"
tokio = { version = "1.20.4" }
messages = { path = "../messages" }
aries_vcx_core = { path = "../aries_vcx_core" }
thiserror = "1.0.37"

[target.'cfg(target_os = "android")'.dependencies]
Expand Down
7 changes: 4 additions & 3 deletions aries_vcx/src/common/anoncreds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
pub mod integration_tests {
use std::sync::Arc;

use aries_vcx_core::errors::error::AriesVcxCoreErrorKind;

use crate::common::test_utils::create_and_store_credential;
use crate::errors::error::AriesVcxErrorKind;
use crate::utils::constants::TAILS_DIR;
use crate::utils::devsetup::{init_holder_setup_in_indy_context, SetupProfile};
use crate::utils::get_temp_dir_path;
Expand All @@ -15,7 +16,7 @@ pub mod integration_tests {
let proof_req = "{";
let anoncreds = Arc::clone(&setup.profile).inject_anoncreds();
let result = anoncreds.prover_get_credentials_for_proof_req(&proof_req).await;
assert_eq!(result.unwrap_err().kind(), AriesVcxErrorKind::InvalidProofRequest);
assert_eq!(result.unwrap_err().kind(), AriesVcxCoreErrorKind::InvalidProofRequest);
})
.await;
}
Expand Down Expand Up @@ -48,7 +49,7 @@ pub mod integration_tests {
let result_malformed_json = anoncreds.prover_get_credentials_for_proof_req("{}").await.unwrap_err();
assert_eq!(
result_malformed_json.kind(),
AriesVcxErrorKind::InvalidAttributesStructure
AriesVcxCoreErrorKind::InvalidAttributesStructure
);
})
.await;
Expand Down
5 changes: 3 additions & 2 deletions aries_vcx/src/common/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub async fn rotate_verkey_apply(profile: &Arc<dyn Profile>, did: &str, temp_vk:
}

let wallet = profile.inject_wallet();
wallet.replace_did_keys_apply(did).await
wallet.replace_did_keys_apply(did).await.map_err(|err| err.into())
}

pub async fn rotate_verkey(profile: &Arc<dyn Profile>, did: &str) -> VcxResult<()> {
Expand Down Expand Up @@ -75,7 +75,8 @@ pub async fn get_verkey_from_ledger(profile: &Arc<dyn Profile>, did: &str) -> Vc
#[cfg(test)]
#[cfg(feature = "pool_tests")]
mod test {
use crate::indy::utils::mocks::pool_mocks::{enable_pool_mocks, PoolMocks};
use aries_vcx_core::indy::utils::mocks::pool_mocks::{enable_pool_mocks, PoolMocks};

use crate::utils::devsetup::*;
use crate::utils::mockdata::mockdata_pool;

Expand Down
1 change: 1 addition & 0 deletions aries_vcx/src/common/ledger/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ pub async fn clear_attr(profile: &Arc<dyn Profile>, did: &str, attr_name: &str)
ledger
.add_attr(did, &json!({ attr_name: Value::Null }).to_string())
.await
.map_err(|err| err.into())
}

pub(self) fn check_response(response: &str) -> VcxResult<()> {
Expand Down
9 changes: 6 additions & 3 deletions aries_vcx/src/common/primitives/credential_definition.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use aries_vcx_core::errors::error::AriesVcxCoreErrorKind;
use aries_vcx_core::ledger::base_ledger::BaseLedger;

use crate::core::profile::profile::Profile;
use crate::errors::error::{AriesVcxError, AriesVcxErrorKind, VcxResult};
use crate::plugins::ledger::base_ledger::BaseLedger;
use crate::utils::constants::{CRED_DEF_ID, CRED_DEF_JSON, DEFAULT_SERIALIZE_VERSION};
use crate::utils::mockdata::mock_settings::StatusCodeMock;
use crate::utils::serialization::ObjectWithVersion;
Expand Down Expand Up @@ -114,7 +116,7 @@ async fn _try_get_cred_def_from_ledger(
}
match ledger.get_cred_def(cred_def_id, Some(issuer_did)).await {
Ok(cred_def) => Ok(Some(cred_def)),
Err(err) if err.kind() == AriesVcxErrorKind::LedgerItemNotFound => Ok(None),
Err(err) if err.kind() == AriesVcxCoreErrorKind::LedgerItemNotFound => Ok(None),
Err(err) => Err(AriesVcxError::from_msg(
AriesVcxErrorKind::InvalidLedgerResponse,
format!(
Expand Down Expand Up @@ -269,6 +271,7 @@ pub async fn generate_cred_def(
anoncreds
.issuer_create_and_store_credential_def(issuer_did, schema_json, tag, sig_type, &config_json)
.await
.map_err(|err| err.into())
}

#[cfg(test)]
Expand Down Expand Up @@ -344,7 +347,7 @@ pub mod integration_tests {
.await
.unwrap();
ledger
.publish_rev_reg_def(&rev_reg_def_json, &setup.institution_did)
.publish_rev_reg_def(&json!(rev_reg_def_json).to_string(), &setup.institution_did)
.await
.unwrap();
ledger
Expand Down
15 changes: 12 additions & 3 deletions aries_vcx/src/common/primitives/revocation_registry.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::sync::Arc;

use aries_vcx_core::errors::error::AriesVcxCoreErrorKind;

use crate::core::profile::profile::Profile;
use crate::errors::error::{AriesVcxError, AriesVcxErrorKind, VcxResult};
use crate::global::settings;
Expand Down Expand Up @@ -101,11 +103,11 @@ impl RevocationRegistry {
self.rev_reg_def.value.tails_location = String::from(tails_url);
let ledger = Arc::clone(profile).inject_ledger();
ledger
.publish_rev_reg_def(&self.rev_reg_def, issuer_did)
.publish_rev_reg_def(&json!(self.rev_reg_def).to_string(), issuer_did)
.await
.map_err(|err| {
err.map(
AriesVcxErrorKind::InvalidState,
AriesVcxCoreErrorKind::InvalidState,
"Cannot publish revocation registry definition",
)
})?;
Expand All @@ -123,7 +125,12 @@ impl RevocationRegistry {
ledger
.publish_rev_reg_delta(&self.rev_reg_id, &self.rev_reg_entry, issuer_did)
.await
.map_err(|err| err.map(AriesVcxErrorKind::InvalidRevocationEntry, "Cannot post RevocationEntry"))?;
.map_err(|err| {
err.map(
AriesVcxCoreErrorKind::InvalidRevocationEntry,
"Cannot post RevocationEntry",
)
})?;
self.rev_reg_delta_state = PublicEntityStateType::Published;
Ok(())
}
Expand Down Expand Up @@ -184,6 +191,7 @@ impl RevocationRegistry {
anoncreds
.revoke_credential_local(&self.tails_dir, &self.rev_reg_id, cred_rev_id)
.await
.map_err(|err| err.into())
}

pub async fn publish_local_revocations(&self, profile: &Arc<dyn Profile>, submitter_did: &str) -> VcxResult<()> {
Expand All @@ -192,6 +200,7 @@ impl RevocationRegistry {
anoncreds
.publish_local_revocations(submitter_did, &self.rev_reg_id)
.await
.map_err(|err| err.into())
}
}

Expand Down
15 changes: 9 additions & 6 deletions aries_vcx/src/common/proofs/prover/prover_internal.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{collections::HashMap, sync::Arc};

use aries_vcx_core::errors::error::{AriesVcxCoreError, AriesVcxCoreErrorKind};
use serde_json::Value;

use crate::errors::error::prelude::*;
Expand Down Expand Up @@ -38,11 +39,11 @@ pub async fn build_schemas_json_prover(
let schema_json = ledger
.get_schema(&cred_info.schema_id, None)
.await
.map_err(|err| err.map(AriesVcxErrorKind::InvalidSchema, "Cannot get schema"))?;
.map_err(|err| err.map(AriesVcxCoreErrorKind::InvalidSchema, "Cannot get schema"))?;

let schema_json = serde_json::from_str(&schema_json).map_err(|err| {
AriesVcxError::from_msg(
AriesVcxErrorKind::InvalidSchema,
AriesVcxCoreError::from_msg(
AriesVcxCoreErrorKind::InvalidSchema,
format!("Cannot deserialize schema: {}", err),
)
})?;
Expand All @@ -68,7 +69,7 @@ pub async fn build_cred_defs_json_prover(
if rtn.get(&cred_info.cred_def_id).is_none() {
let credential_def = ledger.get_cred_def(&cred_info.cred_def_id, None).await.map_err(|err| {
err.map(
AriesVcxErrorKind::InvalidProofCredentialData,
AriesVcxCoreErrorKind::InvalidProofCredentialData,
"Cannot get credential definition",
)
})?;
Expand Down Expand Up @@ -319,6 +320,8 @@ pub mod pool_tests {
#[cfg(test)]
#[cfg(feature = "general_test")]
pub mod unit_tests {
use aries_vcx_core::INVALID_POOL_HANDLE;

use crate::common::test_utils::{indy_handles_to_profile, mock_profile};
use crate::utils::devsetup::*;
use crate::utils::{
Expand Down Expand Up @@ -386,7 +389,7 @@ pub mod unit_tests {
#[tokio::test]
async fn test_find_credential_def_fails() {
SetupLibraryWallet::run(|setup| async move {
let profile = indy_handles_to_profile(setup.wallet_handle, 0);
let profile = indy_handles_to_profile(setup.wallet_handle, INVALID_POOL_HANDLE);
let credential_ids = vec![CredInfoProver {
requested_attr: "1".to_string(),
referent: "2".to_string(),
Expand All @@ -411,7 +414,7 @@ pub mod unit_tests {
#[tokio::test]
async fn test_find_schemas_fails() {
SetupLibraryWallet::run(|setup| async move {
let profile = indy_handles_to_profile(setup.wallet_handle, 0);
let profile = indy_handles_to_profile(setup.wallet_handle, INVALID_POOL_HANDLE);
let credential_ids = vec![CredInfoProver {
requested_attr: "1".to_string(),
referent: "2".to_string(),
Expand Down
1 change: 1 addition & 0 deletions aries_vcx/src/common/proofs/verifier/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub async fn validate_indy_proof(
&rev_regs_json,
)
.await
.map_err(|err| err.into())
}

#[cfg(test)]
Expand Down
3 changes: 2 additions & 1 deletion aries_vcx/src/common/proofs/verifier/verifier_internal.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::sync::Arc;

use aries_vcx_core::errors::error::AriesVcxCoreErrorKind;
use serde_json;
use serde_json::Value;

Expand Down Expand Up @@ -137,7 +138,7 @@ pub async fn build_schemas_json_verifier(
let schema_json = ledger
.get_schema(schema_id, None)
.await
.map_err(|err| err.map(AriesVcxErrorKind::InvalidSchema, "Cannot get schema"))?;
.map_err(|err| err.map(AriesVcxCoreErrorKind::InvalidSchema, "Cannot get schema"))?;
let schema_val = serde_json::from_str(&schema_json).map_err(|err| {
AriesVcxError::from_msg(
AriesVcxErrorKind::InvalidSchema,
Expand Down
Loading