Skip to content

Commit

Permalink
Merge pull request #4 from AvailX/update-to-beta
Browse files Browse the repository at this point in the history
Update to beta
  • Loading branch information
Zack-Xb authored Feb 18, 2024
2 parents 6929359 + 2109866 commit 8fa22a8
Show file tree
Hide file tree
Showing 33 changed files with 946 additions and 476 deletions.
1,027 changes: 761 additions & 266 deletions backend/Cargo.lock

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ crate-type = ["staticlib", "cdylib", "rlib"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
tauri-build = { version = "2.0.0-alpha.11", features = [] }
tauri-build = { version = "2.0.0-beta.1", features = [] }


[dependencies]
Expand Down Expand Up @@ -42,9 +42,10 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
snarkvm = { version = "0.16.17", features = [] }
ssss = "0.2.0"
tauri = { version = "2.0.0-alpha.17", features = [] }
tauri-plugin-deep-link = "0.1.2"
tauri-plugin-http = { version = "2.0.0-alpha.9", features = ["cookies"] }
tauri = { version = "2.0.0-beta.1", features = [] }
tauri-plugin-deep-link = "2.0.0-beta"
tauri-plugin-http = { version = "2.0.0-beta", features = ["cookies"] }
tauri-plugin-updater = { version = "2.0.0-beta.0", features = [] }
tiny-bip39 = "1.0.0"
tokio = { version = "1.29.1", features = ["full"] }
ureq = { version = "2.7.1", features = ["json"] }
Expand Down
19 changes: 19 additions & 0 deletions backend/capabilities/capabilities.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"$schema" = "./schemas/desktop-schema.toml"
identifier = "main-capability"
description = "Capability for the main window"
windows = ["main", "walletConnect"]
permissions = [
"path:default",
"event:default",
"event:allow-listen",
"window:default",
"window:allow-create",
"window:allow-close",
"window:allow-set-title",
"webview:allow-create-webview-window",
"webview:default",
"app:default",
"resources:default",
"menu:default",
"tray:default",
]
Binary file modified backend/icons/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed backend/icons/Square107x107Logo.png
Binary file not shown.
Binary file removed backend/icons/Square142x142Logo.png
Binary file not shown.
Binary file removed backend/icons/Square150x150Logo.png
Binary file not shown.
Binary file removed backend/icons/Square284x284Logo.png
Binary file not shown.
Binary file removed backend/icons/Square30x30Logo.png
Binary file not shown.
Binary file removed backend/icons/Square310x310Logo.png
Binary file not shown.
Binary file removed backend/icons/Square44x44Logo.png
Binary file not shown.
Binary file removed backend/icons/Square71x71Logo.png
Binary file not shown.
Binary file removed backend/icons/Square89x89Logo.png
Binary file not shown.
Binary file removed backend/icons/StoreLogo.png
Binary file not shown.
Binary file modified backend/icons/icon.icns
Binary file not shown.
Binary file modified backend/icons/icon.ico
Binary file not shown.
Binary file added backend/icons/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 6 additions & 27 deletions backend/src/api/aleo_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,16 @@ use crate::services::local_storage::persistent_storage::update_network;

/* --Client Setup functions-- */
pub fn setup_local_client<N: Network>() -> AleoAPIClient<N> {
dotenv::dotenv().ok();

let dev_node_ip = match std::env::var("DEV_NODE_IP") {
Ok(val) => val,
Err(_e) => _e.to_string(),
};

let dev_node_ip = env!("DEV_NODE_IP");
let api_client = AleoAPIClient::<N>::local_testnet3("3030", &dev_node_ip);

api_client
}

pub fn setup_client<N: Network>() -> AvailResult<AleoAPIClient<N>> {
dotenv::dotenv().ok();

let node_api_obscura = match std::env::var("TESTNET_API_OBSCURA") {
Ok(val) => val,
Err(_e) => "".to_string(),
};
let node_api_obscura = env!("TESTNET_API_OBSCURA");

println!("Node API Obscura: {:?}", node_api_obscura);

Expand All @@ -50,10 +41,7 @@ pub struct AleoClient<N: Network> {

impl<N: Network> AleoClient<N> {
pub fn new() -> AvailResult<Self> {
let node_api_obscura = match std::env::var("MAINNET_API_OBSCURA") {
Ok(val) => val,
Err(_e) => "".to_string(),
};
let node_api_obscura = env!("MAINNET_API_OBSCURA");

let base_url = format!("https://aleo-mainnet.obscura.build/v1/{}", node_api_obscura);

Expand All @@ -63,10 +51,7 @@ impl<N: Network> AleoClient<N> {
}

pub fn devnet() -> AvailResult<Self> {
let node_api_obscura = match std::env::var("DEVNET_API_OBSCURA") {
Ok(val) => val,
Err(_e) => "".to_string(),
};
let node_api_obscura = env!("DEVNET_API_OBSCURA");

let base_url = format!("https://aleo-devnet.obscura.build/v1/{}", node_api_obscura);

Expand All @@ -76,10 +61,7 @@ impl<N: Network> AleoClient<N> {
}

pub fn testnet3() -> AvailResult<Self> {
let node_api_obscura = match std::env::var("TESTNET_API_OBSCURA") {
Ok(val) => val,
Err(_e) => "".to_string(),
};
let node_api_obscura = env!("TESTNET_API_OBSCURA");

let base_url = format!(
"https://aleo-testnet3.obscura.build/v1/{}",
Expand Down Expand Up @@ -117,10 +99,7 @@ impl<N: Network> AleoClient<N> {
}

pub fn local_dev() -> AvailResult<Self> {
let dev_node_ip = match std::env::var("DEV_NODE_IP") {
Ok(val) => val,
Err(_e) => "".to_string(),
};
let dev_node_ip = env!("DEV_NODE_IP");

Ok(Self {
client: AleoAPIClient::local_testnet3("3030", &dev_node_ip),
Expand Down
8 changes: 3 additions & 5 deletions backend/src/api/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ pub fn get_rm_client_with_session(
method: reqwest::Method,
path: &str,
) -> AvailResult<reqwest::RequestBuilder> {
dotenv::dotenv().ok();

let api = env!("API");

let api = env!("API");

let client = reqwest::Client::new();
let cookie_name = "id";
Expand Down Expand Up @@ -41,8 +40,7 @@ pub fn get_um_client_with_session(
method: reqwest::Method,
path: &str,
) -> AvailResult<reqwest::RequestBuilder> {
dotenv::dotenv().ok();


let api = env!("API");

let client = reqwest::Client::new();
Expand Down
2 changes: 1 addition & 1 deletion backend/src/api/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use avail_common::{

// create user online account
pub async fn create_user(request: User) -> AvailResult<String> {
dotenv::dotenv().ok();


let api = env!("API");

Expand Down
16 changes: 5 additions & 11 deletions backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ pub mod helpers;
pub mod models;
pub mod services;

use tauri::Manager;

use services::account::generation::create_seed_phrase_wallet;
use services::account::generation::import_wallet;
use services::account::phrase_recovery::recover_wallet_from_seed_phrase;
Expand All @@ -22,7 +20,10 @@ use api::user::{update_backup_flag, update_username};
use services::local_storage::{
encrypted_data::get_and_store_all_data,
tokens::get_stored_tokens,
utils::{delete_util, get_private_key_tauri, get_seed_phrase, get_view_key_tauri,delete_local_for_recovery},
utils::{
delete_local_for_recovery, delete_util, get_private_key_tauri, get_seed_phrase,
get_view_key_tauri,
},
};

// record handliong services
Expand All @@ -40,18 +41,11 @@ use crate::services::wallet_connect_api::{

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri_plugin_deep_link::prepare("com.avail.wallet");

#[cfg(target_os = "macos")]
tauri::Builder::default()
.plugin(tauri_plugin_deep_link::init())
.setup(|app| {
let handle = app.handle().clone();

let _ = tauri_plugin_deep_link::register("avail", move |request| {
dbg!(&request);
handle.emit("wc-request-received", request).unwrap();
});

Ok(())
})
.invoke_handler(tauri::generate_handler![
Expand Down
44 changes: 10 additions & 34 deletions backend/src/services/account/key_management/key_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@ use super::ios::{delete_ios, search, store_keys_local};

use snarkvm::prelude::{Identifier, Network, PrivateKey, ViewKey};

use super::desktop::{delete_key, read_key, store,read_seed_phrase};
use super::desktop::{delete_key, read_key, read_seed_phrase, store};
use avail_common::errors::{AvailError, AvailErrorType, AvailResult};

/// This trait is used as a standard interface for the key management service.
/// The key_type field refers to the private key type when true and the viewing key type when false.
pub trait KeyController<N: Network> {
fn store_key(
&self,
password: &str,
wallet: &BetterAvailWallet<N>
) -> AvailResult<String>;
fn store_key(&self, password: &str, wallet: &BetterAvailWallet<N>) -> AvailResult<String>;

fn delete_key(&self, password: Option<&str>, ext: Identifier<N>) -> AvailResult<String>;
fn read_key(&self, password: Option<&str>, key_type: &str) -> AvailResult<Keys<N>>;
Expand All @@ -30,11 +26,7 @@ pub struct AndroidKeyController;

#[cfg(target_os = "android")]
impl<N: Network> KeyController<N> for AndroidKeyController {
fn store_key(
&self,
password: &str,
wallet: BetterAvailWallet<N>
) -> AvailResult<String> {
fn store_key(&self, password: &str, wallet: BetterAvailWallet<N>) -> AvailResult<String> {
keystore_init(password, access_type, p_key, v_key)
}

Expand Down Expand Up @@ -65,11 +57,7 @@ pub struct iOSKeyController;

#[cfg(target_os = "ios")]
impl<N: Network> KeyController<N> for iOSKeyController {
fn store_key(
&self,
password: &str,
wallet: BetterAvailWallet<N>
) -> AvailResult<String> {
fn store_key(&self, password: &str, wallet: BetterAvailWallet<N>) -> AvailResult<String> {
store_keys_local(password, access_type, p_key, v_key)
}

Expand Down Expand Up @@ -101,12 +89,8 @@ pub struct macKeyController;

#[cfg(target_os = "macos")]
impl<N: Network> KeyController<N> for macKeyController {
fn store_key(
&self,
password: &str,
wallet: &BetterAvailWallet<N>
) -> AvailResult<String> {
store(wallet,password)
fn store_key(&self, password: &str, wallet: &BetterAvailWallet<N>) -> AvailResult<String> {
store(wallet, password)
}

fn delete_key(&self, password: Option<&str>, _ext: Identifier<N>) -> AvailResult<String> {
Expand Down Expand Up @@ -144,12 +128,8 @@ impl<N: Network> KeyController<N> for macKeyController {
pub struct linuxKeyController;

impl<N: Network> KeyController<N> for linuxKeyController {
fn store_key(
&self,
password: &str,
wallet: &BetterAvailWallet<N>
) -> AvailResult<String> {
store(wallet,password)
fn store_key(&self, password: &str, wallet: &BetterAvailWallet<N>) -> AvailResult<String> {
store(wallet, password)
}

//TODO authenticate using read_key
Expand Down Expand Up @@ -189,12 +169,8 @@ pub struct windowsKeyController;

#[cfg(target_os = "windows")]
impl<N: Network> KeyController<N> for windowsKeyController {
fn store_key(
&self,
password: &str,
wallet: &BetterAvailWallet<N>
) -> AvailResult<String> {
store(wallet,password)
fn store_key(&self, password: &str, wallet: &BetterAvailWallet<N>) -> AvailResult<String> {
store(wallet, password)
}

//TODO authenticate using read_key
Expand Down
6 changes: 0 additions & 6 deletions backend/src/services/authentication/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ pub async fn get_session(password: Option<String>) -> AvailResult<String> {
session_id: session_request.session_id,
};

dotenv::dotenv().ok();

let api = env!("API");

let client = reqwest::Client::new();
Expand Down Expand Up @@ -93,8 +91,6 @@ pub async fn get_session_after_creation<N: Network>(
session_id: session_request.session_id,
};

dotenv::dotenv().ok();

let api = env!("API");

let res = reqwest::Client::new()
Expand Down Expand Up @@ -147,8 +143,6 @@ pub async fn request_hash(address:&str) -> AvailResult<server_auth::CreateSessio
public_key: address.to_owned(),
};

dotenv::dotenv().ok();

let api = env!("API");

let res = client
Expand Down
Loading

0 comments on commit 8fa22a8

Please sign in to comment.