diff --git a/core/res/src/main/res/values/strings.xml b/core/res/src/main/res/values/strings.xml index 312a920261..a6a6b012a1 100644 --- a/core/res/src/main/res/values/strings.xml +++ b/core/res/src/main/res/values/strings.xml @@ -1382,8 +1382,6 @@ Target account is not created. Please change the amount to send. The amount to send must be at least %s Leave %s - A trustline for %s is required first. - Can\'t receive token Reduce by %s Reduce to %s Kindly be aware that your transaction may experience delays under specific fee settings diff --git a/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapModel.kt b/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapModel.kt index b6ad8a358f..4d176bfa79 100644 --- a/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapModel.kt +++ b/features/swap/impl/src/main/java/com/tangem/feature/swap/model/SwapModel.kt @@ -1283,6 +1283,55 @@ internal class SwapModel @Inject constructor( } } + private fun onTransferClick() { + val fromSwapCurrencyStatus = dataState.fromSwapCurrencyStatus + val toSwapCurrencyStatus = dataState.toSwapCurrencyStatus + val fee = (feeSelectorRepository.state.value as? FeeSelectorUM.Content)?.selectedFeeItem?.fee + if (fromSwapCurrencyStatus == null || toSwapCurrencyStatus == null || fee == null) { + TangemLogger.e("onTransferClick: missing currency status or fee, aborting") + showAlert() + return + } + uiState = swapTransferStateBuilder.createTransferInProgressState(uiState) + modelScope.launch(dispatchers.main) { + swapTransferInteractor.sendTransfer( + fromSwapCurrencyStatus = fromSwapCurrencyStatus, + toSwapCurrencyStatus = toSwapCurrencyStatus, + fromTokenAmount = lastAmount.value, + fee = fee, + transactionFeeResult = requireNotNull(getSelectedSwapFee()?.transactionFeeResult) { + "It should be not null at this stage" + }, + ).fold( + ifLeft = { error -> + TangemLogger.e("onTransferClick: transfer failed: ${error.getAnalyticsDescription()}") + refreshTransferUIStateAfterFeeUpdate() + showAlert() + }, + ifRight = { txHash -> + val txUrl = getExplorerTransactionUrlUseCase( + txHash = txHash, + currency = fromSwapCurrencyStatus.currency, + ).getOrElse { + TangemLogger.i("onTransferClick: tx hash explore not supported") + "" + } + updateWalletBalance() + uiState = swapTransferStateBuilder.createSuccessState( + uiState = uiState, + dataState = dataState, + appCurrency = selectedAppCurrencyFlow.value, + isAccountsMode = isAccountsMode, + txUrl = txUrl, + timestamp = System.currentTimeMillis(), + fee = null, + ) + router.replaceAll(SwapRoute.Success) + }, + ) + } + } + private suspend fun processTangemPayWithdrawal( fromSwapCurrencyStatus: SwapCurrencyStatus, swapTransactionState: SwapTransactionState.TangemPayWithdrawalData,