Updated on 2026-08-14

This commit is contained in:
Tangem 2020-09-24 11:28:25 +00:00
commit 888eb8bba8
3 changed files with 11 additions and 17 deletions

View file

@ -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))
}

View file

@ -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) {

View file

@ -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)
}
}