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

Use standard UnpackMessageOutput struct until finally needing to transform. #1002

Merged
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
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