Bläddra i källkod

fix: name of blinded_message col in blind_signature

thesimplekid 1 månad sedan
förälder
incheckning
34d8ab763b

+ 1 - 0
crates/cdk-sqlite/src/mint/migrations.rs

@@ -20,4 +20,5 @@ pub static MIGRATIONS: &[(&str, &str)] = &[
     ("20250406091754_mint_time_of_quotes.sql", include_str!(r#"./migrations/20250406091754_mint_time_of_quotes.sql"#)),
     ("20250406091754_mint_time_of_quotes.sql", include_str!(r#"./migrations/20250406091754_mint_time_of_quotes.sql"#)),
     ("20250406093755_mint_created_time_signature.sql", include_str!(r#"./migrations/20250406093755_mint_created_time_signature.sql"#)),
     ("20250406093755_mint_created_time_signature.sql", include_str!(r#"./migrations/20250406093755_mint_created_time_signature.sql"#)),
     ("20250415093121_drop_keystore_foreign.sql", include_str!(r#"./migrations/20250415093121_drop_keystore_foreign.sql"#)),
     ("20250415093121_drop_keystore_foreign.sql", include_str!(r#"./migrations/20250415093121_drop_keystore_foreign.sql"#)),
+    ("20250626120251_rename_blind_message_y_to_b.sql", include_str!(r#"./migrations/20250626120251_rename_blind_message_y_to_b.sql"#)),
 ];
 ];

+ 2 - 0
crates/cdk-sqlite/src/mint/migrations/20250626120251_rename_blind_message_y_to_b.sql

@@ -0,0 +1,2 @@
+-- Rename column y to b
+ALTER TABLE blind_signature RENAME COLUMN y TO blinded_message;

+ 8 - 9
crates/cdk-sqlite/src/mint/mod.rs

@@ -968,12 +968,12 @@ impl MintSignaturesDatabase for MintSqliteDatabase {
             query(
             query(
                 r#"
                 r#"
                     INSERT INTO blind_signature
                     INSERT INTO blind_signature
-                    (y, amount, keyset_id, c, quote_id, dleq_e, dleq_s, created_time)
+                    (blinded_message, amount, keyset_id, c, quote_id, dleq_e, dleq_s, created_time)
                     VALUES
                     VALUES
-                    (:y, :amount, :keyset_id, :c, :quote_id, :dleq_e, :dleq_s, :created_time)
+                    (:blinded_message, :amount, :keyset_id, :c, :quote_id, :dleq_e, :dleq_s, :created_time)
                 "#,
                 "#,
             )
             )
-            .bind(":y", message.to_bytes().to_vec())
+            .bind(":blinded_message", message.to_bytes().to_vec())
             .bind(":amount", u64::from(signature.amount) as i64)
             .bind(":amount", u64::from(signature.amount) as i64)
             .bind(":keyset_id", signature.keyset_id.to_string())
             .bind(":keyset_id", signature.keyset_id.to_string())
             .bind(":c", signature.c.to_bytes().to_vec())
             .bind(":c", signature.c.to_bytes().to_vec())
@@ -988,8 +988,7 @@ impl MintSignaturesDatabase for MintSqliteDatabase {
             )
             )
             .bind(":created_time", current_time as i64)
             .bind(":created_time", current_time as i64)
             .execute(&transaction)
             .execute(&transaction)
-            .await
-            .expect("fasdas");
+            .await?;
         }
         }
 
 
         transaction.commit().await?;
         transaction.commit().await?;
@@ -1008,17 +1007,17 @@ impl MintSignaturesDatabase for MintSqliteDatabase {
                 c,
                 c,
                 dleq_e,
                 dleq_e,
                 dleq_s,
                 dleq_s,
-                y
+                blinded_message
             FROM
             FROM
                 blind_signature
                 blind_signature
-            WHERE y IN (:y)
+            WHERE blinded_message IN (:blinded_message)
             "#,
             "#,
         )
         )
         .bind_vec(
         .bind_vec(
-            ":y",
+            ":blinded_message",
             blinded_messages
             blinded_messages
                 .iter()
                 .iter()
-                .map(|y| y.to_bytes().to_vec())
+                .map(|b_| b_.to_bytes().to_vec())
                 .collect(),
                 .collect(),
         )
         )
         .fetch_all(&self.pool)
         .fetch_all(&self.pool)

+ 16 - 0
justfile

@@ -5,6 +5,22 @@ alias t := test
 default:
 default:
   @just --list
   @just --list
 
 
+# Create a new SQL migration file
+new-migration target name:
+    #!/usr/bin/env bash
+    if [ "{{target}}" != "mint" ] && [ "{{target}}" != "wallet" ]; then
+        echo "Error: target must be either 'mint' or 'wallet'"
+        exit 1
+    fi
+    
+    timestamp=$(date +%Y%m%d%H%M%S)
+    migration_path="./crates/cdk-sqlite/src/{{target}}/migrations/${timestamp}_{{name}}.sql"
+    
+    # Create the file
+    mkdir -p "$(dirname "$migration_path")"
+    touch "$migration_path"
+    echo "Created new migration: $migration_path"
+
 final-check: typos format clippy test
 final-check: typos format clippy test
 
 
 # run `cargo build` on everything
 # run `cargo build` on everything