diff --git a/domain/src/main/java/com/tangem/domain/features/addCustomToken/redux/AddCustomTokenHub.kt b/domain/src/main/java/com/tangem/domain/features/addCustomToken/redux/AddCustomTokenHub.kt index 9a4b0be414..1c09b4116a 100644 --- a/domain/src/main/java/com/tangem/domain/features/addCustomToken/redux/AddCustomTokenHub.kt +++ b/domain/src/main/java/com/tangem/domain/features/addCustomToken/redux/AddCustomTokenHub.kt @@ -2,7 +2,6 @@ package com.tangem.domain.features.addCustomToken.redux import android.webkit.ValueCallback import com.tangem.blockchain.common.Blockchain -import com.tangem.blockchain.common.DerivationStyle import com.tangem.common.extensions.guard import com.tangem.common.services.Result import com.tangem.domain.AddCustomTokenError @@ -571,17 +570,11 @@ private class AddCustomTokenReducer( supportedTokenNetworkIds = supportedTokenNetworkIds ) - var derivationPathState = state.screenState.derivationPath - derivationPathState = when (card.derivationStyle) { - DerivationStyle.LEGACY -> derivationPathState.copy(isVisible = true) - null, DerivationStyle.NEW -> derivationPathState.copy(isVisible = false) - } val form = Form(AddCustomTokenState.createFormFields(card, CustomTokenType.Blockchain)) state.copy( cardDerivationStyle = card.derivationStyle, form = form, tangemTechServiceManager = tangemTechServiceManager, - screenState = state.screenState.copy(derivationPath = derivationPathState) ) } is OnDestroy -> { diff --git a/domain/src/main/java/com/tangem/domain/features/addCustomToken/redux/AddCustomTokenState.kt b/domain/src/main/java/com/tangem/domain/features/addCustomToken/redux/AddCustomTokenState.kt index ed18fe69f5..97c652da19 100644 --- a/domain/src/main/java/com/tangem/domain/features/addCustomToken/redux/AddCustomTokenState.kt +++ b/domain/src/main/java/com/tangem/domain/features/addCustomToken/redux/AddCustomTokenState.kt @@ -50,7 +50,7 @@ data class AddCustomTokenState( fun blockchainToName(blockchain: Blockchain, isDerivationPath: Boolean = false): String? { return when { - isDerivationPath -> blockchain.derivationPath(cardDerivationStyle)?.rawPath + isDerivationPath -> blockchain.derivationPath(DerivationStyle.LEGACY)?.rawPath else -> { when (blockchain) { Blockchain.Unknown -> null @@ -150,10 +150,21 @@ data class AddCustomTokenState( mainNetwork: Blockchain, derivationNetwork: Blockchain, derivationStyle: DerivationStyle? - ): com.tangem.common.hdWallet.DerivationPath? = when (derivationNetwork) { - Blockchain.Unknown -> mainNetwork - else -> derivationNetwork - }.derivationPath(derivationStyle) + ): com.tangem.common.hdWallet.DerivationPath? { + // If we allow user to select derivations, we need to provide different derivations + // (Legacy style derivations). + // But the mainNetwork derivation depends on whether a user has a card + // with legacy derivations or new style derivations. + val derivationStyleToUse = if (derivationNetwork == Blockchain.Unknown) { + derivationStyle + } else { + DerivationStyle.LEGACY + } + return when (derivationNetwork) { + Blockchain.Unknown -> mainNetwork + else -> derivationNetwork + }.derivationPath(derivationStyleToUse) + } internal fun createFormFields(card: Card, type: CustomTokenType): List> { return listOf(