Prechádzať zdrojové kódy

Address PR feedback

David Caseria 11 mesiacov pred
rodič
commit
2a09dff5c6

+ 2 - 5
crates/cdk/Cargo.toml

@@ -10,12 +10,9 @@ license.workspace = true
 
 
 [features]
-default = ["mint", "wallet", "all-nuts"]
+default = ["mint", "wallet"]
 mint = ["dep:bip39"]
-wallet = ["nut13", "dep:bip39", "dep:reqwest"]
-all-nuts = ["nut13"]
-nut13 = ["dep:bip39"]
-
+wallet = ["dep:bip39", "dep:reqwest"]
 
 [dependencies]
 async-trait = "0.1"

+ 0 - 1
crates/cdk/src/error.rs

@@ -37,7 +37,6 @@ pub enum Error {
     #[error(transparent)]
     Secret(#[from] super::secret::Error),
     /// Bip32 error
-    #[cfg(feature = "nut13")]
     #[error(transparent)]
     Bip32(#[from] bitcoin::bip32::Error),
     /// Parse int error

+ 0 - 1
crates/cdk/src/nuts/mod.rs

@@ -11,7 +11,6 @@ pub mod nut09;
 pub mod nut10;
 pub mod nut11;
 pub mod nut12;
-#[cfg(feature = "nut13")]
 pub mod nut13;
 pub mod nut14;
 

+ 5 - 23
crates/cdk/src/wallet.rs

@@ -426,11 +426,7 @@ impl Wallet {
             .get_keyset_counter(&active_keyset_id)
             .await?;
 
-        let count = if let Some(count) = count {
-            count + 1
-        } else {
-            0
-        };
+        let count = count.map_or(0, |c| c + 1);
 
         let premint_secrets = PreMintSecrets::from_xpriv(
             active_keyset_id,
@@ -616,11 +612,7 @@ impl Wallet {
                     .get_keyset_counter(&active_keyset_id)
                     .await?;
 
-                let count = if let Some(count) = count {
-                    count + 1
-                } else {
-                    0
-                };
+                let count = count.map_or(0, |c| c + 1);
 
                 let change_premint_secrets = PreMintSecrets::from_xpriv(
                     active_keyset_id,
@@ -641,11 +633,7 @@ impl Wallet {
                     .get_keyset_counter(&active_keyset_id)
                     .await?;
 
-                let count = if let Some(count) = count {
-                    count + 1
-                } else {
-                    0
-                };
+                let mut count = count.map_or(0, |c| c + 1);
 
                 let premint_secrets = PreMintSecrets::from_xpriv(
                     active_keyset_id,
@@ -655,7 +643,7 @@ impl Wallet {
                     false,
                 )?;
 
-                let count = count + premint_secrets.len() as u32;
+                count += premint_secrets.len() as u32;
 
                 let change_premint_secrets = PreMintSecrets::from_xpriv(
                     active_keyset_id,
@@ -867,11 +855,7 @@ impl Wallet {
             .get_keyset_counter(&active_keyset_id)
             .await?;
 
-        let count = if let Some(count) = count {
-            count + 1
-        } else {
-            0
-        };
+        let count = count.map_or(0, |c| c + 1);
 
         let premint_secrets =
             PreMintSecrets::from_xpriv(active_keyset_id, count, self.xpriv, proofs_amount, true)?;
@@ -1084,7 +1068,6 @@ impl Wallet {
         Ok(Token::new(mint_url, proofs, memo, unit)?.to_string())
     }
 
-    #[cfg(feature = "nut13")]
     #[instrument(skip(self), fields(mint_url = %mint_url))]
     pub async fn restore(&mut self, mint_url: UncheckedUrl) -> Result<Amount, Error> {
         // Check that mint is in store of mints
@@ -1156,7 +1139,6 @@ impl Wallet {
 
                 tracing::debug!("Restored {} proofs", proofs.len());
 
-                #[cfg(feature = "nut13")]
                 self.localstore
                     .increment_keyset_counter(&keyset.id, proofs.len() as u32)
                     .await?;

+ 0 - 1
misc/scripts/check-crates.sh

@@ -27,7 +27,6 @@ buildargs=(
     "-p cdk --no-default-features"
     "-p cdk --no-default-features --features wallet"
     "-p cdk --no-default-features --features mint"
-    "-p cdk --no-default-features --features nut13"
     "-p cdk-redb"
     "-p cdk-redb --no-default-features --features wallet"
     "-p cdk-redb --no-default-features --features mint"