From 7d32dc04b2079ac3497654b95b53ee19f3c54827 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 29 Jan 2026 13:44:17 +0400 Subject: [PATCH] Updated on 2026-08-14 --- .../account/tokens/DefaultMainAccountTokensMigration.kt | 8 +++++--- .../token/DefaultMainAccountTokensMigrationTest.kt | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/data/account/src/main/kotlin/com/tangem/data/account/tokens/DefaultMainAccountTokensMigration.kt b/data/account/src/main/kotlin/com/tangem/data/account/tokens/DefaultMainAccountTokensMigration.kt index ce03285690..f03409232e 100644 --- a/data/account/src/main/kotlin/com/tangem/data/account/tokens/DefaultMainAccountTokensMigration.kt +++ b/data/account/src/main/kotlin/com/tangem/data/account/tokens/DefaultMainAccountTokensMigration.kt @@ -48,15 +48,17 @@ internal class DefaultMainAccountTokensMigration( exception } val mainAccount = findAccount(response = response, derivationIndex = DerivationIndex.Main) - val notMainAccounts = response.accounts + val customAccounts = response.accounts .filterNot { accountDTO -> accountDTO.derivationIndex.toDerivationIndex().isMain } - if (notMainAccounts.isEmpty()) { + if (customAccounts.isEmpty()) { Timber.i("There is only the Main account. Nothing to migrate") return@either response } + val customAccountIndexes = customAccounts.mapTo(hashSetOf(), WalletAccountDTO::derivationIndex) val unassignedTokens = mainAccount.groupUnassignedTokens() + .filter { it.key.value in customAccountIndexes } if (unassignedTokens.isEmpty()) { Timber.i("No unassigned tokens found for migration") @@ -64,7 +66,7 @@ internal class DefaultMainAccountTokensMigration( } var updatedMainAccount = mainAccount - val assignedTokensAccounts = notMainAccounts.mapNotNull { accountDTO -> + val assignedTokensAccounts = customAccounts.mapNotNull { accountDTO -> val derivationIndex = accountDTO.derivationIndex.toDerivationIndex() val tokensForAccount = unassignedTokens[derivationIndex] if (tokensForAccount.isNullOrEmpty()) return@mapNotNull null diff --git a/data/account/src/test/java/com/tangem/data/account/token/DefaultMainAccountTokensMigrationTest.kt b/data/account/src/test/java/com/tangem/data/account/token/DefaultMainAccountTokensMigrationTest.kt index e4d0df9606..150d3ec917 100644 --- a/data/account/src/test/java/com/tangem/data/account/token/DefaultMainAccountTokensMigrationTest.kt +++ b/data/account/src/test/java/com/tangem/data/account/token/DefaultMainAccountTokensMigrationTest.kt @@ -376,6 +376,7 @@ class DefaultMainAccountTokensMigrationTest { derivationIndex = DerivationIndex.Main.value, tokens = listOf( createBitcoin(accountIndex = 0), + createBitcoin(accountIndex = 10), ), )