Skip to content

Commit

Permalink
improve: 'cashu-sdk-js' use gloo client
Browse files Browse the repository at this point in the history
  • Loading branch information
thesimplekid committed Nov 12, 2023
1 parent 2f5d220 commit 0cec20a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 157 deletions.
2 changes: 2 additions & 0 deletions bindings/cashu-js/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
target = "wasm32-unknown-unknown"
2 changes: 2 additions & 0 deletions bindings/cashu-sdk-js/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
target = "wasm32-unknown-unknown"
148 changes: 0 additions & 148 deletions bindings/cashu-sdk-js/src/client.rs

This file was deleted.

2 changes: 0 additions & 2 deletions bindings/cashu-sdk-js/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
mod client;
mod error;
mod mint;
mod types;
mod wallet;

pub use client::JsClient;
pub use mint::JsMint;
pub use wallet::JsWallet;
15 changes: 8 additions & 7 deletions bindings/cashu-sdk-js/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,38 @@ use cashu_js::nuts::nut03::JsRequestMintResponse;
#[cfg(feature = "nut07")]
use cashu_js::JsProofsStatus;
use cashu_js::{JsAmount, JsBolt11Invoice};
use cashu_sdk::client::gloo_client::HttpClient;
use cashu_sdk::wallet::Wallet;
use wasm_bindgen::prelude::*;

use crate::error::{into_err, Result};
use crate::types::{JsMelted, JsSendProofs};
use crate::JsClient;

#[wasm_bindgen(js_name = Wallet)]
pub struct JsWallet {
inner: Wallet,
inner: Wallet<HttpClient>,
}

impl Deref for JsWallet {
type Target = Wallet;
type Target = Wallet<HttpClient>;
fn deref(&self) -> &Self::Target {
&self.inner
}
}

impl From<Wallet> for JsWallet {
fn from(inner: Wallet) -> JsWallet {
impl From<Wallet<HttpClient>> for JsWallet {
fn from(inner: Wallet<HttpClient>) -> JsWallet {
JsWallet { inner }
}
}

#[wasm_bindgen(js_class = Wallet)]
impl JsWallet {
#[wasm_bindgen(constructor)]
pub fn new(client: JsClient, mint_keys: JsKeys) -> JsWallet {
pub fn new(mint_url: String, mint_keys: JsKeys) -> JsWallet {
let client = HttpClient {};
JsWallet {
inner: Wallet::new(client.deref().clone(), mint_keys.deref().clone()),
inner: Wallet::new(client, mint_url.into(), mint_keys.deref().clone()),
}
}

Expand Down

0 comments on commit 0cec20a

Please sign in to comment.