Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #115 from consenlabs/fix-keystore-exists-check-api
Browse files Browse the repository at this point in the history
fix: fix keystore_common_exists interface bug
  • Loading branch information
XuNeal authored Sep 17, 2022
2 parents 3263f04 + 10625e4 commit 1454aba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tcx/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,12 @@ pub(crate) fn keystore_common_exists(data: &[u8]) -> Result<Vec<u8>> {
KeystoreCommonExistsParam::decode(data).expect("keystore_common_exists params");
let key_hash: String;
if param.r#type == KeyType::Mnemonic as i32 {
key_hash = key_hash_from_mnemonic(&param.value)?;
let mnemonic: &str = &param
.value
.split_whitespace()
.collect::<Vec<&str>>()
.join(" ");
key_hash = key_hash_from_mnemonic(mnemonic)?;
} else {
if param.encoding.eq("TEZOS") {
key_hash = key_hash_from_tezos_format_pk(&param.value)?;
Expand Down
13 changes: 13 additions & 0 deletions tcx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1567,6 +1567,19 @@ mod tests {
assert!(result.is_exists);
assert_eq!(result.id, wallet.id);

let wallet = import_default_wallet();
let param: KeystoreCommonExistsParam = KeystoreCommonExistsParam {
r#type: KeyType::Mnemonic as i32,
value: format!("{}", " inject kidney empty canal shadow pact comfort wife crush horse wife sketch ").to_string(),//Badly formatted mnemonic
encoding: "".to_string(),
};

let ret_bytes = call_api("keystore_common_exists", param).unwrap();
let result: KeystoreCommonExistsResult =
KeystoreCommonExistsResult::decode(ret_bytes.as_slice()).unwrap();
assert!(result.is_exists);
assert_eq!(result.id, wallet.id);

remove_created_wallet(&wallet.id);
})
}
Expand Down

0 comments on commit 1454aba

Please sign in to comment.