Преглед на файлове

fix: creating auth keyset when auth disabled (#830)

thesimplekid преди 6 дни
родител
ревизия
0aada22e62
променени са 3 файла, в които са добавени 11 реда и са изтрити 5 реда
  1. 1 1
      crates/cdk-cli/src/sub_commands/check_pending.rs
  2. 1 3
      crates/cdk-signatory/src/db_signatory.rs
  3. 9 1
      crates/cdk/src/mint/builder.rs

+ 1 - 1
crates/cdk-cli/src/sub_commands/check_pending.rs

@@ -26,7 +26,7 @@ pub async fn check_pending(multi_mint_wallet: &MultiMintWallet) -> Result<()> {
         // Try to reclaim any proofs that are no longer pending
         match wallet.reclaim_unspent(pending_proofs).await {
             Ok(()) => println!("Successfully reclaimed pending proofs"),
-            Err(e) => println!("Error reclaimed pending proofs: {}", e),
+            Err(e) => println!("Error reclaimed pending proofs: {e}"),
         }
     }
     Ok(())

+ 1 - 3
crates/cdk-signatory/src/db_signatory.rs

@@ -37,7 +37,7 @@ impl DbSignatory {
     pub async fn new(
         localstore: Arc<dyn database::MintKeysDatabase<Err = database::Error> + Send + Sync>,
         seed: &[u8],
-        mut supported_units: HashMap<CurrencyUnit, (u64, u8)>,
+        supported_units: HashMap<CurrencyUnit, (u64, u8)>,
         custom_paths: HashMap<CurrencyUnit, DerivationPath>,
     ) -> Result<Self, Error> {
         let secp_ctx = Secp256k1::new();
@@ -52,8 +52,6 @@ impl DbSignatory {
         )
         .await?;
 
-        supported_units.entry(CurrencyUnit::Auth).or_insert((0, 1));
-
         // Create new keysets for supported units that aren't covered by the current keysets
         for (unit, (fee, max_order)) in supported_units {
             if !active_keyset_units.contains(&unit) {

+ 9 - 1
crates/cdk/src/mint/builder.rs

@@ -340,6 +340,14 @@ impl MintBuilder {
             .ok_or(anyhow!("Localstore not set"))?;
         let ln = self.ln.clone().ok_or(anyhow!("Ln backends not set"))?;
 
+        #[allow(unused_mut)]
+        let mut supported_units = self.supported_units.clone();
+
+        #[cfg(feature = "auth")]
+        if self.openid_discovery.is_some() {
+            supported_units.entry(CurrencyUnit::Auth).or_insert((0, 1));
+        }
+
         let signatory = if let Some(signatory) = self.signatory.as_ref() {
             signatory.clone()
         } else {
@@ -347,7 +355,7 @@ impl MintBuilder {
             let in_memory_signatory = cdk_signatory::db_signatory::DbSignatory::new(
                 self.keystore.clone().ok_or(anyhow!("keystore not set"))?,
                 seed,
-                self.supported_units.clone(),
+                supported_units,
                 HashMap::new(),
             )
             .await?;