From ea891528cd7371130ace5fe8dd1ece9c9f168710 Mon Sep 17 00:00:00 2001 From: Naian <126972030+nain-F49FF806@users.noreply.github.com> Date: Wed, 27 Sep 2023 16:23:54 +0200 Subject: [PATCH] Use standard UnpackMessage struct until needing to transform. Signed-off-by: Naian <126972030+nain-F49FF806@users.noreply.github.com> --- aries_vcx/src/common/signing.rs | 23 +------------------- libvcx_core/src/api_vcx/api_global/wallet.rs | 6 ++--- wrappers/vcx-napi-rs/src/api/wallet.rs | 5 +++-- 3 files changed, 7 insertions(+), 27 deletions(-) diff --git a/aries_vcx/src/common/signing.rs b/aries_vcx/src/common/signing.rs index 8e1b5112b4..d9ae7f3088 100644 --- a/aries_vcx/src/common/signing.rs +++ b/aries_vcx/src/common/signing.rs @@ -8,7 +8,7 @@ use messages::msg_fields::protocols::connection::{ }; use time; -use crate::{errors::error::prelude::*, global::settings}; +use crate::errors::error::prelude::*; async fn get_signature_data( wallet: &Arc, @@ -90,27 +90,6 @@ pub async fn decode_signed_connection_response( Ok(connection) } -pub async fn unpack_message_to_string( - wallet: &Arc, - msg: &[u8], -) -> VcxResult { - if settings::indy_mocks_enabled() { - return Ok(String::new()); - } - let unpack_msg = wallet.unpack_message(msg).await.map_err(|_| { - AriesVcxError::from_msg( - AriesVcxErrorKind::InvalidMessagePack, - "Failed to unpack message", - ) - })?; - serde_json::to_string(&unpack_msg).map_err(|_| { - AriesVcxError::from_msg( - AriesVcxErrorKind::InvalidMessageFormat, - "Failed to convert message to utf8 string", - ) - }) -} - // #[cfg(test)] // pub mod unit_tests { // use crate::common::test_utils::{create_trustee_key, indy_handles_to_profile}; diff --git a/libvcx_core/src/api_vcx/api_global/wallet.rs b/libvcx_core/src/api_vcx/api_global/wallet.rs index e26d5d1e90..4aace7a7c9 100644 --- a/libvcx_core/src/api_vcx/api_global/wallet.rs +++ b/libvcx_core/src/api_vcx/api_global/wallet.rs @@ -18,10 +18,10 @@ use aries_vcx::{ wallet::{close_wallet, create_and_open_wallet, delete_wallet, import}, IndySdkWallet, IssuerConfig, RestoreWalletConfigs, WalletConfig, }, + structs_io::UnpackMessageOutput, }, SearchHandle, WalletHandle, }, - common::signing::unpack_message_to_string, global::settings::DEFAULT_LINK_SECRET_ALIAS, protocols::mediated_connection::pairwise_info::PairwiseInfo, }; @@ -167,9 +167,9 @@ pub async fn rotate_verkey_apply(did: &str, temp_vk: &str) -> LibvcxResult<()> { ) } -pub async fn wallet_unpack_message_to_string(payload: &[u8]) -> LibvcxResult { +pub async fn wallet_unpack_message(payload: &[u8]) -> LibvcxResult { let wallet = get_main_wallet()?; - map_ariesvcx_result(unpack_message_to_string(&wallet, payload).await) + map_ariesvcx_core_result(wallet.unpack_message(payload).await) } pub async fn wallet_create_and_store_did(seed: Option<&str>) -> LibvcxResult { diff --git a/wrappers/vcx-napi-rs/src/api/wallet.rs b/wrappers/vcx-napi-rs/src/api/wallet.rs index e72990aaa2..e06a612893 100644 --- a/wrappers/vcx-napi-rs/src/api/wallet.rs +++ b/wrappers/vcx-napi-rs/src/api/wallet.rs @@ -72,9 +72,10 @@ pub async fn configure_issuer_wallet(enterprise_seed: String) -> napi::Result napi::Result { let data = data.as_ref(); - wallet::wallet_unpack_message_to_string(data) + let unpacked = wallet::wallet_unpack_message(data) .await - .map_err(to_napi_err) + .map_err(to_napi_err)?; + serde_json::to_string(&unpacked).map_err(|err| napi::Error::from_reason(err.to_string())) } #[napi]