Updated on 2026-08-14

This commit is contained in:
Tangem 2024-04-12 13:50:41 +05:00
commit c9d28994b4
12 changed files with 22 additions and 21 deletions

View file

@ -426,8 +426,8 @@
<string name="scan_card_settings_title">Приготовьте свою карту</string>
<string name="send_additional_field_already_included">Уже содержится в введенном адресе</string>
<string name="send_alert_fee_coverage_subract_text">Вычесть</string>
<string name="send_alert_fee_coverage_title">Недостаточно средств для покрытия комиссии сети. Вычесть комиссию %s из отправляемой суммы?</string>
<string name="send_alert_fee_too_high_text">Сумма комиссии в %s раз превышает рекомендованную. Убедитесь, что указанная комиссия верна.</string>
<string name="send_alert_fee_coverage_title">Недостаточно средств для покрытия комиссии сети. Вычесть недостающую сумму для покрытия комиссии из отправляемой суммы?</string>
<string name="send_alert_fee_too_high_text">Сумма комиссии в %@ раз превышает рекомендованную. Убедитесь, что указанная комиссия верна.</string>
<string name="send_alert_fee_too_low_text">Вы указали комиссию ниже рекомендуемой, это может привести к задержке исполнения вашей транзакции. Продолжить?</string>
<string name="send_alert_transaction_failed_text">Причина: %1$s\nКод: %2$s</string>
<string name="send_alert_transaction_failed_title">Транзакция не выполнена</string>
@ -487,6 +487,7 @@
<string name="send_recipient_label">Отправить</string>
<string name="send_recipient_memo_footer">Мемо/ Код назначения - это код, разделяющий транзакции к общему получателю в сети криптовалют. Внимание: отсутствие мемо может привести к потере средств.</string>
<string name="send_recipient_wallets_title">Мои кошельки</string>
<string name="send_satoshi_per_byte_text">Это способ измерения комиссии за отправку биткоин-транзакции. Он указывает на количество самой маленькой единицы биткоина (сатоши) за каждый байт данных в транзакции. Чем выше это число, тем быстрее будет обработана транзакция сетью.</string>
<string name="send_sending">Отправка</string>
<string name="send_summary_tap_hint">Нажмите на любое поле, чтобы изменить его</string>
<string name="send_summary_title">Отправка %s</string>

View file

@ -421,8 +421,8 @@
<string name="scan_card_settings_title">Get your card ready!</string>
<string name="send_additional_field_already_included">Already included in the entered address</string>
<string name="send_alert_fee_coverage_subract_text">Subtract</string>
<string name="send_alert_fee_coverage_title">Not enough funds to cover the network commission. Subtract the commission %s from the amount sent?</string>
<string name="send_alert_fee_too_high_text">The commission amount is %s times the recommended amount. Make sure that the custom settings are correct.</string>
<string name="send_alert_fee_coverage_title">Not enough funds to cover the network fee. Do you want to subtract the amount required to cover the fee?</string>
<string name="send_alert_fee_too_high_text">The commission amount is %@ times the recommended amount. Make sure that the custom settings are correct.</string>
<string name="send_alert_fee_too_low_text">You specified a commission below the recommended amount, which could cause a delay in your transaction. Continue?</string>
<string name="send_alert_transaction_failed_text">Reason: %1$s\nCode: %2$s</string>
<string name="send_alert_transaction_failed_title">The transaction is not completed</string>
@ -482,6 +482,8 @@
<string name="send_recipient_label">Send to</string>
<string name="send_recipient_memo_footer">A Memo/Destination Tag is a unique ID for differentiating transactions sent to the same recipient on the same network. Caution: Omitting a memo may lead to misplaced funds</string>
<string name="send_recipient_wallets_title">My wallets</string>
<string name="send_satoshi_per_byte_text">Это способ измерения комиссии за отправку биткоин-транзакции. Он указывает на количество самой маленькой единицы биткоина (сатоши) за каждый байт данных в транзакции. Чем выше это число, тем быстрее будет обработана транзакция сетью.</string>
<string name="send_satoshi_per_byte_title">Satoshi per vbyte</string>
<string name="send_sending">Sending...</string>
<string name="send_summary_tap_hint">Tap any field to change it</string>
<string name="send_summary_title">Send %s</string>

View file

@ -69,12 +69,11 @@ internal sealed class SendAlertState {
}
data class FeeCoverage(
val amount: String,
override val onConfirmClick: (() -> Unit),
) : SendAlertState() {
override val title: TextReference? = null
override val message: TextReference =
resourceReference(id = R.string.send_alert_fee_coverage_title, wrappedList(amount))
resourceReference(id = R.string.send_alert_fee_coverage_title)
override val confirmButtonText: TextReference =
resourceReference(id = R.string.send_alert_fee_coverage_subract_text)
}

View file

@ -3,7 +3,6 @@ package com.tangem.features.send.impl.presentation.state
import com.tangem.blockchain.common.transaction.TransactionFee
import com.tangem.core.ui.event.consumedEvent
import com.tangem.core.ui.event.triggeredEvent
import com.tangem.core.ui.utils.BigDecimalFormatter
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
import com.tangem.domain.transaction.error.SendTransactionError
import com.tangem.features.send.impl.presentation.state.fee.FeeSelectorState
@ -50,18 +49,10 @@ internal class SendEventStateFactory(
}
fun getFeeCoverageAlert(onConsume: () -> Unit): SendUiState {
val state = currentStateProvider()
val amount = state.feeState?.fee?.amount ?: return state
val feeAmount = BigDecimalFormatter.formatCryptoAmount(
cryptoAmount = amount.value,
cryptoCurrency = state.cryptoCurrencySymbol,
decimals = amount.decimals,
)
return state.copy(
return currentStateProvider().copy(
event = triggeredEvent(
data = SendEvent.ShowAlert(
SendAlertState.FeeCoverage(
amount = feeAmount,
onConfirmClick = clickIntents::onSubtractSelect,
),
),

View file

@ -52,6 +52,7 @@ internal sealed class SendStates {
val notifications: ImmutableList<SendNotification>,
val appCurrencyCode: String,
val isFeeLoading: Boolean,
val subtractedFee: BigDecimal?,
) : SendStates()
/** Recipient state */

View file

@ -41,6 +41,7 @@ internal class SendAmountStateConverter(
notifications = persistentListOf(),
isFeeLoading = false,
appCurrencyCode = appCurrency.code,
subtractedFee = null,
segmentedButtonConfig = if (status.value.fiatRate.isNullOrZero()) {
persistentListOf()
} else {

View file

@ -15,14 +15,16 @@ internal class SendAmountSubtractConverter(
val state = currentStateProvider()
val cryptoCurrencyStatus = cryptoCurrencyStatusProvider()
val amountState = state.amountState ?: return state
val feeValue = state.feeState?.fee?.amount?.value ?: return state
val feeState = state.feeState ?: return state
val feeValue = feeState.fee?.amount?.value ?: return state
val amountTextField = amountState.amountTextField
val amountValue = amountTextField.cryptoAmount.value ?: return state
val fiatRate = cryptoCurrencyStatus.value.fiatRate
val cryptoDecimals = amountTextField.cryptoAmount.decimals
val fiatDecimals = amountTextField.fiatAmount.decimals
val decimalCryptoValue = amountValue.minus(feeValue)
val feeDiff = amountState.subtractedFee?.let { feeValue.minus(it) } ?: feeValue
val decimalCryptoValue = amountValue.minus(feeDiff)
if (decimalCryptoValue < BigDecimal.ZERO) return state
@ -33,6 +35,7 @@ internal class SendAmountSubtractConverter(
return state.copy(
sendState = state.sendState?.copy(isSubtract = true),
amountState = amountState.copy(
subtractedFee = feeValue,
amountTextField = amountTextField.copy(
value = cryptoValue,
fiatValue = fiatValue,

View file

@ -13,7 +13,7 @@ internal fun checkFeeCoverage(state: SendUiState, cryptoCurrencyStatus: CryptoCu
val balance = cryptoCurrencyStatus.value.amount ?: return false
val fee = state.feeState?.fee?.amount?.value ?: return false
val amount = state.amountState?.amountTextField?.cryptoAmount?.value ?: return false
return balance <= amount + fee
return balance < amount + fee
}
/**

View file

@ -59,8 +59,8 @@ internal class BitcoinCustomFeeConverter(
).toString(),
decimals = SATOSHI_DECIMALS,
symbol = "",
title = resourceReference(R.string.send_gas_price),
footer = resourceReference(R.string.send_gas_price_footer),
title = resourceReference(R.string.send_satoshi_per_byte_title),
footer = resourceReference(R.string.send_satoshi_per_byte_text),
onValueChange = { clickIntents.onCustomFeeValueChange(FEE_SATOSHI_INDEX, it) },
keyboardOptions = KeyboardOptions(
imeAction = if (checkExceedBalance(feeValue)) ImeAction.None else ImeAction.Done,

View file

@ -38,6 +38,7 @@ internal class SendAmountFieldChangeConverter(
return state.copy(
amountState = amountState.copy(
isPrimaryButtonEnabled = !isExceedBalance && !isZero,
subtractedFee = null,
amountTextField = amountTextField.copy(
value = cryptoValue,
fiatValue = fiatValue,

View file

@ -34,6 +34,7 @@ internal class SendAmountFieldMaxAmountConverter(
return state.copy(
amountState = amountState.copy(
isPrimaryButtonEnabled = true,
subtractedFee = null,
amountTextField = amountTextField.copy(
value = cryptoValue,
fiatValue = fiatValue,

View file

@ -25,6 +25,7 @@ internal object AmountStatePreviewData {
notifications = persistentListOf(),
isFeeLoading = false,
appCurrencyCode = "usd",
subtractedFee = null,
amountTextField = SendTextField.AmountField(
value = "123.123123123123123123",
onValueChange = {},