feat: Add xmr-btc-swap repo in subdirectory

This commit is contained in:
binarybaron 2024-07-19 00:01:34 +02:00
parent 462f3b2e6f
commit 757183e857
526 changed files with 41757 additions and 1 deletions

View file

@ -0,0 +1,50 @@
use std::sync::Arc;
use once_cell::sync::OnceCell;
use swap::{api::{request::{Method, Request}, Context}, cli::command::{Bitcoin, Monero}};
// Lazy load the Context
static CONTEXT: OnceCell<Arc<Context>> = OnceCell::new();
#[tauri::command]
async fn balance() -> String {
let context = CONTEXT.get().unwrap();
let request = Request::new(Method::Balance { force_refresh: true });
let response = request.call(context.clone()).await.unwrap();
response.to_string()
}
fn setup<'a>(app: &'a mut tauri::App) -> Result<(), Box<dyn std::error::Error>> {
tauri::async_runtime::block_on(async {
let context = Context::build(
Some(Bitcoin {
bitcoin_electrum_rpc_url: None,
bitcoin_target_block: None,
}),
Some(Monero {
monero_daemon_address: None,
}),
None,
None,
true,
true,
true,
None,
)
.await
.unwrap();
CONTEXT.set(Arc::new(context)).expect("Failed to initialize cli context");
});
Ok(())
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_shell::init())
.invoke_handler(tauri::generate_handler![balance])
.setup(setup)
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

View file

@ -0,0 +1,6 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
fn main() {
unstoppableswap_gui_rs_lib::run()
}