diff --git a/app/src/main/java/org/p2p/wallet/send/model/NewSendButtonState.kt b/app/src/main/java/org/p2p/wallet/send/model/NewSendButtonState.kt index 348febdbf4..de3eebe3ca 100644 --- a/app/src/main/java/org/p2p/wallet/send/model/NewSendButtonState.kt +++ b/app/src/main/java/org/p2p/wallet/send/model/NewSendButtonState.kt @@ -20,7 +20,8 @@ class NewSendButtonState( private val feeRelayerState: FeeRelayerState, private val calculationMode: CalculationMode, private val minRentExemption: BigInteger, - private val resources: Resources + private val resources: Resources, + private val totalFee: SendFeeTotal, ) { private val minSolValidator = SendButtonStateMinSolValidator( @@ -114,7 +115,7 @@ class NewSendButtonState( else -> { State.Enabled( textResId = R.string.send_format, - value = "${calculationMode.getCurrentAmount().toPlainString()} ${tokenToSend.tokenSymbol}", + value = totalFee.totalSumWithSymbol, totalAmountTextColor = R.color.text_night ) } diff --git a/app/src/main/java/org/p2p/wallet/send/model/SendFeeTotal.kt b/app/src/main/java/org/p2p/wallet/send/model/SendFeeTotal.kt index 0b89b947df..26b0cdf7d7 100644 --- a/app/src/main/java/org/p2p/wallet/send/model/SendFeeTotal.kt +++ b/app/src/main/java/org/p2p/wallet/send/model/SendFeeTotal.kt @@ -3,6 +3,7 @@ package org.p2p.wallet.send.model import androidx.annotation.ColorInt import android.os.Parcelable import java.math.BigDecimal +import java.math.BigInteger import kotlinx.parcelize.IgnoredOnParcel import kotlinx.parcelize.Parcelize import org.p2p.core.model.TextHighlighting @@ -12,6 +13,8 @@ import org.p2p.core.utils.formatTokenWithSymbol import org.p2p.core.utils.orZero import org.p2p.uikit.utils.SpanUtils import org.p2p.wallet.R +import org.p2p.wallet.feerelayer.model.Limits +import org.p2p.wallet.feerelayer.model.ProcessedFee import org.p2p.wallet.feerelayer.model.TransactionFeeLimits /** @@ -36,6 +39,33 @@ class SendFeeTotal constructor( val interestBearingPercent: BigDecimal? = null ) : Parcelable { + companion object { + fun createEmpty(): SendFeeTotal = SendFeeTotal( + currentAmount = BigDecimal.ZERO, + currentAmountUsd = null, + receiveFormatted = "", + receiveUsd = null, + sendFee = null, + feeLimit = TransactionFeeLimits( + limits = Limits( + maxFeeCountAllowed = 0, + maxFeeAmountAllowed = BigInteger.ZERO, + maxAccountCreationCountAllowed = 0, + maxAccountCreationAmountAllowed = BigInteger.ZERO + ), + processedFee = ProcessedFee( + totalFeeAmountUsed = BigInteger.ZERO, + totalRentAmountUsed = BigInteger.ZERO, + totalFeeCountUsed = 0, + totalRentCountUsed = 0, + totalAmountUsed = BigInteger.ZERO + ) + ), + sourceSymbol = "", + recipientAddress = "" + ) + } + @IgnoredOnParcel val isSendingToken2022: Boolean get() = transferFeePercent != null || interestBearingPercent != null @@ -115,10 +145,10 @@ class SendFeeTotal constructor( private val totalWithSymbolFormatted: String get() = currentAmount.formatTokenWithSymbol(sourceSymbol, SOL_DECIMALS) - private val totalSumWithSymbol: String + val totalSumWithSymbol: String get() { val transferFee = transferFeePercent - ?.let { it / 100.toBigDecimal() } + ?.multiply("0.01".toBigDecimal()) ?.multiply(currentAmount) val totalSum = currentAmount diff --git a/app/src/main/java/org/p2p/wallet/send/ui/NewSendPresenter.kt b/app/src/main/java/org/p2p/wallet/send/ui/NewSendPresenter.kt index cac374bde3..3495323ff2 100644 --- a/app/src/main/java/org/p2p/wallet/send/ui/NewSendPresenter.kt +++ b/app/src/main/java/org/p2p/wallet/send/ui/NewSendPresenter.kt @@ -616,7 +616,12 @@ class NewSendPresenter( calculationMode = calculationMode, feeRelayerState = feeRelayerState, minRentExemption = sendFeeRelayerManager.getMinRentExemption(), - resources = resources + resources = resources, + totalFee = sendFeeRelayerManager.buildTotalFee( + sourceToken = sourceToken, + calculationMode = calculationMode, + tokenExtensions = (feeRelayerState as? FeeRelayerState.UpdateFee)?.tokenExtensions.orEmpty() + ) ) when (val state = sendButton.getCurrentState()) { diff --git a/app/src/main/java/org/p2p/wallet/svl/ui/send/SendViaLinkPresenter.kt b/app/src/main/java/org/p2p/wallet/svl/ui/send/SendViaLinkPresenter.kt index b7d633bbee..d344901d21 100644 --- a/app/src/main/java/org/p2p/wallet/svl/ui/send/SendViaLinkPresenter.kt +++ b/app/src/main/java/org/p2p/wallet/svl/ui/send/SendViaLinkPresenter.kt @@ -25,6 +25,7 @@ import org.p2p.wallet.send.interactor.SendInteractor import org.p2p.wallet.send.model.CalculationMode import org.p2p.wallet.send.model.FeeRelayerState import org.p2p.wallet.send.model.NewSendButtonState +import org.p2p.wallet.send.model.SendFeeTotal import org.p2p.wallet.send.model.TemporaryAccount import org.p2p.wallet.send.model.toSearchResult import org.p2p.wallet.svl.analytics.SendViaLinkAnalytics @@ -278,7 +279,8 @@ class SendViaLinkPresenter( calculationMode = calculationMode, feeRelayerState = FeeRelayerState.Idle, minRentExemption = minRentExemption, - resources = resources + resources = resources, + totalFee = SendFeeTotal.createEmpty() ) when (val state = sendButton.getCurrentState()) {