From 0592044ec04cf1dfc882fc0cd5f334bcf515171d Mon Sep 17 00:00:00 2001 From: dr-frmr Date: Tue, 11 Jun 2024 21:38:51 -0600 Subject: [PATCH 1/5] cleanup: use features for alloy --- Cargo.lock | 3 +-- kinode/Cargo.toml | 1 - lib/Cargo.toml | 6 ++++-- lib/src/eth.rs | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f7f5fc9bd..645bc8ae4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3371,8 +3371,7 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" name = "lib" version = "0.8.1" dependencies = [ - "alloy-json-rpc 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=05f8162)", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=05f8162)", + "alloy", "kit", "lazy_static", "rand 0.8.5", diff --git a/kinode/Cargo.toml b/kinode/Cargo.toml index c036387f5..3036adb5e 100644 --- a/kinode/Cargo.toml +++ b/kinode/Cargo.toml @@ -41,7 +41,6 @@ alloy = { git = "https://github.com/alloy-rs/alloy", rev = "05f8162", features = "signer-wallet", "signers", ] } - alloy-primitives = "0.7.5" alloy-sol-macro = "0.7.5" alloy-sol-types = "0.7.5" diff --git a/lib/Cargo.toml b/lib/Cargo.toml index e8a4e0875..7d66a4930 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -15,8 +15,10 @@ kit = { git = "https://github.com/kinode-dao/kit", rev = "d319c5b" } tokio = "1.28" [dependencies] -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "05f8162" } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "05f8162" } +alloy = { git = "https://github.com/alloy-rs/alloy", rev = "05f8162", features = [ + "json-rpc", + "rpc-types", +] } lazy_static = "1.4.0" rand = "0.8.4" ring = "0.17.8" diff --git a/lib/src/eth.rs b/lib/src/eth.rs index 16ec46601..ba13b8843 100644 --- a/lib/src/eth.rs +++ b/lib/src/eth.rs @@ -1,5 +1,5 @@ -use alloy_json_rpc::ErrorPayload; -use alloy_rpc_types::pubsub::{Params, SubscriptionKind, SubscriptionResult}; +use alloy::rpc::json_rpc::ErrorPayload; +use alloy::rpc::types::eth::pubsub::{Params, SubscriptionKind, SubscriptionResult}; use serde::{Deserialize, Serialize}; use std::collections::{HashMap, HashSet}; From 926e5744f74544bb94960bbe5993dea1a7149dd5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 03:39:15 +0000 Subject: [PATCH 2/5] Format Rust code using rustfmt --- kinode/src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kinode/src/main.rs b/kinode/src/main.rs index 9d7cfa2a0..57cd8cd1e 100644 --- a/kinode/src/main.rs +++ b/kinode/src/main.rs @@ -520,7 +520,11 @@ async fn setup_networking( (Some(listener), true) } None => { - let min_port = if protocol == "ws" { WS_MIN_PORT } else { TCP_MIN_PORT }; + let min_port = if protocol == "ws" { + WS_MIN_PORT + } else { + TCP_MIN_PORT + }; let listener = http::utils::find_open_port(min_port, MAX_PORT) .await .expect("no ports found in range 9000-65535 for kinode networking"); From dac4a2e52625a14b0c275acf376365b7e88a83fe Mon Sep 17 00:00:00 2001 From: dr-frmr Date: Tue, 11 Jun 2024 22:00:43 -0600 Subject: [PATCH 3/5] vfs: use sha256, remove blake3 dep --- Cargo.lock | 20 -------------------- kinode/Cargo.toml | 1 - kinode/src/vfs.rs | 29 +++++++++++++++-------------- 3 files changed, 15 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 645bc8ae4..a5eacb5fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -883,12 +883,6 @@ dependencies = [ "rand 0.8.5", ] -[[package]] -name = "arrayref" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" - [[package]] name = "arrayvec" version = "0.7.4" @@ -1093,19 +1087,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "blake3" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30cca6d3674597c30ddf2c587bf8d9d65c9a84d2326d941cc79c9842dfe0ef52" -dependencies = [ - "arrayref", - "arrayvec", - "cc", - "cfg-if", - "constant_time_eq 0.3.0", -] - [[package]] name = "block-buffer" version = "0.10.4" @@ -3190,7 +3171,6 @@ dependencies = [ "async-trait", "base64 0.22.0", "bincode", - "blake3", "bytes", "chacha20poly1305", "chrono", diff --git a/kinode/Cargo.toml b/kinode/Cargo.toml index 3036adb5e..0490da277 100644 --- a/kinode/Cargo.toml +++ b/kinode/Cargo.toml @@ -48,7 +48,6 @@ anyhow = "1.0.71" async-trait = "0.1.71" base64 = "0.22.0" bincode = "1.3.3" -blake3 = "1.4.1" bytes = "1.4.0" chacha20poly1305 = "0.10.1" chrono = "0.4.31" diff --git a/kinode/src/vfs.rs b/kinode/src/vfs.rs index e46e08c7d..4312a21cd 100644 --- a/kinode/src/vfs.rs +++ b/kinode/src/vfs.rs @@ -69,7 +69,7 @@ pub async fn vfs( if let Err(e) = handle_request( &our_node, km, - open_files.clone(), + open_files, &send_to_loop, &send_to_terminal, &send_to_caps_oracle, @@ -230,13 +230,13 @@ async fn handle_request( VfsAction::CreateFile => { // create truncates any file that might've existed before open_files.remove(&path); - let _file = open_file(open_files.clone(), path, true, true).await?; + let _file = open_file(open_files, path, true, true).await?; (serde_json::to_vec(&VfsResponse::Ok).unwrap(), None) } VfsAction::OpenFile { create } => { // open file opens an existing file, or creates a new one if create is true - let file = open_file(open_files.clone(), path, create, false).await?; + let file = open_file(open_files, path, create, false).await?; let mut file = file.lock().await; // extra in the case file was just created, todo refactor out. file.seek(SeekFrom::Start(0)).await?; @@ -255,7 +255,7 @@ async fn handle_request( error: "blob needs to exist for WriteAll".into(), }); }; - let file = open_file(open_files.clone(), path, false, false).await?; + let file = open_file(open_files, path, false, false).await?; let mut file = file.lock().await; file.write_all(&blob.bytes).await?; (serde_json::to_vec(&VfsResponse::Ok).unwrap(), None) @@ -275,7 +275,7 @@ async fn handle_request( error: "blob needs to exist for Append".into(), }); }; - let file = open_file(open_files.clone(), path, false, false).await?; + let file = open_file(open_files, path, false, false).await?; let mut file = file.lock().await; file.seek(SeekFrom::End(0)).await?; file.write_all(&blob.bytes).await?; @@ -283,7 +283,7 @@ async fn handle_request( (serde_json::to_vec(&VfsResponse::Ok).unwrap(), None) } VfsAction::SyncAll => { - let file = open_file(open_files.clone(), path, false, false).await?; + let file = open_file(open_files, path, false, false).await?; let file = file.lock().await; file.sync_all().await?; (serde_json::to_vec(&VfsResponse::Ok).unwrap(), None) @@ -297,7 +297,7 @@ async fn handle_request( ) } VfsAction::ReadToEnd => { - let file = open_file(open_files.clone(), path.clone(), false, false).await?; + let file = open_file(open_files, path.clone(), false, false).await?; let mut file = file.lock().await; let mut contents = Vec::new(); @@ -309,7 +309,7 @@ async fn handle_request( ) } VfsAction::ReadExact(length) => { - let file = open_file(open_files.clone(), path, false, false).await?; + let file = open_file(open_files, path, false, false).await?; let mut file = file.lock().await; let mut contents = vec![0; length as usize]; file.read_exact(&mut contents).await?; @@ -339,7 +339,7 @@ async fn handle_request( ) } VfsAction::ReadToString => { - let file = open_file(open_files.clone(), path, false, false).await?; + let file = open_file(open_files, path, false, false).await?; let mut file = file.lock().await; let mut contents = String::new(); file.read_to_string(&mut contents).await?; @@ -349,7 +349,7 @@ async fn handle_request( ) } VfsAction::Seek { seek_from } => { - let file = open_file(open_files.clone(), path, false, false).await?; + let file = open_file(open_files, path, false, false).await?; let mut file = file.lock().await; // same type, rust tingz let seek_from = match seek_from { @@ -401,22 +401,23 @@ async fn handle_request( ) } VfsAction::Len => { - let file = open_file(open_files.clone(), path, false, false).await?; + let file = open_file(open_files, path, false, false).await?; let file = file.lock().await; let len = file.metadata().await?.len(); (serde_json::to_vec(&VfsResponse::Len(len)).unwrap(), None) } VfsAction::SetLen(len) => { - let file = open_file(open_files.clone(), path, false, false).await?; + let file = open_file(open_files, path, false, false).await?; let file = file.lock().await; file.set_len(len).await?; (serde_json::to_vec(&VfsResponse::Ok).unwrap(), None) } VfsAction::Hash => { - let file = open_file(open_files.clone(), path, false, false).await?; + use sha2::{Digest, Sha256}; + let file = open_file(open_files, path, false, false).await?; let mut file = file.lock().await; file.seek(SeekFrom::Start(0)).await?; - let mut hasher = blake3::Hasher::new(); + let mut hasher = Sha256::new(); let mut buffer = [0; 1024]; loop { let bytes_read = file.read(&mut buffer).await?; From 1538f8e90f702aec305c47c3b05a4c923cab3a61 Mon Sep 17 00:00:00 2001 From: dr-frmr Date: Tue, 11 Jun 2024 22:43:30 -0600 Subject: [PATCH 4/5] cleanup: get rid of unused deps --- Cargo.lock | 128 ++++++++++++++++++++++++----------------- kinode/Cargo.toml | 21 ++----- kinode/build.rs | 2 +- kinode/src/keygen.rs | 2 +- kinode/src/main.rs | 4 +- kinode/src/register.rs | 50 ++++++---------- lib/Cargo.toml | 2 +- 7 files changed, 103 insertions(+), 106 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a5eacb5fd..f1e313933 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -24,7 +24,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" dependencies = [ "crypto-common", - "generic-array 0.14.7", + "generic-array", ] [[package]] @@ -1093,7 +1093,7 @@ version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ - "generic-array 0.14.7", + "generic-array", ] [[package]] @@ -1699,7 +1699,7 @@ dependencies = [ "futures-core", "libc", "mio", - "parking_lot", + "parking_lot 0.12.1", "signal-hook", "signal-hook-mio", "winapi", @@ -1726,7 +1726,7 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ - "generic-array 0.14.7", + "generic-array", "rand_core 0.6.4", "subtle", "zeroize", @@ -1738,7 +1738,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array 0.14.7", + "generic-array", "rand_core 0.6.4", "typenum", ] @@ -1824,7 +1824,7 @@ dependencies = [ "hashbrown 0.14.3", "lock_api", "once_cell", - "parking_lot_core", + "parking_lot_core 0.9.9", ] [[package]] @@ -1933,7 +1933,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.7", + "generic-array", ] [[package]] @@ -2080,9 +2080,8 @@ dependencies = [ "crypto-bigint", "digest 0.10.7", "ff", - "generic-array 0.14.7", + "generic-array", "group", - "hkdf", "pkcs8", "rand_core 0.6.4", "sec1", @@ -2425,15 +2424,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "generic-array" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe739944a5406424e080edccb6add95685130b9f160d5407c639c7df0c5836b0" -dependencies = [ - "typenum", -] - [[package]] name = "get_block" version = "0.1.0" @@ -2644,15 +2634,6 @@ dependencies = [ "wit-bindgen", ] -[[package]] -name = "hkdf" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" -dependencies = [ - "hmac", -] - [[package]] name = "hmac" version = "0.12.1" @@ -2971,7 +2952,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" dependencies = [ - "generic-array 0.14.7", + "generic-array", ] [[package]] @@ -2985,6 +2966,15 @@ dependencies = [ "wit-bindgen", ] +[[package]] +name = "instant" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" +dependencies = [ + "cfg-if", +] + [[package]] name = "io-extras" version = "0.18.2" @@ -3171,30 +3161,20 @@ dependencies = [ "async-trait", "base64 0.22.0", "bincode", - "bytes", - "chacha20poly1305", "chrono", "clap", "crossterm", - "curve25519-dalek", "dashmap", - "digest 0.10.7", - "elliptic-curve", - "flate2", "futures", - "generic-array 1.0.0", - "getrandom", + "generic-array", "hex", - "hkdf", "hmac", "http 1.1.0", "jwt", "kit", "lazy_static", "lib", - "log", "nohash-hasher", - "num-traits", "open", "public-ip", "rand 0.8.5", @@ -3207,7 +3187,6 @@ dependencies = [ "rusqlite", "serde", "serde_json", - "serde_urlencoded", "sha2", "sha3", "snow", @@ -3217,7 +3196,6 @@ dependencies = [ "tokio", "tokio-tungstenite 0.21.0", "url", - "uuid", "walkdir", "warp", "wasi-common", @@ -3280,8 +3258,8 @@ dependencies = [ [[package]] name = "kit" -version = "0.4.2" -source = "git+https://github.com/kinode-dao/kit?rev=d319c5b#d319c5b573166e54ead9da47d363e65b9cd47c57" +version = "0.6.2" +source = "git+https://github.com/kinode-dao/kit?tag=v0.6.2#59ca74d4952998753bf5e64404d09f31a4424830" dependencies = [ "anyhow", "base64 0.21.7", @@ -3301,15 +3279,17 @@ dependencies = [ "serde", "serde_json", "sha2", + "ssh2", "thiserror", "tokio", - "tokio-tungstenite 0.21.0", + "tokio-tungstenite 0.20.1", "toml", "tracing", "tracing-appender", "tracing-error", "tracing-subscriber", "walkdir", + "wit-bindgen", "zip 0.6.6", ] @@ -3834,9 +3814,9 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "open" -version = "5.1.2" +version = "5.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "449f0ff855d85ddbf1edd5b646d65249ead3f5e422aaa86b7d2d0b049b103e32" +checksum = "b5ca541f22b1c46d4bb9801014f234758ab4297e7870b904b6a8415b980a7388" dependencies = [ "is-wsl", "libc", @@ -3931,6 +3911,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core 0.8.6", +] + [[package]] name = "parking_lot" version = "0.12.1" @@ -3938,7 +3929,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core", + "parking_lot_core 0.9.9", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall 0.2.16", + "smallvec", + "winapi", ] [[package]] @@ -3949,7 +3954,7 @@ checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.4.1", "smallvec", "windows-targets 0.48.5", ] @@ -4472,6 +4477,15 @@ dependencies = [ "rand_core 0.3.1", ] +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "redox_syscall" version = "0.4.1" @@ -4918,7 +4932,7 @@ checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ "base16ct", "der", - "generic-array 0.14.7", + "generic-array", "pkcs8", "subtle", "zeroize", @@ -5244,6 +5258,18 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a" +[[package]] +name = "ssh2" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7fe461910559f6d5604c3731d00d2aafc4a83d1665922e280f42f9a168d5455" +dependencies = [ + "bitflags 1.3.2", + "libc", + "libssh2-sys", + "parking_lot 0.11.2", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -6085,10 +6111,6 @@ name = "uuid" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" -dependencies = [ - "getrandom", - "serde", -] [[package]] name = "valuable" diff --git a/kinode/Cargo.toml b/kinode/Cargo.toml index 0490da277..8638130e9 100644 --- a/kinode/Cargo.toml +++ b/kinode/Cargo.toml @@ -14,9 +14,8 @@ path = "src/main.rs" [build-dependencies] anyhow = "1.0.71" -kit = { git = "https://github.com/kinode-dao/kit", rev = "d319c5b" } +kit = { git = "https://github.com/kinode-dao/kit", tag = "v0.6.2" } rayon = "1.8.1" -sha2 = "0.10" tokio = "1.28" walkdir = "2.4" zip = "0.6" @@ -48,30 +47,20 @@ anyhow = "1.0.71" async-trait = "0.1.71" base64 = "0.22.0" bincode = "1.3.3" -bytes = "1.4.0" -chacha20poly1305 = "0.10.1" chrono = "0.4.31" clap = { version = "4.4", features = ["derive"] } crossterm = { version = "0.27.0", features = ["event-stream", "bracketed-paste"] } -curve25519-dalek = "^4.1.2" dashmap = "5.5.3" -digest = "0.10" -elliptic-curve = { version = "0.13.8", features = ["ecdh"] } -flate2 = "1.0" futures = "0.3" -generic-array = "1.0.0" -getrandom = "0.2.10" +generic-array = "0.14.7" hex = "0.4.3" -hkdf = "0.12.3" hmac = "0.12" http = "1.1.0" jwt = "0.16" lib = { path = "../lib" } lazy_static = "1.4.0" -log = "0.4.20" nohash-hasher = "0.2.0" -num-traits = "0.2" -open = "5.0.0" +open = "5.1.4" public-ip = "0.2.2" rand = "0.8.4" reqwest = "0.12.4" @@ -82,8 +71,7 @@ route-recognizer = "0.3.1" rusqlite = { version = "0.31.0", features = ["bundled"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -serde_urlencoded = "0.7" -sha2 = "0.10" +sha2 = "0.10.8" sha3 = "0.10.8" # snow = { version = "0.9.5", features = ["ring-resolver"] } # unfortunately need to use forked version for async use and in-place encryption @@ -94,7 +82,6 @@ thiserror = "1.0" tokio = { version = "1.28", features = ["fs", "macros", "rt-multi-thread", "signal", "sync"] } tokio-tungstenite = { version = "0.21.0", features = ["native-tls"] } url = "2.4.1" -uuid = { version = "1.1.2", features = ["serde", "v4"] } warp = "0.3.5" wasi-common = "19.0.1" wasmtime = "19.0.1" diff --git a/kinode/build.rs b/kinode/build.rs index 4e416676e..cd9264ac7 100644 --- a/kinode/build.rs +++ b/kinode/build.rs @@ -59,7 +59,7 @@ fn build_and_zip_package( ) -> anyhow::Result<(String, String, Vec)> { let rt = tokio::runtime::Runtime::new().unwrap(); rt.block_on(async { - kit::build::execute(&entry_path, true, false, true, features, None, None) // TODO + kit::build::execute(&entry_path, true, false, true, features, None, None, true) .await .map_err(|e| anyhow::anyhow!("{:?}", e))?; diff --git a/kinode/src/keygen.rs b/kinode/src/keygen.rs index 7b71443cf..945238b0e 100644 --- a/kinode/src/keygen.rs +++ b/kinode/src/keygen.rs @@ -4,7 +4,7 @@ use aes_gcm::{ }; use alloy_primitives::keccak256; use anyhow::Result; -use digest::generic_array::GenericArray; +use generic_array::GenericArray; use hmac::Hmac; use jwt::SignWithKey; use lib::types::core::Keyfile; diff --git a/kinode/src/main.rs b/kinode/src/main.rs index 57cd8cd1e..14a04a6d3 100644 --- a/kinode/src/main.rs +++ b/kinode/src/main.rs @@ -779,13 +779,13 @@ async fn login_with_password( maybe_rpc: Option, password: &str, ) -> (Identity, Vec, Keyfile) { - use {alloy_primitives::Address as EthAddress, digest::Digest, ring::signature::KeyPair}; + use {alloy_primitives::Address as EthAddress, sha2::{Digest, Sha256}, ring::signature::KeyPair}; let disk_keyfile: Vec = tokio::fs::read(format!("{}/.keys", home_directory_path)) .await .expect("could not read keyfile"); - let password_hash = format!("0x{}", hex::encode(sha2::Sha256::digest(password))); + let password_hash = format!("0x{}", hex::encode(Sha256::digest(password))); // KnsRegistrar contract address let kns_address: EthAddress = KNS_ADDRESS.parse().unwrap(); diff --git a/kinode/src/register.rs b/kinode/src/register.rs index 03527ef8d..863a02998 100644 --- a/kinode/src/register.rs +++ b/kinode/src/register.rs @@ -106,26 +106,25 @@ pub async fn register( let static_files = warp::path("assets").and(static_dir!("src/register-ui/build/assets/")); let react_app = warp::path::end() + .or(warp::path("login")) + .or(warp::path("register-name")) + .or(warp::path("claim-invite")) + .or(warp::path("reset")) + .or(warp::path("import-keyfile")) + .or(warp::path("set-password")) .and(warp::get()) - .map(move || warp::reply::html(include_str!("register-ui/build/index.html"))) - .or(warp::path("login") - .and(warp::get()) - .map(move || warp::reply::html(include_str!("register-ui/build/index.html")))) - .or(warp::path("register-name") - .and(warp::get()) - .map(move || warp::reply::html(include_str!("register-ui/build/index.html")))) - .or(warp::path("claim-invite") - .and(warp::get()) - .map(move || warp::reply::html(include_str!("register-ui/build/index.html")))) - .or(warp::path("reset") - .and(warp::get()) - .map(move || warp::reply::html(include_str!("register-ui/build/index.html")))) - .or(warp::path("import-keyfile") - .and(warp::get()) - .map(move || warp::reply::html(include_str!("register-ui/build/index.html")))) - .or(warp::path("set-password") - .and(warp::get()) - .map(move || warp::reply::html(include_str!("register-ui/build/index.html")))) + .map(move |_| warp::reply::html(include_str!("register-ui/build/index.html"))); + + let boot_provider = provider.clone(); + let login_provider = provider.clone(); + let import_provider = provider.clone(); + + let api = warp::path("info") + .and( + warp::get() + .and(keyfile.clone()) + .and_then(get_unencrypted_info), + ) .or(warp::path("current-chain") .and(warp::get()) .map(move || warp::reply::json(&"0xa"))) @@ -146,18 +145,7 @@ pub async fn register( } warp::reply::html(String::new()) }, - )); - - let boot_provider = provider.clone(); - let login_provider = provider.clone(); - let import_provider = provider.clone(); - - let api = warp::path("info") - .and( - warp::get() - .and(keyfile.clone()) - .and_then(get_unencrypted_info), - ) + )) .or(warp::path("generate-networking-info").and( warp::post() .and(our_temp_id.clone()) diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 7d66a4930..2ce33b95c 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -11,7 +11,7 @@ license = "Apache-2.0" [lib] [build-dependencies] -kit = { git = "https://github.com/kinode-dao/kit", rev = "d319c5b" } +kit = { git = "https://github.com/kinode-dao/kit", tag = "v0.6.2" } tokio = "1.28" [dependencies] From 03d4eff379433766dc2ba1b3c05c5ef100d4e22a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 04:43:53 +0000 Subject: [PATCH 5/5] Format Rust code using rustfmt --- kinode/src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kinode/src/main.rs b/kinode/src/main.rs index 14a04a6d3..43c8e02f6 100644 --- a/kinode/src/main.rs +++ b/kinode/src/main.rs @@ -779,7 +779,11 @@ async fn login_with_password( maybe_rpc: Option, password: &str, ) -> (Identity, Vec, Keyfile) { - use {alloy_primitives::Address as EthAddress, sha2::{Digest, Sha256}, ring::signature::KeyPair}; + use { + alloy_primitives::Address as EthAddress, + ring::signature::KeyPair, + sha2::{Digest, Sha256}, + }; let disk_keyfile: Vec = tokio::fs::read(format!("{}/.keys", home_directory_path)) .await