From 3dd1d03fa55f23a85eb8171a0264ce387372817e Mon Sep 17 00:00:00 2001 From: thesimplekid Date: Sun, 21 Apr 2024 21:24:05 +0100 Subject: [PATCH] refactor: remove unused localstore --- crates/cdk/src/{mint/mod.rs => mint.rs} | 0 crates/cdk/src/mint/localstore/mod.rs | 101 -------------------- crates/cdk/src/{wallet/mod.rs => wallet.rs} | 0 crates/cdk/src/wallet/localstore/mod.rs | 93 ------------------ 4 files changed, 194 deletions(-) rename crates/cdk/src/{mint/mod.rs => mint.rs} (100%) delete mode 100644 crates/cdk/src/mint/localstore/mod.rs rename crates/cdk/src/{wallet/mod.rs => wallet.rs} (100%) delete mode 100644 crates/cdk/src/wallet/localstore/mod.rs diff --git a/crates/cdk/src/mint/mod.rs b/crates/cdk/src/mint.rs similarity index 100% rename from crates/cdk/src/mint/mod.rs rename to crates/cdk/src/mint.rs diff --git a/crates/cdk/src/mint/localstore/mod.rs b/crates/cdk/src/mint/localstore/mod.rs deleted file mode 100644 index 570b940b..00000000 --- a/crates/cdk/src/mint/localstore/mod.rs +++ /dev/null @@ -1,101 +0,0 @@ -use std::collections::HashMap; -use std::num::ParseIntError; - -use async_trait::async_trait; -use thiserror::Error; - -pub mod memory; -#[cfg(all(not(target_arch = "wasm32"), feature = "redb"))] -pub mod redb_store; - -pub use self::memory::MemoryLocalStore; -#[cfg(all(not(target_arch = "wasm32"), feature = "redb"))] -pub use self::redb_store::RedbLocalStore; -use crate::nuts::nut02::MintKeySet; -use crate::nuts::{BlindSignature, CurrencyUnit, Id, MintInfo, Proof, PublicKey}; -use crate::secret::Secret; -use crate::types::{MeltQuote, MintQuote}; - -#[derive(Debug, Error)] -pub enum Error { - #[cfg(all(not(target_arch = "wasm32"), feature = "redb"))] - #[error(transparent)] - Redb(#[from] redb::Error), - #[cfg(all(not(target_arch = "wasm32"), feature = "redb"))] - #[error(transparent)] - Database(#[from] redb::DatabaseError), - #[cfg(all(not(target_arch = "wasm32"), feature = "redb"))] - #[error(transparent)] - Transaction(#[from] redb::TransactionError), - #[cfg(all(not(target_arch = "wasm32"), feature = "redb"))] - #[error(transparent)] - Commit(#[from] redb::CommitError), - #[cfg(all(not(target_arch = "wasm32"), feature = "redb"))] - #[error(transparent)] - Table(#[from] redb::TableError), - #[cfg(all(not(target_arch = "wasm32"), feature = "redb"))] - #[error(transparent)] - Storage(#[from] redb::StorageError), - #[cfg(all(not(target_arch = "wasm32"), feature = "redb"))] - #[error(transparent)] - Serde(#[from] serde_json::Error), - #[error(transparent)] - ParseInt(#[from] ParseIntError), - #[error("Unknown Mint Info")] - UnknownMintInfo, - #[error(transparent)] - Cashu(#[from] crate::error::Error), - #[error(transparent)] - NUT00(#[from] crate::nuts::nut00::Error), - #[error(transparent)] - CashuNut02(#[from] crate::nuts::nut02::Error), - #[error(transparent)] - Secret(#[from] crate::secret::Error), -} - -#[async_trait] -pub trait LocalStore { - async fn set_mint_info(&self, mint_info: &MintInfo) -> Result<(), Error>; - async fn get_mint_info(&self) -> Result; - - async fn add_active_keyset(&self, unit: CurrencyUnit, id: Id) -> Result<(), Error>; - async fn get_active_keyset_id(&self, unit: &CurrencyUnit) -> Result, Error>; - async fn get_active_keysets(&self) -> Result, Error>; - - async fn add_mint_quote(&self, quote: MintQuote) -> Result<(), Error>; - async fn get_mint_quote(&self, quote_id: &str) -> Result, Error>; - async fn get_mint_quotes(&self) -> Result, Error>; - async fn remove_mint_quote(&self, quote_id: &str) -> Result<(), Error>; - - async fn add_melt_quote(&self, quote: MeltQuote) -> Result<(), Error>; - async fn get_melt_quote(&self, quote_id: &str) -> Result, Error>; - async fn get_melt_quotes(&self) -> Result, Error>; - async fn remove_melt_quote(&self, quote_id: &str) -> Result<(), Error>; - - async fn add_keyset(&self, keyset: MintKeySet) -> Result<(), Error>; - async fn get_keyset(&self, id: &Id) -> Result, Error>; - async fn get_keysets(&self) -> Result, Error>; - - async fn add_spent_proof(&self, proof: Proof) -> Result<(), Error>; - async fn get_spent_proof_by_secret(&self, secret: &Secret) -> Result, Error>; - async fn get_spent_proof_by_y(&self, y: &PublicKey) -> Result, Error>; - - async fn add_pending_proof(&self, proof: Proof) -> Result<(), Error>; - async fn get_pending_proof_by_secret(&self, secret: &Secret) -> Result, Error>; - async fn get_pending_proof_by_y(&self, y: &PublicKey) -> Result, Error>; - async fn remove_pending_proof(&self, secret: &Secret) -> Result<(), Error>; - - async fn add_blinded_signature( - &self, - blinded_message: PublicKey, - blinded_signature: BlindSignature, - ) -> Result<(), Error>; - async fn get_blinded_signature( - &self, - blinded_message: &PublicKey, - ) -> Result, Error>; - async fn get_blinded_signatures( - &self, - blinded_messages: Vec, - ) -> Result>, Error>; -} diff --git a/crates/cdk/src/wallet/mod.rs b/crates/cdk/src/wallet.rs similarity index 100% rename from crates/cdk/src/wallet/mod.rs rename to crates/cdk/src/wallet.rs diff --git a/crates/cdk/src/wallet/localstore/mod.rs b/crates/cdk/src/wallet/localstore/mod.rs deleted file mode 100644 index 5527fd2c..00000000 --- a/crates/cdk/src/wallet/localstore/mod.rs +++ /dev/null @@ -1,93 +0,0 @@ -use std::collections::HashMap; -use std::num::ParseIntError; - -use async_trait::async_trait; -use thiserror::Error; - -mod memory; -#[cfg(all(not(target_arch = "wasm32"), feature = "redb"))] -mod redb_store; - -pub use self::memory::MemoryLocalStore; -#[cfg(all(not(target_arch = "wasm32"), feature = "redb"))] -pub use self::redb_store::RedbLocalStore; -use crate::nuts::{Id, KeySetInfo, Keys, MintInfo, Proofs}; -use crate::types::{MeltQuote, MintQuote}; -use crate::url::UncheckedUrl; - -#[derive(Debug, Error)] -pub enum Error { - #[cfg(all(not(target_arch = "wasm32"), feature = "redb"))] - #[error("`{0}`")] - Redb(#[from] redb::Error), - #[cfg(all(not(target_arch = "wasm32"), feature = "redb"))] - #[error("`{0}`")] - Database(#[from] redb::DatabaseError), - #[cfg(all(not(target_arch = "wasm32"), feature = "redb"))] - #[error("`{0}`")] - Transaction(#[from] redb::TransactionError), - #[cfg(all(not(target_arch = "wasm32"), feature = "redb"))] - #[error("`{0}`")] - Commit(#[from] redb::CommitError), - #[cfg(all(not(target_arch = "wasm32"), feature = "redb"))] - #[error("`{0}`")] - Table(#[from] redb::TableError), - #[cfg(all(not(target_arch = "wasm32"), feature = "redb"))] - #[error("`{0}`")] - Storage(#[from] redb::StorageError), - #[cfg(all(not(target_arch = "wasm32"), feature = "redb"))] - #[error("`{0}`")] - Serde(#[from] serde_json::Error), - #[error("`{0}`")] - ParseInt(#[from] ParseIntError), -} - -#[async_trait] -pub trait LocalStore { - async fn add_mint( - &self, - mint_url: UncheckedUrl, - mint_info: Option, - ) -> Result<(), Error>; - async fn get_mint(&self, mint_url: UncheckedUrl) -> Result, Error>; - async fn get_mints(&self) -> Result>, Error>; - - async fn add_mint_keysets( - &self, - mint_url: UncheckedUrl, - keysets: Vec, - ) -> Result<(), Error>; - async fn get_mint_keysets( - &self, - mint_url: UncheckedUrl, - ) -> Result>, Error>; - - async fn add_mint_quote(&self, quote: MintQuote) -> Result<(), Error>; - async fn get_mint_quote(&self, quote_id: &str) -> Result, Error>; - async fn remove_mint_quote(&self, quote_id: &str) -> Result<(), Error>; - - async fn add_melt_quote(&self, quote: MeltQuote) -> Result<(), Error>; - async fn get_melt_quote(&self, quote_id: &str) -> Result, Error>; - async fn remove_melt_quote(&self, quote_id: &str) -> Result<(), Error>; - - async fn add_keys(&self, keys: Keys) -> Result<(), Error>; - async fn get_keys(&self, id: &Id) -> Result, Error>; - async fn remove_keys(&self, id: &Id) -> Result<(), Error>; - - async fn add_proofs(&self, mint_url: UncheckedUrl, proof: Proofs) -> Result<(), Error>; - async fn get_proofs(&self, mint_url: UncheckedUrl) -> Result, Error>; - async fn remove_proofs(&self, mint_url: UncheckedUrl, proofs: &Proofs) -> Result<(), Error>; - - async fn add_pending_proofs(&self, mint_url: UncheckedUrl, proof: Proofs) -> Result<(), Error>; - async fn get_pending_proofs(&self, mint_url: UncheckedUrl) -> Result, Error>; - async fn remove_pending_proofs( - &self, - mint_url: UncheckedUrl, - proofs: &Proofs, - ) -> Result<(), Error>; - - #[cfg(feature = "nut13")] - async fn increment_keyset_counter(&self, keyset_id: &Id, count: u64) -> Result<(), Error>; - #[cfg(feature = "nut13")] - async fn get_keyset_counter(&self, keyset_id: &Id) -> Result, Error>; -}