diff --git a/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AddressPayIdMiddleware.kt b/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AddressPayIdMiddleware.kt index 6b87085cb6..1a82a4d1db 100644 --- a/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AddressPayIdMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AddressPayIdMiddleware.kt @@ -47,8 +47,9 @@ internal class AddressPayIdMiddleware { } private fun setAddressAndCheck(data: String, isUserInput: Boolean, dispatch: (Action) -> Unit) { - if (PayIdManager.isPayId(data)) { - dispatch(SetPayIdWalletAddress(data, "", isUserInput)) + val potentialPayId = data.toLowerCase() + if (PayIdManager.isPayId(potentialPayId)) { + dispatch(SetPayIdWalletAddress(potentialPayId, "", isUserInput)) } else { dispatch(SetWalletAddress(data, isUserInput)) } diff --git a/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AmountMiddleware.kt b/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AmountMiddleware.kt index c54d5f2dd1..d77bb638f0 100644 --- a/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AmountMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AmountMiddleware.kt @@ -5,10 +5,7 @@ import com.tangem.blockchain.common.TransactionError import com.tangem.common.extensions.isZero import com.tangem.tap.common.redux.AppState import com.tangem.tap.domain.TapError -import com.tangem.tap.features.send.redux.AmountAction -import com.tangem.tap.features.send.redux.AmountActionUi -import com.tangem.tap.features.send.redux.ReceiptAction -import com.tangem.tap.features.send.redux.SendAction +import com.tangem.tap.features.send.redux.* import com.tangem.tap.features.send.redux.states.MainCurrencyType import org.rekotlin.Action import java.math.BigDecimal @@ -46,7 +43,7 @@ class AmountMiddleware { } dispatch(AmountAction.SetAmount(inputValueCrypto, true)) - dispatch(AmountActionUi.CheckAmountToSend) + dispatch(FeeAction.RequestFee) } private fun checkAmountToSend(appState: AppState?, dispatch: (Action) -> Unit) { @@ -89,6 +86,7 @@ class AmountMiddleware { val amountState = appState?.sendState?.amountState ?: return dispatch(AmountAction.SetAmount(amountState.balanceCrypto, false)) + dispatch(FeeAction.RequestFee) } private fun toggleMainCurrency(appState: AppState?, dispatch: (Action) -> Unit) { diff --git a/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/RequestFeeMiddleware.kt b/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/RequestFeeMiddleware.kt index 5ba0bc7bc2..2b662e5852 100644 --- a/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/RequestFeeMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/RequestFeeMiddleware.kt @@ -1,12 +1,12 @@ package com.tangem.tap.features.send.redux.middlewares import com.tangem.blockchain.common.Amount -import com.tangem.blockchain.common.AmountType import com.tangem.blockchain.common.Blockchain import com.tangem.blockchain.common.TransactionSender import com.tangem.blockchain.extensions.Result import com.tangem.common.extensions.isZero import com.tangem.tap.common.redux.AppState +import com.tangem.tap.features.send.redux.AmountActionUi import com.tangem.tap.features.send.redux.FeeAction import com.tangem.tap.features.send.redux.ReceiptAction import com.tangem.tap.features.send.redux.SendAction @@ -34,15 +34,11 @@ class RequestFeeMiddleware { return } + val typedAmount = sendState.amountState.amountToExtract ?: return val recipientAddress = sendState.addressPayIdState.recipientWalletAddress!! - val amountState = sendState.amountState - val cryptoSendToRecipient = amountState.amountToSendCrypto - val recipientAmount = if (amountState.typeOfAmount == AmountType.Coin) { - Amount(cryptoSendToRecipient, walletManager.wallet.blockchain, type = AmountType.Coin) - } else { - Amount(cryptoSendToRecipient, walletManager.wallet.blockchain, recipientAddress, AmountType.Token) - } + val cryptoSendToRecipient = sendState.amountState.amountToSendCrypto + val recipientAmount = Amount(typedAmount, cryptoSendToRecipient) val txSender = walletManager as TransactionSender scope.launch { val feeResult = txSender.getFee(recipientAmount, recipientAddress) @@ -68,8 +64,7 @@ class RequestFeeMiddleware { dispatch(FeeAction.ChangeLayoutVisibility(main = false, controls = false, chipGroup = false)) } } - dispatch(ReceiptAction.RefreshReceipt) - dispatch(SendAction.ChangeSendButtonState(sendState.getButtonState())) + dispatch(AmountActionUi.CheckAmountToSend) } }