Updated on 2026-08-14

This commit is contained in:
Tangem 2020-09-20 00:03:29 +03:00
parent 9e399946d7
commit f8a1e3f2fe
3 changed files with 9 additions and 7 deletions

View file

@ -31,13 +31,10 @@ class AmountMiddleware {
if (inputValue.isZero() && sendState.amountState.amountToSendCrypto.isZero()) return
val inputCrypto = sendState.convertInputValueToCrypto(inputValue)
val fee = sendState.feeState.getCurrentFee()
val feeCrypto = sendState.feeState.getCurrentFee()
val needToExtractFee = sendState.amountState.isCoinAmount() && sendState.feeState.feeIsIncluded
val totalToSend = if (needToExtractFee) inputCrypto.minus(fee) else inputCrypto
val feeAmount = Amount(fee, walletManager.wallet.blockchain)
val totalAmount = Amount(totalToSend, walletManager.wallet.blockchain)
val feeAmount = Amount(feeCrypto, walletManager.wallet.blockchain)
val totalAmount = Amount(sendState.getTotalAmountToSend(inputCrypto), walletManager.wallet.blockchain)
val transactionErrors = walletManager.validateTransaction(totalAmount, feeAmount)
if (transactionErrors.isEmpty()) {

View file

@ -59,7 +59,7 @@ private fun verifyAndSendTransaction(appState: AppState?, dispatch: (Action) ->
val recipientAddress = sendState.addressPayIdState.recipientWalletAddress!!
val feeAmount = Amount(sendState.feeState.getCurrentFee(), blockchain)
val amountToSend = Amount(sendState.amountState.amountToSendCrypto, blockchain, recipientAddress)
val amountToSend = Amount(sendState.getTotalAmountToSend(), blockchain, recipientAddress)
val txSender = walletManager as TransactionSender

View file

@ -74,6 +74,11 @@ data class SendState(
}
fun getButtonState(): SendButtonState = if (isReadyToSend()) SendButtonState.ENABLED else SendButtonState.DISABLED
fun getTotalAmountToSend(value: BigDecimal = amountState.amountToSendCrypto): BigDecimal {
val needToExtractFee = amountState.isCoinAmount() && feeState.feeIsIncluded
return if (needToExtractFee) value.minus(feeState.getCurrentFee()) else value
}
}
enum class SendButtonState {