Skip to content

Commit

Permalink
Use standard UnpackMessage struct until needing to transform.
Browse files Browse the repository at this point in the history
Signed-off-by: Naian <126972030+nain-F49FF806@users.noreply.github.com>
  • Loading branch information
nain-F49FF806 committed Sep 27, 2023
1 parent ac35fdd commit ea89152
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 27 deletions.
23 changes: 1 addition & 22 deletions aries_vcx/src/common/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn BaseWallet>,
Expand Down Expand Up @@ -90,27 +90,6 @@ pub async fn decode_signed_connection_response(
Ok(connection)
}

pub async fn unpack_message_to_string(
wallet: &Arc<dyn BaseWallet>,
msg: &[u8],
) -> VcxResult<String> {
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};
Expand Down
6 changes: 3 additions & 3 deletions libvcx_core/src/api_vcx/api_global/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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<String> {
pub async fn wallet_unpack_message(payload: &[u8]) -> LibvcxResult<UnpackMessageOutput> {
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<PairwiseInfo> {
Expand Down
5 changes: 3 additions & 2 deletions wrappers/vcx-napi-rs/src/api/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ pub async fn configure_issuer_wallet(enterprise_seed: String) -> napi::Result<St
#[napi]
pub async fn unpack(data: Buffer) -> napi::Result<String> {
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]
Expand Down

0 comments on commit ea89152

Please sign in to comment.