diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index 34986cd..5ad698d 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -1236,46 +1236,12 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
-[[package]]
-name = "libappindicator"
-version = "0.7.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "db2d3cb96d092b4824cb306c9e544c856a4cb6210c1081945187f7f1924b47e8"
-dependencies = [
- "glib",
- "gtk",
- "gtk-sys",
- "libappindicator-sys",
- "log",
-]
-
-[[package]]
-name = "libappindicator-sys"
-version = "0.7.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f1b3b6681973cea8cc3bce7391e6d7d5502720b80a581c9a95c9cbaf592826aa"
-dependencies = [
- "gtk-sys",
- "libloading",
- "once_cell",
-]
-
[[package]]
name = "libc"
version = "0.2.139"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
-[[package]]
-name = "libloading"
-version = "0.7.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
-dependencies = [
- "cfg-if",
- "winapi",
-]
-
[[package]]
name = "line-wrap"
version = "0.1.1"
@@ -1538,16 +1504,6 @@ version = "1.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3"
-[[package]]
-name = "open"
-version = "3.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2078c0039e6a54a0c42c28faa984e115fb4c2d5bf2208f77d1961002df8576f8"
-dependencies = [
- "pathdiff",
- "windows-sys 0.42.0",
-]
-
[[package]]
name = "os_pipe"
version = "1.1.3"
@@ -1618,12 +1574,6 @@ version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba"
-[[package]]
-name = "pathdiff"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd"
-
[[package]]
name = "percent-encoding"
version = "2.2.0"
@@ -2387,7 +2337,6 @@ dependencies = [
"core-foundation",
"core-graphics",
"crossbeam-channel",
- "dirs-next",
"dispatch",
"gdk",
"gdk-pixbuf",
@@ -2401,7 +2350,6 @@ dependencies = [
"instant",
"jni",
"lazy_static",
- "libappindicator",
"libc",
"log",
"ndk",
@@ -2454,7 +2402,6 @@ dependencies = [
"ignore",
"objc",
"once_cell",
- "open",
"os_pipe",
"percent-encoding",
"rand 0.8.5",
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 718bd75..96afa65 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -13,7 +13,7 @@ edition = "2021"
tauri-build = { version = "1.2", features = [] }
[dependencies]
-tauri = { version = "1.2", features = ["shell-all", "system-tray"] }
+tauri = { version = "1.2", features = ["fs-exists", "fs-read-file", "path-all", "shell-sidecar"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 0f2e930..1f7e54a 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -6,12 +6,11 @@ use std::{
process::{Command, Stdio},
thread
};
-use tauri::{
- // api::process::{Command, CommandChild, Output},
- AppHandle, CustomMenuItem, SystemTray, SystemTrayEvent,
- SystemTrayMenu, SystemTrayMenuItem,
- Manager,
+/* use tauri::{
+ api::process::{Command, CommandChild, Output},
+ AppHandle, Manager
};
+ */
#[tauri::command]
fn stop_testnet(process: u32) {
@@ -42,7 +41,7 @@ async fn start_testnet(
}
fn main() {
- let tray_menu = SystemTrayMenu::new()
+/* let tray_menu = SystemTrayMenu::new()
.add_item(CustomMenuItem::new(
"visibility-toggle".to_string(),
"Hide"))
@@ -51,7 +50,7 @@ fn main() {
"quit".to_string(),
"Quit"
));
- let _tray = SystemTray::new().with_menu(tray_menu);
+ let _tray = SystemTray::new().with_menu(tray_menu); */
/* .setup(|app| {
// the default value is `main`. note that it must be unique
@@ -71,22 +70,22 @@ fn main() {
let app = tauri::Builder::default()
- // .setup(|app| {
- // https://tauri.app/v1/guides/features/events
- // let id = app.listen_global("event-name", |event| {
- // println!("got event-name with payload {:?}", event.payload());
- // });
- // // unlisten to the event using the `id` returned on the `listen_global` function
- // // an `once_global` API is also exposed on the `App` struct
- // app.unlisten(id);
+/* .setup(|app| {
+ https://tauri.app/v1/guides/features/events
+ let id = app.listen_global("event-name", |event| {
+ println!("got event-name with payload {:?}", event.payload());
+ });
+ // unlisten to the event using the `id` returned on the `listen_global` function
+ // an `once_global` API is also exposed on the `App` struct
+ app.unlisten(id);
- // // emit the `event-name` event to all webview windows on the frontend
- // app.emit_all("event-name", Payload { message: "Tauri is awesome!".into() }).unwrap();
- // Ok(())
- // })
- // .system_tray(tray)
- // .on_system_tray_event(on_tray_event)
- // .manage(AppState {anvil_output: Default::default()})
+ // emit the `event-name` event to all webview windows on the frontend
+ app.emit_all("event-name", Payload { message: "Tauri is awesome!".into() }).unwrap();
+ Ok(())
+ })
+ .system_tray(tray)
+ .on_system_tray_event(on_tray_event)
+ .manage(AppState {anvil_output: Default::default()}) */
.invoke_handler(tauri::generate_handler![stop_testnet, start_testnet])
.build(tauri::generate_context!())
.expect("error while running tauri application");
@@ -102,10 +101,10 @@ fn main() {
}
-/**
+/*
* Limbo till I figure out where to listen for window close outside before clicking on a menuitem
*/
-fn _on_tray_event(
+/* fn _on_tray_event(
app: &AppHandle,
event: SystemTrayEvent,
) {
@@ -151,4 +150,4 @@ fn _on_tray_event(
}
_ => {}
}
-}
\ No newline at end of file
+} */
\ No newline at end of file
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index 0bd6e4b..8b99019 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -11,16 +11,9 @@
"version": "0.0.1"
},
"tauri": {
- "systemTray": {
- "iconPath": "icons/icon.png",
- "menuOnLeftClick": false,
- "iconAsTemplate": true
- },
"allowlist": {
"all": false,
"shell": {
- "all": true,
- "open": true,
"sidecar": true,
"scope": [
{
@@ -29,6 +22,14 @@
"args": true
}
]
+ },
+ "fs": {
+ "scope": ["$APPLOCALDATA/config.json"],
+ "readFile": true,
+ "exists": true
+ },
+ "path": {
+ "all": true
}
},
"bundle": {
@@ -41,7 +42,7 @@
"icons/icon.icns",
"icons/icon.ico"
],
- "identifier": "anvil.sameold.lab",
+ "identifier": "com.sameoldlab.anvil-ui",
"targets": "all"
},
"security": {
diff --git a/src/anvil.ts b/src/anvil.ts
index b552e2b..bc4213b 100644
--- a/src/anvil.ts
+++ b/src/anvil.ts
@@ -17,15 +17,17 @@ export const killTestnet = () => {
return _child.kill()
}
+import { appLocalDataDir } from "@tauri-apps/api/path"
+
export async function startTestnet(args: string[] = []) {
- // args = ["--config-out", "~/.anvil-ui/anvil.json", ...args]
+ const appLocalDataDirPath = await appLocalDataDir()
+ args = ["--config-out", `${appLocalDataDirPath}config.json`, ...args]
const cmd = Command.sidecar("../public/bin/anvil", args)
- let i = 0
const unwatch = client.watchBlocks({
onBlock: (block) => {
block_number.update((current) => {
- // Check if current block has changed then update block_number and blocks.
+ // Check if current block has changed then update block_number and blocks.
// Avoids double check and unnecessary updates on block store
if (block.number === null) return current
if (current === block.number.toString()) return current
@@ -66,17 +68,15 @@ export async function startTestnet(args: string[] = []) {
})
cmd.on("error", (line: string) => {
- console.error("on err: ", line)
live.set(false)
+ console.error("on err: ", line)
testnet_log.update((state) => state + `${line}\n`)
})
- // Assigning after don't accidentally get a running process when commnd fails
_child = await cmd.spawn()
cmd.stdout.on("data", (line: string) => {
console.info("stdout: ", line)
- live.set(true)
testnet_log.update((state) => {
if (state.includes("command finished with code")) {
blocks.set([]) // save output until next run
@@ -85,9 +85,9 @@ export async function startTestnet(args: string[] = []) {
return state + `${line}
`
}
})
+ live.set(true)
})
- // Not needed. Errors already handled by listen events
cmd.stderr.on("data", (line) => {
console.debug("stderr: ", line)
testnet_log.update((state) => state + `${line}
`)
diff --git a/src/lib/ConfigData.svelte b/src/lib/ConfigData.svelte
index 1722fa3..ea9102c 100644
--- a/src/lib/ConfigData.svelte
+++ b/src/lib/ConfigData.svelte
@@ -1,12 +1,21 @@