瀏覽代碼

refactor: rename "KeysetInfo" to "MintKeySetInfo"

thesimplekid 1 年之前
父節點
當前提交
a69490feb2

+ 10 - 10
bindings/cashu-sdk-ffi/src/types/keyset_info.rs

@@ -1,28 +1,28 @@
 use std::ops::Deref;
 use std::sync::Arc;
 
-use cashu_sdk::types::KeysetInfo as KeySetInfoSdk;
+use cashu_sdk::mint::MintKeySetInfo as MintKeySetInfoSdk;
 
 use crate::Id;
 
-pub struct KeySetInfo {
-    inner: KeySetInfoSdk,
+pub struct MintKeySetInfo {
+    inner: MintKeySetInfoSdk,
 }
 
-impl Deref for KeySetInfo {
-    type Target = KeySetInfoSdk;
+impl Deref for MintKeySetInfo {
+    type Target = MintKeySetInfoSdk;
     fn deref(&self) -> &Self::Target {
         &self.inner
     }
 }
 
-impl From<KeySetInfoSdk> for KeySetInfo {
-    fn from(inner: KeySetInfoSdk) -> KeySetInfo {
-        KeySetInfo { inner }
+impl From<MintKeySetInfoSdk> for MintKeySetInfo {
+    fn from(inner: MintKeySetInfoSdk) -> MintKeySetInfo {
+        MintKeySetInfo { inner }
     }
 }
 
-impl KeySetInfo {
+impl MintKeySetInfo {
     pub fn new(
         id: Arc<Id>,
         active: bool,
@@ -33,7 +33,7 @@ impl KeySetInfo {
         max_order: u8,
     ) -> Self {
         Self {
-            inner: KeySetInfoSdk {
+            inner: MintKeySetInfoSdk {
                 id: *id.as_ref().deref(),
                 active,
                 unit,

+ 1 - 1
bindings/cashu-sdk-ffi/src/types/mod.rs

@@ -3,7 +3,7 @@ pub mod melted;
 pub mod proofs_status;
 pub mod send_proofs;
 
-pub use keyset_info::KeySetInfo as MintKeySetInfo;
+pub use keyset_info::MintKeySetInfo;
 pub use melted::Melted;
 pub use proofs_status::ProofsStatus;
 pub use send_proofs::SendProofs;

+ 23 - 3
crates/cashu-sdk/src/mint.rs

@@ -9,15 +9,15 @@ use cashu::nuts::{
 #[cfg(feature = "nut07")]
 use cashu::nuts::{CheckSpendableRequest, CheckSpendableResponse};
 use cashu::secret::Secret;
-use cashu::types::KeysetInfo;
 use cashu::Amount;
+use serde::{Deserialize, Serialize};
 use tracing::{debug, info};
 
 pub struct Mint {
     //    pub pubkey: PublicKey
     secret: String,
     pub keysets: HashMap<Id, nut02::mint::KeySet>,
-    pub keysets_info: HashMap<Id, KeysetInfo>,
+    pub keysets_info: HashMap<Id, MintKeySetInfo>,
     pub spent_secrets: HashSet<Secret>,
     pub pending_secrets: HashSet<Secret>,
     pub fee_reserve: FeeReserve,
@@ -26,7 +26,7 @@ pub struct Mint {
 impl Mint {
     pub fn new(
         secret: &str,
-        keysets_info: HashSet<KeysetInfo>,
+        keysets_info: HashSet<MintKeySetInfo>,
         spent_secrets: HashSet<Secret>,
         min_fee_reserve: Amount,
         percent_fee_reserve: f32,
@@ -324,3 +324,23 @@ pub struct FeeReserve {
     pub min_fee_reserve: Amount,
     pub percent_fee_reserve: f32,
 }
+
+#[derive(Debug, Hash, Clone, PartialEq, Eq, Serialize, Deserialize)]
+pub struct MintKeySetInfo {
+    pub id: Id,
+    pub unit: String,
+    pub active: bool,
+    pub valid_from: u64,
+    pub valid_to: Option<u64>,
+    pub derivation_path: String,
+    pub max_order: u8,
+}
+
+impl From<MintKeySetInfo> for KeySetInfo {
+    fn from(keyset_info: MintKeySetInfo) -> Self {
+        Self {
+            id: keyset_info.id,
+            unit: keyset_info.unit,
+        }
+    }
+}

+ 0 - 20
crates/cashu/src/types.rs

@@ -32,23 +32,3 @@ pub enum InvoiceStatus {
     Expired,
     InFlight,
 }
-
-#[derive(Debug, Hash, Clone, PartialEq, Eq, Serialize, Deserialize)]
-pub struct KeysetInfo {
-    pub id: Id,
-    pub unit: String,
-    pub active: bool,
-    pub valid_from: u64,
-    pub valid_to: Option<u64>,
-    pub derivation_path: String,
-    pub max_order: u8,
-}
-
-impl From<KeysetInfo> for KeySetInfo {
-    fn from(keyset_info: KeysetInfo) -> Self {
-        Self {
-            id: keyset_info.id,
-            unit: keyset_info.unit,
-        }
-    }
-}