mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-23 15:44:50 +01:00
feat(cdk): add quote_id field to transactions for quote tracking (#1041)
- Add quote_id field to Transaction struct in cdk-common - Add database migrations for quote_id column in SQLite and PostgreSQL - Update wallet operations to populate quote_id for mint/melt transactions - Set quote_id to None for send/receive operations without associated quotes
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
/// @generated
|
||||
/// Auto-generated by build.rs
|
||||
pub static MIGRATIONS: &[(&str, &str, &str)] = &[
|
||||
("sqlite", "1_fix_sqlx_migration.sql", include_str!(r#"./migrations/sqlite/1_fix_sqlx_migration.sql"#)),
|
||||
("postgres", "1_init.sql", include_str!(r#"./migrations/postgres/1_init.sql"#)),
|
||||
("sqlite", "1_fix_sqlx_migration.sql", include_str!(r#"./migrations/sqlite/1_fix_sqlx_migration.sql"#)),
|
||||
("sqlite", "20250109143347_init.sql", include_str!(r#"./migrations/sqlite/20250109143347_init.sql"#)),
|
||||
("sqlite", "20250822104351_rename_blind_message_y_to_b.sql", include_str!(r#"./migrations/sqlite/20250822104351_rename_blind_message_y_to_b.sql"#)),
|
||||
("postgres", "20250822104351_rename_blind_message_y_to_b.sql", include_str!(r#"./migrations/postgres/20250822104351_rename_blind_message_y_to_b.sql"#)),
|
||||
("sqlite", "20250822104351_rename_blind_message_y_to_b.sql", include_str!(r#"./migrations/sqlite/20250822104351_rename_blind_message_y_to_b.sql"#)),
|
||||
];
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/// @generated
|
||||
/// Auto-generated by build.rs
|
||||
pub static MIGRATIONS: &[(&str, &str, &str)] = &[
|
||||
("sqlite", "1_fix_sqlx_migration.sql", include_str!(r#"./migrations/sqlite/1_fix_sqlx_migration.sql"#)),
|
||||
("postgres", "1_initial.sql", include_str!(r#"./migrations/postgres/1_initial.sql"#)),
|
||||
("sqlite", "1_fix_sqlx_migration.sql", include_str!(r#"./migrations/sqlite/1_fix_sqlx_migration.sql"#)),
|
||||
("postgres", "2_remove_request_lookup_kind_constraints.sql", include_str!(r#"./migrations/postgres/2_remove_request_lookup_kind_constraints.sql"#)),
|
||||
("sqlite", "20240612124932_init.sql", include_str!(r#"./migrations/sqlite/20240612124932_init.sql"#)),
|
||||
("sqlite", "20240618195700_quote_state.sql", include_str!(r#"./migrations/sqlite/20240618195700_quote_state.sql"#)),
|
||||
@@ -27,8 +27,8 @@ pub static MIGRATIONS: &[(&str, &str, &str)] = &[
|
||||
("sqlite", "20250706101057_bolt12.sql", include_str!(r#"./migrations/sqlite/20250706101057_bolt12.sql"#)),
|
||||
("sqlite", "20250812132015_drop_melt_request.sql", include_str!(r#"./migrations/sqlite/20250812132015_drop_melt_request.sql"#)),
|
||||
("sqlite", "20250819200000_remove_request_lookup_kind_constraints.sql", include_str!(r#"./migrations/sqlite/20250819200000_remove_request_lookup_kind_constraints.sql"#)),
|
||||
("sqlite", "20250901090000_add_kv_store.sql", include_str!(r#"./migrations/sqlite/20250901090000_add_kv_store.sql"#)),
|
||||
("postgres", "20250901090000_add_kv_store.sql", include_str!(r#"./migrations/postgres/20250901090000_add_kv_store.sql"#)),
|
||||
("sqlite", "20250903200000_add_signatory_amounts.sql", include_str!(r#"./migrations/sqlite/20250903200000_add_signatory_amounts.sql"#)),
|
||||
("sqlite", "20250901090000_add_kv_store.sql", include_str!(r#"./migrations/sqlite/20250901090000_add_kv_store.sql"#)),
|
||||
("postgres", "20250903200000_add_signatory_amounts.sql", include_str!(r#"./migrations/postgres/20250903200000_add_signatory_amounts.sql"#)),
|
||||
("sqlite", "20250903200000_add_signatory_amounts.sql", include_str!(r#"./migrations/sqlite/20250903200000_add_signatory_amounts.sql"#)),
|
||||
];
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/// @generated
|
||||
/// Auto-generated by build.rs
|
||||
pub static MIGRATIONS: &[(&str, &str, &str)] = &[
|
||||
("sqlite", "1_fix_sqlx_migration.sql", include_str!(r#"./migrations/sqlite/1_fix_sqlx_migration.sql"#)),
|
||||
("postgres", "1_initial.sql", include_str!(r#"./migrations/postgres/1_initial.sql"#)),
|
||||
("sqlite", "1_fix_sqlx_migration.sql", include_str!(r#"./migrations/sqlite/1_fix_sqlx_migration.sql"#)),
|
||||
("sqlite", "20240612132920_init.sql", include_str!(r#"./migrations/sqlite/20240612132920_init.sql"#)),
|
||||
("sqlite", "20240618200350_quote_state.sql", include_str!(r#"./migrations/sqlite/20240618200350_quote_state.sql"#)),
|
||||
("sqlite", "20240626091921_nut04_state.sql", include_str!(r#"./migrations/sqlite/20240626091921_nut04_state.sql"#)),
|
||||
@@ -22,6 +22,8 @@ pub static MIGRATIONS: &[(&str, &str, &str)] = &[
|
||||
("sqlite", "20250707093445_bolt12.sql", include_str!(r#"./migrations/sqlite/20250707093445_bolt12.sql"#)),
|
||||
("sqlite", "20250729111701_keyset_v2_u32.sql", include_str!(r#"./migrations/sqlite/20250729111701_keyset_v2_u32.sql"#)),
|
||||
("sqlite", "20250812084621_keyset_plus_one.sql", include_str!(r#"./migrations/sqlite/20250812084621_keyset_plus_one.sql"#)),
|
||||
("sqlite", "20250831215438_melt_quote_method.sql", include_str!(r#"./migrations/sqlite/20250831215438_melt_quote_method.sql"#)),
|
||||
("postgres", "20250831215438_melt_quote_method.sql", include_str!(r#"./migrations/postgres/20250831215438_melt_quote_method.sql"#)),
|
||||
("sqlite", "20250831215438_melt_quote_method.sql", include_str!(r#"./migrations/sqlite/20250831215438_melt_quote_method.sql"#)),
|
||||
("postgres", "20250906200000_add_transaction_quote_id.sql", include_str!(r#"./migrations/postgres/20250906200000_add_transaction_quote_id.sql"#)),
|
||||
("sqlite", "20250906200000_add_transaction_quote_id.sql", include_str!(r#"./migrations/sqlite/20250906200000_add_transaction_quote_id.sql"#)),
|
||||
];
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE transactions ADD COLUMN quote_id TEXT;
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE transactions ADD COLUMN quote_id TEXT;
|
||||
@@ -903,9 +903,9 @@ ON CONFLICT(id) DO UPDATE SET
|
||||
query(
|
||||
r#"
|
||||
INSERT INTO transactions
|
||||
(id, mint_url, direction, unit, amount, fee, ys, timestamp, memo, metadata)
|
||||
(id, mint_url, direction, unit, amount, fee, ys, timestamp, memo, metadata, quote_id)
|
||||
VALUES
|
||||
(:id, :mint_url, :direction, :unit, :amount, :fee, :ys, :timestamp, :memo, :metadata)
|
||||
(:id, :mint_url, :direction, :unit, :amount, :fee, :ys, :timestamp, :memo, :metadata, :quote_id)
|
||||
ON CONFLICT(id) DO UPDATE SET
|
||||
mint_url = excluded.mint_url,
|
||||
direction = excluded.direction,
|
||||
@@ -915,7 +915,8 @@ ON CONFLICT(id) DO UPDATE SET
|
||||
ys = excluded.ys,
|
||||
timestamp = excluded.timestamp,
|
||||
memo = excluded.memo,
|
||||
metadata = excluded.metadata
|
||||
metadata = excluded.metadata,
|
||||
quote_id = excluded.quote_id
|
||||
;
|
||||
"#,
|
||||
)?
|
||||
@@ -932,6 +933,7 @@ ON CONFLICT(id) DO UPDATE SET
|
||||
"metadata",
|
||||
serde_json::to_string(&transaction.metadata).map_err(Error::from)?,
|
||||
)
|
||||
.bind("quote_id", transaction.quote_id)
|
||||
.execute(&*conn)
|
||||
.await?;
|
||||
|
||||
@@ -955,7 +957,8 @@ ON CONFLICT(id) DO UPDATE SET
|
||||
ys,
|
||||
timestamp,
|
||||
memo,
|
||||
metadata
|
||||
metadata,
|
||||
quote_id
|
||||
FROM
|
||||
transactions
|
||||
WHERE
|
||||
@@ -989,7 +992,8 @@ ON CONFLICT(id) DO UPDATE SET
|
||||
ys,
|
||||
timestamp,
|
||||
memo,
|
||||
metadata
|
||||
metadata,
|
||||
quote_id
|
||||
FROM
|
||||
transactions
|
||||
"#,
|
||||
@@ -1226,7 +1230,8 @@ fn sql_row_to_transaction(row: Vec<Column>) -> Result<Transaction, Error> {
|
||||
ys,
|
||||
timestamp,
|
||||
memo,
|
||||
metadata
|
||||
metadata,
|
||||
quote_id
|
||||
) = row
|
||||
);
|
||||
|
||||
@@ -1249,5 +1254,6 @@ fn sql_row_to_transaction(row: Vec<Column>) -> Result<Transaction, Error> {
|
||||
serde_json::from_slice(&v).ok()
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
quote_id: column_as_nullable_string!(quote_id),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user