Updated on 2026-08-14
This commit is contained in:
parent
3ef300ee56
commit
640e6433ff
7 changed files with 165 additions and 18 deletions
|
|
@ -1,16 +1,26 @@
|
|||
plugins {
|
||||
alias(deps.plugins.kotlin.jvm)
|
||||
alias(deps.plugins.android.library)
|
||||
alias(deps.plugins.kotlin.android)
|
||||
alias(deps.plugins.kotlin.kapt)
|
||||
alias(deps.plugins.kotlin.serialization)
|
||||
id("configuration")
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.tangem.domain.referral"
|
||||
}
|
||||
dependencies {
|
||||
|
||||
/** Libs */
|
||||
implementation(project(":core:utils"))
|
||||
implementation(project(":libs:crypto"))
|
||||
implementation(projects.core.utils)
|
||||
|
||||
/** Time */
|
||||
/** Core modules */
|
||||
implementation(projects.libs.crypto)
|
||||
|
||||
/** Feature Apis */
|
||||
implementation(projects.features.wallet.api)
|
||||
|
||||
/** Dependencies */
|
||||
implementation(deps.jodatime)
|
||||
|
||||
/** DI */
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.tangem.feature.referral.domain
|
|||
import com.tangem.feature.referral.domain.converter.TokensConverter
|
||||
import com.tangem.feature.referral.domain.models.ReferralData
|
||||
import com.tangem.feature.referral.domain.models.TokenData
|
||||
import com.tangem.features.wallet.featuretoggles.WalletFeatureToggles
|
||||
import com.tangem.lib.crypto.DerivationManager
|
||||
import com.tangem.lib.crypto.UserWalletManager
|
||||
import com.tangem.lib.crypto.models.Currency
|
||||
|
|
@ -12,6 +13,7 @@ internal class ReferralInteractorImpl(
|
|||
private val derivationManager: DerivationManager,
|
||||
private val userWalletManager: UserWalletManager,
|
||||
private val tokensConverter: TokensConverter,
|
||||
private val walletFeatureToggles: WalletFeatureToggles,
|
||||
) : ReferralInteractor {
|
||||
|
||||
private val tokensForReferral = mutableListOf<TokenData>()
|
||||
|
|
@ -30,7 +32,11 @@ internal class ReferralInteractorImpl(
|
|||
override suspend fun startReferral(): ReferralData {
|
||||
if (tokensForReferral.isNotEmpty()) {
|
||||
val currency = tokensConverter.convert(tokensForReferral.first())
|
||||
val derivationPath = deriveOrAddTokens(currency)
|
||||
val derivationPath = if (walletFeatureToggles.isRedesignedScreenEnabled) {
|
||||
derivationManager.deriveAndAddTokens(currency)
|
||||
} else {
|
||||
deriveAndAddTokens(currency)
|
||||
}
|
||||
val publicAddress = userWalletManager.getWalletAddress(currency.networkId, derivationPath)
|
||||
return repository.startReferral(
|
||||
walletId = userWalletManager.getWalletId(),
|
||||
|
|
@ -43,7 +49,7 @@ internal class ReferralInteractorImpl(
|
|||
}
|
||||
}
|
||||
|
||||
private suspend fun deriveOrAddTokens(currency: Currency): String {
|
||||
private suspend fun deriveAndAddTokens(currency: Currency): String {
|
||||
val derivationPath = derivationManager.getDerivationPathForBlockchain(currency.networkId)
|
||||
if (derivationPath.isNullOrEmpty()) error("derivationPath shouldn't be empty")
|
||||
if (!derivationManager.hasDerivation(currency.networkId, derivationPath)) {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.tangem.feature.referral.domain.ReferralInteractor
|
|||
import com.tangem.feature.referral.domain.ReferralInteractorImpl
|
||||
import com.tangem.feature.referral.domain.ReferralRepository
|
||||
import com.tangem.feature.referral.domain.converter.TokensConverter
|
||||
import com.tangem.features.wallet.featuretoggles.WalletFeatureToggles
|
||||
import com.tangem.lib.crypto.DerivationManager
|
||||
import com.tangem.lib.crypto.UserWalletManager
|
||||
import dagger.Module
|
||||
|
|
@ -23,12 +24,14 @@ class ReferralDomainModule {
|
|||
derivationManager: DerivationManager,
|
||||
userWalletManager: UserWalletManager,
|
||||
tokensConverter: TokensConverter,
|
||||
walletFeatureToggles: WalletFeatureToggles,
|
||||
): ReferralInteractor {
|
||||
return ReferralInteractorImpl(
|
||||
repository = referralRepository,
|
||||
derivationManager = derivationManager,
|
||||
userWalletManager = userWalletManager,
|
||||
tokensConverter = tokensConverter,
|
||||
walletFeatureToggles = walletFeatureToggles,
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue