Updated on 2026-08-14

This commit is contained in:
Tangem 2025-11-05 12:22:31 +04:00
parent 17a97c66b6
commit 5a8f4299a6
8 changed files with 621 additions and 2 deletions

View file

@ -7,21 +7,28 @@ import javax.inject.Inject
/**
* Container for converter factories related to accounts.
*
* @property accountsListCF factory for creating an account list converter
* @property getWalletAccountsResponseCF factory for creating a wallet accounts response converter
* @property accountsListCF factory for creating an account list converter
* @property cryptoPortfolioCF factory for creating a crypto portfolio converter
* @property userWalletsStore store for accessing user wallet data
*
* @constructor Creates an instance of the container with injected factories.
*
[REDACTED_AUTHOR]
*/
internal class AccountConverterFactoryContainer @Inject constructor(
val getWalletAccountsResponseCF: GetWalletAccountsResponseConverter.Factory,
private val getWalletAccountsResponseCF: GetWalletAccountsResponseConverter.Factory,
private val accountsListCF: AccountListConverter.Factory,
private val cryptoPortfolioCF: CryptoPortfolioConverter.Factory,
private val userWalletsStore: UserWalletsStore,
) {
fun createWalletAccountsResponseConverter(userWalletId: UserWalletId): GetWalletAccountsResponseConverter {
val userWallet = userWalletsStore.getSyncStrict(key = userWalletId)
return getWalletAccountsResponseCF.create(userWallet)
}
fun createAccountListConverter(userWalletId: UserWalletId): AccountListConverter {
val userWallet = userWalletsStore.getSyncStrict(key = userWalletId)

View file

@ -132,6 +132,17 @@ internal class DefaultAccountsCRUDRepository(
}
}
override suspend fun saveAccountsLocally(accountList: AccountList) {
val converter = convertersContainer.createWalletAccountsResponseConverter(
userWalletId = accountList.userWalletId,
)
walletAccountsSaver.store(
userWalletId = accountList.userWalletId,
response = converter.convert(accountList),
)
}
override suspend fun saveAccounts(accountList: AccountList) {
val converter = convertersContainer.createCryptoPortfolioConverter(userWalletId = accountList.userWalletId)