From cf07e3d30e8265c2051c9415d0ca57ef8c0e6c03 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Wed, 26 Feb 2025 23:22:40 -0500 Subject: [PATCH] Lint fixes --- Cargo.toml | 1 + crates/sage-api/macro/src/lib.rs | 2 +- crates/sage-database/src/coin_states.rs | 2 +- crates/sage-database/src/derivations.rs | 2 +- crates/sage-database/src/peaks.rs | 2 +- crates/sage-database/src/primitives/cats.rs | 2 +- crates/sage-database/src/primitives/dids.rs | 2 +- crates/sage-database/src/primitives/nfts.rs | 14 +++++++------- crates/sage-database/src/primitives/xch.rs | 2 +- crates/sage-database/src/transactions.rs | 2 +- crates/sage-wallet/src/queues/nft_uri_queue.rs | 2 +- 11 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 936f0678..edf8c58e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,6 +42,7 @@ unwrap_used = "warn" wildcard_imports = "allow" cast_possible_truncation = "allow" cast_sign_loss = "allow" +cast_lossless = "allow" [workspace.dependencies] sage = { path = "./crates/sage" } diff --git a/crates/sage-api/macro/src/lib.rs b/crates/sage-api/macro/src/lib.rs index 4559750e..8fbd4422 100644 --- a/crates/sage-api/macro/src/lib.rs +++ b/crates/sage-api/macro/src/lib.rs @@ -66,7 +66,7 @@ fn convert( TokenTree::Group(group) => { let mut stream = group.stream().into_iter().peekable(); - let repeat = stream.peek().map_or(false, |token| { + let repeat = stream.peek().is_some_and(|token| { if let TokenTree::Ident(ident) = &token { ident.to_string() == "repeat" && group.delimiter() == Delimiter::Parenthesis } else { diff --git a/crates/sage-database/src/coin_states.rs b/crates/sage-database/src/coin_states.rs index 76f9f185..e7e7122e 100644 --- a/crates/sage-database/src/coin_states.rs +++ b/crates/sage-database/src/coin_states.rs @@ -74,7 +74,7 @@ impl Database { } } -impl<'a> DatabaseTx<'a> { +impl DatabaseTx<'_> { pub async fn insert_coin_state( &mut self, coin_state: CoinState, diff --git a/crates/sage-database/src/derivations.rs b/crates/sage-database/src/derivations.rs index ad60ea2b..99979902 100644 --- a/crates/sage-database/src/derivations.rs +++ b/crates/sage-database/src/derivations.rs @@ -41,7 +41,7 @@ impl Database { } } -impl<'a> DatabaseTx<'a> { +impl DatabaseTx<'_> { pub async fn insert_derivation( &mut self, p2_puzzle_hash: Bytes32, diff --git a/crates/sage-database/src/peaks.rs b/crates/sage-database/src/peaks.rs index b045eafb..b415182f 100644 --- a/crates/sage-database/src/peaks.rs +++ b/crates/sage-database/src/peaks.rs @@ -13,7 +13,7 @@ impl Database { } } -impl<'a> DatabaseTx<'a> { +impl DatabaseTx<'_> { pub async fn latest_peak(&mut self) -> Result> { latest_peak(&mut *self.tx).await } diff --git a/crates/sage-database/src/primitives/cats.rs b/crates/sage-database/src/primitives/cats.rs index 235fd104..e751e0b7 100644 --- a/crates/sage-database/src/primitives/cats.rs +++ b/crates/sage-database/src/primitives/cats.rs @@ -58,7 +58,7 @@ impl Database { } } -impl<'a> DatabaseTx<'a> { +impl DatabaseTx<'_> { pub async fn insert_cat(&mut self, row: CatRow) -> Result<()> { insert_cat(&mut *self.tx, row).await } diff --git a/crates/sage-database/src/primitives/dids.rs b/crates/sage-database/src/primitives/dids.rs index 51f8ea65..5a7bf633 100644 --- a/crates/sage-database/src/primitives/dids.rs +++ b/crates/sage-database/src/primitives/dids.rs @@ -59,7 +59,7 @@ impl Database { } } -impl<'a> DatabaseTx<'a> { +impl DatabaseTx<'_> { pub async fn insert_did(&mut self, row: DidRow) -> Result<()> { insert_did(&mut *self.tx, row).await } diff --git a/crates/sage-database/src/primitives/nfts.rs b/crates/sage-database/src/primitives/nfts.rs index 3fe220b1..cfa0caed 100644 --- a/crates/sage-database/src/primitives/nfts.rs +++ b/crates/sage-database/src/primitives/nfts.rs @@ -179,7 +179,7 @@ impl Database { } } -impl<'a> DatabaseTx<'a> { +impl DatabaseTx<'_> { pub async fn insert_nft_coin( &mut self, coin_id: Bytes32, @@ -870,11 +870,11 @@ async fn search_nfts( // Common parts let order_by = format!( - r#"ORDER BY {visible_order} + r"ORDER BY {visible_order} is_pending DESC, {sort_order}, launcher_id ASC - LIMIT ? OFFSET ?"#, + LIMIT ? OFFSET ?", visible_order = if params.include_hidden { "visible DESC," } else { @@ -920,7 +920,7 @@ async fn search_nfts( // Construct query based on whether we're doing a name search let query = if params.name.is_some() { format!( - r#" + r" WITH matched_names AS ( SELECT launcher_id FROM nft_name_fts @@ -932,16 +932,16 @@ async fn search_nfts( INNER JOIN matched_names ON nfts.launcher_id = matched_names.launcher_id WHERE {where_clause} {order_by} - "# + " ) } else { format!( - r#" + r" SELECT *, COUNT(*) OVER() as total_count FROM nfts INDEXED BY {index} WHERE {where_clause} {order_by} - "# + " ) }; diff --git a/crates/sage-database/src/primitives/xch.rs b/crates/sage-database/src/primitives/xch.rs index 921c62f2..89e972b6 100644 --- a/crates/sage-database/src/primitives/xch.rs +++ b/crates/sage-database/src/primitives/xch.rs @@ -27,7 +27,7 @@ impl Database { } } -impl<'a> DatabaseTx<'a> { +impl DatabaseTx<'_> { pub async fn insert_p2_coin(&mut self, coin_id: Bytes32) -> Result<()> { insert_p2_coin(&mut *self.tx, coin_id).await } diff --git a/crates/sage-database/src/transactions.rs b/crates/sage-database/src/transactions.rs index 0ad75271..9f871d2b 100644 --- a/crates/sage-database/src/transactions.rs +++ b/crates/sage-database/src/transactions.rs @@ -42,7 +42,7 @@ impl Database { } } -impl<'a> DatabaseTx<'a> { +impl DatabaseTx<'_> { pub async fn insert_pending_transaction( &mut self, transaction_id: Bytes32, diff --git a/crates/sage-wallet/src/queues/nft_uri_queue.rs b/crates/sage-wallet/src/queues/nft_uri_queue.rs index 3d9dbcde..0f149f72 100644 --- a/crates/sage-wallet/src/queues/nft_uri_queue.rs +++ b/crates/sage-wallet/src/queues/nft_uri_queue.rs @@ -64,7 +64,7 @@ impl NftUriQueue { let existing = tx.fetch_nft_data(item.hash).await?; - if existing.as_ref().map_or(true, |data| !data.hash_matches) { + if existing.as_ref().is_none_or(|data| !data.hash_matches) { tx.insert_nft_data( item.hash, NftData {