Skip to content

Commit

Permalink
Merge pull request #115 from AvailX/fix/testnet-fix-keys-and-obscura-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-blc authored Jul 6, 2024
2 parents 8b971e7 + 73f2e0f commit df866e0
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "avail_wallet"
version = "0.4.2"
version = "0.4.3"
description = "Avail Wallet | Make it yours."
authors = ["Avail"]
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</dict>
</array>
<key>CFBundleShortVersionString</key>
<string>0.4.2</string>
<string>0.4.3</string>
<key>CFBundleVersion</key>
<string>20240222.152850</string>
<key>CSResourcesFileMapped</key>
Expand Down
1 change: 0 additions & 1 deletion src-tauri/src/api/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ mod tests {
#[tokio::test]
async fn test_create_record() {
let new_exec = get_execution_object().await.unwrap();
// let new_exec = Execution::<Testnet3>::new();
let exec_obj: Vec<u8> = FeeRequest::to_bytes_execution_object::<TestnetV0>(new_exec)
.await
.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/src/models/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ impl<N: Network> BetterAvailWallet<N> {
/// ```
/// use availx_lib::models::wallet::BetterAvailWallet;
/// # use availx_lib::models::storage::languages::Languages;
/// # use snarkvm::prelude::Testnet3;
/// # use snarkvm::prelude::TestnetV0;
///
/// let wallet = BetterAvailWallet::<Testnet3>::new(24, &Languages::English);
/// let wallet = BetterAvailWallet::<TestnetV0>::new(24, &Languages::English);
///
/// assert!(wallet.is_ok());
/// ```
Expand Down
10 changes: 5 additions & 5 deletions src-tauri/src/services/account/key_management/android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ pub fn keystore_delete(password: Option<&str>) -> AvailResult<String> {
let network = get_network()?;

let _validation = match SupportedNetworks::from_str(&network)? {
SupportedNetworks::Testnet => keystore_load::<Testnet3>(password, "avl-v")?,
SupportedNetworks::Testnet => keystore_load::<TestnetV0>(password, "avl-v")?,
};

let (jvm, activity) = prepare_jvm()?;
Expand Down Expand Up @@ -664,7 +664,7 @@ mod tests {

#[test]
fn test_keystore_init_password() {
let wallet = AvailWallet::<Testnet3>::new().unwrap();
let wallet = AvailWallet::<TestnetV0>::new().unwrap();

let _result = keystore_init(
STRONG_PASSWORD,
Expand All @@ -678,15 +678,15 @@ mod tests {
//Requires android environment to run
#[test]
fn test_keystore_init_biometric() {
let wallet = AvailWallet::<Testnet3>::new().unwrap();
let wallet = AvailWallet::<TestnetV0>::new().unwrap();

let _result = keystore_init("", true, &wallet.private_key, &wallet.view_key).unwrap();
}

//Requires android environment to run if not password auth
#[test]
fn test_keystore_load() {
let _result = keystore_load::<Testnet3>(Some(STRONG_PASSWORD), "avl-p").unwrap();
let _result = keystore_load::<TestnetV0>(Some(STRONG_PASSWORD), "avl-p").unwrap();
}

//Requires android environment to run
Expand Down Expand Up @@ -714,6 +714,6 @@ mod tests {
110, 76, 116, 67, 76, 82, 82, 82, 116, 100, 115, 69,
];

let _view_key = ViewKey::<Testnet3>::from_bytes_le(&v_key).unwrap();
let _view_key = ViewKey::<TestnetV0>::from_bytes_le(&v_key).unwrap();
}
}
12 changes: 6 additions & 6 deletions src-tauri/src/services/account/key_management/iOS.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub fn delete_ios(password: Option<&str>) -> AvailResult<String> {
let network = get_network()?;
// verify password is correct before deletion
let _validation = match SupportedNetworks::from_str(&network)? {
SupportedNetworks::Testnet => search::<Testnet3>(password, "avl-v")?,
SupportedNetworks::Testnet => search::<TestnetV0>(password, "avl-v")?,
};
match passwords::delete_generic_password("com.avail", "avail-user-view", "avl-v") {
Expand Down Expand Up @@ -200,11 +200,11 @@ pub fn prepare_context() -> bool {
mod tests {
use super::*;
use avail_common::models::constants::STRONG_PASSWORD;
use snarkvm::prelude::{PrivateKey, Testnet3};
use snarkvm::prelude::{PrivateKey, TestnetV0};

#[test]
fn test_store_key_local_password() {
let pk = PrivateKey::<Testnet3>::new(&mut rand::thread_rng()).unwrap();
let pk = PrivateKey::<TestnetV0>::new(&mut rand::thread_rng()).unwrap();
let seed = pk.to_bytes_le().unwrap();
let password = STRONG_PASSWORD.to_string();

Expand All @@ -213,7 +213,7 @@ mod tests {

#[test]
fn test_store_key_local_biometrics() {
let pk = PrivateKey::<Testnet3>::new(&mut rand::thread_rng()).unwrap();
let pk = PrivateKey::<TestnetV0>::new(&mut rand::thread_rng()).unwrap();
let seed = pk.to_bytes_le().unwrap();

store_key_local(&seed, "", true, true).unwrap();
Expand All @@ -229,12 +229,12 @@ mod tests {

#[test]
fn test_search_password() {
search::<Testnet3>(Some(STRONG_PASSWORD), "avl-p").unwrap();
search::<TestnetV0>(Some(STRONG_PASSWORD), "avl-p").unwrap();
}

#[test]
fn test_search_biometrics() {
search::<Testnet3>(None, "avl-p").unwrap();
search::<TestnetV0>(None, "avl-p").unwrap();
}

#[tokio::test]
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/src/services/authentication/android.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use snarkvm::prelude::{Testnet3, ToBytes};
use snarkvm::prelude::{TestnetV0, ToBytes};
use std::str::FromStr;

use crate::{
Expand All @@ -19,7 +19,7 @@ pub fn android_auth(password: Option<&str>, _key_type: &str) -> AvailResult<()>
let network = get_network()?;

let result = match SupportedNetworks::from_str(&network)? {
SupportedNetworks::Testnet => keystore_load::<Testnet3>(password, "avl-v")?,
SupportedNetworks::Testnet => keystore_load::<TestnetV0>(password, "avl-v")?,
};

let view_key_bytes = match result {
Expand Down
6 changes: 3 additions & 3 deletions src-tauri/src/services/authentication/ios.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use snarkvm::prelude::{Testnet3, ToBytes};
use snarkvm::prelude::{TestnetV0, ToBytes};
use std::str::FromStr;

use avail_common::models::network::SupportedNetworks;
Expand All @@ -16,8 +16,8 @@ pub fn ios_auth(password: Option<&str>, key_type: &str) -> AvailResult<()> {
let network = get_network()?;

let key = match SupportedNetworks::from_str(&network)? {
SupportedNetworks::Testnet => search::<Testnet3>(password, key_type)?,
_ => search::<Testnet3>(password, key_type)?,
SupportedNetworks::Testnet => search::<TestnetV0>(password, key_type)?,
_ => search::<TestnetV0>(password, key_type)?,
};

let view_key_bytes = match key {
Expand Down
3 changes: 3 additions & 0 deletions src-tauri/src/services/record_handling/records.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ pub fn get_records<N: Network>(
|| e.to_string().contains("status code 500")
|| e.to_string().contains("Error getting blocks")
|| e.to_string().contains("https://aleo-testnetbeta.obscura.network/v1/92acf30f-5cea-4679-880c-f06e9a7e8465/testnet/blocks?start=")
|| e.to_string().contains("Invalid Data")
|| e.to_string().contains("Failed to parse block")
|| e.to_string().contains("JSON")
{
api_client = setup_aleo_client::<N>()?;
println!("Switched to aleo client;;;;{:?}", api_client.base_url());
Expand Down

0 comments on commit df866e0

Please sign in to comment.