Updated on 2026-08-14
This commit is contained in:
commit
0d8bf205bc
4 changed files with 8 additions and 63 deletions
|
|
@ -41,7 +41,6 @@ internal class FeeConverter(
|
|||
private val kaspaCustomFeeConverter by lazy(LazyThreadSafetyMode.NONE) {
|
||||
KaspaCustomFeeConverter(
|
||||
clickIntents = clickIntents,
|
||||
stateRouterProvider = stateRouterProvider,
|
||||
appCurrencyProvider = appCurrencyProvider,
|
||||
feeCryptoCurrencyStatusProvider = feeCryptoCurrencyStatusProvider,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ internal class SendFeeCustomFieldConverter(
|
|||
private val kaspaCustomFeeConverter by lazy(LazyThreadSafetyMode.NONE) {
|
||||
KaspaCustomFeeConverter(
|
||||
clickIntents = clickIntents,
|
||||
stateRouterProvider = stateRouterProvider,
|
||||
appCurrencyProvider = appCurrencyProvider,
|
||||
feeCryptoCurrencyStatusProvider = feeCryptoCurrencyStatusProvider,
|
||||
)
|
||||
|
|
@ -74,7 +73,6 @@ internal class SendFeeCustomFieldConverter(
|
|||
customValues = feeSelectorState.customValues,
|
||||
index = index,
|
||||
value = value,
|
||||
utxoCount = fee.utxoCount,
|
||||
)
|
||||
else -> feeSelectorState.customValues
|
||||
},
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ import com.tangem.core.ui.utils.parseToBigDecimal
|
|||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.features.send.impl.R
|
||||
import com.tangem.features.send.impl.presentation.state.StateRouter
|
||||
import com.tangem.features.send.impl.presentation.state.fee.checkExceedBalance
|
||||
import com.tangem.features.send.impl.presentation.state.fields.SendTextField
|
||||
import com.tangem.features.send.impl.presentation.viewmodel.SendClickIntents
|
||||
import com.tangem.utils.Provider
|
||||
|
|
@ -24,7 +22,6 @@ import java.math.RoundingMode
|
|||
|
||||
internal class KaspaCustomFeeConverter(
|
||||
private val clickIntents: SendClickIntents,
|
||||
private val stateRouterProvider: Provider<StateRouter>,
|
||||
private val appCurrencyProvider: Provider<AppCurrency>,
|
||||
private val feeCryptoCurrencyStatusProvider: Provider<CryptoCurrencyStatus?>,
|
||||
) : CustomFeeConverter<Fee.Kaspa> {
|
||||
|
|
@ -53,29 +50,6 @@ internal class KaspaCustomFeeConverter(
|
|||
),
|
||||
keyboardActions = KeyboardActions(),
|
||||
),
|
||||
SendTextField.CustomFee(
|
||||
value = value.valuePerUtxo.parseBigDecimal(value.amount.decimals),
|
||||
decimals = value.amount.decimals,
|
||||
symbol = "",
|
||||
title = resourceReference(R.string.send_custom_kaspa_per_utxo_title),
|
||||
footer = resourceReference(R.string.send_custom_kaspa_per_utxo_footer),
|
||||
onValueChange = { clickIntents.onCustomFeeValueChange(FEE_VALUE_PER_UTXO_INDEX, it) },
|
||||
keyboardOptions = KeyboardOptions(
|
||||
imeAction = if (checkExceedBalance(
|
||||
feeBalance = feeCurrency?.amount,
|
||||
feeAmount = feeValue,
|
||||
)
|
||||
) {
|
||||
ImeAction.None
|
||||
} else {
|
||||
ImeAction.Done
|
||||
},
|
||||
keyboardType = KeyboardType.Number,
|
||||
),
|
||||
keyboardActions = KeyboardActions(
|
||||
onDone = { clickIntents.onNextClick(stateRouterProvider().isEditState) },
|
||||
),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
persistentListOf()
|
||||
|
|
@ -83,12 +57,15 @@ internal class KaspaCustomFeeConverter(
|
|||
}
|
||||
|
||||
override fun convertBack(normalFee: Fee.Kaspa, value: ImmutableList<SendTextField.CustomFee>): Fee.Kaspa {
|
||||
val feeAmount = value[FEE_AMOUNT_INDEX].value.parseToBigDecimal(value[FEE_AMOUNT_INDEX].decimals)
|
||||
val valuePerUtxo =
|
||||
value[FEE_VALUE_PER_UTXO_INDEX].value.parseToBigDecimal(value[FEE_VALUE_PER_UTXO_INDEX].decimals)
|
||||
val decimals = value[FEE_AMOUNT_INDEX].decimals
|
||||
val feeAmount = value[FEE_AMOUNT_INDEX].value.parseToBigDecimal(decimals)
|
||||
return normalFee.copy(
|
||||
amount = normalFee.amount.copy(value = feeAmount),
|
||||
valuePerUtxo = valuePerUtxo,
|
||||
mass = normalFee.mass,
|
||||
feeRate = feeAmount
|
||||
.divide(normalFee.mass.toBigDecimal(), decimals, RoundingMode.HALF_UP)
|
||||
.movePointRight(decimals)
|
||||
.toBigInteger(),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -96,24 +73,12 @@ internal class KaspaCustomFeeConverter(
|
|||
customValues: ImmutableList<SendTextField.CustomFee>,
|
||||
index: Int,
|
||||
value: String,
|
||||
utxoCount: Int,
|
||||
): ImmutableList<SendTextField.CustomFee> {
|
||||
val mutableCustomValues = customValues.toMutableList()
|
||||
return mutableCustomValues.apply {
|
||||
when (index) {
|
||||
FEE_AMOUNT_INDEX -> {
|
||||
val valueDecimal = value.parseToBigDecimal(this[FEE_AMOUNT_INDEX].decimals)
|
||||
val newValuePerUtxo = valueDecimal.divide(
|
||||
/* divisor = */ utxoCount.toBigDecimal(),
|
||||
/* scale = */ this[FEE_VALUE_PER_UTXO_INDEX].decimals,
|
||||
/* roundingMode = */ RoundingMode.HALF_UP,
|
||||
)
|
||||
set(
|
||||
FEE_VALUE_PER_UTXO_INDEX,
|
||||
this[FEE_VALUE_PER_UTXO_INDEX].copy(
|
||||
value = newValuePerUtxo.parseBigDecimal(this[FEE_VALUE_PER_UTXO_INDEX].decimals),
|
||||
),
|
||||
)
|
||||
set(
|
||||
index,
|
||||
this[index].copy(
|
||||
|
|
@ -126,28 +91,11 @@ internal class KaspaCustomFeeConverter(
|
|||
),
|
||||
)
|
||||
}
|
||||
FEE_VALUE_PER_UTXO_INDEX -> {
|
||||
val valuePerUtxo = value.parseToBigDecimal(this[FEE_VALUE_PER_UTXO_INDEX].decimals)
|
||||
val newFeeAmount = valuePerUtxo.multiply(utxoCount.toBigDecimal())
|
||||
set(
|
||||
FEE_AMOUNT_INDEX,
|
||||
this[FEE_AMOUNT_INDEX].copy(
|
||||
value = newFeeAmount.parseBigDecimal(this[FEE_AMOUNT_INDEX].decimals),
|
||||
label = getFiatReference(
|
||||
rate = feeCryptoCurrencyStatusProvider()?.value?.fiatRate,
|
||||
value = newFeeAmount,
|
||||
appCurrency = appCurrencyProvider(),
|
||||
),
|
||||
),
|
||||
)
|
||||
set(index, this[index].copy(value = value))
|
||||
}
|
||||
}
|
||||
}.toImmutableList()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
private const val FEE_AMOUNT_INDEX = 0
|
||||
private const val FEE_VALUE_PER_UTXO_INDEX = 1
|
||||
}
|
||||
}
|
||||
|
|
@ -88,7 +88,7 @@ markdown = "0.7.2"
|
|||
# endregion Other libraries
|
||||
|
||||
# region Tangem
|
||||
tangemBlockchainSdk = "release-app_5.14-763"
|
||||
tangemBlockchainSdk = "release-app_5.14-772"
|
||||
#tangemBlockchainSdk = "0.0.1" # Keep it! - used for local builds
|
||||
tangemCardSdk = "release-app_5.14-379"
|
||||
#tangemCardSdk = "0.0.1" # Keep it! - used for local builds ^
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue