improve: export nut structs, add nut08

This commit is contained in:
thesimplekid
2023-11-16 20:17:29 +00:00
parent e1264d3ee0
commit 3f6e7bfdd5
15 changed files with 68 additions and 53 deletions

View File

@@ -1,7 +1,7 @@
use std::ops::Deref;
use std::sync::Arc;
use cashu::nuts::nut00::BlindedMessage as BlindedMessageSdk;
use cashu::nuts::BlindedMessage as BlindedMessageSdk;
use crate::nuts::nut01::public_key::PublicKey;
use crate::Amount;

View File

@@ -2,7 +2,7 @@ use std::collections::HashMap;
use std::ops::Deref;
use std::sync::Arc;
use cashu::nuts::nut01::{Keys as KeysSdk, Response as KeysResponseSdk};
use cashu::nuts::nut01::{Keys as KeysSdk, KeysResponse as KeysResponseSdk};
use cashu::Amount as AmountSdk;
use crate::{Amount, PublicKey};

View File

@@ -1,7 +1,7 @@
use std::ops::Deref;
use std::sync::Arc;
use cashu::nuts::nut02::{Id as IdSdk, KeySet as KeySetSdk, Response};
use cashu::nuts::nut02::{Id as IdSdk, KeySet as KeySetSdk, KeysetResponse as KeysetResponseSdk};
use crate::error::Result;
use crate::nuts::nut01::keys::Keys;
@@ -73,14 +73,14 @@ impl From<cashu::nuts::nut02::KeySet> for KeySet {
}
pub struct KeySetResponse {
inner: Response,
inner: KeysetResponseSdk,
}
impl KeySetResponse {
pub fn new(keyset_ids: Vec<Arc<Id>>) -> Self {
let keysets = keyset_ids.into_iter().map(|id| id.inner).collect();
Self {
inner: Response { keysets },
inner: KeysetResponseSdk { keysets },
}
}
@@ -94,8 +94,8 @@ impl KeySetResponse {
}
}
impl From<cashu::nuts::nut02::Response> for KeySetResponse {
fn from(inner: Response) -> KeySetResponse {
impl From<KeysetResponseSdk> for KeySetResponse {
fn from(inner: KeysetResponseSdk) -> KeySetResponse {
KeySetResponse { inner }
}
}

View File

@@ -1,7 +1,6 @@
use std::ops::Deref;
use cashu::nuts::nut01::Response as KeysResponse;
use cashu::nuts::nut02::{Id, KeySet, Response as KeySetsResponse};
use cashu::nuts::{Id, KeySet, KeysResponse, KeysetResponse};
use wasm_bindgen::prelude::*;
use crate::error::{into_err, Result};
@@ -86,18 +85,18 @@ impl JsKeySet {
#[wasm_bindgen(js_name = KeySetsResponse)]
pub struct JsKeySetsResponse {
inner: KeySetsResponse,
inner: KeysetResponse,
}
impl Deref for JsKeySetsResponse {
type Target = KeySetsResponse;
type Target = KeysetResponse;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl From<KeySetsResponse> for JsKeySetsResponse {
fn from(inner: KeySetsResponse) -> JsKeySetsResponse {
impl From<KeysetResponse> for JsKeySetsResponse {
fn from(inner: KeysetResponse) -> JsKeySetsResponse {
JsKeySetsResponse { inner }
}
}

View File

@@ -8,8 +8,7 @@ use cashu_js::nuts::nut07::{JsCheckSpendableRequest, JsCheckSpendableResponse};
use cashu_js::nuts::nut08::{JsMeltRequest, JsMeltResponse};
use cashu_js::JsAmount;
use cashu_sdk::mint::Mint;
use cashu_sdk::nuts::nut01;
use cashu_sdk::nuts::nut02::KeySet;
use cashu_sdk::nuts::{KeySet, KeysResponse};
use wasm_bindgen::prelude::*;
use crate::error::{into_err, Result};
@@ -64,7 +63,7 @@ impl JsMint {
pub fn active_keyset_pubkeys(&self) -> Result<JsKeysResponse> {
let keyset: KeySet = self.inner.active_keyset.clone().into();
Ok(nut01::Response { keys: keyset.keys }.into())
Ok(KeysResponse { keys: keyset.keys }.into())
}
/// Get Keysets