diff --git a/aries_vcx/src/common/signing.rs b/aries_vcx/src/common/signing.rs index 8e1b5112b4..093ff226ad 100644 --- a/aries_vcx/src/common/signing.rs +++ b/aries_vcx/src/common/signing.rs @@ -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..7777d412ea 100644 --- a/libvcx_core/src/api_vcx/api_global/wallet.rs +++ b/libvcx_core/src/api_vcx/api_global/wallet.rs @@ -17,11 +17,10 @@ use aries_vcx::{ internal::{close_search_wallet, fetch_next_records_wallet, open_search_wallet}, 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 +166,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]