Răsfoiți Sursa

drk: chore clippy

skoupidi 1 an în urmă
părinte
comite
0eb5e08f1e

+ 10 - 11
bin/drk/src/dao.rs

@@ -536,7 +536,7 @@ impl DaoParams {
             self.dao.notes_public_key,
         );
         match self.notes_secret_key {
-            Some(secret_key) => toml += &format!("notes_secret_key = \"{}\"\n\n", secret_key),
+            Some(secret_key) => toml += &format!("notes_secret_key = \"{secret_key}\"\n\n"),
             None => toml += "\n",
         }
         toml += &format!(
@@ -545,7 +545,7 @@ impl DaoParams {
             self.dao.proposer_public_key,
         );
         match self.proposer_secret_key {
-            Some(secret_key) => toml += &format!("proposer_secret_key = \"{}\"\n\n", secret_key),
+            Some(secret_key) => toml += &format!("proposer_secret_key = \"{secret_key}\"\n\n"),
             None => toml += "\n",
         }
         toml += &format!(
@@ -554,7 +554,7 @@ impl DaoParams {
             self.dao.proposals_public_key,
         );
         match self.proposals_secret_key {
-            Some(secret_key) => toml += &format!("proposals_secret_key = \"{}\"\n\n", secret_key),
+            Some(secret_key) => toml += &format!("proposals_secret_key = \"{secret_key}\"\n\n"),
             None => toml += "\n",
         }
         toml += &format!(
@@ -563,7 +563,7 @@ impl DaoParams {
             self.dao.votes_public_key,
         );
         match self.votes_secret_key {
-            Some(secret_key) => toml += &format!("votes_secret_key = \"{}\"\n\n", secret_key),
+            Some(secret_key) => toml += &format!("votes_secret_key = \"{secret_key}\"\n\n"),
             None => toml += "\n",
         }
         toml += &format!(
@@ -572,7 +572,7 @@ impl DaoParams {
             self.dao.exec_public_key,
         );
         match self.exec_secret_key {
-            Some(secret_key) => toml += &format!("exec_secret_key = \"{}\"\n\n", secret_key),
+            Some(secret_key) => toml += &format!("exec_secret_key = \"{secret_key}\"\n\n"),
             None => toml += "\n",
         }
         toml += &format!(
@@ -581,7 +581,7 @@ impl DaoParams {
             self.dao.early_exec_public_key,
         );
         if let Some(secret_key) = self.early_exec_secret_key {
-            toml += &format!("\nearly_exec_secret_key = \"{}\"", secret_key)
+            toml += &format!("\nearly_exec_secret_key = \"{secret_key}\"")
         }
 
         toml
@@ -661,7 +661,7 @@ impl fmt::Display for DaoParams {
             self.dao.bulla_blind,
         );
 
-        write!(f, "{}", s)
+        write!(f, "{s}")
     }
 }
 
@@ -793,7 +793,7 @@ impl fmt::Display for DaoRecord {
             call_index,
         );
 
-        write!(f, "{}", s)
+        write!(f, "{s}")
     }
 }
 
@@ -860,7 +860,7 @@ impl fmt::Display for ProposalRecord {
             "Block windows"
         );
 
-        write!(f, "{}", s)
+        write!(f, "{s}")
     }
 }
 
@@ -1206,8 +1206,7 @@ impl Drk {
             }
 
             println!(
-                "[apply_dao_mint_data] Found minted DAO {}, noting down for wallet update",
-                new_bulla
+                "[apply_dao_mint_data] Found minted DAO {new_bulla}, noting down for wallet update"
             );
 
             // We have this DAO imported in our wallet. Add the metadata:

+ 3 - 3
bin/drk/src/main.rs

@@ -2497,7 +2497,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 .await;
 
                 if let Err(e) = drk.deploy_auth_keygen().await {
-                    eprintln!("Error creating deploy auth keypair: {:?}", e);
+                    eprintln!("Error creating deploy auth keypair: {e}");
                     exit(2);
                 }
 
