Updated on 2026-08-14
This commit is contained in:
parent
798c69bb14
commit
2c2da057ef
3 changed files with 24 additions and 8 deletions
|
|
@ -69,6 +69,20 @@ class GetExtendedPublicKeyForCurrencyUseCase(
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if xpub generation is supported, false otherwise
|
||||
*/
|
||||
suspend fun isSupported(userWalletId: UserWalletId, network: Network): Boolean {
|
||||
val userWallet = walletManagersFacade.getOrCreateWalletManager(userWalletId, network)
|
||||
?: error("Wallet not found")
|
||||
|
||||
val blockchain = Blockchain.fromId(network.id.value)
|
||||
val isSecp256k1Blockchain = Blockchain.secp256k1Blockchains(network.isTestnet).contains(blockchain)
|
||||
val isHdKey = userWallet.wallet.publicKey.derivationType?.hdKey
|
||||
|
||||
return isSecp256k1Blockchain && isHdKey != null
|
||||
}
|
||||
|
||||
private suspend fun deriveKeys(
|
||||
userWalletId: UserWalletId,
|
||||
seedKey: ByteArray,
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ import com.tangem.domain.txhistory.models.TxHistoryStateError
|
|||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.domain.wallets.usecase.GetUserWalletUseCase
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.SwapTransactionsState
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenBalanceSegmentedButtonConfig
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsAppBarMenuConfig
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsState
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.*
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.components.TokenDetailsDialogConfig
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.factory.txhistory.TokenDetailsLoadedTxHistoryConverter
|
||||
import com.tangem.feature.tokendetails.presentation.tokendetails.state.factory.txhistory.TokenDetailsLoadingTxHistoryConverter
|
||||
|
|
@ -366,13 +366,13 @@ internal class TokenDetailsStateFactory(
|
|||
fun getStateWithUpdatedMenu(
|
||||
cardTypesResolver: CardTypesResolver,
|
||||
hasDerivations: Boolean,
|
||||
isBitcoin: Boolean,
|
||||
isSupported: Boolean,
|
||||
): TokenDetailsState {
|
||||
return with(currentStateProvider()) {
|
||||
copy(
|
||||
topAppBarConfig = topAppBarConfig.copy(
|
||||
tokenDetailsAppBarMenuConfig = topAppBarConfig.tokenDetailsAppBarMenuConfig
|
||||
?.updateMenu(cardTypesResolver, hasDerivations, isBitcoin),
|
||||
?.updateMenu(cardTypesResolver, hasDerivations, isSupported),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
@ -387,10 +387,10 @@ internal class TokenDetailsStateFactory(
|
|||
private fun TokenDetailsAppBarMenuConfig.updateMenu(
|
||||
cardTypesResolver: CardTypesResolver,
|
||||
hasDerivations: Boolean,
|
||||
isBitcoin: Boolean,
|
||||
isSupported: Boolean,
|
||||
): TokenDetailsAppBarMenuConfig? {
|
||||
if (cardTypesResolver.isSingleWalletWithToken()) return null
|
||||
val showGenerateExtendedKey = featureToggles.isGenerateXPubEnabled() && isBitcoin
|
||||
val showGenerateExtendedKey = featureToggles.isGenerateXPubEnabled() && isSupported
|
||||
return copy(
|
||||
items = buildList {
|
||||
if (showGenerateExtendedKey && hasDerivations) {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,6 @@ import com.tangem.feature.tokendetails.presentation.tokendetails.ui.components.e
|
|||
import com.tangem.features.staking.api.featuretoggles.StakingFeatureToggles
|
||||
import com.tangem.features.tokendetails.featuretoggles.TokenDetailsFeatureToggles
|
||||
import com.tangem.features.tokendetails.impl.R
|
||||
import com.tangem.lib.crypto.BlockchainUtils.isBitcoin
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.coroutines.*
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
|
|
@ -123,7 +122,7 @@ internal class TokenDetailsViewModel @Inject constructor(
|
|||
private val analyticsEventsHandler: AnalyticsEventHandler,
|
||||
private val vibratorHapticManager: VibratorHapticManager,
|
||||
private val clipboardManager: ClipboardManager,
|
||||
private val getUserWalletUseCase: GetUserWalletUseCase,
|
||||
getUserWalletUseCase: GetUserWalletUseCase,
|
||||
tokenDetailsFeatureToggles: TokenDetailsFeatureToggles,
|
||||
deepLinksRegistry: DeepLinksRegistry,
|
||||
savedStateHandle: SavedStateHandle,
|
||||
|
|
@ -412,10 +411,13 @@ internal class TokenDetailsViewModel @Inject constructor(
|
|||
viewModelScope.launch(dispatchers.main) {
|
||||
val hasDerivations =
|
||||
networkHasDerivationUseCase(userWallet.scanResponse, cryptoCurrency.network).getOrElse { false }
|
||||
|
||||
val isSupported = getExtendedPublicKeyForCurrencyUseCase.isSupported(userWalletId, cryptoCurrency.network)
|
||||
|
||||
internalUiState.value = stateFactory.getStateWithUpdatedMenu(
|
||||
cardTypesResolver = userWallet.scanResponse.cardTypesResolver,
|
||||
hasDerivations = hasDerivations,
|
||||
isBitcoin = isBitcoin(cryptoCurrency.network.id.value),
|
||||
isSupported = isSupported,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue