diff --git a/src-gui/src/renderer/rpc.ts b/src-gui/src/renderer/rpc.ts index da691a16..2497ad7f 100644 --- a/src-gui/src/renderer/rpc.ts +++ b/src-gui/src/renderer/rpc.ts @@ -1,5 +1,4 @@ import { invoke } from "@tauri-apps/api/core"; -import { BalanceBitcoinResponse } from "models/rpcModel"; import { store } from "./store/storeRenderer"; import { rpcSetBalance, rpcSetSwapInfo } from "store/features/rpcSlice"; @@ -14,6 +13,6 @@ export async function checkBitcoinBalance() { export async function getRawSwapInfos() { const response = await invoke("swap_infos_all"); - console.log(response); + (response as any[]).forEach((info) => store.dispatch(rpcSetSwapInfo(info))); } diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 37776609..20b36575 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "unstoppableswap-gui-rs" version = "0.0.0" -authors = ["binarybaron", "einliterflasche", "unstoppableswap"] +authors = [ "binarybaron", "einliterflasche", "unstoppableswap" ] edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -9,16 +9,16 @@ description = "A Tauri App" [lib] name = "unstoppableswap_gui_rs_lib" -crate-type = ["lib", "cdylib", "staticlib"] +crate-type = [ "lib", "cdylib", "staticlib" ] [build-dependencies] -tauri-build = { version = "2.0.0-rc.1", features = ["config-json5"] } +tauri-build = { version = "2.0.0-rc.1", features = [ "config-json5" ] } [dependencies] anyhow = "1" once_cell = "1" -serde = { version = "1", features = ["derive"] } +serde = { version = "1", features = [ "derive" ] } serde_json = "1" swap = { path = "../swap" } -tauri = { version = "2.0.0-rc.1", features = ["config-json5"] } +tauri = { version = "2.0.0-rc.1", features = [ "config-json5" ] } uuid = "1.10.0" diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index b9189c81..1f78c45f 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -4,23 +4,22 @@ use once_cell::sync::OnceCell; use swap::{ api::{ request::{ - get_balance, get_swap_info, get_swap_infos_all, BalanceArgs, BalanceResponse, - GetSwapInfoResponse, + get_balance as get_balance_impl, get_swap_infos_all as get_swap_infos_all_impl, + BalanceArgs, BalanceResponse, GetSwapInfoResponse, }, Context, }, cli::command::{Bitcoin, Monero}, }; -use uuid::Uuid; // Lazy load the Context static CONTEXT: OnceCell> = OnceCell::new(); #[tauri::command] -async fn balance() -> Result { +async fn get_balance() -> Result { let context = CONTEXT.get().unwrap(); - get_balance( + get_balance_impl( BalanceArgs { force_refresh: true, }, @@ -31,10 +30,10 @@ async fn balance() -> Result { } #[tauri::command] -async fn swap_infos_all() -> Result, String> { +async fn get_swap_infos_all() -> Result, String> { let context = CONTEXT.get().unwrap(); - get_swap_infos_all(context.clone()) + get_swap_infos_all_impl(context.clone()) .await .map_err(|e| e.to_string()) } @@ -69,7 +68,7 @@ fn setup<'a>(app: &'a mut tauri::App) -> Result<(), Box> #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { tauri::Builder::default() - .invoke_handler(tauri::generate_handler![balance, swap_infos_all]) + .invoke_handler(tauri::generate_handler![get_balance, get_swap_infos_all]) .setup(setup) .run(tauri::generate_context!()) .expect("error while running tauri application");