diff --git a/Cargo.toml b/Cargo.toml index 76bca3c7..937c898b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ log = "0.4.6" reqwest = { version = "0.12", default-features = false, features = ["json", "cookies"] } secp256k1 = { version = "0.30.0", features = ["recovery"] } tokio-util = { version = "0.7.7", features = ["codec"] } -tokio = { version = "1", features = ["time"] } +tokio = { version = "1", features = ["time", "sync"] } bytes = "1" futures = "0.3" jsonrpc-core = "18" @@ -58,7 +58,7 @@ async-iterator = "2.3.0" [target.'cfg(target_arch = "wasm32")'.dependencies] getrandom = { version = "0.2.16", features = ["js"] } web-time = "1.1.0" -tokio_with_wasm = { version = "0.8.2", features = ["time"] } +tokio_with_wasm = { version = "0.8", features = ["time", "rt"] } [features] default = ["default-tls"] diff --git a/examples/script_unlocker_example.rs b/examples/script_unlocker_example.rs index 8ec59049..9a354fcd 100644 --- a/examples/script_unlocker_example.rs +++ b/examples/script_unlocker_example.rs @@ -17,8 +17,7 @@ use std::collections::HashMap; /// [CapacityDiff]: https://github.com/doitian/ckb-sdk-examples-capacity-diff struct CapacityDiffUnlocker {} -#[cfg_attr(target_arch="wasm32", async_trait::async_trait(?Send))] -#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)] +#[async_trait::async_trait] impl ScriptUnlocker for CapacityDiffUnlocker { // This works for any args fn match_args(&self, _args: &[u8]) -> bool { @@ -114,7 +113,7 @@ impl ScriptUnlocker for CapacityDiffUnlocker { } fn other_unlock_error(message: &str) -> UnlockError { - UnlockError::Other(std::io::Error::new(std::io::ErrorKind::Other, message).into()) + UnlockError::Other(std::io::Error::other(message).into()) } fn main() { diff --git a/examples/sudt_issue.rs b/examples/sudt_issue.rs index ea69b9d3..91754a78 100644 --- a/examples/sudt_issue.rs +++ b/examples/sudt_issue.rs @@ -15,7 +15,7 @@ fn main() -> Result<(), Box> { let configuration = TransactionBuilderConfiguration::new_with_network(network_info.clone())?; let issuer = Address::from_str("ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq2qf8keemy2p5uu0g0gn8cd4ju23s5269qk8rg4r")?; - let iterator = InputIterator::new_with_address(&[issuer.clone()], &network_info); + let iterator = InputIterator::new_with_address(std::slice::from_ref(&issuer), &network_info); let mut builder = SudtTransactionBuilder::new(configuration, iterator, &issuer, true)?; builder.add_output(&issuer, 42); diff --git a/examples/sudt_send.rs b/examples/sudt_send.rs index e7e4444a..9c894f3b 100644 --- a/examples/sudt_send.rs +++ b/examples/sudt_send.rs @@ -16,7 +16,7 @@ fn main() -> Result<(), Box> { let sender = Address::from_str("ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq2qf8keemy2p5uu0g0gn8cd4ju23s5269qk8rg4r")?; let receiver= Address::from_str("ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqv5dsed9par23x4g58seaw58j3ym5ml2hs8ztche")?; - let iterator = InputIterator::new_with_address(&[sender.clone()], &network_info); + let iterator = InputIterator::new_with_address(std::slice::from_ref(&sender), &network_info); let mut builder = SudtTransactionBuilder::new(configuration, iterator, &sender, false)?; builder.add_output(&receiver, 50); diff --git a/rust-toolchain b/rust-toolchain index f288d111..7f229af9 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.85.0 +1.92.0 diff --git a/src/pubsub/stream_codec.rs b/src/pubsub/stream_codec.rs index 79f1abd3..663f46e0 100644 --- a/src/pubsub/stream_codec.rs +++ b/src/pubsub/stream_codec.rs @@ -60,7 +60,7 @@ impl tokio_util::codec::Decoder for StreamCodec { match str::from_utf8(line.as_ref()) { Ok(_) => Ok(Some(line)), - Err(_) => Err(io::Error::new(io::ErrorKind::Other, "invalid UTF-8")), + Err(_) => Err(io::Error::other("invalid UTF-8")), } } else { Ok(None) diff --git a/src/rpc/ckb_indexer.rs b/src/rpc/ckb_indexer.rs index 83e89080..c8efbfb1 100644 --- a/src/rpc/ckb_indexer.rs +++ b/src/rpc/ckb_indexer.rs @@ -20,8 +20,10 @@ pub struct SearchKey { #[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, Hash)] #[serde(rename_all = "snake_case")] +#[derive(Default)] pub enum SearchMode { // search with prefix + #[default] Prefix, // search with exact match Exact, @@ -29,12 +31,6 @@ pub enum SearchMode { Partial, } -impl Default for SearchMode { - fn default() -> Self { - Self::Prefix - } -} - #[derive(Serialize, Deserialize, Default, Clone, Debug)] pub struct SearchKeyFilter { pub script: Option