diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/UserWalletsListManager.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/UserWalletsListManager.kt index fd85a066ba..91d3b8dd91 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/UserWalletsListManager.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/UserWalletsListManager.kt @@ -6,16 +6,62 @@ import com.tangem.tap.domain.model.UserWallet import kotlinx.coroutines.flow.Flow interface UserWalletsListManager { + /** + * [Flow] with all saved [UserWallet]s updates + * */ val userWallets: Flow> + + /** + * [Flow] with selected [UserWallet] updates + * */ val selectedUserWallet: Flow + + /** + * Selected [UserWallet] + * */ val selectedUserWalletSync: UserWallet? + + /** + * Indicates that all [UserWallet]s is unlocked + * + * @see [isLockedSync] + * @see [UserWallet.isLocked] + * */ val isLocked: Flow + + /** + * Indicates that all [UserWallet]s is unlocked + * + * Sync version + * + * @see [isLocked] + * @see [UserWallet.isLocked] + * */ val isLockedSync: Boolean + val hasSavedUserWallets: Boolean + /** + * Receive saved [UserWallet]s, populate [userWallets] flow with it and set [isLocked] as false. + * Require biometric user authorization + * + * @return [CompletionResult] of operation, with selected [UserWallet] + * or null if there is no selected [UserWallet] + * */ suspend fun unlockWithBiometry(): CompletionResult + + /** + * Remove [UserWallet]s from [userWallets] and set [isLocked] as true + * */ fun lock() + /** + * Set [UserWallet] with provided [UserWalletId] as selected + * + * @param userWalletId [UserWalletId] of [UserWallet] which must be selected + * + * @return [CompletionResult] of operation with selected [UserWallet] + * */ suspend fun selectWallet(userWalletId: UserWalletId): CompletionResult /** @@ -38,10 +84,30 @@ interface UserWalletsListManager { * */ suspend fun update(userWalletId: UserWalletId, update: (UserWallet) -> UserWallet): CompletionResult + /** + * Delete saved [UserWallet]s with provided [UserWalletId]s + * + * @param userWalletIds [UserWalletId]s of [UserWallet]s which must be deleted + * + * @return [CompletionResult] of operation + * */ suspend fun delete(userWalletIds: List): CompletionResult + + /** + * Clear all saved [UserWallet]s and set [isLocked] as true + * + * @return [CompletionResult] of operation + * */ suspend fun clear(): CompletionResult + /** + * Get [UserWallet] with provided [UserWalletId] + * May terminate with [NoSuchElementException] if [UserWallet] is not found + * + * @return [CompletionResult] of operation with found [UserWallet] + * */ suspend fun get(userWalletId: UserWalletId): CompletionResult + // For provider companion object } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/domain/walletCurrencies/WalletCurrenciesManager.kt b/app/src/main/java/com/tangem/tap/domain/walletCurrencies/WalletCurrenciesManager.kt index fb77a29584..2738438ac1 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletCurrencies/WalletCurrenciesManager.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletCurrencies/WalletCurrenciesManager.kt @@ -5,25 +5,70 @@ import com.tangem.tap.domain.model.UserWallet import com.tangem.tap.features.wallet.models.Currency interface WalletCurrenciesManager { + /** + * Update [UserWallet] currencies with same blockchain as provided [Currency] blockchain + * [UserWallet] currencies updates can be observed + * with [com.tangem.tap.domain.walletStores.WalletStoresManager.getAll] + * or [com.tangem.tap.domain.walletStores.WalletStoresManager.get] + * + * @param userWallet [UserWallet] which currencies will be updated + * @param currency [Currency] to find other currencies to update + * + * @return [CompletionResult] of operation + * */ suspend fun update( userWallet: UserWallet, currency: Currency, ): CompletionResult + /** + * Add list of [Currency] to [UserWallet]. + * [UserWallet] currencies updates can be observed + * with [com.tangem.tap.domain.walletStores.WalletStoresManager.getAll] + * or [com.tangem.tap.domain.walletStores.WalletStoresManager.get] + * + * @param userWallet [UserWallet] to add currencies + * @param currenciesToAdd list of [Currency] to add [UserWallet] + * + * @return [CompletionResult] of operation + * */ suspend fun addCurrencies( userWallet: UserWallet, currenciesToAdd: List, ): CompletionResult + /** + * Remove [Currency] from [UserWallet] + * [UserWallet] currencies updates can be observed + * with [com.tangem.tap.domain.walletStores.WalletStoresManager.getAll] + * or [com.tangem.tap.domain.walletStores.WalletStoresManager.get] + * + * @param userWallet [UserWallet] which currency will be removed + * @param currencyToRemove [Currency] to remove from [UserWallet] + * + * @return [CompletionResult] of operation + * */ suspend fun removeCurrency( userWallet: UserWallet, currencyToRemove: Currency, ): CompletionResult + /** + * Remove list of [Currency] from [UserWallet] + * [UserWallet] currencies updates can be observed + * with [com.tangem.tap.domain.walletStores.WalletStoresManager.getAll] + * or [com.tangem.tap.domain.walletStores.WalletStoresManager.get] + * + * @param userWallet [UserWallet] which currency will be removed + * @param currenciesToRemove list of [Currency] to remove from [UserWallet] + * + * @return [CompletionResult] of operation + * */ suspend fun removeCurrencies( userWallet: UserWallet, currenciesToRemove: List, ): CompletionResult + // For provider companion object } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/domain/walletStores/WalletStoresManager.kt b/app/src/main/java/com/tangem/tap/domain/walletStores/WalletStoresManager.kt index e834cf0541..ed773b522d 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletStores/WalletStoresManager.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletStores/WalletStoresManager.kt @@ -7,25 +7,77 @@ import com.tangem.tap.domain.model.WalletStoreModel import kotlinx.coroutines.flow.Flow interface WalletStoresManager { + /** + * Get all [WalletStoreModel]s updates + * + * @return [Flow] with map of [WalletStoreModel] list assigned by [UserWalletId] + * */ fun getAll(): Flow>> + + /** + * Get [WalletStoreModel]s updates which associated with provided [UserWalletId] + * + * @param userWalletId [UserWalletId] of user wallet + * + * @return [Flow] with [WalletStoreModel] list + * */ fun get(userWalletId: UserWalletId): Flow> + /** + * Delete [WalletStoreModel]s associated with provided [UserWalletId]s + * + * @param userWalletsIds [UserWalletId] list + * + * @return [CompletionResult] of operation + * */ suspend fun delete(userWalletsIds: List): CompletionResult + + /** + * Clear all [WalletStoreModel]s + * + * @return [CompletionResult] of operation + * */ suspend fun clear(): CompletionResult + /** + * Fetch wallet stores associated with provided [UserWallet]. Fetched [WalletStoreModel]s updates can be observed + * with [get] and [getAll] methods + * + * @param userWallet [UserWallet] to fetch [WalletStoreModel]s + + * + * @return [CompletionResult] of operation + * */ suspend fun fetch( userWallet: UserWallet, refresh: Boolean = false, ): CompletionResult + /** + * Fetch wallet stores associated with provided [UserWallet]s. Fetched [WalletStoreModel]s updates can be observed + * with [get] and [getAll] methods + * + * @param userWallets [UserWallet]s list to fetch [WalletStoreModel]s + + * + * @return [CompletionResult] of operation + * */ suspend fun fetch( userWallets: List, refresh: Boolean = false, ): CompletionResult + /** + * Update [WalletStoreModel]s amounts associated with provided [UserWallet]s + * + * @param userWallets [UserWallet]s list to update [WalletStoreModel]s amounts + * + * @return [CompletionResult] of operation + * */ suspend fun updateAmounts( userWallets: List, ): CompletionResult + // For provider companion object } \ No newline at end of file