Updated on 2026-08-14

This commit is contained in:
Tangem 2022-05-31 16:05:24 +04:00
parent fe05b89d66
commit 0d039d681e
3 changed files with 29 additions and 4 deletions

View file

@ -1,9 +1,13 @@
package com.tangem.tap.features.send.redux.reducers
import com.tangem.blockchain.common.Amount
import com.tangem.blockchain.common.AmountType
import com.tangem.blockchain.common.Blockchain
import com.tangem.tap.common.extensions.fullNameWithoutTestnet
import com.tangem.tap.features.send.redux.FeeAction
import com.tangem.tap.features.send.redux.FeeActionUi
import com.tangem.tap.features.send.redux.SendScreenAction
import com.tangem.tap.features.send.redux.states.FeePrecision
import com.tangem.tap.features.send.redux.states.FeeState
import com.tangem.tap.features.send.redux.states.FeeType
import com.tangem.tap.features.send.redux.states.SendState
@ -57,7 +61,8 @@ class FeeReducer : SendInternalReducer {
selectedFeeType = feeType,
feeList = fees,
currentFee = currentFee,
error = null
error = null,
feePrecision = getFeePrecision(sendState)
)
} else {
val feeType = getCurrentFeeType(state)
@ -67,7 +72,8 @@ class FeeReducer : SendInternalReducer {
selectedFeeType = feeType,
feeList = fees,
currentFee = currentFee,
error = null
error = null,
feePrecision = getFeePrecision(sendState)
)
}
}
@ -98,6 +104,17 @@ class FeeReducer : SendInternalReducer {
}
}
private fun getFeePrecision(sendState: SendState): FeePrecision {
val blockchain = sendState.walletManager?.wallet?.blockchain
return if (blockchain?.fullNameWithoutTestnet == Blockchain.Tron.fullName &&
sendState.amountState.typeOfAmount is AmountType.Token) {
FeePrecision.CAN_BE_LOWER
} else {
FeePrecision.PRECISE
}
}
private fun getCurrentFeeType(state: FeeState): FeeType {
return if (state.selectedFeeType == FeeType.SINGLE) FeeType.NORMAL else state.selectedFeeType
}

View file

@ -160,14 +160,14 @@ class ReceiptReducer : SendInternalReducer {
ReceiptTokenCrypto(
amountToken = tokensToSend.stripZeroPlainString(),
feeCoin = feeCoin.stripZeroPlainString(),
feeCoin = feeCoin.stripZeroPlainString().addPrecisionSign(),
totalFiat = totalFiat.scaleToFiat(true).stripZeroPlainString(),
symbols = symbols
)
} else {
ReceiptTokenCrypto(
amountToken = tokensToSend.stripZeroPlainString(),
feeCoin = feeCoin.stripZeroPlainString(),
feeCoin = feeCoin.stripZeroPlainString().addPrecisionSign(),
totalFiat = EMPTY,
symbols = symbols
)
@ -208,4 +208,7 @@ class ReceiptReducer : SendInternalReducer {
else -> EMPTY
}
}
private fun String.addPrecisionSign(): String =
("${feeState.feePrecision.symbol} $this").trim()
}

View file

@ -11,6 +11,10 @@ enum class FeeType {
SINGLE, LOW, NORMAL, PRIORITY
}
enum class FeePrecision(val symbol: String) {
PRECISE(""), CAN_BE_LOWER("<")
}
data class FeeState(
val selectedFeeType: FeeType = FeeType.NORMAL,
val feeList: List<Amount>? = null,
@ -21,6 +25,7 @@ data class FeeState(
val feeChipGroupIsVisible: Boolean = true,
val includeFeeSwitcherIsEnabled: Boolean = true,
val error: FeeAction.Error? = null,
val feePrecision: FeePrecision = FeePrecision.PRECISE
) : SendScreenState {
override val stateId: StateId = StateId.FEE