diff --git a/.github/workflows/build-release-ios.yml b/.github/workflows/build-release-ios.yml index 3ea24d03..0f87db6d 100644 --- a/.github/workflows/build-release-ios.yml +++ b/.github/workflows/build-release-ios.yml @@ -52,12 +52,12 @@ jobs: - name: Install Rust run: | - rustup toolchain install nightly-2022-10-31 - rustup default nightly-2022-10-31-x86_64-apple-darwin + rustup toolchain install nightly-2023-06-15 + rustup default nightly-2023-06-15-x86_64-apple-darwin rustup target add aarch64-apple-ios x86_64-apple-ios rustup show cargo install cargo-lipo - cargo install cbindgen + cargo install cbindgen --version 0.26.0 brew install protobuf - name: Read VERSION file diff --git a/token-core/tcx-proto/src/params.proto b/token-core/tcx-proto/src/params.proto index ea672cf1..88ab27b9 100644 --- a/token-core/tcx-proto/src/params.proto +++ b/token-core/tcx-proto/src/params.proto @@ -234,8 +234,22 @@ message MigrateKeystoreResult { } message ScanKeystoresResult { - repeated KeystoreResult hdKeystores = 1; - repeated ImportPrivateKeyResult privateKeyKeystores = 2; + repeated ScannedKeystore keystores = 1; +} + +message ScannedKeystore { + string id = 1; + string name = 2; + string identifier = 3; + string ipfsId = 4; + string source = 5; + int64 createdAt = 6; + repeated AccountResponse accounts = 7; + string migration_status = 8;// This field can have one of three values: "migrated", "unmigrated", or "new". + repeated string identifiedChainTypes = 9; + string identifiedNetwork = 10; + string identifiedCurve = 11; + string sourceFingerprint = 12; } message LegacyKeystoreResult { diff --git a/token-core/tcx/src/api.rs b/token-core/tcx/src/api.rs index f7564f28..2f33eb0a 100644 --- a/token-core/tcx/src/api.rs +++ b/token-core/tcx/src/api.rs @@ -666,9 +666,36 @@ pub struct MigrateKeystoreResult { #[derive(Clone, PartialEq, ::prost::Message)] pub struct ScanKeystoresResult { #[prost(message, repeated, tag = "1")] - pub hd_keystores: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag = "2")] - pub private_key_keystores: ::prost::alloc::vec::Vec, + pub keystores: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ScannedKeystore { + #[prost(string, tag = "1")] + pub id: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub name: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub identifier: ::prost::alloc::string::String, + #[prost(string, tag = "4")] + pub ipfs_id: ::prost::alloc::string::String, + #[prost(string, tag = "5")] + pub source: ::prost::alloc::string::String, + #[prost(int64, tag = "6")] + pub created_at: i64, + #[prost(message, repeated, tag = "7")] + pub accounts: ::prost::alloc::vec::Vec, + /// This field can have one of three values: "migrated", "unmigrated", or "new". + #[prost(string, tag = "8")] + pub migration_status: ::prost::alloc::string::String, + #[prost(string, repeated, tag = "9")] + pub identified_chain_types: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(string, tag = "10")] + pub identified_network: ::prost::alloc::string::String, + #[prost(string, tag = "11")] + pub identified_curve: ::prost::alloc::string::String, + #[prost(string, tag = "12")] + pub source_fingerprint: ::prost::alloc::string::String, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] diff --git a/token-core/tcx/src/handler.rs b/token-core/tcx/src/handler.rs index 33c97af7..b8667fbb 100644 --- a/token-core/tcx/src/handler.rs +++ b/token-core/tcx/src/handler.rs @@ -38,8 +38,8 @@ use crate::api::{ GetExtendedPublicKeysParam, GetExtendedPublicKeysResult, GetPublicKeysParam, GetPublicKeysResult, ImportJsonParam, ImportMnemonicParam, ImportPrivateKeyParam, ImportPrivateKeyResult, KeystoreResult, MnemonicToPublicKeyParam, MnemonicToPublicKeyResult, - ScanKeystoresResult, SignAuthenticationMessageParam, SignAuthenticationMessageResult, - SignHashesParam, SignHashesResult, WalletKeyParam, + ScanKeystoresResult, ScannedKeystore, SignAuthenticationMessageParam, + SignAuthenticationMessageResult, SignHashesParam, SignHashesResult, WalletKeyParam, }; use crate::api::{EthBatchPersonalSignParam, EthBatchPersonalSignResult}; use crate::api::{InitTokenCoreXParam, SignParam}; @@ -72,7 +72,8 @@ use tcx_tezos::{encode_tezos_private_key, parse_tezos_private_key}; use crate::macros::{impl_to_key, use_chains}; use crate::migration::{ - read_all_identity_wallet_ids, remove_all_identity_wallets, remove_old_keystore_by_id, + is_migrated, read_all_identity_wallet_ids, remove_all_identity_wallets, + remove_old_keystore_by_id, scan_legacy_keystores, }; use crate::reset_password::assert_seed_equals; @@ -414,6 +415,27 @@ pub fn init_token_core_x(data: &[u8]) -> Result<()> { pub fn scan_keystores() -> Result { clean_keystore(); + + let mut ret_keystores = vec![]; + let legacy_keystores = scan_legacy_keystores()?; + for keystore in legacy_keystores.keystores.iter() { + let mut scanned_keystore = ScannedKeystore { + id: keystore.id.clone(), + name: keystore.name.clone(), + identifier: legacy_keystores.identifier.clone(), + ipfs_id: legacy_keystores.ipfs_id.clone(), + source: legacy_keystores.source.clone(), + created_at: f64::from_str(&keystore.created_at).expect("f64 from timestamp") as i64, + accounts: keystore.accounts.clone(), + migration_status: "unmigrated".to_string(), + ..Default::default() + }; + if is_migrated(&keystore.id) { + scanned_keystore.migration_status = "migrated".to_string(); + } + ret_keystores.push(scanned_keystore); + } + let file_dir = WALLET_FILE_DIR.read(); let p = Path::new(file_dir.as_str()); let walk_dir = std::fs::read_dir(p).expect("read dir"); @@ -444,7 +466,6 @@ pub fn scan_keystores() -> Result { if version == HdKeystore::VERSION || version == PrivateKeystore::VERSION { let keystore = Keystore::from_json(&contents)?; - if version == HdKeystore::VERSION { let keystore_result = KeystoreResult { id: keystore.id(), @@ -456,12 +477,37 @@ pub fn scan_keystores() -> Result { source_fingerprint: keystore.fingerprint().to_string(), ..Default::default() }; + if is_migrated(&keystore.id()) { + let mut found = false; + for legacy_keystore in &mut ret_keystores { + if legacy_keystore.id == keystore.id() { + legacy_keystore.migration_status = "migrated".to_string(); + legacy_keystore.source_fingerprint = + keystore_result.source_fingerprint.clone(); + found = true; + break; + } + } + if !found { + let scanned_keystore = ScannedKeystore { + id: keystore_result.id.clone(), + name: keystore_result.name.clone(), + identifier: keystore_result.identifier.clone(), + ipfs_id: keystore_result.ipfs_id.clone(), + source: keystore_result.source.clone(), + created_at: keystore_result.created_at.clone(), + migration_status: "new".to_string(), + ..Default::default() + }; + ret_keystores.push(scanned_keystore); + } + } hd_keystores.push(keystore_result); } else { let curve = keystore .get_curve() .expect("pk keystore must contains curve"); - let kestore_result = ImportPrivateKeyResult { + let keystore_result = ImportPrivateKeyResult { id: keystore.id(), name: keystore.meta().name.to_string(), identifier: keystore.identity().identifier.to_string(), @@ -474,15 +520,52 @@ pub fn scan_keystores() -> Result { identified_curve: curve.as_str().to_string(), ..Default::default() }; - private_key_keystores.push(kestore_result); + if is_migrated(&keystore_result.id) { + let mut found = false; + for legacy_keystore in &mut ret_keystores { + if legacy_keystore.id == keystore_result.id { + legacy_keystore.migration_status = "migrated".to_string(); + legacy_keystore.source_fingerprint = + keystore_result.source_fingerprint.clone(); + legacy_keystore.identified_chain_types = + keystore_result.identified_chain_types.clone(); + legacy_keystore.identified_network = + keystore_result.identified_network.clone(); + legacy_keystore.identified_curve = + keystore_result.identified_curve.clone(); + legacy_keystore.source_fingerprint = + keystore_result.source_fingerprint.clone(); + found = true; + break; + } + } + if !found { + let scanned_keystore = ScannedKeystore { + id: keystore_result.id.clone(), + name: keystore_result.name.clone(), + identifier: keystore_result.identifier.clone(), + ipfs_id: keystore_result.ipfs_id.clone(), + source: keystore_result.source.clone(), + created_at: keystore_result.created_at.clone(), + migration_status: "new".to_string(), + identified_chain_types: keystore_result.identified_chain_types.clone(), + identified_network: keystore_result.identified_network.clone(), + identified_curve: keystore_result.identified_curve.clone(), + source_fingerprint: keystore_result.source_fingerprint.clone(), + ..Default::default() + }; + ret_keystores.push(scanned_keystore); + } + } + private_key_keystores.push(keystore_result); } + cache_keystore(keystore); } } Ok(ScanKeystoresResult { - hd_keystores, - private_key_keystores, + keystores: ret_keystores, }) } @@ -1487,7 +1570,7 @@ mod tests { use tcx_constants::CurveType; use tcx_keystore::Source; - use crate::{api::ImportPrivateKeyResult, filemanager::WALLET_FILE_DIR}; + use crate::{api::{ImportPrivateKeyResult, ScannedKeystore}, filemanager::WALLET_FILE_DIR}; use super::{decode_private_key, scan_keystores}; use serial_test::serial; @@ -1578,8 +1661,8 @@ mod tests { fn test_scan_keystores() { *WALLET_FILE_DIR.write() = "../test-data/scan-keystores-fixtures/".to_string(); let result = scan_keystores().unwrap(); - assert_eq!(result.hd_keystores.len(), 1); - let hd = result.hd_keystores.first().unwrap(); + assert_eq!(result.keystores.len(), 1); + let hd = result.keystores.first().unwrap(); assert_eq!(hd.id, "1055741c-2904-4973-b7ee-4b69bfd8bcc6"); assert_eq!(hd.identifier, "im14x5UYkoqtYbJFTLam7c9Ft4BQiFvJbieKWfK"); assert_eq!(hd.ipfs_id, "Qme1RuM33X8SmVjisWS3sP4irqNZv6vuqL3L3T6poZ6c2b"); @@ -1590,10 +1673,10 @@ mod tests { assert_eq!(hd.created_at, 1705040852); assert_eq!(hd.source, "MNEMONIC"); assert_eq!(hd.name, "test-wallet"); - assert_eq!(result.private_key_keystores.len(), 4); + assert_eq!(result.keystores.len(), 4); - let founded_pk_stores: Vec<&ImportPrivateKeyResult> = result - .private_key_keystores + let founded_pk_stores: Vec<&ScannedKeystore> = result + .keystores .iter() .filter(|x| x.id == "7e1c2c55-5b7f-4a5a-8061-c42b594ceb2f") .collect(); @@ -1609,8 +1692,8 @@ mod tests { assert_eq!(pk.name, "test_filecoin_import_private_key"); assert_eq!(pk.identified_curve, "bls12-381"); - let founded_pk_stores: Vec<&ImportPrivateKeyResult> = result - .private_key_keystores + let founded_pk_stores: Vec<&ScannedKeystore> = result + .keystores .iter() .filter(|x| x.id == "1233134b-8377-4fb0-b06f-56062e858708") .collect(); @@ -1626,8 +1709,8 @@ mod tests { assert_eq!(pk.name, "test account"); assert_eq!(pk.identified_curve, "sr25519"); - let founded_pk_stores: Vec<&ImportPrivateKeyResult> = result - .private_key_keystores + let founded_pk_stores: Vec<&ScannedKeystore> = result + .keystores .iter() .filter(|x| x.id == "beb68589-0f0f-41e2-94d9-d78f10a72dec") .collect(); @@ -1643,8 +1726,8 @@ mod tests { assert_eq!(pk.name, "test_filecoin_import_private_key"); assert_eq!(pk.identified_curve, "secp256k1"); - let founded_pk_stores: Vec<&ImportPrivateKeyResult> = result - .private_key_keystores + let founded_pk_stores: Vec<&ScannedKeystore> = result + .keystores .iter() .filter(|x| x.id == "beb68589-0f0f-41e2-94d9-d78f10a72dec") .collect(); @@ -1660,8 +1743,8 @@ mod tests { assert_eq!(pk.name, "test_filecoin_import_private_key"); assert_eq!(pk.identified_curve, "secp256k1"); - let founded_pk_stores: Vec<&ImportPrivateKeyResult> = result - .private_key_keystores + let founded_pk_stores: Vec<&ScannedKeystore> = result + .keystores .iter() .filter(|x| x.id == "efcfffb2-9b63-418b-a9d0-ec3600012284") .collect(); diff --git a/token-core/tcx/src/lib.rs b/token-core/tcx/src/lib.rs index 3fcb1900..8991b276 100644 --- a/token-core/tcx/src/lib.rs +++ b/token-core/tcx/src/lib.rs @@ -27,8 +27,8 @@ use crate::handler::{ encode_message, encrypt_data_to_ipfs, eth_batch_personal_sign, exists_json, exists_mnemonic, exists_private_key, export_json, export_mnemonic, export_private_key, get_derived_key, get_extended_public_keys, get_public_keys, import_json, import_mnemonic, import_private_key, - mnemonic_to_public, sign_authentication_message, sign_hashes, sign_message, sign_psbt, - sign_psbts, sign_tx, unlock_then_crash, verify_password, + mnemonic_to_public, scan_keystores, sign_authentication_message, sign_hashes, sign_message, + sign_psbt, sign_psbts, sign_tx, unlock_then_crash, verify_password, }; use crate::migration::{migrate_keystore, scan_legacy_keystores}; @@ -80,6 +80,10 @@ pub unsafe extern "C" fn call_tcx_api(hex_str: *const c_char) -> *const c_char { let ret = scan_legacy_keystores()?; encode_message(ret) }), + "scan_keystores" => landingpad(|| { + let ret = scan_keystores()?; + encode_message(ret) + }), "read_keystore_mnemonic_path" => { landingpad(|| read_legacy_keystore_mnemonic_path(&action.param.unwrap().value)) } diff --git a/token-core/tcx/src/migration.rs b/token-core/tcx/src/migration.rs index 292a4664..f4a88f5f 100644 --- a/token-core/tcx/src/migration.rs +++ b/token-core/tcx/src/migration.rs @@ -4,7 +4,7 @@ use crate::api::{ ReadKeystoreMnemonicPathResult, ScanLegacyKeystoresResult, WalletId, }; use crate::error_handling::Result; -use crate::filemanager::{cache_keystore, KEYSTORE_MAP, WALLET_FILE_DIR}; +use crate::filemanager::{cache_keystore, KEYSTORE_MAP, WALLET_FILE_DIR, WALLET_V1_DIR}; use crate::filemanager::{flush_keystore, LEGACY_WALLET_FILE_DIR}; use crate::handler::{encode_message, encrypt_xpub}; use anyhow::anyhow; @@ -523,6 +523,13 @@ fn merge_migrate_source(id: &str, ori_source: &str) -> String { } } +pub fn is_migrated(id: &str) -> bool { + let migrated_id_map = read_migrated_map().1; + migrated_id_map + .values() + .any(|ids| ids.contains(&id.to_string())) +} + #[cfg(test)] mod tests { use std::fs; diff --git a/token-core/tcx/tests/common/mod.rs b/token-core/tcx/tests/common/mod.rs index 30dc345d..73af49c4 100644 --- a/token-core/tcx/tests/common/mod.rs +++ b/token-core/tcx/tests/common/mod.rs @@ -87,7 +87,7 @@ pub fn import_default_pk_store() -> ImportPrivateKeyResult { ImportPrivateKeyResult::decode(ret.as_slice()).unwrap() } -pub fn import_filecoin_pk_store() -> KeystoreResult { +pub fn import_filecoin_pk_store() -> ImportPrivateKeyResult { let param: ImportPrivateKeyParam = ImportPrivateKeyParam { private_key: "f15716d3b003b304b8055d9cc62e6b9c869d56cc930c3858d4d7c31f5f53f14a".to_string(), password: TEST_PASSWORD.to_string(), @@ -98,7 +98,7 @@ pub fn import_filecoin_pk_store() -> KeystoreResult { }; let ret = import_private_key(&encode_message(param).unwrap()).unwrap(); - KeystoreResult::decode(ret.as_slice()).unwrap() + ImportPrivateKeyResult::decode(ret.as_slice()).unwrap() } pub fn import_and_derive(derivation: Derivation) -> (KeystoreResult, DeriveAccountsResult) { diff --git a/token-core/tcx/tests/export_test.rs b/token-core/tcx/tests/export_test.rs index da1f67e9..c8b41ad2 100644 --- a/token-core/tcx/tests/export_test.rs +++ b/token-core/tcx/tests/export_test.rs @@ -76,7 +76,8 @@ pub fn test_tezos_import_private_key_export() { }; let ret = import_private_key(&encode_message(param).unwrap()).unwrap(); - let import_result: KeystoreResult = KeystoreResult::decode(ret.as_slice()).unwrap(); + let import_result: ImportPrivateKeyResult = + ImportPrivateKeyResult::decode(ret.as_slice()).unwrap(); let derivations = vec![Derivation { chain_type: "TEZOS".to_string(), diff --git a/token-core/tcx/tests/import_test.rs b/token-core/tcx/tests/import_test.rs index 6a73c837..6b63782e 100644 --- a/token-core/tcx/tests/import_test.rs +++ b/token-core/tcx/tests/import_test.rs @@ -434,7 +434,8 @@ pub fn test_filecoin_private_key_secp256k1_import() { }; let ret = import_private_key(&encode_message(param).unwrap()).unwrap(); - let import_result: KeystoreResult = KeystoreResult::decode(ret.as_slice()).unwrap(); + let import_result: ImportPrivateKeyResult = + ImportPrivateKeyResult::decode(ret.as_slice()).unwrap(); let derivations = vec![Derivation { chain_type: "FILECOIN".to_string(), @@ -500,7 +501,8 @@ pub fn test_filecoin_private_key_bls_import() { }; let ret = import_private_key(&encode_message(param).unwrap()).unwrap(); - let import_result: KeystoreResult = KeystoreResult::decode(ret.as_slice()).unwrap(); + let import_result: ImportPrivateKeyResult = + ImportPrivateKeyResult::decode(ret.as_slice()).unwrap(); let derivations = vec![Derivation { chain_type: "FILECOIN".to_string(), @@ -612,7 +614,8 @@ pub fn test_fil_bls_tezos_reimport() { }; let ret = import_private_key(&encode_message(param).unwrap()).unwrap(); - let pk_import_result: KeystoreResult = KeystoreResult::decode(ret.as_slice()).unwrap(); + let pk_import_result: ImportPrivateKeyResult = + ImportPrivateKeyResult::decode(ret.as_slice()).unwrap(); let derivations = vec![Derivation { chain_type: case.0.to_string(), @@ -832,7 +835,8 @@ pub fn test_import_substrate_keystore() { assert!(!exists_result.is_exists); let ret_bytes = call_api("import_json", param.clone()).unwrap(); - let wallet_ret: KeystoreResult = KeystoreResult::decode(ret_bytes.as_slice()).unwrap(); + let wallet_ret: ImportPrivateKeyResult = + ImportPrivateKeyResult::decode(ret_bytes.as_slice()).unwrap(); let ret_bytes = call_api("exists_json", param.clone()).unwrap(); let exists_result: ExistsKeystoreResult = @@ -923,7 +927,8 @@ pub fn test_import_substrate_keystore_v3() { assert!(!exists_result.is_exists); let ret_bytes = call_api("import_json", param.clone()).unwrap(); - let wallet_ret: KeystoreResult = KeystoreResult::decode(ret_bytes.as_slice()).unwrap(); + let wallet_ret: ImportPrivateKeyResult = + ImportPrivateKeyResult::decode(ret_bytes.as_slice()).unwrap(); let ret_bytes = call_api("exists_json", param.clone()).unwrap(); let exists_result: ExistsKeystoreResult = @@ -1012,7 +1017,8 @@ pub fn test_import_multi_curve() { }; let ret_bytes = call_api("import_json", param).unwrap(); - let wallet_ret: KeystoreResult = KeystoreResult::decode(ret_bytes.as_slice()).unwrap(); + let wallet_ret: ImportPrivateKeyResult = + ImportPrivateKeyResult::decode(ret_bytes.as_slice()).unwrap(); let derivation = Derivation { chain_type: "KUSAMA".to_string(), path: "".to_string(), diff --git a/token-core/tcx/tests/migration_test.rs b/token-core/tcx/tests/migration_test.rs index 7572ac9b..cbd72784 100644 --- a/token-core/tcx/tests/migration_test.rs +++ b/token-core/tcx/tests/migration_test.rs @@ -13,14 +13,14 @@ use prost::Message; use tcx::api::{ export_mnemonic_param, migrate_keystore_param, wallet_key_param, BackupResult, ExportMnemonicParam, ExportMnemonicResult, GeneralResult, MarkIdentityWalletsParam, - MigrateKeystoreParam, MigrateKeystoreResult, ReadKeystoreMnemonicPathResult, SignParam, - WalletId, WalletKeyParam, + MigrateKeystoreParam, MigrateKeystoreResult, ReadKeystoreMnemonicPathResult, + ScanKeystoresResult, SignParam, WalletId, WalletKeyParam, }; use tcx::handler::encode_message; use tcx_constants::CurveType; use tcx_constants::{OTHER_MNEMONIC, TEST_PASSWORD}; -use tcx_keystore::Keystore; +use tcx_keystore::{keystore, Keystore}; use anyhow::{anyhow, format_err}; use std::path::Path; @@ -75,6 +75,17 @@ pub fn test_migrate_keystores_existed() { assert!(result.is_existed); assert_eq!(result.existed_id, "0a2756cd-ff70-437b-9bdb-ad46b8bb0819"); + let ret = call_api("scan_keystores", "".to_string()).unwrap(); + let resp: ScanKeystoresResult = ScanKeystoresResult::decode(ret.as_slice()).unwrap(); + for keystore in resp.keystores { + println!("{:?}", keystore.clone()); + if "0a2756cd-ff70-437b-9bdb-ad46b8bb0819".eq(&keystore.id) + || "00fc0804-7cea-46d8-9e95-ed1efac65358".eq(&keystore.id) + { + assert_eq!(&keystore.migration_status, "migrated"); + } + } + fs::remove_dir_all("../test-data/walletsV2").unwrap(); } diff --git a/token-core/tcx/tests/other_test.rs b/token-core/tcx/tests/other_test.rs index 5bf09e87..e8710636 100644 --- a/token-core/tcx/tests/other_test.rs +++ b/token-core/tcx/tests/other_test.rs @@ -1,5 +1,6 @@ use std::fs; +use api::ScanKeystoresResult; use common::run_test; use serial_test::serial; @@ -11,13 +12,13 @@ use prost::Message; use tcx::api::{ DecryptDataFromIpfsParam, DecryptDataFromIpfsResult, DerivedKeyResult, EncryptDataToIpfsParam, EncryptDataToIpfsResult, ExistsKeystoreResult, ExistsMnemonicParam, ExistsPrivateKeyParam, - GeneralResult, ImportPrivateKeyParam, KeystoreResult, SignAuthenticationMessageParam, - SignAuthenticationMessageResult, WalletKeyParam, + GeneralResult, ImportPrivateKeyParam, ImportPrivateKeyResult, KeystoreResult, + SignAuthenticationMessageParam, SignAuthenticationMessageResult, WalletKeyParam, }; use tcx::handler::{encode_message, get_derived_key, import_private_key}; -use tcx_constants::{TEST_MNEMONIC, TEST_PASSWORD}; +use tcx_constants::{TEST_MNEMONIC, TEST_PASSWORD, TEST_PRIVATE_KEY}; use sp_core::ByteArray; @@ -71,7 +72,8 @@ pub fn test_delete_keystore_by_password() { }; let ret_bytes = import_private_key(&encode_message(param).unwrap()).unwrap(); - let import_result: KeystoreResult = KeystoreResult::decode(ret_bytes.as_slice()).unwrap(); + let import_result: ImportPrivateKeyResult = + ImportPrivateKeyResult::decode(ret_bytes.as_slice()).unwrap(); let param: WalletKeyParam = WalletKeyParam { id: import_result.id.to_string(), key: Some(api::wallet_key_param::Key::Password( @@ -119,7 +121,8 @@ pub fn test_delete_keystore_by_derived_key() { }; let ret_bytes = import_private_key(&encode_message(param).unwrap()).unwrap(); - let import_result: KeystoreResult = KeystoreResult::decode(ret_bytes.as_slice()).unwrap(); + let import_result: ImportPrivateKeyResult = + ImportPrivateKeyResult::decode(ret_bytes.as_slice()).unwrap(); let param = WalletKeyParam { id: import_result.id.to_string(), key: Some(api::wallet_key_param::Key::Password(