mirror of
https://github.com/aljazceru/cdk.git
synced 2026-02-11 16:16:14 +01:00
bindings/cashu-js nut03
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
mod nut00;
|
||||
mod nut01;
|
||||
mod nut02;
|
||||
mod nut03;
|
||||
|
||||
49
bindings/cashu-js/src/nuts/nut03.rs
Normal file
49
bindings/cashu-js/src/nuts/nut03.rs
Normal file
@@ -0,0 +1,49 @@
|
||||
use std::ops::Deref;
|
||||
|
||||
use cashu::nuts::nut03::RequestMintResponse;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
use crate::types::JsBolt11Invoice;
|
||||
|
||||
#[wasm_bindgen(js_name = RequestMintResponse)]
|
||||
pub struct JsRequestMintResponse {
|
||||
inner: RequestMintResponse,
|
||||
}
|
||||
|
||||
impl Deref for JsRequestMintResponse {
|
||||
type Target = RequestMintResponse;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.inner
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RequestMintResponse> for JsRequestMintResponse {
|
||||
fn from(inner: RequestMintResponse) -> JsRequestMintResponse {
|
||||
JsRequestMintResponse { inner }
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen(js_class = RequestMintResponse)]
|
||||
impl JsRequestMintResponse {
|
||||
#[wasm_bindgen(constructor)]
|
||||
pub fn new(pr: JsBolt11Invoice, hash: String) -> JsRequestMintResponse {
|
||||
JsRequestMintResponse {
|
||||
inner: RequestMintResponse {
|
||||
pr: pr.deref().clone(),
|
||||
hash,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Get Bolt11 Invoice
|
||||
#[wasm_bindgen(getter)]
|
||||
pub fn invoice(&self) -> JsBolt11Invoice {
|
||||
self.inner.pr.clone().into()
|
||||
}
|
||||
|
||||
/// Get Hash
|
||||
#[wasm_bindgen(getter)]
|
||||
pub fn hash(&self) -> String {
|
||||
self.inner.hash.to_string()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user