Updated on 2026-08-14

This commit is contained in:
Tangem 2025-08-26 14:30:38 +05:00
commit d65c760c56
7 changed files with 42 additions and 28 deletions

View file

@ -240,15 +240,19 @@ internal class DefaultTransactionRepository(
val validator = walletManager as? TransactionValidator
if (validator != null) {
val transactionData = walletManager.createTransaction(
amount = amount,
fee = fee ?: Fee.Common(amount = amount),
destination = destination,
).copy(
extras = getMemoExtras(networkId = network.rawId, memo = memo),
)
try {
val transactionData = walletManager.createTransaction(
amount = amount,
fee = fee ?: Fee.Common(amount = amount),
destination = destination,
).copy(
extras = getMemoExtras(networkId = network.rawId, memo = memo),
)
validator.validate(transactionData = transactionData)
validator.validate(transactionData = transactionData)
} catch (ex: Exception) {
Result.failure(ex)
}
} else {
Timber.e("${walletManager?.wallet?.blockchain} does not support transaction validation")
Result.success(Unit)

View file

@ -21,14 +21,12 @@ class ValidateTransactionUseCase(
destination: String,
userWalletId: UserWalletId,
network: Network,
): Either<Throwable, Unit> = Either.catch {
transactionRepository.validateTransaction(
amount = amount,
fee = fee,
memo = memo,
destination = destination,
userWalletId = userWalletId,
network = network,
).fold(onSuccess = { Unit.right() }, onFailure = { it.left() })
}
): Either<Throwable, Unit> = transactionRepository.validateTransaction(
amount = amount,
fee = fee,
memo = memo,
destination = destination,
userWalletId = userWalletId,
network = network,
).fold(onSuccess = { Unit.right() }, onFailure = { it.left() })
}

View file

@ -139,8 +139,16 @@ internal class SendConfirmModel @Inject constructor(
reduceAmountBy = amountState?.reduceAmountBy.orZero(),
isIgnoreReduce = amountState?.isIgnoreReduce == true,
enteredDestination = destinationUM?.addressTextField?.actualAddress,
fee = feeSelectorUM?.selectedFee,
feeError = (feeUM?.feeSelectorUM as? FeeSelectorUM.Error)?.error,
fee = if (uiState.value.isRedesignEnabled) {
feeUMV2?.selectedFeeItem?.fee
} else {
feeSelectorUM?.selectedFee
},
feeError = if (uiState.value.isRedesignEnabled) {
(uiState.value.feeSelectorUM as? FeeSelectorUMRedesigned.Error)?.error
} else {
(feeUM?.feeSelectorUM as? FeeSelectorUM.Error)?.error
},
)
private var sendIdleTimer: Long = 0L

View file

@ -111,7 +111,7 @@ internal class DefaultNFTSendComponent @AssistedInject constructor(
val stackState by childStack.subscribeAsState()
val state by model.uiState.collectAsStateWithLifecycle()
BackHandler(onBack = ::onChildBack)
BackHandler(onBack = model::onBackClick)
SendContent(
navigationUM = state.navigationUM,
stackState = stackState,

View file

@ -28,6 +28,7 @@ import com.tangem.domain.transaction.error.GetFeeError
import com.tangem.domain.transaction.usecase.CreateNFTTransferTransactionUseCase
import com.tangem.domain.transaction.usecase.GetFeeUseCase
import com.tangem.domain.wallets.usecase.GetUserWalletUseCase
import com.tangem.features.nft.entity.NFTSendSuccessTrigger
import com.tangem.features.send.v2.api.NFTSendComponent
import com.tangem.features.send.v2.api.SendFeatureToggles
import com.tangem.features.send.v2.api.entity.FeeSelectorUM
@ -74,6 +75,7 @@ internal class NFTSendModel @Inject constructor(
private val sendFeedbackEmailUseCase: SendFeedbackEmailUseCase,
private val alertFactory: SendConfirmAlertFactory,
private val sendFeatureToggles: SendFeatureToggles,
private val nftSendSuccessTrigger: NFTSendSuccessTrigger,
) : Model(), SendNFTComponentCallback, NFTSendSuccessComponent.ModelCallback {
val params: NFTSendComponent.Params = paramsContainer.require()
@ -119,6 +121,11 @@ internal class NFTSendModel @Inject constructor(
}
override fun onBackClick() {
if (currentRouteFlow.value == ConfirmSuccess) {
modelScope.launch {
nftSendSuccessTrigger.triggerSuccessNFTSend()
}
}
router.pop()
}

View file

@ -4,6 +4,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.tangem.common.ui.navigationButtons.NavigationModelCallback
import com.tangem.core.decompose.context.AppComponentContext
import com.tangem.core.decompose.context.child
import com.tangem.core.decompose.model.getOrCreateModel
@ -85,7 +86,7 @@ internal class NFTSendSuccessComponent @AssistedInject constructor(
val callback: ModelCallback,
)
interface ModelCallback {
interface ModelCallback : NavigationModelCallback {
fun onResult(nftSendUM: NFTSendUM)
}

View file

@ -1,7 +1,6 @@
package com.tangem.features.send.v2.sendnft.success.model
import androidx.compose.runtime.Stable
import com.tangem.common.routing.AppRouter
import com.tangem.common.ui.navigationButtons.NavigationButton
import com.tangem.common.ui.navigationButtons.NavigationUM
import com.tangem.core.analytics.api.AnalyticsEventHandler
@ -31,7 +30,6 @@ internal class NFTSendSuccessModel @Inject constructor(
paramsContainer: ParamsContainer,
override val dispatchers: CoroutineDispatcherProvider,
private val analyticsEventHandler: AnalyticsEventHandler,
private val appRouter: AppRouter,
private val urlOpener: UrlOpener,
private val shareManager: ShareManager,
) : Model() {
@ -64,16 +62,14 @@ internal class NFTSendSuccessModel @Inject constructor(
isValid = true,
),
)
appRouter.pop()
params.callback.onBackClick()
},
primaryButton = NavigationButton(
textReference = resourceReference(R.string.common_close),
iconRes = null,
isEnabled = true,
isHapticClick = false,
onClick = {
appRouter.pop()
},
onClick = params.callback::onBackClick,
),
prevButton = null,
secondaryPairButtonsUM = NavigationButton(