Updated on 2026-08-14

This commit is contained in:
Tangem 2026-01-27 15:59:27 +07:00
parent 10599d6770
commit 0051a20463
4 changed files with 13 additions and 11 deletions

View file

@ -1,13 +1,14 @@
package com.tangem.datasource.local.accounts package com.tangem.datasource.local.accounts
import com.tangem.domain.models.account.AccountName
import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.models.wallet.UserWalletId
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
interface AccountTokenMigrationStore { interface AccountTokenMigrationStore {
fun get(userWalletId: UserWalletId): Flow<Pair<String, String>?> fun get(userWalletId: UserWalletId): Flow<Pair<AccountName, AccountName>?>
suspend fun store(userWalletId: UserWalletId, value: Pair<String, String>) suspend fun store(userWalletId: UserWalletId, value: Pair<AccountName, AccountName>)
suspend fun remove(userWalletId: UserWalletId) suspend fun remove(userWalletId: UserWalletId)
} }

View file

@ -1,19 +1,20 @@
package com.tangem.datasource.local.accounts package com.tangem.datasource.local.accounts
import com.tangem.datasource.local.datastore.RuntimeStateStore import com.tangem.datasource.local.datastore.RuntimeStateStore
import com.tangem.domain.models.account.AccountName
import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.models.wallet.UserWalletId
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
internal class DefaultAccountTokenMigrationStore( internal class DefaultAccountTokenMigrationStore(
private val runtimeStateStore: RuntimeStateStore<Map<UserWalletId, Pair<String, String>>>, private val runtimeStateStore: RuntimeStateStore<Map<UserWalletId, Pair<AccountName, AccountName>>>,
) : AccountTokenMigrationStore { ) : AccountTokenMigrationStore {
override fun get(userWalletId: UserWalletId): Flow<Pair<String, String>?> { override fun get(userWalletId: UserWalletId): Flow<Pair<AccountName, AccountName>?> {
return runtimeStateStore.get().map { it[userWalletId] } return runtimeStateStore.get().map { it[userWalletId] }
} }
override suspend fun store(userWalletId: UserWalletId, value: Pair<String, String>) { override suspend fun store(userWalletId: UserWalletId, value: Pair<AccountName, AccountName>) {
runtimeStateStore.update { it + (userWalletId to value) } runtimeStateStore.update { it + (userWalletId to value) }
} }

View file

@ -7,6 +7,7 @@ import arrow.core.raise.ensureNotNull
import arrow.core.toNonEmptyListOrNull import arrow.core.toNonEmptyListOrNull
import com.tangem.blockchain.common.Blockchain import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchainsdk.utils.fromNetworkId import com.tangem.blockchainsdk.utils.fromNetworkId
import com.tangem.data.account.converter.AccountNameConverter
import com.tangem.data.account.converter.toDerivationIndex import com.tangem.data.account.converter.toDerivationIndex
import com.tangem.data.account.store.AccountsResponseStoreFactory import com.tangem.data.account.store.AccountsResponseStoreFactory
import com.tangem.data.account.utils.assignTokens import com.tangem.data.account.utils.assignTokens
@ -144,11 +145,9 @@ internal class DefaultMainAccountTokensMigration(
store.updateData { updatedResponse } store.updateData { updatedResponse }
val mainAccountName = mainAccount.name val mainAccountName = AccountNameConverter.convertBack(mainAccount.name)
val selectedAccountName = selectedAccount.name val selectedAccountName = AccountNameConverter.convertBack(selectedAccount.name)
if (mainAccountName != null && selectedAccountName != null) { accountTokenMigrationStore.store(userWalletId, mainAccountName to selectedAccountName)
accountTokenMigrationStore.store(userWalletId, mainAccountName to selectedAccountName)
}
val userTokensResponse = updatedResponse.toUserTokensResponse() val userTokensResponse = updatedResponse.toUserTokensResponse()
userTokensSaver.pushWithRetryer( userTokensSaver.pushWithRetryer(

View file

@ -10,6 +10,7 @@ import com.arkivanov.decompose.extensions.compose.subscribeAsState
import com.arkivanov.decompose.router.slot.childSlot import com.arkivanov.decompose.router.slot.childSlot
import com.arkivanov.decompose.router.slot.dismiss import com.arkivanov.decompose.router.slot.dismiss
import com.arkivanov.essenty.lifecycle.subscribe import com.arkivanov.essenty.lifecycle.subscribe
import com.tangem.common.ui.account.toUM
import com.tangem.core.decompose.context.AppComponentContext import com.tangem.core.decompose.context.AppComponentContext
import com.tangem.core.decompose.context.childByContext import com.tangem.core.decompose.context.childByContext
import com.tangem.core.decompose.model.getOrCreateModel import com.tangem.core.decompose.model.getOrCreateModel
@ -146,7 +147,7 @@ internal class DefaultWalletSettingsComponent @AssistedInject constructor(
title = resourceReference(R.string.accounts_migration_alert_title), title = resourceReference(R.string.accounts_migration_alert_title),
message = resourceReference( message = resourceReference(
R.string.accounts_migration_alert_message, R.string.accounts_migration_alert_message,
wrappedList(fromAccount, toAccount), wrappedList(fromAccount.toUM().value, toAccount.toUM().value),
), ),
firstActionBuilder = { firstActionBuilder = {
EventMessageAction( EventMessageAction(