|
@@ -1,6 +1,7 @@
|
|
|
use std::ops::Deref;
|
|
|
|
|
|
use cdk::nuts::nut06::{MintInfo, MintVersion};
|
|
|
+use cdk::nuts::ContactInfo;
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
|
|
use super::nut01::JsPublicKey;
|
|
@@ -74,7 +75,7 @@ impl JsMintInfo {
|
|
|
version: Option<JsMintVersion>,
|
|
|
description: Option<String>,
|
|
|
description_long: Option<String>,
|
|
|
- contact: JsValue,
|
|
|
+ contact: Option<Vec<JsContactInfo>>,
|
|
|
nuts: JsValue,
|
|
|
motd: Option<String>,
|
|
|
) -> Result<JsMintInfo> {
|
|
@@ -85,7 +86,8 @@ impl JsMintInfo {
|
|
|
version: version.map(|v| v.deref().clone()),
|
|
|
description,
|
|
|
description_long,
|
|
|
- contact: serde_wasm_bindgen::from_value(contact).map_err(into_err)?,
|
|
|
+ contact: contact
|
|
|
+ .map(|contacts| contacts.iter().map(|c| c.deref().clone()).collect()),
|
|
|
nuts: serde_wasm_bindgen::from_value(nuts).map_err(into_err)?,
|
|
|
motd,
|
|
|
},
|
|
@@ -122,10 +124,13 @@ impl JsMintInfo {
|
|
|
self.inner.description_long.clone()
|
|
|
}
|
|
|
|
|
|
- /// Get contact
|
|
|
+ /// Get contact info
|
|
|
#[wasm_bindgen(getter)]
|
|
|
- pub fn contact(&self) -> Result<JsValue> {
|
|
|
- serde_wasm_bindgen::to_value(&self.inner.contact).map_err(into_err)
|
|
|
+ pub fn contact(&self) -> Option<Vec<JsContactInfo>> {
|
|
|
+ self.inner
|
|
|
+ .contact
|
|
|
+ .clone()
|
|
|
+ .map(|c| c.into_iter().map(|c| c.into()).collect())
|
|
|
}
|
|
|
|
|
|
/// Get supported nuts
|
|
@@ -140,3 +145,42 @@ impl JsMintInfo {
|
|
|
self.inner.motd.clone()
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+#[wasm_bindgen(js_name = ContactInfo)]
|
|
|
+pub struct JsContactInfo {
|
|
|
+ inner: ContactInfo,
|
|
|
+}
|
|
|
+
|
|
|
+impl Deref for JsContactInfo {
|
|
|
+ type Target = ContactInfo;
|
|
|
+ fn deref(&self) -> &Self::Target {
|
|
|
+ &self.inner
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+impl From<ContactInfo> for JsContactInfo {
|
|
|
+ fn from(inner: ContactInfo) -> JsContactInfo {
|
|
|
+ JsContactInfo { inner }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+#[wasm_bindgen(js_class = ContactInfo)]
|
|
|
+impl JsContactInfo {
|
|
|
+ #[wasm_bindgen(constructor)]
|
|
|
+ pub fn new(method: String, info: String) -> Result<JsContactInfo> {
|
|
|
+ Ok(JsContactInfo {
|
|
|
+ inner: ContactInfo { method, info },
|
|
|
+ })
|
|
|
+ }
|
|
|
+ /// Method
|
|
|
+ #[wasm_bindgen(getter)]
|
|
|
+ pub fn method(&self) -> String {
|
|
|
+ self.inner.method.clone()
|
|
|
+ }
|
|
|
+
|
|
|
+ /// Info
|
|
|
+ #[wasm_bindgen(getter)]
|
|
|
+ pub fn info(&self) -> String {
|
|
|
+ self.inner.info.clone()
|
|
|
+ }
|
|
|
+}
|