Updated on 2026-08-14

This commit is contained in:
Tangem 2022-10-24 21:31:05 +05:00
parent d7bee9e5c5
commit ddabdb4944
5 changed files with 24 additions and 27 deletions

View file

@ -3,10 +3,10 @@ package com.tangem.tap.features.onboarding
import com.tangem.common.services.Result
import com.tangem.domain.common.ScanResponse
import com.tangem.domain.common.extensions.successOr
import com.tangem.tap.features.onboarding.products.wallet.saltPay.SaltPayRegistrationManager
import com.tangem.tap.features.onboarding.products.wallet.saltPay.SaltPayActivationManager
import com.tangem.tap.features.onboarding.products.wallet.saltPay.message.SaltPayRegistrationError
import com.tangem.tap.features.onboarding.products.wallet.saltPay.redux.SaltPayRegistrationStep
import com.tangem.tap.features.onboarding.products.wallet.saltPay.redux.updateSaltPayStatus
import com.tangem.tap.features.onboarding.products.wallet.saltPay.redux.updateActivationStatus
/**
[REDACTED_AUTHOR]
@ -16,10 +16,10 @@ class OnboardingSaltPayHelper {
suspend fun isOnboardingCase(
scanResponse: ScanResponse,
manager: SaltPayRegistrationManager,
manager: SaltPayActivationManager,
): Result<Boolean> {
return try {
val status = manager.updateSaltPayStatus(
val status = manager.updateActivationStatus(
amountToClaim = null,
step = SaltPayRegistrationStep.None,
).successOr { return it }
@ -36,12 +36,12 @@ class OnboardingSaltPayHelper {
suspend fun testProceedToOnboarding(
scanResponse: ScanResponse,
manager: SaltPayRegistrationManager,
manager: SaltPayActivationManager,
): Result<Boolean> = Result.Success(true)
suspend fun testProceedToMainScreen(
scanResponse: ScanResponse,
manager: SaltPayRegistrationManager,
manager: SaltPayActivationManager,
): Result<Boolean> = Result.Success(false)
}
}

View file

@ -27,7 +27,7 @@ import java.math.BigDecimal
/**
[REDACTED_AUTHOR]
*/
class SaltPayRegistrationManager(
class SaltPayActivationManager(
val cardId: String,
val cardPublicKey: ByteArray,
val walletPublicKey: ByteArray,
@ -162,7 +162,7 @@ class SaltPayRegistrationManager(
)
companion object {
fun stub(): SaltPayRegistrationManager = SaltPayRegistrationManager(
fun stub(): SaltPayActivationManager = SaltPayActivationManager(
kycProvider = SaltPayConfig.stub().kycProvider,
paymentologyService = PaymentologyApiService.stub(),
gnosisRegistrator = GnosisRegistrator.stub(),

View file

@ -1,8 +1,8 @@
package com.tangem.tap.features.onboarding.products.wallet.saltPay.redux
import com.tangem.blockchain.common.Amount
import com.tangem.tap.features.onboarding.products.wallet.saltPay.SaltPayActivationManager
import com.tangem.tap.features.onboarding.products.wallet.saltPay.SaltPayConfig
import com.tangem.tap.features.onboarding.products.wallet.saltPay.SaltPayRegistrationManager
import org.rekotlin.Action
import java.math.BigDecimal
@ -12,7 +12,7 @@ import java.math.BigDecimal
sealed class OnboardingSaltPayAction : Action {
sealed class Init : OnboardingSaltPayAction() {
data class SetDependencies(
val registrationManager: SaltPayRegistrationManager,
val registrationManager: SaltPayActivationManager,
val saltPayConfig: SaltPayConfig,
) : Init()
}

View file

@ -17,8 +17,8 @@ import com.tangem.tap.domain.TangemSigner
import com.tangem.tap.features.demo.DemoHelper
import com.tangem.tap.features.onboarding.products.wallet.redux.OnboardingWalletState
import com.tangem.tap.features.onboarding.products.wallet.saltPay.AllSymbolsTheSameFilter
import com.tangem.tap.features.onboarding.products.wallet.saltPay.SaltPayActivationManager
import com.tangem.tap.features.onboarding.products.wallet.saltPay.SaltPayExceptionHandler
import com.tangem.tap.features.onboarding.products.wallet.saltPay.SaltPayRegistrationManager
import com.tangem.tap.features.onboarding.products.wallet.saltPay.message.SaltPayRegistrationError
import com.tangem.tap.scope
import com.tangem.tap.store
@ -63,7 +63,7 @@ private fun handleOnboardingSaltPayAction(anyAction: Action, appState: () -> App
val state = getState()
scope.launch {
val updateResult = state.saltPayManager.updateSaltPayStatus(
val updateResult = state.saltPayManager.updateActivationStatus(
amountToClaim = state.amountToClaim,
step = state.step,
).successOr {
@ -146,12 +146,9 @@ private fun handleOnboardingSaltPayAction(anyAction: Action, appState: () -> App
onException(it.error)
return@launch
}
handleInProgress = false
val step = when (state.readyToClaim()) {
true -> SaltPayRegistrationStep.Claim
else -> SaltPayRegistrationStep.Finished
}
withMainContext { store.dispatch(OnboardingSaltPayAction.SetStep(step)) }
withMainContext { store.dispatch(OnboardingSaltPayAction.Update) }
}
}
is OnboardingSaltPayAction.TrySetPin -> {
@ -228,7 +225,7 @@ data class UpdateResult(
val amountToClaim: Amount? = null,
)
suspend fun SaltPayRegistrationManager.updateSaltPayStatus(
suspend fun SaltPayActivationManager.updateActivationStatus(
amountToClaim: Amount?,
step: SaltPayRegistrationStep,
): Result<UpdateResult> {
@ -267,7 +264,7 @@ suspend fun SaltPayRegistrationManager.updateSaltPayStatus(
}
private suspend fun getAmountToClaimIfNeeded(
saltPayManager: SaltPayRegistrationManager,
saltPayManager: SaltPayActivationManager,
amountToClaim: Amount?,
): Amount? {
Timber.d("getAmountToClaimIfNeeded: for amount: %s", amountToClaim)
@ -315,7 +312,7 @@ private suspend fun onException(error: Throwable) {
}
private suspend fun checkGasIfNeeded(
saltPayManager: SaltPayRegistrationManager,
saltPayManager: SaltPayActivationManager,
step: SaltPayRegistrationStep,
): Result<Unit> {
Timber.d("checkGasIfNeeded: for step: %s", step)
@ -336,7 +333,7 @@ private suspend fun checkGasIfNeeded(
}
private suspend fun registerKYCIfNeeded(
saltPayManager: SaltPayRegistrationManager,
saltPayManager: SaltPayActivationManager,
step: SaltPayRegistrationStep,
): Result<Unit> {
Timber.d("registerKYCIfNeeded: step: %s", step)
@ -355,7 +352,7 @@ private suspend fun registerKYCIfNeeded(
}
private suspend fun checkRegistration(
saltPayManager: SaltPayRegistrationManager,
saltPayManager: SaltPayActivationManager,
): Result<SaltPayRegistrationStep> {
Timber.d("checkRegistration")
return try {

View file

@ -14,8 +14,8 @@ import com.tangem.tap.copyToClipboard
import com.tangem.tap.domain.extensions.makeSaltPayWalletManager
import com.tangem.tap.features.onboarding.products.wallet.saltPay.GnosisRegistrator
import com.tangem.tap.features.onboarding.products.wallet.saltPay.KYCProvider
import com.tangem.tap.features.onboarding.products.wallet.saltPay.SaltPayActivationManager
import com.tangem.tap.features.onboarding.products.wallet.saltPay.SaltPayConfig
import com.tangem.tap.features.onboarding.products.wallet.saltPay.SaltPayRegistrationManager
import com.tangem.tap.features.wallet.redux.ProgressState
import com.tangem.tap.persistence.SaltPayRegistrationStorage
import com.tangem.tap.preferencesStorage
@ -27,7 +27,7 @@ import java.math.BigDecimal
*/
data class OnboardingSaltPayState(
@Transient
val saltPayManager: SaltPayRegistrationManager = SaltPayRegistrationManager.stub(),
val saltPayManager: SaltPayActivationManager = SaltPayActivationManager.stub(),
val saltPayConfig: SaltPayConfig = SaltPayConfig.stub(),
val pinCode: String? = null,
val accessCode: String? = null,
@ -47,7 +47,7 @@ data class OnboardingSaltPayState(
val pinLength: Int = 4
companion object {
fun initDependency(scanResponse: ScanResponse): Pair<SaltPayRegistrationManager, SaltPayConfig> {
fun initDependency(scanResponse: ScanResponse): Pair<SaltPayActivationManager, SaltPayConfig> {
val globalState = store.state.globalState
val saltPayConfig = globalState.configManager?.config?.saltPayConfig.guard {
throw NullPointerException("SaltPayConfig is not initialized")
@ -85,7 +85,7 @@ data class OnboardingSaltPayState(
paymentologyService: PaymentologyApiService,
registrationStorage: SaltPayRegistrationStorage,
kycProvider: KYCProvider,
): SaltPayRegistrationManager {
): SaltPayActivationManager {
if (!scanResponse.isSaltPay()) {
throw IllegalArgumentException("Can't initialize the OnboardingSaltPayMiddleware if card is not SalPay")
}
@ -93,7 +93,7 @@ data class OnboardingSaltPayState(
throw NullPointerException("SaltPay card must have one wallet at least")
}
return SaltPayRegistrationManager(
return SaltPayActivationManager(
cardId = scanResponse.card.cardId,
cardPublicKey = scanResponse.card.cardPublicKey,
walletPublicKey = saltPaySingleWallet.publicKey,