Updated on 2026-08-14

This commit is contained in:
Tangem 2026-04-06 20:37:03 +07:00
commit e52f9de341
987 changed files with 20247 additions and 8171 deletions

View file

@ -17,7 +17,7 @@ import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import timber.log.Timber
import com.tangem.utils.logging.TangemLogger
@Suppress("LongParameterList")
internal class DefaultStakingDeepLinkHandler @AssistedInject constructor(
@ -44,7 +44,7 @@ internal class DefaultStakingDeepLinkHandler @AssistedInject constructor(
// If selected user wallet is different than from deeplink - ignore deeplink
// If selected user wallet is null - ignore deeplink
if (walletId != selectedUserWalletId || selectedUserWalletId == null) {
Timber.e("Error on getting user wallet")
TangemLogger.e("Error on getting user wallet")
return
}
@ -60,7 +60,7 @@ internal class DefaultStakingDeepLinkHandler @AssistedInject constructor(
}
if (cryptoCurrency == null) {
Timber.e(
TangemLogger.e(
"""
Could not get crypto currency for
|- $NETWORK_ID_KEY: $networkId
@ -77,7 +77,7 @@ internal class DefaultStakingDeepLinkHandler @AssistedInject constructor(
val option = (availability as? StakingAvailability.Available)?.option
if (option == null) {
Timber.e("Staking is unavailable for ${cryptoCurrency.name}")
TangemLogger.e("Staking is unavailable for ${cryptoCurrency.name}")
return@launch
}

View file

@ -106,7 +106,7 @@ import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import timber.log.Timber
import com.tangem.utils.logging.TangemLogger
import java.math.BigDecimal
import java.util.concurrent.CopyOnWriteArrayList
import javax.inject.Inject
@ -835,7 +835,7 @@ internal class StakingModel @Inject constructor(
userWalletId = userWalletId,
).fold(
ifLeft = { error ->
Timber.e(error.toString())
TangemLogger.e(error.toString())
analyticsEventHandler.send(
StakingAnalyticsEvent.TransactionError(
errorCode = "CreateApprovalTxError",
@ -864,7 +864,7 @@ internal class StakingModel @Inject constructor(
network = tokenCryptoCurrency.network,
).fold(
ifLeft = { error ->
Timber.e(error.toString())
TangemLogger.e(error.toString())
analyticsEventHandler.send(
StakingAnalyticsEvent.TransactionError(
errorCode = error.getAnalyticsDescription(),
@ -1438,7 +1438,7 @@ internal class StakingModel @Inject constructor(
userWalletId = userWalletId,
network = cryptoCurrencyStatus.currency.network,
).getOrElse { throwable ->
Timber.e(throwable)
TangemLogger.e("Error", throwable)
false
}
@ -1483,8 +1483,7 @@ internal class StakingModel @Inject constructor(
fun getApprovalParams(): GiveApprovalComponent.Params? {
val amountState = value.amountState as? AmountState.Data ?: return null
val validatorState = value.validatorState as? StakingStates.ValidatorState.Data ?: return null
val targetAddress = validatorState.chosenTarget.address
val approval = stakingApproval as? StakingApproval.Needed ?: return null
val feeCurrencyStatus = feeCryptoCurrencyStatus ?: return null
return GiveApprovalComponent.Params(
@ -1492,11 +1491,13 @@ internal class StakingModel @Inject constructor(
cryptoCurrencyStatus = cryptoCurrencyStatus,
feeCryptoCurrencyStatus = feeCurrencyStatus,
amount = amountState.amountTextField.value,
spenderAddress = targetAddress,
subtitle = resourceReference(
spenderAddress = approval.spenderAddress,
amountFooter = resourceReference(
id = R.string.give_permission_staking_subtitle,
formatArgs = wrappedList(cryptoCurrencyStatus.currency.symbol),
),
feeFooter = resourceReference(R.string.staking_give_permission_fee_footer),
isHoldToConfirm = value.shouldShowHoldToConfirmButton,
callback = approvalCallback,
)
}

View file

@ -39,7 +39,7 @@ import dagger.assisted.AssistedInject
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.coroutineScope
import timber.log.Timber
import com.tangem.utils.logging.TangemLogger
import java.math.BigDecimal
@Suppress("LongParameterList")
@ -286,7 +286,7 @@ internal class StakeKitTransactionSender @AssistedInject constructor(
transactionHash = transactionHash,
)
}.onRight {
Timber.d("Successful hash submission")
TangemLogger.d("Successful hash submission")
}
}
}

View file

@ -44,8 +44,10 @@ internal class SetButtonsStateTransformer(
val isConfirmation = prevState.currentStep == StakingStep.Confirmation
val isInProgress = innerConfirmState == InnerConfirmationStakingState.IN_PROGRESS
val isCompleted = innerConfirmState == InnerConfirmationStakingState.COMPLETED
val isApprovalRequired = prevState.isApprovalRequired()
val isHoldToConfirm = prevState.shouldShowHoldToConfirmButton && isConfirmation && !isCompleted
val isHoldToConfirm = prevState.shouldShowHoldToConfirmButton &&
isConfirmation && !isCompleted && !isApprovalRequired
val isIconVisible = isConfirmation && !isCompleted && !isHoldToConfirm
val isPrimaryButtonDisabled = prevState.isPrimaryButtonDisabled()
return NavigationButton(
@ -114,14 +116,9 @@ internal class SetButtonsStateTransformer(
private fun StakingUiState.getConfirmationButtonText(): TextReference {
val confirmationState = confirmationState as? StakingStates.ConfirmationState.Data
?: return resourceReference(R.string.common_close)
val amountState = amountState as? AmountState.Data
?: return resourceReference(R.string.common_close)
if (actionType is StakingActionCommonType.Enter) {
val amount = amountState.amountTextField.cryptoAmount.value.orZero()
if (confirmationState.isApprovalNeeded && confirmationState.allowance < amount) {
return resourceReference(R.string.give_permission_title)
}
if (isApprovalRequired()) {
return resourceReference(R.string.give_permission_title)
}
return getBaseActionText(confirmationState)
@ -151,18 +148,13 @@ internal class SetButtonsStateTransformer(
private fun StakingUiState.onConfirmationClick() {
val confirmationState = confirmationState as? StakingStates.ConfirmationState.Data
val amountState = amountState as? AmountState.Data
if (confirmationState != null && amountState != null) {
if (confirmationState != null) {
if (confirmationState.innerState == InnerConfirmationStakingState.COMPLETED) {
clickIntents.onNextClick()
} else if (isApprovalRequired()) {
clickIntents.showApprovalBottomSheet()
} else {
val amount = amountState.amountTextField.cryptoAmount.value.orZero()
val isEnterAction = actionType is StakingActionCommonType.Enter
if (isEnterAction && confirmationState.isApprovalNeeded && confirmationState.allowance < amount) {
clickIntents.showApprovalBottomSheet()
} else {
clickIntents.onActionClick()
}
clickIntents.onActionClick()
}
} else {
clickIntents.onBackClick()
@ -177,6 +169,15 @@ internal class SetButtonsStateTransformer(
return !hasNotStaking && isCardano && currentStep == StakingStep.InitialInfo
}
private fun StakingUiState.isApprovalRequired(): Boolean {
val confirmState = confirmationState as? StakingStates.ConfirmationState.Data ?: return false
val amountState = amountState as? AmountState.Data ?: return false
val amount = amountState.amountTextField.cryptoAmount.value.orZero()
return actionType is StakingActionCommonType.Enter &&
confirmState.isApprovalNeeded &&
confirmState.allowance < amount
}
private fun StakingUiState.isButtonEnabled(): Boolean {
return when (currentStep) {
StakingStep.InitialInfo -> initialInfoState.isPrimaryButtonEnabled

View file

@ -78,6 +78,7 @@ internal class ShowApprovalBottomSheetTransformer(
footerText = resourceReference(R.string.staking_give_permission_fee_footer),
onChangeApproveType = prevState.clickIntents::onApproveTypeChange,
onOpenLearnMoreAboutApproveClick = {},
isResetApproval = false,
),
walletInteractionIcon = walletInterationIcon(userWallet),
onCancel = onDismiss,