nut06: mint_icon_url -> icon_url

This commit is contained in:
Pavol Rusnak
2024-09-02 17:16:29 +02:00
committed by thesimplekid
parent e67dc15ce6
commit 5a14ddbc67
7 changed files with 21 additions and 20 deletions

View File

@@ -77,7 +77,7 @@ impl JsMintInfo {
description_long: Option<String>, description_long: Option<String>,
contact: Option<Vec<JsContactInfo>>, contact: Option<Vec<JsContactInfo>>,
nuts: JsValue, nuts: JsValue,
mint_icon_url: Option<String>, icon_url: Option<String>,
motd: Option<String>, motd: Option<String>,
time: Option<u64>, time: Option<u64>,
) -> Result<JsMintInfo> { ) -> Result<JsMintInfo> {
@@ -91,7 +91,7 @@ impl JsMintInfo {
contact: contact contact: contact
.map(|contacts| contacts.iter().map(|c| c.deref().clone()).collect()), .map(|contacts| contacts.iter().map(|c| c.deref().clone()).collect()),
nuts: serde_wasm_bindgen::from_value(nuts).map_err(into_err)?, nuts: serde_wasm_bindgen::from_value(nuts).map_err(into_err)?,
mint_icon_url, icon_url,
motd, motd,
time, time,
}, },
@@ -145,8 +145,8 @@ impl JsMintInfo {
/// Get mint icon url /// Get mint icon url
#[wasm_bindgen(getter)] #[wasm_bindgen(getter)]
pub fn mint_icon_url(&self) -> Option<String> { pub fn icon_url(&self) -> Option<String> {
self.inner.mint_icon_url.clone() self.inner.icon_url.clone()
} }
/// Get motd /// Get motd

View File

@@ -14,7 +14,7 @@ mnemonic = ""
# description = "These are not real sats for testing only" # description = "These are not real sats for testing only"
# description_long = "A longer mint for testing" # description_long = "A longer mint for testing"
# motd = "Hello world" # motd = "Hello world"
# mint_icon_url = "https://this-is-a-mint-icon-url.com/icon.png" # icon_url = "https://this-is-a-mint-icon-url.com/icon.png"
# contact_email = "hello@cashu.me" # contact_email = "hello@cashu.me"
# Nostr pubkey of mint (Hex) # Nostr pubkey of mint (Hex)
# contact_nostr_public_key = "" # contact_nostr_public_key = ""

View File

@@ -117,7 +117,7 @@ pub struct MintInfo {
/// long description /// long description
pub description_long: Option<String>, pub description_long: Option<String>,
/// url to the mint icon /// url to the mint icon
pub mint_icon_url: Option<String>, pub icon_url: Option<String>,
/// message of the day that the wallet must display to the user /// message of the day that the wallet must display to the user
pub motd: Option<String>, pub motd: Option<String>,
/// Nostr publickey /// Nostr publickey

View File

@@ -407,8 +407,8 @@ async fn main() -> anyhow::Result<()> {
mint_info = mint_info.pubkey(pubkey); mint_info = mint_info.pubkey(pubkey);
} }
if let Some(mint_icon_url) = &settings.mint_info.mint_icon_url { if let Some(icon_url) = &settings.mint_info.icon_url {
mint_info = mint_info.mint_icon_url(mint_icon_url); mint_info = mint_info.icon_url(icon_url);
} }
if let Some(motd) = settings.mint_info.motd { if let Some(motd) = settings.mint_info.motd {

View File

@@ -0,0 +1 @@
ALTER TABLE mint RENAME COLUMN mint_icon_url TO icon_url;

View File

@@ -90,7 +90,7 @@ impl WalletDatabase for WalletSqliteDatabase {
description_long, description_long,
contact, contact,
nuts, nuts,
mint_icon_url, icon_url,
motd, motd,
time, time,
) = match mint_info { ) = match mint_info {
@@ -103,7 +103,7 @@ impl WalletDatabase for WalletSqliteDatabase {
description_long, description_long,
contact, contact,
nuts, nuts,
mint_icon_url, icon_url,
motd, motd,
time, time,
} = mint_info; } = mint_info;
@@ -116,7 +116,7 @@ impl WalletDatabase for WalletSqliteDatabase {
description_long, description_long,
contact.map(|c| serde_json::to_string(&c).ok()), contact.map(|c| serde_json::to_string(&c).ok()),
serde_json::to_string(&nuts).ok(), serde_json::to_string(&nuts).ok(),
mint_icon_url, icon_url,
motd, motd,
time, time,
) )
@@ -127,7 +127,7 @@ impl WalletDatabase for WalletSqliteDatabase {
sqlx::query( sqlx::query(
r#" r#"
INSERT OR REPLACE INTO mint INSERT OR REPLACE INTO mint
(mint_url, name, pubkey, version, description, description_long, contact, nuts, mint_icon_url, motd, mint_time) (mint_url, name, pubkey, version, description, description_long, contact, nuts, icon_url, motd, mint_time)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
"#, "#,
) )
@@ -139,7 +139,7 @@ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
.bind(description_long) .bind(description_long)
.bind(contact) .bind(contact)
.bind(nuts) .bind(nuts)
.bind(mint_icon_url) .bind(icon_url)
.bind(motd) .bind(motd)
.bind(time.map(|v| v as i64)) .bind(time.map(|v| v as i64))
.execute(&self.pool) .execute(&self.pool)
@@ -773,7 +773,7 @@ fn sqlite_row_to_mint_info(row: &SqliteRow) -> Result<MintInfo, Error> {
let description_long: Option<String> = row.try_get("description_long").map_err(Error::from)?; let description_long: Option<String> = row.try_get("description_long").map_err(Error::from)?;
let row_contact: Option<String> = row.try_get("contact").map_err(Error::from)?; let row_contact: Option<String> = row.try_get("contact").map_err(Error::from)?;
let row_nuts: Option<String> = row.try_get("nuts").map_err(Error::from)?; let row_nuts: Option<String> = row.try_get("nuts").map_err(Error::from)?;
let mint_icon_url: Option<String> = row.try_get("mint_icon_url").map_err(Error::from)?; let icon_url: Option<String> = row.try_get("icon_url").map_err(Error::from)?;
let motd: Option<String> = row.try_get("motd").map_err(Error::from)?; let motd: Option<String> = row.try_get("motd").map_err(Error::from)?;
let time: Option<i64> = row.try_get("mint_time").map_err(Error::from)?; let time: Option<i64> = row.try_get("mint_time").map_err(Error::from)?;
@@ -787,7 +787,7 @@ fn sqlite_row_to_mint_info(row: &SqliteRow) -> Result<MintInfo, Error> {
nuts: row_nuts nuts: row_nuts
.and_then(|n| serde_json::from_str(&n).ok()) .and_then(|n| serde_json::from_str(&n).ok())
.unwrap_or_default(), .unwrap_or_default(),
mint_icon_url, icon_url,
motd, motd,
time: time.map(|t| t as u64), time: time.map(|t| t as u64),
}) })

View File

@@ -75,7 +75,7 @@ pub struct MintInfo {
pub nuts: Nuts, pub nuts: Nuts,
/// Mint's icon URL /// Mint's icon URL
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub mint_icon_url: Option<String>, pub icon_url: Option<String>,
/// message of the day that the wallet must display to the user /// message of the day that the wallet must display to the user
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub motd: Option<String>, pub motd: Option<String>,
@@ -153,12 +153,12 @@ impl MintInfo {
} }
/// Set mint icon url /// Set mint icon url
pub fn mint_icon_url<S>(self, mint_icon_url: S) -> Self pub fn icon_url<S>(self, icon_url: S) -> Self
where where
S: Into<String>, S: Into<String>,
{ {
Self { Self {
mint_icon_url: Some(mint_icon_url.into()), icon_url: Some(icon_url.into()),
..self ..self
} }
} }
@@ -417,7 +417,7 @@ mod tests {
} }
], ],
"motd": "Message to display to users.", "motd": "Message to display to users.",
"mint_icon_url": "https://this-is-a-mint-icon-url.com/icon.png", "icon_url": "https://this-is-a-mint-icon-url.com/icon.png",
"nuts": { "nuts": {
"4": { "4": {
"methods": [ "methods": [
@@ -460,7 +460,7 @@ mod tests {
["email", "contact@me.com"] ["email", "contact@me.com"]
], ],
"motd": "Message to display to users.", "motd": "Message to display to users.",
"mint_icon_url": "https://this-is-a-mint-icon-url.com/icon.png", "icon_url": "https://this-is-a-mint-icon-url.com/icon.png",
"nuts": { "nuts": {
"4": { "4": {
"methods": [ "methods": [