Updated on 2026-08-14
This commit is contained in:
commit
72a3eb6d7f
6 changed files with 91 additions and 73 deletions
|
|
@ -4,6 +4,7 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import com.arkivanov.decompose.ComponentContext
|
||||
import com.arkivanov.decompose.DelicateDecomposeApi
|
||||
import com.arkivanov.decompose.extensions.compose.stack.Children
|
||||
import com.arkivanov.decompose.extensions.compose.stack.animation.stackAnimation
|
||||
import com.arkivanov.decompose.extensions.compose.subscribeAsState
|
||||
|
|
@ -13,6 +14,7 @@ import com.tangem.core.decompose.context.AppComponentContext
|
|||
import com.tangem.core.decompose.context.childByContext
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
|
||||
import com.tangem.core.ui.decompose.ComposableContentComponent
|
||||
import com.tangem.domain.tokens.model.Network
|
||||
import com.tangem.features.managetokens.analytics.CustomTokenAnalyticsEvent
|
||||
import com.tangem.features.managetokens.component.AddCustomTokenComponent
|
||||
import com.tangem.features.managetokens.component.CustomTokenFormComponent
|
||||
|
|
@ -171,6 +173,7 @@ internal class DefaultAddCustomTokenComponent @AssistedInject constructor(
|
|||
showForm(derivationPath = derivationPath)
|
||||
}
|
||||
|
||||
@OptIn(DelicateDecomposeApi::class)
|
||||
private fun showDerivationPathSelector(formValues: CustomTokenFormValues) {
|
||||
val currentConfig = contentStack.value.active.configuration
|
||||
|
||||
|
|
@ -181,6 +184,7 @@ internal class DefaultAddCustomTokenComponent @AssistedInject constructor(
|
|||
navigation.push(config)
|
||||
}
|
||||
|
||||
@OptIn(DelicateDecomposeApi::class)
|
||||
private fun showNetworkSelector(formValues: CustomTokenFormValues) {
|
||||
val currentConfig = contentStack.value.active.configuration
|
||||
|
||||
|
|
@ -194,14 +198,35 @@ internal class DefaultAddCustomTokenComponent @AssistedInject constructor(
|
|||
private fun showForm(network: SelectedNetwork? = null, derivationPath: SelectedDerivationPath? = null) {
|
||||
val currentConfig = contentStack.value.active.configuration
|
||||
|
||||
val selectedNetwork = network ?: currentConfig.selectedNetwork
|
||||
val selectedDerivationPath = derivationPath ?: currentConfig.selectedDerivationPath
|
||||
|
||||
val config = currentConfig.copy(
|
||||
step = AddCustomTokenConfig.Step.FORM,
|
||||
selectedNetwork = network ?: currentConfig.selectedNetwork,
|
||||
selectedDerivationPath = derivationPath ?: currentConfig.selectedDerivationPath,
|
||||
selectedNetwork = selectedNetwork,
|
||||
selectedDerivationPath = defineSelectedDerivationPath(selectedNetwork, selectedDerivationPath),
|
||||
)
|
||||
|
||||
navigation.replaceAll(config)
|
||||
}
|
||||
|
||||
private fun defineSelectedDerivationPath(
|
||||
selectedNetwork: SelectedNetwork?,
|
||||
selectedDerivationPath: SelectedDerivationPath?,
|
||||
): SelectedDerivationPath? {
|
||||
// if default derivation path
|
||||
if (selectedDerivationPath?.value == selectedNetwork?.derivationPath) return null
|
||||
|
||||
// map to custom derivation path
|
||||
return if (selectedDerivationPath != null && selectedDerivationPath.value.value != null) {
|
||||
selectedDerivationPath.copy(
|
||||
value = Network.DerivationPath.Custom(value = requireNotNull(selectedDerivationPath.value.value)),
|
||||
)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private fun dismissAndNotify() {
|
||||
dismiss()
|
||||
params.onCurrencyAdded()
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ internal class OnrampAddToPortfolioModel @Inject constructor(
|
|||
|
||||
addCryptoCurrenciesUseCase(
|
||||
userWalletId = params.userWalletId,
|
||||
currencies = listOfNotNull(params.cryptoCurrency),
|
||||
currency = params.cryptoCurrency,
|
||||
)
|
||||
.onRight { params.onSuccessAdding(params.cryptoCurrency.id) }
|
||||
.onLeft { changeAddButtonProgressStatus(isProgress = false) }
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ internal class ReferralInteractorImpl(
|
|||
}
|
||||
|
||||
val cryptoCurrency = repository.getCryptoCurrency(userWalletId = userWallet.walletId, tokenData = tokenData)
|
||||
?: error("Failed to create crypto currency")
|
||||
|
||||
derivePublicKeysUseCase(userWallet.walletId, listOfNotNull(cryptoCurrency)).getOrElse {
|
||||
Timber.e("Failed to derive public keys: $it")
|
||||
throw it.mapToDomainError()
|
||||
|
|
@ -47,12 +49,12 @@ internal class ReferralInteractorImpl(
|
|||
|
||||
addCryptoCurrenciesUseCase(
|
||||
userWalletId = userWallet.walletId,
|
||||
currencies = listOfNotNull(cryptoCurrency),
|
||||
currency = cryptoCurrency,
|
||||
)
|
||||
|
||||
val publicAddress = userWalletManager.getWalletAddress(
|
||||
networkId = tokenData.networkId,
|
||||
derivationPath = cryptoCurrency?.network?.derivationPath?.value,
|
||||
derivationPath = cryptoCurrency.network.derivationPath.value,
|
||||
)
|
||||
|
||||
return repository.startReferral(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue