diff --git a/Cargo.lock b/Cargo.lock index b47619c304..5023bf4187 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -895,16 +895,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "console_error_panic_hook" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" -dependencies = [ - "cfg-if 1.0.0", - "wasm-bindgen", -] - [[package]] name = "constant_time_eq" version = "0.3.1" @@ -2256,10 +2246,11 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -5125,12 +5116,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "scoped-tls" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" - [[package]] name = "scopeguard" version = "1.2.0" @@ -6222,12 +6207,13 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if 1.0.0", "once_cell", + "rustversion", "serde", "serde_json", "wasm-bindgen-macro", @@ -6235,13 +6221,12 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", "syn 2.0.79", @@ -6250,21 +6235,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.43" +version = "0.4.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" dependencies = [ "cfg-if 1.0.0", "js-sys", + "once_cell", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -6272,9 +6258,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", @@ -6285,20 +6271,21 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] [[package]] name = "wasm-bindgen-test" -version = "0.3.43" +version = "0.3.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68497a05fb21143a08a7d24fc81763384a3072ee43c44e86aad1744d6adef9d9" +checksum = "66c8d5e33ca3b6d9fa3b4676d774c5778031d27a578c2b007f905acf816152c3" dependencies = [ - "console_error_panic_hook", "js-sys", "minicov", - "scoped-tls", "wasm-bindgen", "wasm-bindgen-futures", "wasm-bindgen-test-macro", @@ -6306,9 +6293,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.43" +version = "0.3.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8220be1fa9e4c889b30fd207d4906657e7e90b12e0e6b0c8b8d8709f5de021" +checksum = "17d5042cc5fa009658f9a7333ef24291b1291a25b6382dd68862a7f3b969f69b" dependencies = [ "proc-macro2", "quote", @@ -6317,9 +6304,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.70" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/Cargo.toml b/Cargo.toml index e9d123f6b6..7ab0a2579d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -256,9 +256,9 @@ tonic = { version = "0.12.3", features = ["tls-webpki-roots", "gzip", "transport tonic-build = { version = "0.12.3", features = ["prost"] } triggered = "0.1.2" uuid = { version = "1.5.0", features = ["v4", "fast-rng", "serde"] } -wasm-bindgen = { version = "0.2.93", features = ["serde-serialize"] } +wasm-bindgen = { version = "0.2.100", features = ["serde-serialize"] } wasm-bindgen-futures = "0.4.43" -wasm-bindgen-test = "0.3.43" +wasm-bindgen-test = "0.3.50" web-sys = "0.3.70" xxhash-rust = { version = "0.8.7", features = ["xxh3"] } zeroize = { version = "1.6.0", default-features = false, features = ["alloc"] } diff --git a/cli/src/modules/guide.rs b/cli/src/modules/guide.rs index 0419f8d2db..4c9ccac1b3 100644 --- a/cli/src/modules/guide.rs +++ b/cli/src/modules/guide.rs @@ -12,10 +12,10 @@ impl Guide { let mut paras = Vec::::new(); let mut para = String::new(); + let regex = Regex::new(r"\s+").unwrap(); for line in lines { if line.trim().is_empty() { if !para.is_empty() { - let regex = Regex::new(r"\s+").unwrap(); let text = regex.replace_all(para.trim(), " "); paras.push(text.to_string()); para.clear(); diff --git a/consensus/core/src/tx/script_public_key.rs b/consensus/core/src/tx/script_public_key.rs index b0a4756066..00a0ffe29d 100644 --- a/consensus/core/src/tx/script_public_key.rs +++ b/consensus/core/src/tx/script_public_key.rs @@ -405,7 +405,9 @@ impl TryCastFromJs for ScriptPublicKey { #[cfg(test)] mod tests { use super::*; + #[cfg(target_arch = "wasm32")] use js_sys::Object; + #[cfg(target_arch = "wasm32")] use wasm_bindgen::__rt::IntoJsResult; #[test] @@ -438,10 +440,14 @@ mod tests { assert_eq!(spk, spk2); } + #[cfg(target_arch = "wasm32")] use wasm_bindgen::convert::IntoWasmAbi; + #[cfg(target_arch = "wasm32")] use wasm_bindgen_test::wasm_bindgen_test; + #[cfg(target_arch = "wasm32")] use workflow_wasm::serde::{from_value, to_value}; + #[cfg(target_arch = "wasm32")] #[wasm_bindgen_test] pub fn test_wasm_serde_constructor() { let version = 0xc0de; @@ -459,6 +465,7 @@ mod tests { assert_eq!(JsValue::from_str("string"), spk_js.js_typeof()); } + #[cfg(target_arch = "wasm32")] #[wasm_bindgen_test] pub fn test_wasm_serde_js_spk_object() { let version = 0xc0de; @@ -478,6 +485,7 @@ mod tests { assert_eq!(spk, actual); } + #[cfg(target_arch = "wasm32")] #[wasm_bindgen_test] pub fn test_wasm_serde_spk_object() { let version = 0xc0de; diff --git a/crypto/addresses/src/lib.rs b/crypto/addresses/src/lib.rs index 48c0baf198..aa0d6d8d3f 100644 --- a/crypto/addresses/src/lib.rs +++ b/crypto/addresses/src/lib.rs @@ -638,11 +638,16 @@ mod tests { // cspell:enable } + #[cfg(target_arch = "wasm32")] use js_sys::Object; + #[cfg(target_arch = "wasm32")] use wasm_bindgen::{JsValue, __rt::IntoJsResult}; + #[cfg(target_arch = "wasm32")] use wasm_bindgen_test::wasm_bindgen_test; + #[cfg(target_arch = "wasm32")] use workflow_wasm::{extensions::ObjectExtension, serde::from_value, serde::to_value}; + #[cfg(target_arch = "wasm32")] #[wasm_bindgen_test] pub fn test_wasm_serde_constructor() { let str = "kaspa:qpauqsvk7yf9unexwmxsnmg547mhyga37csh0kj53q6xxgl24ydxjsgzthw5j"; @@ -654,6 +659,7 @@ mod tests { assert_eq!(a, from_value(value).unwrap()); } + #[cfg(target_arch = "wasm32")] #[wasm_bindgen_test] pub fn test_wasm_js_serde_object() { let expected = Address::constructor("kaspa:qpauqsvk7yf9unexwmxsnmg547mhyga37csh0kj53q6xxgl24ydxjsgzthw5j"); @@ -678,6 +684,7 @@ mod tests { assert_eq!(expected, actual); } + #[cfg(target_arch = "wasm32")] #[wasm_bindgen_test] pub fn test_wasm_serde_object() { use wasm_bindgen::convert::IntoWasmAbi; diff --git a/protocol/p2p/src/core/router.rs b/protocol/p2p/src/core/router.rs index 6cd63bb146..55caf26c43 100644 --- a/protocol/p2p/src/core/router.rs +++ b/protocol/p2p/src/core/router.rs @@ -467,9 +467,6 @@ fn match_for_io_error(err_status: &tonic::Status) -> Option<&std::io::Error> { } } - err = match err.source() { - Some(err) => err, - None => return None, - }; + err = err.source()?; } } diff --git a/rpc/grpc/server/src/connection.rs b/rpc/grpc/server/src/connection.rs index 442eb2f423..7613ac58ea 100644 --- a/rpc/grpc/server/src/connection.rs +++ b/rpc/grpc/server/src/connection.rs @@ -374,10 +374,7 @@ fn match_for_io_error(err_status: &tonic::Status) -> Option<&std::io::Error> { } } - err = match err.source() { - Some(err) => err, - None => return None, - }; + err = err.source()?; } } diff --git a/rpc/macros/src/wrpc/wasm.rs b/rpc/macros/src/wrpc/wasm.rs index 30af3e74a3..a3c955d102 100644 --- a/rpc/macros/src/wrpc/wasm.rs +++ b/rpc/macros/src/wrpc/wasm.rs @@ -136,6 +136,7 @@ impl Parse for RpcSubscriptions { impl ToTokens for RpcSubscriptions { fn to_tokens(&self, tokens: &mut TokenStream) { let mut targets = Vec::new(); + let regex = Regex::new(r"^Notify").unwrap(); for handler in self.handlers.elems.iter() { let (name, docs) = match handler { @@ -146,7 +147,6 @@ impl ToTokens for RpcSubscriptions { }; let name = format!("Notify{}", name.as_str()); - let regex = Regex::new(r"^Notify").unwrap(); let blank = regex.replace(&name, ""); let subscribe = regex.replace(&name, "Subscribe"); let unsubscribe = regex.replace(&name, "Unsubscribe"); diff --git a/wallet/bip32/src/prefix.rs b/wallet/bip32/src/prefix.rs index daff8267e7..e391c5eb48 100644 --- a/wallet/bip32/src/prefix.rs +++ b/wallet/bip32/src/prefix.rs @@ -135,7 +135,7 @@ impl Prefix { /// Validate that the given prefix string is well-formed. // TODO(tarcieri): validate the string ends with `prv` or `pub`? pub(crate) const fn validate_str(s: &str) -> crate::error::ResultConst<&str> { - if s.as_bytes().len() != Self::LENGTH { + if s.len() != Self::LENGTH { return Err(crate::error::ErrorImpl::DecodeInvalidLength); }