Skip to content

Commit d8e7602

Browse files
Use standard UnpackMessage struct until needing to transform. (#1002)
Signed-off-by: Naian <126972030+nain-F49FF806@users.noreply.github.com>
1 parent e04ba1a commit d8e7602

File tree

3 files changed

+7
-27
lines changed

3 files changed

+7
-27
lines changed

aries_vcx/src/common/signing.rs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use messages::msg_fields::protocols::connection::{
88
};
99
use time;
1010

11-
use crate::{errors::error::prelude::*, global::settings};
11+
use crate::errors::error::prelude::*;
1212

1313
async fn get_signature_data(
1414
wallet: &Arc<dyn BaseWallet>,
@@ -90,27 +90,6 @@ pub async fn decode_signed_connection_response(
9090
Ok(connection)
9191
}
9292

93-
pub async fn unpack_message_to_string(
94-
wallet: &Arc<dyn BaseWallet>,
95-
msg: &[u8],
96-
) -> VcxResult<String> {
97-
if settings::indy_mocks_enabled() {
98-
return Ok(String::new());
99-
}
100-
let unpack_msg = wallet.unpack_message(msg).await.map_err(|_| {
101-
AriesVcxError::from_msg(
102-
AriesVcxErrorKind::InvalidMessagePack,
103-
"Failed to unpack message",
104-
)
105-
})?;
106-
serde_json::to_string(&unpack_msg).map_err(|_| {
107-
AriesVcxError::from_msg(
108-
AriesVcxErrorKind::InvalidMessageFormat,
109-
"Failed to convert message to utf8 string",
110-
)
111-
})
112-
}
113-
11493
// #[cfg(test)]
11594
// pub mod unit_tests {
11695
// use crate::common::test_utils::{create_trustee_key, indy_handles_to_profile};

libvcx_core/src/api_vcx/api_global/wallet.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ use aries_vcx::{
1818
wallet::{close_wallet, create_and_open_wallet, delete_wallet, import},
1919
IndySdkWallet, IssuerConfig, RestoreWalletConfigs, WalletConfig,
2020
},
21+
structs_io::UnpackMessageOutput,
2122
},
2223
SearchHandle, WalletHandle,
2324
},
24-
common::signing::unpack_message_to_string,
2525
global::settings::DEFAULT_LINK_SECRET_ALIAS,
2626
protocols::mediated_connection::pairwise_info::PairwiseInfo,
2727
};
@@ -167,9 +167,9 @@ pub async fn rotate_verkey_apply(did: &str, temp_vk: &str) -> LibvcxResult<()> {
167167
)
168168
}
169169

170-
pub async fn wallet_unpack_message_to_string(payload: &[u8]) -> LibvcxResult<String> {
170+
pub async fn wallet_unpack_message(payload: &[u8]) -> LibvcxResult<UnpackMessageOutput> {
171171
let wallet = get_main_wallet()?;
172-
map_ariesvcx_result(unpack_message_to_string(&wallet, payload).await)
172+
map_ariesvcx_core_result(wallet.unpack_message(payload).await)
173173
}
174174

175175
pub async fn wallet_create_and_store_did(seed: Option<&str>) -> LibvcxResult<PairwiseInfo> {

wrappers/vcx-napi-rs/src/api/wallet.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ pub async fn configure_issuer_wallet(enterprise_seed: String) -> napi::Result<St
7272
#[napi]
7373
pub async fn unpack(data: Buffer) -> napi::Result<String> {
7474
let data = data.as_ref();
75-
wallet::wallet_unpack_message_to_string(data)
75+
let unpacked = wallet::wallet_unpack_message(data)
7676
.await
77-
.map_err(to_napi_err)
77+
.map_err(to_napi_err)?;
78+
serde_json::to_string(&unpacked).map_err(|err| napi::Error::from_reason(err.to_string()))
7879
}
7980

8081
#[napi]

0 commit comments

Comments
 (0)