Updated on 2026-08-14
This commit is contained in:
parent
e16b575348
commit
1be41e20d1
1 changed files with 33 additions and 16 deletions
|
|
@ -7,10 +7,10 @@ import com.tangem.blockchain.common.*
|
|||
import com.tangem.blockchain.extensions.SimpleResult
|
||||
import com.tangem.common.card.Card
|
||||
import com.tangem.common.core.TangemSdkError
|
||||
import com.tangem.common.services.Result
|
||||
import com.tangem.tap.common.analytics.AnalyticsEvent
|
||||
import com.tangem.tap.common.analytics.FirebaseAnalyticsHandler
|
||||
import com.tangem.tap.common.extensions.dispatchOnMain
|
||||
import com.tangem.tap.common.extensions.stripZeroPlainString
|
||||
import com.tangem.tap.common.extensions.*
|
||||
import com.tangem.tap.common.redux.AppState
|
||||
import com.tangem.tap.common.redux.global.GlobalAction
|
||||
import com.tangem.tap.common.redux.navigation.NavigationAction
|
||||
|
|
@ -57,12 +57,12 @@ class SendMiddleware {
|
|||
val transactionData = appState()?.sendState?.externalTransactionData
|
||||
if (transactionData != null) {
|
||||
store.dispatchOnMain(AddressPayIdVerifyAction.AddressVerification.SetWalletAddress(
|
||||
transactionData.destinationAddress, false
|
||||
transactionData.destinationAddress, false
|
||||
))
|
||||
store.dispatchOnMain(AmountActionUi.SetMainCurrency(MainCurrencyType.CRYPTO))
|
||||
store.dispatchOnMain(AmountActionUi.HandleUserInput(transactionData.amount))
|
||||
store.dispatchOnMain(AmountAction.SetAmount(transactionData.amount.toBigDecimal(),
|
||||
false))
|
||||
false))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -72,8 +72,9 @@ class SendMiddleware {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
private fun verifyAndSendTransaction(
|
||||
action: SendActionUi.SendAmountToRecipient, appState: AppState?, dispatch: (Action) -> Unit,
|
||||
action: SendActionUi.SendAmountToRecipient, appState: AppState?, dispatch: (Action) -> Unit,
|
||||
) {
|
||||
val sendState = appState?.sendState ?: return
|
||||
val walletManager = sendState.walletManager ?: return
|
||||
|
|
@ -105,21 +106,21 @@ private fun verifyAndSendTransaction(
|
|||
}
|
||||
else -> {
|
||||
sendTransaction(action, walletManager, amountToSend, feeAmount, destinationAddress,
|
||||
sendState.transactionExtrasState, card, sendState.externalTransactionData, dispatch)
|
||||
sendState.transactionExtrasState, card, sendState.externalTransactionData, dispatch)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun sendTransaction(
|
||||
action: SendActionUi.SendAmountToRecipient,
|
||||
walletManager: WalletManager,
|
||||
amountToSend: Amount,
|
||||
feeAmount: Amount,
|
||||
destinationAddress: String,
|
||||
transactionExtras: TransactionExtrasState,
|
||||
card: Card,
|
||||
externalTransactionData: ExternalTransactionData?,
|
||||
dispatch: (Action) -> Unit,
|
||||
action: SendActionUi.SendAmountToRecipient,
|
||||
walletManager: WalletManager,
|
||||
amountToSend: Amount,
|
||||
feeAmount: Amount,
|
||||
destinationAddress: String,
|
||||
transactionExtras: TransactionExtrasState,
|
||||
card: Card,
|
||||
externalTransactionData: ExternalTransactionData?,
|
||||
dispatch: (Action) -> Unit,
|
||||
) {
|
||||
dispatch(SendAction.ChangeSendButtonState(ButtonState.PROGRESS))
|
||||
var txData = walletManager.createTransaction(amountToSend, feeAmount, destinationAddress)
|
||||
|
|
@ -128,7 +129,23 @@ private fun sendTransaction(
|
|||
transactionExtras.xrpDestinationTag?.tag?.let { txData = txData.copy(extras = XrpTransactionBuilder.XrpTransactionExtras(it)) }
|
||||
|
||||
scope.launch {
|
||||
walletManager.update()
|
||||
val updateWalletResult = walletManager.safeUpdate()
|
||||
if (updateWalletResult is Result.Failure) {
|
||||
when (val error = updateWalletResult.error) {
|
||||
is TapError -> store.dispatchErrorNotification(error)
|
||||
else -> {
|
||||
val tapError = if (error.message == null) {
|
||||
TapError.UnknownError
|
||||
} else {
|
||||
TapError.CustomError(error.message!!)
|
||||
}
|
||||
store.dispatchErrorNotification(tapError)
|
||||
}
|
||||
}
|
||||
withMainContext { dispatch(SendAction.ChangeSendButtonState(ButtonState.ENABLED)) }
|
||||
return@launch
|
||||
}
|
||||
|
||||
val isLinkedTerminal = tangemSdk.config.linkedTerminal
|
||||
if (card.isStart2Coin) {
|
||||
tangemSdk.config.linkedTerminal = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue