mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-19 13:44:55 +01:00
NUT-06: add urls field
This commit is contained in:
@@ -78,6 +78,7 @@ impl JsMintInfo {
|
|||||||
contact: Option<Vec<JsContactInfo>>,
|
contact: Option<Vec<JsContactInfo>>,
|
||||||
nuts: JsValue,
|
nuts: JsValue,
|
||||||
icon_url: Option<String>,
|
icon_url: Option<String>,
|
||||||
|
urls: Option<Vec<String>>,
|
||||||
motd: Option<String>,
|
motd: Option<String>,
|
||||||
time: Option<u64>,
|
time: Option<u64>,
|
||||||
) -> Result<JsMintInfo> {
|
) -> Result<JsMintInfo> {
|
||||||
@@ -92,6 +93,7 @@ impl JsMintInfo {
|
|||||||
.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)?,
|
||||||
icon_url,
|
icon_url,
|
||||||
|
urls,
|
||||||
motd,
|
motd,
|
||||||
time,
|
time,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE mint ADD urls TEXT;
|
||||||
@@ -91,6 +91,7 @@ impl WalletDatabase for WalletSqliteDatabase {
|
|||||||
contact,
|
contact,
|
||||||
nuts,
|
nuts,
|
||||||
icon_url,
|
icon_url,
|
||||||
|
urls,
|
||||||
motd,
|
motd,
|
||||||
time,
|
time,
|
||||||
) = match mint_info {
|
) = match mint_info {
|
||||||
@@ -104,6 +105,7 @@ impl WalletDatabase for WalletSqliteDatabase {
|
|||||||
contact,
|
contact,
|
||||||
nuts,
|
nuts,
|
||||||
icon_url,
|
icon_url,
|
||||||
|
urls,
|
||||||
motd,
|
motd,
|
||||||
time,
|
time,
|
||||||
} = mint_info;
|
} = mint_info;
|
||||||
@@ -117,18 +119,21 @@ impl WalletDatabase for WalletSqliteDatabase {
|
|||||||
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(),
|
||||||
icon_url,
|
icon_url,
|
||||||
|
urls.map(|c| serde_json::to_string(&c).ok()),
|
||||||
motd,
|
motd,
|
||||||
time,
|
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(
|
sqlx::query(
|
||||||
r#"
|
r#"
|
||||||
INSERT OR REPLACE INTO mint
|
INSERT OR REPLACE INTO mint
|
||||||
(mint_url, name, pubkey, version, description, description_long, contact, nuts, icon_url, motd, mint_time)
|
(mint_url, name, pubkey, version, description, description_long, contact, nuts, icon_url, urls, motd, mint_time)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
.bind(mint_url.to_string())
|
.bind(mint_url.to_string())
|
||||||
@@ -140,6 +145,7 @@ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
|
|||||||
.bind(contact)
|
.bind(contact)
|
||||||
.bind(nuts)
|
.bind(nuts)
|
||||||
.bind(icon_url)
|
.bind(icon_url)
|
||||||
|
.bind(urls)
|
||||||
.bind(motd)
|
.bind(motd)
|
||||||
.bind(time.map(|v| v as i64))
|
.bind(time.map(|v| v as i64))
|
||||||
.execute(&self.pool)
|
.execute(&self.pool)
|
||||||
@@ -775,6 +781,7 @@ fn sqlite_row_to_mint_info(row: &SqliteRow) -> Result<MintInfo, Error> {
|
|||||||
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 icon_url: Option<String> = row.try_get("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 row_urls: Option<String> = row.try_get("urls").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)?;
|
||||||
|
|
||||||
Ok(MintInfo {
|
Ok(MintInfo {
|
||||||
@@ -788,6 +795,7 @@ fn sqlite_row_to_mint_info(row: &SqliteRow) -> Result<MintInfo, Error> {
|
|||||||
.and_then(|n| serde_json::from_str(&n).ok())
|
.and_then(|n| serde_json::from_str(&n).ok())
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
icon_url,
|
icon_url,
|
||||||
|
urls: row_urls.and_then(|c| serde_json::from_str(&c).ok()),
|
||||||
motd,
|
motd,
|
||||||
time: time.map(|t| t as u64),
|
time: time.map(|t| t as u64),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -76,6 +76,9 @@ pub struct MintInfo {
|
|||||||
/// Mint's icon URL
|
/// Mint's icon URL
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub icon_url: Option<String>,
|
pub icon_url: Option<String>,
|
||||||
|
/// Mint's endpoint URLs
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub urls: Option<Vec<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>,
|
||||||
|
|||||||
Reference in New Issue
Block a user