Pārlūkot izejas kodu

refactor: remove unused localstore

thesimplekid 11 mēneši atpakaļ
vecāks
revīzija
3dd1d03fa5

+ 0 - 0
crates/cdk/src/mint/mod.rs → crates/cdk/src/mint.rs


+ 0 - 101
crates/cdk/src/mint/localstore/mod.rs

@@ -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<MintInfo, Error>;
-
-    async fn add_active_keyset(&self, unit: CurrencyUnit, id: Id) -> Result<(), Error>;
-    async fn get_active_keyset_id(&self, unit: &CurrencyUnit) -> Result<Option<Id>, Error>;
-    async fn get_active_keysets(&self) -> Result<HashMap<CurrencyUnit, Id>, Error>;
-
-    async fn add_mint_quote(&self, quote: MintQuote) -> Result<(), Error>;
-    async fn get_mint_quote(&self, quote_id: &str) -> Result<Option<MintQuote>, Error>;
-    async fn get_mint_quotes(&self) -> Result<Vec<MintQuote>, 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<Option<MeltQuote>, Error>;
-    async fn get_melt_quotes(&self) -> Result<Vec<MeltQuote>, 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<Option<MintKeySet>, Error>;
-    async fn get_keysets(&self) -> Result<Vec<MintKeySet>, Error>;
-
-    async fn add_spent_proof(&self, proof: Proof) -> Result<(), Error>;
-    async fn get_spent_proof_by_secret(&self, secret: &Secret) -> Result<Option<Proof>, Error>;
-    async fn get_spent_proof_by_y(&self, y: &PublicKey) -> Result<Option<Proof>, Error>;
-
-    async fn add_pending_proof(&self, proof: Proof) -> Result<(), Error>;
-    async fn get_pending_proof_by_secret(&self, secret: &Secret) -> Result<Option<Proof>, Error>;
-    async fn get_pending_proof_by_y(&self, y: &PublicKey) -> Result<Option<Proof>, 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<Option<BlindSignature>, Error>;
-    async fn get_blinded_signatures(
-        &self,
-        blinded_messages: Vec<PublicKey>,
-    ) -> Result<Vec<Option<BlindSignature>>, Error>;
-}

+ 0 - 0
crates/cdk/src/wallet/mod.rs → crates/cdk/src/wallet.rs


+ 0 - 93
crates/cdk/src/wallet/localstore/mod.rs

@@ -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<MintInfo>,
-    ) -> Result<(), Error>;
-    async fn get_mint(&self, mint_url: UncheckedUrl) -> Result<Option<MintInfo>, Error>;
-    async fn get_mints(&self) -> Result<HashMap<UncheckedUrl, Option<MintInfo>>, Error>;
-
-    async fn add_mint_keysets(
-        &self,
-        mint_url: UncheckedUrl,
-        keysets: Vec<KeySetInfo>,
-    ) -> Result<(), Error>;
-    async fn get_mint_keysets(
-        &self,
-        mint_url: UncheckedUrl,
-    ) -> Result<Option<Vec<KeySetInfo>>, Error>;
-
-    async fn add_mint_quote(&self, quote: MintQuote) -> Result<(), Error>;
-    async fn get_mint_quote(&self, quote_id: &str) -> Result<Option<MintQuote>, 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<Option<MeltQuote>, 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<Option<Keys>, 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<Option<Proofs>, 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<Option<Proofs>, 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<Option<u64>, Error>;
-}