diff --git a/bindings/cdk-js/src/nuts/nut06.rs b/bindings/cdk-js/src/nuts/nut06.rs index dbbb1912..0f5c8888 100644 --- a/bindings/cdk-js/src/nuts/nut06.rs +++ b/bindings/cdk-js/src/nuts/nut06.rs @@ -78,6 +78,7 @@ impl JsMintInfo { contact: Option>, nuts: JsValue, icon_url: Option, + urls: Option>, motd: Option, time: Option, ) -> Result { @@ -92,6 +93,7 @@ impl JsMintInfo { .map(|contacts| contacts.iter().map(|c| c.deref().clone()).collect()), nuts: serde_wasm_bindgen::from_value(nuts).map_err(into_err)?, icon_url, + urls, motd, time, }, diff --git a/crates/cdk-sqlite/src/wallet/migrations/20241011125207_mint_urls.sql b/crates/cdk-sqlite/src/wallet/migrations/20241011125207_mint_urls.sql new file mode 100644 index 00000000..0be88e8f --- /dev/null +++ b/crates/cdk-sqlite/src/wallet/migrations/20241011125207_mint_urls.sql @@ -0,0 +1 @@ +ALTER TABLE mint ADD urls TEXT; diff --git a/crates/cdk-sqlite/src/wallet/mod.rs b/crates/cdk-sqlite/src/wallet/mod.rs index f45c6bb4..0decfac3 100644 --- a/crates/cdk-sqlite/src/wallet/mod.rs +++ b/crates/cdk-sqlite/src/wallet/mod.rs @@ -91,6 +91,7 @@ impl WalletDatabase for WalletSqliteDatabase { contact, nuts, icon_url, + urls, motd, time, ) = match mint_info { @@ -104,6 +105,7 @@ impl WalletDatabase for WalletSqliteDatabase { contact, nuts, icon_url, + urls, motd, time, } = mint_info; @@ -117,18 +119,21 @@ impl WalletDatabase for WalletSqliteDatabase { contact.map(|c| serde_json::to_string(&c).ok()), serde_json::to_string(&nuts).ok(), icon_url, + urls.map(|c| serde_json::to_string(&c).ok()), motd, time, ) } - None => (None, None, None, None, None, None, None, None, None, None), + None => ( + None, None, None, None, None, None, None, None, None, None, None, + ), }; sqlx::query( r#" INSERT OR REPLACE INTO mint -(mint_url, name, pubkey, version, description, description_long, contact, nuts, icon_url, motd, mint_time) -VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); +(mint_url, name, pubkey, version, description, description_long, contact, nuts, icon_url, urls, motd, mint_time) +VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); "#, ) .bind(mint_url.to_string()) @@ -140,6 +145,7 @@ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); .bind(contact) .bind(nuts) .bind(icon_url) + .bind(urls) .bind(motd) .bind(time.map(|v| v as i64)) .execute(&self.pool) @@ -775,6 +781,7 @@ fn sqlite_row_to_mint_info(row: &SqliteRow) -> Result { let row_nuts: Option = row.try_get("nuts").map_err(Error::from)?; let icon_url: Option = row.try_get("icon_url").map_err(Error::from)?; let motd: Option = row.try_get("motd").map_err(Error::from)?; + let row_urls: Option = row.try_get("urls").map_err(Error::from)?; let time: Option = row.try_get("mint_time").map_err(Error::from)?; Ok(MintInfo { @@ -788,6 +795,7 @@ fn sqlite_row_to_mint_info(row: &SqliteRow) -> Result { .and_then(|n| serde_json::from_str(&n).ok()) .unwrap_or_default(), icon_url, + urls: row_urls.and_then(|c| serde_json::from_str(&c).ok()), motd, time: time.map(|t| t as u64), }) diff --git a/crates/cdk/src/nuts/nut06.rs b/crates/cdk/src/nuts/nut06.rs index e2d4465f..5b22bc2b 100644 --- a/crates/cdk/src/nuts/nut06.rs +++ b/crates/cdk/src/nuts/nut06.rs @@ -76,6 +76,9 @@ pub struct MintInfo { /// Mint's icon URL #[serde(skip_serializing_if = "Option::is_none")] pub icon_url: Option, + /// Mint's endpoint URLs + #[serde(skip_serializing_if = "Option::is_none")] + pub urls: Option>, /// message of the day that the wallet must display to the user #[serde(skip_serializing_if = "Option::is_none")] pub motd: Option,