mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-08-01 11:06:13 -04:00
feat(gui, tauri): Accept --testnet flag, default to mainnet (#106)
This PR tackles #92 - Add the `tauri-plugin-cli` (only on desktop) - Check in the frontend if the `--testnet` flag is set. If it's set we pass `testnet=true` to the `initialize_context` command on invokation - We add the `vite-plugin-top-level-await` to allow top level await in all browsers - Remove the `bitcoin_confirmation_target` from settings for simplicity
This commit is contained in:
parent
9e94dca7aa
commit
83f831ccac
23 changed files with 311 additions and 53 deletions
|
@ -27,3 +27,6 @@ tauri-plugin-process = "2.0.0"
|
|||
tauri-plugin-shell = "2.0.0"
|
||||
tauri-plugin-store = "2.0.0"
|
||||
tracing = "0.1.40"
|
||||
|
||||
[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
|
||||
tauri-plugin-cli = "2.0.0"
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
"clipboard-manager:allow-write-text",
|
||||
"shell:allow-open",
|
||||
"store:default",
|
||||
"process:default"
|
||||
"process:default",
|
||||
"cli:allow-cli-matches"
|
||||
]
|
||||
}
|
||||
|
|
11
src-tauri/capabilities/desktop.json
Normal file
11
src-tauri/capabilities/desktop.json
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"identifier": "desktop-capability",
|
||||
"platforms": [
|
||||
"macOS",
|
||||
"windows",
|
||||
"linux"
|
||||
],
|
||||
"permissions": [
|
||||
"cli:default"
|
||||
]
|
||||
}
|
|
@ -114,6 +114,9 @@ impl State {
|
|||
fn setup(app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let app_handle = app.app_handle().to_owned();
|
||||
|
||||
#[cfg(desktop)]
|
||||
app_handle.plugin(tauri_plugin_cli::init())?;
|
||||
|
||||
// We need to set a value for the Tauri state right at the start
|
||||
// If we don't do this, Tauri commands will panic at runtime if no value is present
|
||||
app_handle.manage::<RwLock<State>>(RwLock::new(State::new()));
|
||||
|
@ -201,6 +204,7 @@ async fn is_context_available(context: tauri::State<'_, RwLock<State>>) -> Resul
|
|||
#[tauri::command]
|
||||
async fn initialize_context(
|
||||
settings: TauriSettings,
|
||||
testnet: bool,
|
||||
app_handle: tauri::AppHandle,
|
||||
state: tauri::State<'_, RwLock<State>>,
|
||||
) -> Result<(), String> {
|
||||
|
@ -213,13 +217,13 @@ async fn initialize_context(
|
|||
// Get app handle and create a Tauri handle
|
||||
let tauri_handle = TauriHandle::new(app_handle.clone());
|
||||
|
||||
let context_result = ContextBuilder::new(true)
|
||||
let context_result = ContextBuilder::new(testnet)
|
||||
.with_bitcoin(Bitcoin {
|
||||
bitcoin_electrum_rpc_url: settings.electrum_rpc_url,
|
||||
bitcoin_target_block: settings.bitcoin_confirmation_target.into(),
|
||||
bitcoin_electrum_rpc_url: settings.electrum_rpc_url.clone(),
|
||||
bitcoin_target_block: None,
|
||||
})
|
||||
.with_monero(Monero {
|
||||
monero_daemon_address: settings.monero_node_url,
|
||||
monero_daemon_address: settings.monero_node_url.clone(),
|
||||
})
|
||||
.with_json(false)
|
||||
.with_debug(true)
|
||||
|
|
|
@ -5,10 +5,6 @@
|
|||
"build": {
|
||||
"devUrl": "http://localhost:1420",
|
||||
"frontendDist": "../src-gui/dist",
|
||||
"beforeDevCommand": {
|
||||
"cwd": "../src-gui",
|
||||
"script": "yarn run dev"
|
||||
},
|
||||
"beforeBuildCommand": {
|
||||
"cwd": "../src-gui",
|
||||
"script": "yarn run build"
|
||||
|
@ -36,5 +32,15 @@
|
|||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
]
|
||||
},
|
||||
"plugins": {
|
||||
"cli": {
|
||||
"description": "Start the GUI application",
|
||||
"args": [
|
||||
{
|
||||
"name": "testnet"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue