Răsfoiți Sursa

improve: add gloo feature
fix: clippy warning
fix: melted getter for preimage was named wrong

thesimplekid 1 an în urmă
părinte
comite
bb8e573b6f

+ 1 - 1
bindings/cashu-sdk-js/Cargo.toml

@@ -14,7 +14,7 @@ crate-type = ["cdylib", "rlib"]
 default = ["console_error_panic_hook"]
 
 [dependencies]
-cashu-sdk = { path = "../../crates/cashu-sdk" }
+cashu-sdk = { path = "../../crates/cashu-sdk", features = ["all-nuts", "gloo"] }
 cashu-js = { path = "../cashu-js" }
 wasm-bindgen = "0.2.84"
 js-sys = "0.3.64"

+ 2 - 2
bindings/cashu-sdk-js/src/types/melted.rs

@@ -39,14 +39,14 @@ impl JsMelted {
 
     /// Get Preimage
     #[wasm_bindgen(getter)]
-    pub fn from_sat(&self) -> Option<String> {
+    pub fn preimage(&self) -> Option<String> {
         self.inner.preimage.clone()
     }
 
     /// Get Paid
     #[wasm_bindgen(getter)]
     pub fn paid(&self) -> bool {
-        self.inner.paid.clone()
+        self.inner.paid
     }
 
     /// Get Change

+ 1 - 5
bindings/cashu-sdk-js/src/wallet.rs

@@ -162,10 +162,6 @@ impl JsWallet {
     pub fn proofs_to_token(&self, proofs: JsValue, memo: Option<String>) -> Result<String> {
         let proofs = serde_wasm_bindgen::from_value(proofs).map_err(into_err)?;
 
-        Ok(self
-            .inner
-            .proofs_to_token(proofs, memo)
-            .map_err(into_err)?
-            .into())
+        self.inner.proofs_to_token(proofs, memo).map_err(into_err)
     }
 }

+ 2 - 1
crates/cashu-sdk/Cargo.toml

@@ -13,6 +13,7 @@ license.workspace = true
 default = ["mint", "wallet"]
 mint = ["cashu/mint"]
 wallet = ["cashu/wallet", "dep:minreq", "dep:once_cell"]
+gloo = ["dep:gloo"]
 all-nuts = ["nut07", "nut09"]
 nut07 = ["cashu/nut07"]
 # nut08 = ["cashu/nut08"]
@@ -29,6 +30,7 @@ futures-util = { version = "0.3", default-features = false, features = ["sink",
 once_cell = { version = "1.17", optional = true }
 thiserror = { workspace = true }
 async-trait = "0.1.74"
+gloo = { version = "0.10.0", optional = true, features = ["net"]}
 
 [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
 tokio = { workspace = true, features = ["rt-multi-thread", "time", "macros", "sync"] }
@@ -36,7 +38,6 @@ minreq = { version = "2.7.0", optional = true, features = ["json-using-serde", "
 
 [target.'cfg(target_arch = "wasm32")'.dependencies]
 tokio = { workspace = true, features = ["rt", "macros", "sync", "time"] }
-gloo = { version = "0.10.0", features = ["net"]}
 
 
 

+ 2 - 2
crates/cashu-sdk/src/client/mod.rs

@@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize};
 use thiserror::Error;
 use url::Url;
 
-#[cfg(target_arch = "wasm32")]
+#[cfg(feature = "gloo")]
 pub mod gloo_client;
 #[cfg(not(target_arch = "wasm32"))]
 pub mod minreq_client;
@@ -45,7 +45,7 @@ pub enum Error {
     #[cfg(not(target_arch = "wasm32"))]
     #[error("`{0}`")]
     MinReq(#[from] minreq::Error),
-    #[cfg(target_arch = "wasm32")]
+    #[cfg(feature = "gloo")]
     #[error("`{0}`")]
     Gloo(String),
     /// Custom Error