@@ -2549,7 +2549,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 let mut tx = match drk.deploy_contract(deploy_auth, wasm_bin, deploy_ix).await {
                     Ok(v) => v,
                     Err(e) => {
-                        eprintln!("Error creating contract deployment tx: {}", e);
+                        eprintln!("Error creating contract deployment tx: {e}");
                         exit(2);
                     }
                 };
@@ -2577,7 +2577,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
                 let mut tx = match drk.lock_contract(deploy_auth).await {
                     Ok(v) => v,
                     Err(e) => {
-                        eprintln!("Error creating contract lock tx: {}", e);
+                        eprintln!("Error creating contract lock tx: {e}");
                         exit(2);
                     }
                 };

+ 1 - 1
bin/drk/src/money.rs

@@ -630,7 +630,7 @@ impl Drk {
         let mut map: HashMap<String, String> = HashMap::new();
         for (alias, token_id) in aliases {
             let aliases_string = if let Some(prev) = map.get(&token_id.to_string()) {
-                format!("{}, {}", prev, alias)
+                format!("{prev}, {alias}")
             } else {
                 alias
             };

+ 4 - 12
bin/drk/src/scanned_blocks.rs

@@ -40,11 +40,7 @@ impl Drk {
         rollback_query: &str,
     ) -> WalletDbResult<()> {
         let query = format!(
-            "INSERT INTO {} ({}, {}, {}) VALUES (?1, ?2, ?3);",
-            WALLET_SCANNED_BLOCKS_TABLE,
-            WALLET_SCANNED_BLOCKS_COL_HEIGH,
-            WALLET_SCANNED_BLOCKS_COL_HASH,
-            WALLET_SCANNED_BLOCKS_COL_ROLLBACK_QUERY,
+            "INSERT INTO {WALLET_SCANNED_BLOCKS_TABLE} ({WALLET_SCANNED_BLOCKS_COL_HEIGH}, {WALLET_SCANNED_BLOCKS_COL_HASH}, {WALLET_SCANNED_BLOCKS_COL_ROLLBACK_QUERY}) VALUES (?1, ?2, ?3);"
         );
         self.wallet.exec_sql(&query, rusqlite::params![height, hash, rollback_query])
     }
@@ -96,8 +92,7 @@ impl Drk {
     /// If database is empty default (0, '-') is returned.
     pub fn get_last_scanned_block(&self) -> WalletDbResult<(u32, String)> {
         let query = format!(
-            "SELECT * FROM {} ORDER BY {} DESC LIMIT 1;",
-            WALLET_SCANNED_BLOCKS_TABLE, WALLET_SCANNED_BLOCKS_COL_HEIGH,
+            "SELECT * FROM {WALLET_SCANNED_BLOCKS_TABLE} ORDER BY {WALLET_SCANNED_BLOCKS_COL_HEIGH} DESC LIMIT 1;"
         );
         let ret = self.wallet.query_custom(&query, &[])?;
 
@@ -113,7 +108,7 @@ impl Drk {
     /// Reset the scanned blocks information records in the wallet.
     pub fn reset_scanned_blocks(&self) -> WalletDbResult<()> {
         println!("Resetting scanned blocks");
-        let query = format!("DELETE FROM {};", WALLET_SCANNED_BLOCKS_TABLE);
+        let query = format!("DELETE FROM {WALLET_SCANNED_BLOCKS_TABLE};");
         self.wallet.exec_sql(&query, &[])?;
         println!("Successfully reset scanned blocks");
 
@@ -145,10 +140,7 @@ impl Drk {
             let (height, hash, query) = self.get_scanned_block_record(height)?;
             println!("Reverting block: {height} - {hash}");
             self.wallet.exec_batch_sql(&query)?;
-            let query = format!(
-                "DELETE FROM {} WHERE {} = {};",
-                WALLET_SCANNED_BLOCKS_TABLE, WALLET_SCANNED_BLOCKS_COL_HEIGH, height
-            );
+            let query = format!("DELETE FROM {WALLET_SCANNED_BLOCKS_TABLE} WHERE {WALLET_SCANNED_BLOCKS_COL_HEIGH} = {height};");
             self.wallet.exec_batch_sql(&query)?;
         }
 

+ 2 - 2
bin/drk/src/swap.rs

@@ -66,7 +66,7 @@ impl fmt::Display for PartialSwapData {
             self.value_blinds, self.token_blinds,
         );
 
-        write!(f, "{}", s)
+        write!(f, "{s}")
     }
 }
 
@@ -315,7 +315,7 @@ impl Drk {
         }
 
         let params: MoneyTransferParamsV1 = deserialize_async(&tx.calls[0].data.data[1..]).await?;
-        println!("Parameters:\n{:#?}", params);
+        println!("Parameters:\n{params:#?}");
 
         if params.inputs.len() != 2 {
             eprintln!("Found {} inputs, there should be 2", params.inputs.len());

+ 4 - 12
bin/drk/src/txs_history.rs

@@ -44,11 +44,7 @@ impl Drk {
     ) -> WalletDbResult<String> {
         // Create an SQL `INSERT OR REPLACE` query
         let query = format!(
-            "INSERT OR REPLACE INTO {} ({}, {}, {}) VALUES (?1, ?2, ?3);",
-            WALLET_TXS_HISTORY_TABLE,
-            WALLET_TXS_HISTORY_COL_TX_HASH,
-            WALLET_TXS_HISTORY_COL_STATUS,
-            WALLET_TXS_HISTORY_COL_TX,
+            "INSERT OR REPLACE INTO {WALLET_TXS_HISTORY_TABLE} ({WALLET_TXS_HISTORY_COL_TX_HASH}, {WALLET_TXS_HISTORY_COL_STATUS}, {WALLET_TXS_HISTORY_COL_TX}) VALUES (?1, ?2, ?3);"
         );
 
         // Create its inverse query
@@ -56,10 +52,7 @@ impl Drk {
         // We only need to set the transaction status to "Reverted"
         let inverse = self.wallet.create_prepared_statement(
             &format!(
-                "UPDATE {} SET {} = ?1 WHERE {} = ?2;",
-                WALLET_TXS_HISTORY_TABLE,
-                WALLET_TXS_HISTORY_COL_STATUS,
-                WALLET_TXS_HISTORY_COL_TX_HASH
+                "UPDATE {WALLET_TXS_HISTORY_TABLE} SET {WALLET_TXS_HISTORY_COL_STATUS} = ?1 WHERE {WALLET_TXS_HISTORY_COL_TX_HASH} = ?2;"
             ),
             rusqlite::params!["Reverted", tx_hash],
         )?;
@@ -153,7 +146,7 @@ impl Drk {
     /// Reset the transaction history records in the wallet.
     pub fn reset_tx_history(&self) -> WalletDbResult<()> {
         println!("Resetting transactions history");
-        let query = format!("DELETE FROM {};", WALLET_TXS_HISTORY_TABLE);
+        let query = format!("DELETE FROM {WALLET_TXS_HISTORY_TABLE};");
         self.wallet.exec_sql(&query, &[])?;
         println!("Successfully reset transactions history");
 
@@ -165,8 +158,7 @@ impl Drk {
     pub fn remove_reverted_txs(&self) -> WalletDbResult<()> {
         println!("Removing reverted transactions history records");
         let query = format!(
-            "DELETE FROM {} WHERE {} = 'Reverted';",
-            WALLET_TXS_HISTORY_TABLE, WALLET_TXS_HISTORY_COL_STATUS
+            "DELETE FROM {WALLET_TXS_HISTORY_TABLE} WHERE {WALLET_TXS_HISTORY_COL_STATUS} = 'Reverted';"
         );
         self.wallet.exec_sql(&query, &[])?;
         println!("Successfully removed reverted transactions history records");

+ 2 - 2
bin/drk/src/walletdb.rs

@@ -165,9 +165,9 @@ impl WalletDb {
         params: &[(&str, &dyn ToSql)],
     ) -> String {
         let mut query = if col_names.is_empty() {
-            format!("SELECT * FROM {}", table)
+            format!("SELECT * FROM {table}")
         } else {
-            format!("SELECT {} FROM {}", col_names.join(", "), table)
+            format!("SELECT {} FROM {table}", col_names.join(", "))
         };
         if params.is_empty() {
             return query