Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nut06: mint_icon_url -> icon_url #312

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bindings/cdk-js/src/nuts/nut06.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl JsMintInfo {
description_long: Option<String>,
contact: Option<Vec<JsContactInfo>>,
nuts: JsValue,
mint_icon_url: Option<String>,
icon_url: Option<String>,
motd: Option<String>,
time: Option<u64>,
) -> Result<JsMintInfo> {
Expand All @@ -91,7 +91,7 @@ impl JsMintInfo {
contact: contact
.map(|contacts| contacts.iter().map(|c| c.deref().clone()).collect()),
nuts: serde_wasm_bindgen::from_value(nuts).map_err(into_err)?,
mint_icon_url,
icon_url,
motd,
time,
},
Expand Down Expand Up @@ -145,8 +145,8 @@ impl JsMintInfo {

/// Get mint icon url
#[wasm_bindgen(getter)]
pub fn mint_icon_url(&self) -> Option<String> {
self.inner.mint_icon_url.clone()
pub fn icon_url(&self) -> Option<String> {
self.inner.icon_url.clone()
}

/// Get motd
Expand Down
2 changes: 1 addition & 1 deletion crates/cdk-mintd/example.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ mnemonic = ""
# description = "These are not real sats for testing only"
# description_long = "A longer mint for testing"
# 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 = "[email protected]"
# Nostr pubkey of mint (Hex)
# contact_nostr_public_key = ""
Expand Down
2 changes: 1 addition & 1 deletion crates/cdk-mintd/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub struct MintInfo {
/// long description
pub description_long: Option<String>,
/// 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
pub motd: Option<String>,
/// Nostr publickey
Expand Down
4 changes: 2 additions & 2 deletions crates/cdk-mintd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ async fn main() -> anyhow::Result<()> {
mint_info = mint_info.pubkey(pubkey);
}

if let Some(mint_icon_url) = &settings.mint_info.mint_icon_url {
mint_info = mint_info.mint_icon_url(mint_icon_url);
if let Some(icon_url) = &settings.mint_info.icon_url {
mint_info = mint_info.icon_url(icon_url);
}

if let Some(motd) = settings.mint_info.motd {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE mint RENAME COLUMN mint_icon_url TO icon_url;
14 changes: 7 additions & 7 deletions crates/cdk-sqlite/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl WalletDatabase for WalletSqliteDatabase {
description_long,
contact,
nuts,
mint_icon_url,
icon_url,
motd,
time,
) = match mint_info {
Expand All @@ -103,7 +103,7 @@ impl WalletDatabase for WalletSqliteDatabase {
description_long,
contact,
nuts,
mint_icon_url,
icon_url,
motd,
time,
} = mint_info;
Expand All @@ -116,7 +116,7 @@ impl WalletDatabase for WalletSqliteDatabase {
description_long,
contact.map(|c| serde_json::to_string(&c).ok()),
serde_json::to_string(&nuts).ok(),
mint_icon_url,
icon_url,
motd,
time,
)
Expand All @@ -127,7 +127,7 @@ impl WalletDatabase for WalletSqliteDatabase {
sqlx::query(
r#"
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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
"#,
)
Expand All @@ -139,7 +139,7 @@ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
.bind(description_long)
.bind(contact)
.bind(nuts)
.bind(mint_icon_url)
.bind(icon_url)
.bind(motd)
.bind(time.map(|v| v as i64))
.execute(&self.pool)
Expand Down Expand Up @@ -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 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 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 time: Option<i64> = row.try_get("mint_time").map_err(Error::from)?;

Expand All @@ -787,7 +787,7 @@ fn sqlite_row_to_mint_info(row: &SqliteRow) -> Result<MintInfo, Error> {
nuts: row_nuts
.and_then(|n| serde_json::from_str(&n).ok())
.unwrap_or_default(),
mint_icon_url,
icon_url,
motd,
time: time.map(|t| t as u64),
})
Expand Down
10 changes: 5 additions & 5 deletions crates/cdk/src/nuts/nut06.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub struct MintInfo {
pub nuts: Nuts,
/// Mint's icon URL
#[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
#[serde(skip_serializing_if = "Option::is_none")]
pub motd: Option<String>,
Expand Down Expand Up @@ -153,12 +153,12 @@ impl MintInfo {
}

/// 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
S: Into<String>,
{
Self {
mint_icon_url: Some(mint_icon_url.into()),
icon_url: Some(icon_url.into()),
..self
}
}
Expand Down Expand Up @@ -417,7 +417,7 @@ mod tests {
}
],
"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": {
"4": {
"methods": [
Expand Down Expand Up @@ -460,7 +460,7 @@ mod tests {
["email", "[email protected]"]
],
"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": {
"4": {
"methods": [
Expand Down
Loading