Updated on 2026-08-14

This commit is contained in:
Tangem 2023-10-09 11:49:43 +08:00
parent 45229675f2
commit 2a97712a72
6 changed files with 72 additions and 20 deletions

View file

@ -255,9 +255,18 @@ internal class TapApplication : Application(), ImageLoaderFactory {
walletConnectRepository = WalletConnectRepository(this)
val configLoader = FeaturesLocalLoader(assetReader, MoshiConverter.sdkMoshi, BuildConfig.ENVIRONMENT)
initUserWalletsListManager()
// TODO: Try to performance and user experience.
// [REDACTED_JIRA]
runBlocking {
featureTogglesManager.init()
appRatingRepository.initialize()
// learn2earnInteractor.init()
}
initConfigManager(configLoader, ::initWithConfigDependency)
initWarningMessagesManager()
initUserWalletsListManager()
loadNativeLibraries()
@ -283,14 +292,6 @@ internal class TapApplication : Application(), ImageLoaderFactory {
appStateHolder.userTokensRepository = userTokensRepository
appStateHolder.walletStoresManager = walletStoresManager
// TODO: Try to performance and user experience.
// [REDACTED_JIRA]
runBlocking {
featureTogglesManager.init()
appRatingRepository.initialize()
// learn2earnInteractor.init()
}
initTopUpController()
walletConnect2Repository.init(projectId = configManager.config.walletConnectProjectId)
}
@ -354,14 +355,20 @@ internal class TapApplication : Application(), ImageLoaderFactory {
foregroundActivityObserver: ForegroundActivityObserver,
store: Store<AppState>,
) {
fun initAdditionalFeedbackInfo(context: Context): AdditionalFeedbackInfo = AdditionalFeedbackInfo().apply {
appVersion = try {
// TODO don't use deprecated method
val pInfo = context.packageManager.getPackageInfo(context.packageName, 0)
pInfo.versionName
} catch (e: PackageManager.NameNotFoundException) {
e.printStackTrace()
"x.y.z"
fun initAdditionalFeedbackInfo(context: Context): AdditionalFeedbackInfo {
return AdditionalFeedbackInfo(
userWalletsListManager = userWalletsListManager,
walletManagersFacade = walletManagersFacade,
walletFeatureToggles = walletFeatureToggles,
).apply {
appVersion = try {
// TODO don't use deprecated method
val pInfo = context.packageManager.getPackageInfo(context.packageName, 0)
pInfo.versionName
} catch (e: PackageManager.NameNotFoundException) {
e.printStackTrace()
"x.y.z"
}
}
}

View file

@ -6,9 +6,36 @@ import com.tangem.blockchain.common.address.Address
import com.tangem.domain.models.scan.CardDTO
import com.tangem.domain.models.scan.ScanResponse
import com.tangem.domain.userwallets.UserWalletIdBuilder
import com.tangem.domain.walletmanager.WalletManagersFacade
import com.tangem.domain.wallets.legacy.UserWalletsListManager
import com.tangem.features.wallet.featuretoggles.WalletFeatureToggles
import com.tangem.tap.common.extensions.stripZeroPlainString
import com.tangem.tap.scope
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
class AdditionalFeedbackInfo(
userWalletsListManager: UserWalletsListManager,
walletManagersFacade: WalletManagersFacade,
walletFeatureToggles: WalletFeatureToggles,
) {
init {
if (walletFeatureToggles.isRedesignedScreenEnabled) {
userWalletsListManager.selectedUserWallet
.distinctUntilChanged()
.onEach { userWallet ->
setCardInfo(data = userWallet.scanResponse)
walletManagersFacade.getAll(userWalletId = userWallet.walletId)
.onEach(::setWalletsInfo)
.launchIn(scope)
}
.launchIn(scope)
}
}
class AdditionalFeedbackInfo {
class EmailWalletInfo(
var blockchain: Blockchain = Blockchain.Unknown,
var derivationPath: String = "",
@ -46,6 +73,7 @@ class AdditionalFeedbackInfo {
private val Address.name: String
get() = type.javaClass.simpleName
@Deprecated("Don't use it directly")
fun setCardInfo(data: ScanResponse) {
cardId = data.card.cardId
cardBlockchain = data.walletData?.blockchain ?: ""
@ -55,6 +83,7 @@ class AdditionalFeedbackInfo {
userWalletId = UserWalletIdBuilder.scanResponse(data).build()?.stringValue ?: ""
}
@Deprecated("Don't use it directly")
fun setWalletsInfo(walletManagers: List<WalletManager>) {
walletsInfo.clear()
tokens.clear()

View file

@ -6,6 +6,7 @@ import com.tangem.datasource.local.datastore.core.StringKeyDataStore
import com.tangem.datasource.local.datastore.core.StringKeyDataStoreDecorator
import com.tangem.domain.wallets.models.UserWalletId
import com.tangem.utils.extensions.addOrReplace
import kotlinx.coroutines.flow.Flow
internal class DefaultWalletManagersStore(
dataStore: StringKeyDataStore<List<WalletManager>>,
@ -15,6 +16,10 @@ internal class DefaultWalletManagersStore(
return key.stringValue
}
override fun getAll(userWalletId: UserWalletId): Flow<List<WalletManager>> {
return get(key = userWalletId)
}
override suspend fun getSyncOrNull(
userWalletId: UserWalletId,
blockchain: Blockchain,

View file

@ -3,9 +3,12 @@ package com.tangem.datasource.local.walletmanager
import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchain.common.WalletManager
import com.tangem.domain.wallets.models.UserWalletId
import kotlinx.coroutines.flow.Flow
interface WalletManagersStore {
fun getAll(userWalletId: UserWalletId): Flow<List<WalletManager>>
suspend fun getSyncOrNull(
userWalletId: UserWalletId,
blockchain: Blockchain,

View file

@ -7,8 +7,8 @@ import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchain.common.BlockchainSdkError
import com.tangem.blockchain.common.WalletManager
import com.tangem.blockchain.common.address.Address
import com.tangem.blockchain.common.txhistory.TransactionHistoryRequest
import com.tangem.blockchain.common.address.AddressType
import com.tangem.blockchain.common.txhistory.TransactionHistoryRequest
import com.tangem.blockchain.extensions.Result
import com.tangem.crypto.hdWallet.DerivationPath
import com.tangem.datasource.config.ConfigManager
@ -26,6 +26,7 @@ import com.tangem.domain.walletmanager.model.UpdateWalletManagerResult
import com.tangem.domain.walletmanager.utils.*
import com.tangem.domain.wallets.models.UserWallet
import com.tangem.domain.wallets.models.UserWalletId
import kotlinx.coroutines.flow.Flow
import timber.log.Timber
import java.math.BigDecimal
@ -275,6 +276,10 @@ class DefaultWalletManagersFacade(
return if (manager is ExistentialDepositProvider) manager.getExistentialDeposit() else null
}
override fun getAll(userWalletId: UserWalletId): Flow<List<WalletManager>> {
return walletManagersStore.getAll(userWalletId)
}
private fun updateWalletManagerTokensIfNeeded(walletManager: WalletManager, tokens: Set<CryptoCurrency.Token>) {
if (tokens.isEmpty()) return

View file

@ -4,15 +4,16 @@ import com.tangem.blockchain.blockchains.solana.RentProvider
import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchain.common.WalletManager
import com.tangem.blockchain.common.address.Address
import com.tangem.blockchain.common.address.AddressType
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.tokens.model.Network
import com.tangem.domain.tokens.model.warnings.CryptoCurrencyWarning
import com.tangem.blockchain.common.address.AddressType
import com.tangem.domain.txhistory.models.PaginationWrapper
import com.tangem.domain.txhistory.models.TxHistoryItem
import com.tangem.domain.txhistory.models.TxHistoryState
import com.tangem.domain.walletmanager.model.UpdateWalletManagerResult
import com.tangem.domain.wallets.models.UserWalletId
import kotlinx.coroutines.flow.Flow
import java.math.BigDecimal
// TODO: Move to its own module
@ -97,4 +98,6 @@ interface WalletManagersFacade {
* deactivated and any remaining funds will be destroyed.
*/
suspend fun getExistentialDeposit(userWalletId: UserWalletId, network: Network): BigDecimal?
fun getAll(userWalletId: UserWalletId): Flow<List<WalletManager>>
}