Updated on 2026-08-14

This commit is contained in:
Tangem 2025-09-29 15:01:51 +04:00
parent e83898b9ee
commit 9aecc175bf
5 changed files with 420 additions and 1 deletions

View file

@ -0,0 +1,23 @@
package com.tangem.domain.account.tokens
import arrow.core.Either
import com.tangem.domain.models.account.DerivationIndex
import com.tangem.domain.models.wallet.UserWalletId
/**
* Interface for migrating tokens associated with a main account,
* but belonging to another account according to the derivation path.
*
[REDACTED_AUTHOR]
*/
interface MainAccountTokensMigration {
/**
* Migration of non-native tokens from the main account to the account with the provided [derivationIndex].
* If there are no such tokens, the function will complete successfully.
*
* @param userWalletId The unique identifier of the user's wallet.
* @param derivationIndex The derivation index associated with the account.
*/
suspend fun migrate(userWalletId: UserWalletId, derivationIndex: DerivationIndex): Either<Throwable, Unit>
}

View file

@ -28,7 +28,7 @@ class GetUnoccupiedAccountIndexUseCase(
suspend operator fun invoke(userWalletId: UserWalletId): Either<Error, DerivationIndex> = either {
val totalAccountsCount = getTotalAccountsCount(userWalletId = userWalletId)
DerivationIndex(totalAccountsCount + 1).getOrElse {
DerivationIndex(value = totalAccountsCount).getOrElse {
raise(Error.InvalidDerivationIndex(it))
}
}