mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-25 00:24:57 +01:00
feat: mint and melt quote getters
This commit is contained in:
@@ -78,7 +78,7 @@ impl JsMintBolt11Request {
|
||||
}
|
||||
|
||||
#[wasm_bindgen(js_name = totalAmount)]
|
||||
pub fn totoal_amount(&self) -> JsAmount {
|
||||
pub fn total_amount(&self) -> JsAmount {
|
||||
self.inner.total_amount().into()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ impl From<MeltQuoteBolt11Response> for JsMeltQuoteBolt11Response {
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen(js_name = MintBolt11Request)]
|
||||
#[wasm_bindgen(js_name = MeltBolt11Request)]
|
||||
pub struct JsMeltBolt11Request {
|
||||
inner: MeltBolt11Request,
|
||||
}
|
||||
@@ -96,7 +96,7 @@ impl From<MeltMethodSettings> for JsMeltMethodSettings {
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen(js_name = Settings)]
|
||||
#[wasm_bindgen(js_name = Nut05Settings)]
|
||||
pub struct JsSettings {
|
||||
inner: NUT05Settings,
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ impl From<SecretData> for JsSecretData {
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen(js_name = Secret)]
|
||||
#[wasm_bindgen(js_name = Nut10Secret)]
|
||||
pub struct JsNut10Secret {
|
||||
inner: Nut10Secret,
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ impl From<u64> for JsAmount {
|
||||
#[wasm_bindgen(js_class = Amount)]
|
||||
impl JsAmount {
|
||||
#[wasm_bindgen(constructor)]
|
||||
pub fn new(sats: u32) -> Self {
|
||||
pub fn new(sats: u64) -> Self {
|
||||
Self {
|
||||
inner: Amount::from(sats as u64),
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ use std::ops::Deref;
|
||||
use cdk::types::MeltQuote;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
use crate::nuts::JsCurrencyUnit;
|
||||
use crate::types::JsAmount;
|
||||
|
||||
#[wasm_bindgen(js_name = MeltQuote)]
|
||||
pub struct JsMeltQuote {
|
||||
inner: MeltQuote,
|
||||
@@ -20,3 +23,41 @@ impl From<MeltQuote> for JsMeltQuote {
|
||||
JsMeltQuote { inner }
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen(js_class = MeltQuote)]
|
||||
impl JsMeltQuote {
|
||||
#[wasm_bindgen(getter)]
|
||||
pub fn id(&self) -> String {
|
||||
self.inner.id.clone()
|
||||
}
|
||||
|
||||
#[wasm_bindgen(getter)]
|
||||
pub fn unit(&self) -> JsCurrencyUnit {
|
||||
self.inner.unit.clone().into()
|
||||
}
|
||||
|
||||
#[wasm_bindgen(getter)]
|
||||
pub fn amount(&self) -> JsAmount {
|
||||
self.inner.amount.into()
|
||||
}
|
||||
|
||||
#[wasm_bindgen(getter)]
|
||||
pub fn request(&self) -> String {
|
||||
self.inner.request.clone()
|
||||
}
|
||||
|
||||
#[wasm_bindgen(getter)]
|
||||
pub fn fee_reserve(&self) -> JsAmount {
|
||||
self.inner.fee_reserve.into()
|
||||
}
|
||||
|
||||
#[wasm_bindgen(getter)]
|
||||
pub fn paid(&self) -> bool {
|
||||
self.inner.paid
|
||||
}
|
||||
|
||||
#[wasm_bindgen(getter)]
|
||||
pub fn expiry(&self) -> u64 {
|
||||
self.inner.expiry
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ use std::ops::Deref;
|
||||
use cdk::types::MintQuote;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
use crate::nuts::JsCurrencyUnit;
|
||||
use crate::types::JsAmount;
|
||||
|
||||
#[wasm_bindgen(js_name = MintQuote)]
|
||||
pub struct JsMintQuote {
|
||||
inner: MintQuote,
|
||||
@@ -20,3 +23,36 @@ impl From<MintQuote> for JsMintQuote {
|
||||
JsMintQuote { inner }
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen(js_class = MintQuote)]
|
||||
impl JsMintQuote {
|
||||
#[wasm_bindgen(getter)]
|
||||
pub fn id(&self) -> String {
|
||||
self.inner.id.clone()
|
||||
}
|
||||
|
||||
#[wasm_bindgen(getter)]
|
||||
pub fn unit(&self) -> JsCurrencyUnit {
|
||||
self.inner.unit.clone().into()
|
||||
}
|
||||
|
||||
#[wasm_bindgen(getter)]
|
||||
pub fn amount(&self) -> JsAmount {
|
||||
self.inner.amount.into()
|
||||
}
|
||||
|
||||
#[wasm_bindgen(getter)]
|
||||
pub fn request(&self) -> String {
|
||||
self.inner.request.clone()
|
||||
}
|
||||
|
||||
#[wasm_bindgen(getter)]
|
||||
pub fn paid(&self) -> bool {
|
||||
self.inner.paid
|
||||
}
|
||||
|
||||
#[wasm_bindgen(getter)]
|
||||
pub fn expiry(&self) -> u64 {
|
||||
self.inner.expiry
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,13 +75,13 @@ impl JsWallet {
|
||||
pub async fn mint_quote(
|
||||
&mut self,
|
||||
mint_url: String,
|
||||
amount: JsAmount,
|
||||
amount: u64,
|
||||
unit: JsCurrencyUnit,
|
||||
) -> Result<JsMintQuote> {
|
||||
let mint_url = UncheckedUrl::from_str(&mint_url).map_err(into_err)?;
|
||||
let quote = self
|
||||
.inner
|
||||
.mint_quote(mint_url, *amount.deref(), unit.into())
|
||||
.mint_quote(mint_url, amount.into(), unit.into())
|
||||
.await
|
||||
.map_err(into_err)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user