From a69490feb2956631ae0260bf0723ef536476c4c7 Mon Sep 17 00:00:00 2001 From: thesimplekid Date: Tue, 28 Nov 2023 06:36:24 +0000 Subject: [PATCH] refactor: rename "KeysetInfo" to "MintKeySetInfo" --- .../cashu-sdk-ffi/src/types/keyset_info.rs | 20 +++++++------- bindings/cashu-sdk-ffi/src/types/mod.rs | 2 +- crates/cashu-sdk/src/mint.rs | 26 ++++++++++++++++--- crates/cashu/src/types.rs | 20 -------------- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/bindings/cashu-sdk-ffi/src/types/keyset_info.rs b/bindings/cashu-sdk-ffi/src/types/keyset_info.rs index cc7e4272..810a992b 100644 --- a/bindings/cashu-sdk-ffi/src/types/keyset_info.rs +++ b/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 for KeySetInfo { - fn from(inner: KeySetInfoSdk) -> KeySetInfo { - KeySetInfo { inner } +impl From for MintKeySetInfo { + fn from(inner: MintKeySetInfoSdk) -> MintKeySetInfo { + MintKeySetInfo { inner } } } -impl KeySetInfo { +impl MintKeySetInfo { pub fn new( id: Arc, active: bool, @@ -33,7 +33,7 @@ impl KeySetInfo { max_order: u8, ) -> Self { Self { - inner: KeySetInfoSdk { + inner: MintKeySetInfoSdk { id: *id.as_ref().deref(), active, unit, diff --git a/bindings/cashu-sdk-ffi/src/types/mod.rs b/bindings/cashu-sdk-ffi/src/types/mod.rs index cf604c97..969dd4b8 100644 --- a/bindings/cashu-sdk-ffi/src/types/mod.rs +++ b/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; diff --git a/crates/cashu-sdk/src/mint.rs b/crates/cashu-sdk/src/mint.rs index d10fea6f..e454706a 100644 --- a/crates/cashu-sdk/src/mint.rs +++ b/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, - pub keysets_info: HashMap, + pub keysets_info: HashMap, pub spent_secrets: HashSet, pub pending_secrets: HashSet, pub fee_reserve: FeeReserve, @@ -26,7 +26,7 @@ pub struct Mint { impl Mint { pub fn new( secret: &str, - keysets_info: HashSet, + keysets_info: HashSet, spent_secrets: HashSet, 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, + pub derivation_path: String, + pub max_order: u8, +} + +impl From for KeySetInfo { + fn from(keyset_info: MintKeySetInfo) -> Self { + Self { + id: keyset_info.id, + unit: keyset_info.unit, + } + } +} diff --git a/crates/cashu/src/types.rs b/crates/cashu/src/types.rs index 2d90cdda..49580696 100644 --- a/crates/cashu/src/types.rs +++ b/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, - pub derivation_path: String, - pub max_order: u8, -} - -impl From for KeySetInfo { - fn from(keyset_info: KeysetInfo) -> Self { - Self { - id: keyset_info.id, - unit: keyset_info.unit, - } - } -}