Quellcode durchsuchen

feat: aaga post mmw cleanup (#1622)

tsk vor 1 Woche
Ursprung
Commit
64627a847e

+ 1 - 11
crates/cdk-common/src/error.rs

@@ -283,16 +283,7 @@ pub enum Error {
     #[error("Preimage not provided")]
     PreimageNotProvided,
 
-    // MultiMint Wallet Errors
-    /// Currency unit mismatch in MultiMintWallet
-    #[error("Currency unit mismatch: wallet uses {expected}, but {found} provided")]
-    MultiMintCurrencyUnitMismatch {
-        /// Expected currency unit
-        expected: CurrencyUnit,
-        /// Found currency unit
-        found: CurrencyUnit,
-    },
-    /// Unknown mint in MultiMintWallet
+    /// Unknown mint
     #[error("Unknown mint: {mint_url}")]
     UnknownMint {
         /// URL of the unknown mint
@@ -561,7 +552,6 @@ impl Error {
             | Self::IncorrectMint
             | Self::MultiMintTokenNotSupported
             | Self::PreimageNotProvided
-            | Self::MultiMintCurrencyUnitMismatch { .. }
             | Self::UnknownMint { .. }
             | Self::UnexpectedProofState
             | Self::NoActiveKeyset

+ 1 - 1
crates/cdk-ffi/src/logging.rs

@@ -23,7 +23,7 @@ static INIT: Once = std::sync::Once::new();
 /// ```dart
 /// await CdkFfi.initLogging("debug");
 /// // Now all logs will be visible in stdout
-/// final wallet = await MultiMintWallet.create(...);
+/// final wallet = await WalletRepository.create(...);
 /// ```
 #[uniffi::export]
 pub fn init_logging(level: String) {

+ 11 - 11
crates/cdk-integration-tests/tests/happy_path_mint_wallet.rs

@@ -715,35 +715,35 @@ async fn test_melt_quote_status_after_melt() {
     );
 }
 
-/// Tests that the melt quote status can be checked via MultiMintWallet after a melt has completed
+/// Tests that the melt quote status can be checked via WalletRepository after a melt has completed
 ///
 /// This test verifies the same flow as test_melt_quote_status_after_melt but using
-/// the MultiMintWallet abstraction:
-/// 1. Create a MultiMintWallet and add a mint
-/// 2. Mint tokens via the multi mint wallet
+/// the WalletRepository abstraction:
+/// 1. Create a WalletRepository and add a mint
+/// 2. Mint tokens via the wallet repository
 /// 3. Create a melt quote and execute the melt
 /// 4. Check the melt quote status via check_melt_quote
 /// 5. Verify the quote is in the Paid state
 #[tokio::test(flavor = "multi_thread", worker_threads = 1)]
-async fn test_melt_quote_status_after_melt_multi_mint_wallet() {
+async fn test_melt_quote_status_after_melt_wallet_repository() {
     let seed = Mnemonic::generate(12).unwrap().to_seed_normalized("");
     let localstore = Arc::new(memory::empty().await.unwrap());
 
-    let multi_mint_wallet = WalletRepositoryBuilder::new()
+    let wallet_repository = WalletRepositoryBuilder::new()
         .localstore(localstore.clone())
         .seed(seed)
         .build()
         .await
-        .expect("failed to create multi mint wallet");
+        .expect("failed to create wallet repository");
 
     let mint_url = MintUrl::from_str(&get_mint_url_from_env()).expect("invalid mint url");
-    multi_mint_wallet
+    wallet_repository
         .add_wallet(mint_url.clone())
         .await
         .expect("failed to add mint");
 
     // Get the wallet from the repository to call methods directly
-    let wallet = multi_mint_wallet
+    let wallet = wallet_repository
         .get_wallet(&mint_url, &CurrencyUnit::Sat)
         .await
         .expect("failed to get wallet");
@@ -773,7 +773,7 @@ async fn test_melt_quote_status_after_melt_multi_mint_wallet() {
         .await
         .expect("mint failed");
 
-    let balances = multi_mint_wallet.total_balance().await.unwrap();
+    let balances = wallet_repository.total_balance().await.unwrap();
     let balance = balances
         .get(&CurrencyUnit::Sat)
         .copied()
@@ -808,7 +808,7 @@ async fn test_melt_quote_status_after_melt_multi_mint_wallet() {
     assert_eq!(
         quote_status.state,
         MeltQuoteState::Paid,
-        "Melt quote should be in Paid state after successful melt (via MultiMintWallet)"
+        "Melt quote should be in Paid state after successful melt (via WalletRepository)"
     );
 
     use cdk_common::database::WalletDatabase;

+ 8 - 8
crates/cdk/examples/multimint-npubcash.rs

@@ -1,12 +1,12 @@
-//! Example: MultiMint Wallet with NpubCash - Switching Active Mints
+//! Example: WalletRepository with NpubCash - Switching Active Mints
 //!
 //! This example demonstrates:
-//! 1. Creating a MultiMintWallet with multiple mints
-//! 2. Using NpubCash integration with the MultiMintWallet API
+//! 1. Creating a WalletRepository with multiple mints
+//! 2. Using NpubCash integration with the WalletRepository API
 //! 3. Switching the active mint for NpubCash deposits
 //! 4. Receiving payments to different mints and verifying balances
 //!
-//! Key concept: Since all wallets in a MultiMintWallet share the same seed, they all
+//! Key concept: Since all wallets in a WalletRepository share the same seed, they all
 //! derive the same Nostr keypair. This means your npub.cash address stays the same,
 //! but you can change which mint receives the deposits.
 
@@ -29,12 +29,12 @@ const PAYMENT_AMOUNT_MSATS: u64 = 10000; // 10 sats
 
 #[tokio::main]
 async fn main() -> Result<(), Box<dyn std::error::Error>> {
-    println!("=== MultiMint Wallet with NpubCash Example ===\n");
+    println!("=== WalletRepository with NpubCash Example ===\n");
 
     // -------------------------------------------------------------------------
-    // Step 1: Create MultiMintWallet and add mints
+    // Step 1: Create WalletRepository and add mints
     // -------------------------------------------------------------------------
-    println!("Step 1: Setting up MultiMintWallet...\n");
+    println!("Step 1: Setting up WalletRepository...\n");
 
     let seed: [u8; 64] = {
         let mut s = [0u8; 64];
@@ -111,7 +111,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
     request_invoice(&npub, PAYMENT_AMOUNT_MSATS).await?;
     println!("   Waiting for payment...");
 
-    // The stream is for the multimint wallet so it handles switching mints automatically
+    // The stream is for the wallet repository so it handles switching mints automatically
     let (_, proofs_2) = stream.next().await.ok_or("Stream ended unexpectedly")??;
 
     let amount_2: u64 = proofs_2.total_amount()?.into();

+ 4 - 1
crates/cdk/src/wallet/issue/saga/resume.rs

@@ -33,7 +33,10 @@ impl Wallet {
     /// - SecretsPrepared: No mint request sent, safe to compensate.
     /// - MintRequested: Mint request sent, attempt to recover outputs.
     #[instrument(skip(self, saga))]
-    pub async fn resume_issue_saga(&self, saga: &WalletSaga) -> Result<RecoveryAction, Error> {
+    pub(crate) async fn resume_issue_saga(
+        &self,
+        saga: &WalletSaga,
+    ) -> Result<RecoveryAction, Error> {
         let state = match &saga.state {
             cdk_common::wallet::WalletSagaState::Issue(s) => s,
             _ => {

+ 9 - 11
crates/cdk/src/wallet/melt/mod.rs

@@ -619,13 +619,10 @@ impl Wallet {
         Ok(results)
     }
 
-    /// Confirm a prepared melt with already-reserved proofs.
+    /// Internal method called by `PreparedMelt::confirm` with cached data.
     ///
-    /// This is used by `MultiMintPreparedMelt::confirm` which holds an `Arc<Wallet>`
-    /// and has already prepared/reserved proofs. For the normal API path, use
-    /// `PreparedMelt::confirm()` which uses the typestate saga.
-    ///
-    /// The `operation_id` and `quote` must correspond to an existing prepared saga.
+    /// Not intended for direct use - use [`PreparedMelt::confirm`] instead.
+    #[doc(hidden)]
     #[instrument(skip(self, proofs, proofs_to_swap, metadata))]
     #[allow(clippy::too_many_arguments)]
     pub async fn confirm_prepared_melt(
@@ -651,10 +648,10 @@ impl Wallet {
         .await
     }
 
-    /// Confirm a prepared melt with already-reserved proofs and custom options.
+    /// Internal method called by `PreparedMelt::confirm_with_options` with cached data.
     ///
-    /// This is used by `MultiMintPreparedMelt::confirm_with_options` which holds an `Arc<Wallet>`
-    /// and has already prepared/reserved proofs.
+    /// Not intended for direct use - use [`PreparedMelt::confirm_with_options`] instead.
+    #[doc(hidden)]
     #[instrument(skip(self, proofs, proofs_to_swap, metadata, options))]
     #[allow(clippy::too_many_arguments)]
     pub async fn confirm_prepared_melt_with_options(
@@ -708,9 +705,10 @@ impl Wallet {
         }
     }
 
-    /// Cancel a prepared melt and release reserved proofs.
+    /// Internal method called by `PreparedMelt::cancel` with cached data.
     ///
-    /// This is used by `MultiMintPreparedMelt::cancel` which holds an `Arc<Wallet>`.
+    /// Not intended for direct use - use [`PreparedMelt::cancel`] instead.
+    #[doc(hidden)]
     #[instrument(skip(self, proofs, proofs_to_swap))]
     pub async fn cancel_prepared_melt(
         &self,

+ 1 - 1
crates/cdk/src/wallet/melt/saga/resume.rs

@@ -28,7 +28,7 @@ impl Wallet {
     /// - `Ok(None)` - The melt was skipped (still pending, mint unreachable)
     /// - `Err(e)` - An error occurred during recovery
     #[instrument(skip(self, saga))]
-    pub async fn resume_melt_saga(
+    pub(crate) async fn resume_melt_saga(
         &self,
         saga: &WalletSaga,
     ) -> Result<Option<FinalizedMelt>, Error> {

+ 4 - 1
crates/cdk/src/wallet/receive/saga/resume.rs

@@ -26,7 +26,10 @@ impl Wallet {
     /// For `SwapRequested` state, checks if input proofs are spent and either
     /// recovers outputs or compensates.
     #[instrument(skip(self, saga))]
-    pub async fn resume_receive_saga(&self, saga: &WalletSaga) -> Result<RecoveryAction, Error> {
+    pub(crate) async fn resume_receive_saga(
+        &self,
+        saga: &WalletSaga,
+    ) -> Result<RecoveryAction, Error> {
         let state = match &saga.state {
             cdk_common::wallet::WalletSagaState::Receive(s) => s,
             _ => {

+ 8 - 2
crates/cdk/src/wallet/send/mod.rs

@@ -181,7 +181,10 @@ impl Wallet {
         Ok(prepared)
     }
 
-    /// Called by `PreparedSend::confirm` with cached data.
+    /// Internal method called by `PreparedSend::confirm` with cached data.
+    ///
+    /// Not intended for direct use - use [`PreparedSend::confirm`] instead.
+    #[doc(hidden)]
     #[instrument(skip(self, options, proofs_to_swap, proofs_to_send))]
     #[allow(clippy::too_many_arguments)]
     pub async fn confirm_send(
@@ -216,7 +219,10 @@ impl Wallet {
         Ok(token)
     }
 
-    /// Called by `PreparedSend::cancel` with cached data.
+    /// Internal method called by `PreparedSend::cancel` with cached data.
+    ///
+    /// Not intended for direct use - use [`PreparedSend::cancel`] instead.
+    #[doc(hidden)]
     #[instrument(skip(self, proofs_to_swap, proofs_to_send))]
     pub async fn cancel_send(
         &self,

+ 4 - 1
crates/cdk/src/wallet/send/saga/resume.rs

@@ -15,7 +15,10 @@ use crate::{Error, Wallet};
 impl Wallet {
     /// Resume an incomplete send saga after crash recovery.
     #[instrument(skip(self, saga))]
-    pub async fn resume_send_saga(&self, saga: &WalletSaga) -> Result<RecoveryAction, Error> {
+    pub(crate) async fn resume_send_saga(
+        &self,
+        saga: &WalletSaga,
+    ) -> Result<RecoveryAction, Error> {
         let state = match &saga.state {
             cdk_common::wallet::WalletSagaState::Send(s) => s,
             _ => {

+ 4 - 1
crates/cdk/src/wallet/swap/saga/resume.rs

@@ -32,7 +32,10 @@ impl Wallet {
     ///   Check the mint to determine if the swap succeeded, then either
     ///   complete the operation or compensate.
     #[instrument(skip(self, saga))]
-    pub async fn resume_swap_saga(&self, saga: &WalletSaga) -> Result<RecoveryAction, Error> {
+    pub(crate) async fn resume_swap_saga(
+        &self,
+        saga: &WalletSaga,
+    ) -> Result<RecoveryAction, Error> {
         let state = match &saga.state {
             cdk_common::wallet::WalletSagaState::Swap(s) => s,
             _ => {