Updated on 2026-08-14

This commit is contained in:
Tangem 2020-09-29 18:44:14 +03:00
parent e84bb2f96c
commit 0cd8e6878d
7 changed files with 35 additions and 14 deletions

View file

@ -1,5 +1,6 @@
package com.tangem.tap.features.send.redux
import com.tangem.Message
import com.tangem.blockchain.common.Amount
import com.tangem.tap.common.redux.ErrorAction
import com.tangem.tap.common.redux.ToastNotificationAction
@ -102,7 +103,7 @@ sealed class ReceiptAction : SendScreenAction {
}
sealed class SendActionUi : SendScreenActionUi {
object SendAmountToRecipient : SendScreenActionUi
data class SendAmountToRecipient(val messageForSigner: Message) : SendScreenActionUi
}
sealed class SendAction : SendScreenAction {

View file

@ -35,14 +35,17 @@ val sendMiddleware: Middleware<AppState> = { dispatch, appState ->
is AddressPayIdActionUi -> AddressPayIdMiddleware().handle(action, appState(), dispatch)
is AmountActionUi -> AmountMiddleware().handle(action, appState(), dispatch)
is RequestFee -> RequestFeeMiddleware().handle(appState(), dispatch)
is SendActionUi.SendAmountToRecipient -> verifyAndSendTransaction(appState(), dispatch)
is SendActionUi.SendAmountToRecipient ->
verifyAndSendTransaction(action, appState(), dispatch)
}
nextDispatch(action)
}
}
}
private fun verifyAndSendTransaction(appState: AppState?, dispatch: (Action) -> Unit) {
private fun verifyAndSendTransaction(
action: SendActionUi.SendAmountToRecipient, appState: AppState?, dispatch: (Action) -> Unit
) {
val sendState = appState?.sendState ?: return
val walletManager = appState.globalState.scanNoteResponse?.walletManager ?: return
val recipientAddress = sendState.addressPayIdState.recipientWalletAddress ?: return
@ -61,7 +64,8 @@ private fun verifyAndSendTransaction(appState: AppState?, dispatch: (Action) ->
val txData = walletManager.createTransaction(amountToSend, feeAmount, recipientAddress)
scope.launch {
walletManager.update()
val result = (walletManager as TransactionSender).send(txData, Signer(tangemSdk))
val signer = Signer(tangemSdk, action.messageForSigner)
val result = (walletManager as TransactionSender).send(txData, signer)
withContext(Dispatchers.Main) {
when (result) {
is Result.Success -> {

View file

@ -9,6 +9,7 @@ import android.view.inputmethod.EditorInfo
import android.widget.EditText
import androidx.core.view.postDelayed
import androidx.core.widget.addTextChangedListener
import com.tangem.Message
import com.tangem.merchant.common.toggleWidget.ToggleWidget
import com.tangem.tangem_sdk_new.extensions.hideSoftKeyboard
import com.tangem.tap.common.KeyboardObserver
@ -65,7 +66,9 @@ class SendFragment : BaseStoreFragment(R.layout.fragment_send) {
setupFeeLayout()
btnSend.setOnClickListener {
store.dispatch(SendActionUi.SendAmountToRecipient)
store.dispatch(SendActionUi.SendAmountToRecipient(
Message(getString(R.string.tap_to_sign))
))
}
}
@ -205,7 +208,8 @@ class SendFragment : BaseStoreFragment(R.layout.fragment_send) {
val sp = requireContext().getSharedPreferences("SendScreen", Context.MODE_PRIVATE)
val mainCurrency = sp.getString("mainCurrency", TapCurrency.DEFAULT_FIAT_CURRENCY)
val foundType = MainCurrencyType.values()
.firstOrNull { it.name.toLowerCase() == mainCurrency!!.toLowerCase() } ?: MainCurrencyType.FIAT
.firstOrNull { it.name.toLowerCase() == mainCurrency!!.toLowerCase() }
?: MainCurrencyType.FIAT
return foundType
}