diff --git a/app/src/main/java/com/tangem/tap/common/redux/global/GlobalAction.kt b/app/src/main/java/com/tangem/tap/common/redux/global/GlobalAction.kt index b0328ee0c2..419fa5737d 100644 --- a/app/src/main/java/com/tangem/tap/common/redux/global/GlobalAction.kt +++ b/app/src/main/java/com/tangem/tap/common/redux/global/GlobalAction.kt @@ -1,5 +1,6 @@ package com.tangem.tap.common.redux.global +import com.tangem.blockchain.common.WalletManager import com.tangem.common.CompletionResult import com.tangem.tap.domain.configurable.config.ConfigManager import com.tangem.tap.domain.configurable.warningMessage.WarningMessage @@ -38,6 +39,7 @@ sealed class GlobalAction : Action { data class SetFeedbackManager(val feedbackManager: FeedbackManager) : GlobalAction() data class SendFeedback(val emailData: EmailData) : GlobalAction() + data class UpdateFeedbackInfo(val walletManagers: List) : GlobalAction() data class ShowDialog(val stateDialog: StateDialog) : GlobalAction() object HideDialog : GlobalAction() diff --git a/app/src/main/java/com/tangem/tap/common/redux/global/GlobalMidlleware.kt b/app/src/main/java/com/tangem/tap/common/redux/global/GlobalMidlleware.kt index b06dc1b5df..2f79a5bbcc 100644 --- a/app/src/main/java/com/tangem/tap/common/redux/global/GlobalMidlleware.kt +++ b/app/src/main/java/com/tangem/tap/common/redux/global/GlobalMidlleware.kt @@ -56,6 +56,10 @@ val globalMiddleware: Middleware = { dispatch, appState -> is GlobalAction.UpdateWalletSignedHashes -> { store.dispatch(WalletAction.Warnings.CheckRemainingSignatures(action.remainingSignatures)) } + is GlobalAction.UpdateFeedbackInfo -> { + store.state.globalState.feedbackManager?.infoHolder + ?.setWalletsInfo(action.walletManagers) + } } nextDispatch(action) } diff --git a/app/src/main/java/com/tangem/tap/features/feedback/FeedbackManager.kt b/app/src/main/java/com/tangem/tap/features/feedback/FeedbackManager.kt index 080a4838b3..c3ff7b8de0 100644 --- a/app/src/main/java/com/tangem/tap/features/feedback/FeedbackManager.kt +++ b/app/src/main/java/com/tangem/tap/features/feedback/FeedbackManager.kt @@ -12,10 +12,7 @@ import androidx.core.content.ContextCompat import androidx.core.content.FileProvider import com.tangem.Log import com.tangem.TangemSdkLogger -import com.tangem.blockchain.common.Amount -import com.tangem.blockchain.common.AmountType -import com.tangem.blockchain.common.Blockchain -import com.tangem.blockchain.common.Wallet +import com.tangem.blockchain.common.* import com.tangem.commands.common.card.Card import com.tangem.tap.common.extensions.stripZeroPlainString import com.tangem.tap.domain.TapWorkarounds @@ -138,6 +135,7 @@ class AdditionalEmailInfo { var blockchain: Blockchain = Blockchain.Unknown, var address: String = "", var explorerLink: String = "", + var host: String = "", // var outputsCount: String = "" // var transactionHex: String = "" ) @@ -178,14 +176,28 @@ class AdditionalEmailInfo { signedHashesCount = card.signedHashesCount().toString() } - fun setWalletsInfo(wallets: List) { + fun setWalletsInfo(walletManagers: List) { walletsInfo.clear() - wallets.forEach { walletsInfo.add(EmailWalletInfo(it.blockchain, getAddress(it), getExploreUri(it))) } + walletManagers.forEach { manager -> + walletsInfo.add( + EmailWalletInfo( + blockchain = manager.wallet.blockchain, + address = getAddress(manager.wallet), + explorerLink = getExploreUri(manager.wallet), + host = manager.currentHost + ) + ) + } } - fun updateOnSendError(wallet: Wallet, amountToSend: Amount, feeAmount: Amount, destinationAddress: String) { + fun updateOnSendError(wallet: Wallet, host: String, amountToSend: Amount, feeAmount: Amount, destinationAddress: String) { val amountState = store.state.sendState.amountState - onSendErrorWalletInfo = EmailWalletInfo(wallet.blockchain, getAddress(wallet), getExploreUri(wallet)) + onSendErrorWalletInfo = EmailWalletInfo( + blockchain = wallet.blockchain, + address = getAddress(wallet), + explorerLink = getExploreUri(wallet), + host = host + ) this.destinationAddress = destinationAddress amount = amountToSend.value?.stripZeroPlainString() ?: "0" @@ -267,6 +279,7 @@ class SendTransactionFailedEmail(private val error: String) : EmailData { appendKeyValue("Error", error) appendKeyValue("Card ID", infoHolder.cardId) appendKeyValue("Blockchain", walletInfo.blockchain.fullName) + appendKeyValue("Host", walletInfo.host) appendKeyValue("Token", infoHolder.token) appendKeyValue("Source address", walletInfo.address) appendKeyValue("Destination address", infoHolder.destinationAddress) @@ -291,6 +304,7 @@ class FeedbackEmail : EmailData { infoHolder.walletsInfo.forEach { builder.appendKeyValue("Blockchain", it.blockchain.fullName) + builder.appendKeyValue("Host", it.host) builder.appendKeyValue("Wallet address", it.address) builder.appendKeyValue("Explorer link", it.explorerLink) } diff --git a/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/SendMiddleware.kt b/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/SendMiddleware.kt index 6ad9802785..3d2b5e9c37 100644 --- a/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/SendMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/SendMiddleware.kt @@ -4,9 +4,7 @@ import com.google.firebase.crashlytics.FirebaseCrashlytics import com.tangem.blockchain.blockchains.stellar.StellarTransactionExtras import com.tangem.blockchain.blockchains.xrp.XrpTransactionBuilder import com.tangem.blockchain.common.* -import com.tangem.blockchain.extensions.Signer import com.tangem.blockchain.extensions.SimpleResult -import com.tangem.commands.SignResponse import com.tangem.commands.common.card.Card import com.tangem.tap.common.analytics.AnalyticsEvent import com.tangem.tap.common.analytics.FirebaseAnalyticsHandler @@ -162,7 +160,13 @@ private fun sendTransaction( when { message == null -> { dispatch(SendAction.SendError(TapError.UnknownError)) - infoHolder?.updateOnSendError(walletManager.wallet, amountToSend, feeAmount, destinationAddress) + infoHolder?.updateOnSendError( + wallet = walletManager.wallet, + host = walletManager.currentHost, + amountToSend = amountToSend, + feeAmount = feeAmount, + destinationAddress = destinationAddress + ) dispatch(SendAction.Dialog.SendTransactionFails("unknown error")) } message.contains("50002") -> { @@ -177,7 +181,13 @@ private fun sendTransaction( Timber.e(throwable) FirebaseCrashlytics.getInstance().recordException(throwable) dispatch(SendAction.SendError(TapError.CustomError(message))) - infoHolder?.updateOnSendError(walletManager.wallet, amountToSend, feeAmount, destinationAddress) + infoHolder?.updateOnSendError( + wallet = walletManager.wallet, + host = walletManager.currentHost, + amountToSend = amountToSend, + feeAmount = feeAmount, + destinationAddress = destinationAddress + ) dispatch(SendAction.Dialog.SendTransactionFails(message)) } } diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/MultiWalletMiddleware.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/MultiWalletMiddleware.kt index e2a0042f55..d35eea4fd3 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/MultiWalletMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/MultiWalletMiddleware.kt @@ -26,8 +26,8 @@ class MultiWalletMiddleware { ) { when (action) { is WalletAction.MultiWallet.AddWalletManagers -> { - val wallets = action.walletManagers.map { it.wallet } - store.state.globalState.feedbackManager?.infoHolder?.setWalletsInfo(wallets) + store.state.globalState.feedbackManager?.infoHolder + ?.setWalletsInfo(action.walletManagers) } is WalletAction.MultiWallet.SelectWallet -> { if (action.walletData != null) { diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletFragment.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletFragment.kt index 8aa058881c..f5f61139b1 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletFragment.kt @@ -2,13 +2,11 @@ package com.tangem.tap.features.wallet.ui import android.os.Bundle import android.view.Menu -import android.view.Menu.NONE import android.view.MenuInflater import android.view.MenuItem import android.view.View import androidx.activity.OnBackPressedCallback import androidx.appcompat.app.AppCompatActivity -import androidx.core.view.get import androidx.fragment.app.Fragment import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView @@ -17,6 +15,7 @@ import com.squareup.picasso.Picasso import com.tangem.tangem_sdk_new.extensions.dpToPx import com.tangem.tap.MainActivity import com.tangem.tap.common.extensions.show +import com.tangem.tap.common.redux.global.GlobalAction import com.tangem.tap.common.redux.navigation.AppScreen import com.tangem.tap.common.redux.navigation.NavigationAction import com.tangem.tap.domain.configurable.warningMessage.WarningMessage @@ -156,6 +155,7 @@ class WalletFragment : Fragment(R.layout.fragment_wallet), StoreSubscriber { + store.dispatch(GlobalAction.UpdateFeedbackInfo(store.state.walletState.walletManagers)) store.state.globalState.scanNoteResponse?.let { scanNoteResponse -> store.dispatch(DetailsAction.PrepareScreen( scanNoteResponse.card, scanNoteResponse,