Updated on 2026-08-14

This commit is contained in:
Tangem 2020-11-19 19:40:08 +03:00
parent 426250efff
commit 7166307e43
9 changed files with 32 additions and 22 deletions

View file

@ -26,7 +26,6 @@ import java.math.BigDecimal
class TapWalletManager {
private val payIdManager = PayIdManager()
private val coinMarketCapService = CoinMarketCapService()
private var tapWorkarounds: TapWorkarounds? = null
suspend fun loadWalletData() {
val walletManager = store.state.globalState.scanNoteResponse?.walletManager
@ -84,7 +83,7 @@ class TapWalletManager {
if (addAnalyticsEvent) {
FirebaseAnalyticsHandler.triggerEvent(AnalyticsEvent.CARD_IS_SCANNED, data.card)
}
tapWorkarounds = TapWorkarounds(data.card)
TapWorkarounds.updateCard(data.card)
withContext(Dispatchers.Main) {
store.dispatch(WalletAction.ResetState)
store.dispatch(GlobalAction.SaveScanNoteResponse(data))
@ -103,7 +102,7 @@ class TapWalletManager {
}
store.dispatch(WalletAction.LoadWallet(
data.walletManager.wallet, data.verifyResponse?.artworkInfo?.id,
tapWorkarounds?.isStart2Coin != true && TapConfig.useTopUp
TapWorkarounds.isStart2Coin != true && TapConfig.useTopUp
))
store.dispatch(WalletAction.LoadArtwork(data.card, artworkId))
store.dispatch(WalletAction.LoadFiatRate)
@ -168,7 +167,7 @@ class TapWalletManager {
when (result) {
is Result.Success -> {
val payId = result.data
if (tapWorkarounds?.isPayIdEnabled() == false) {
if (TapWorkarounds.isPayIdEnabled() == false) {
store.dispatch(WalletAction.DisablePayId)
return@withContext
}

View file

@ -3,17 +3,19 @@ package com.tangem.tap.domain
import com.tangem.commands.Card
import java.util.*
class TapWorkarounds(val card: Card) {
object TapWorkarounds {
val isStart2Coin: Boolean =
card.cardData?.issuerName?.toLowerCase(Locale.US) == START_2_COIN_ISSUER
var isStart2Coin: Boolean = false
private set
fun updateCard(card: Card) {
isStart2Coin = card.cardData?.issuerName?.toLowerCase(Locale.US) == START_2_COIN_ISSUER
}
fun isPayIdEnabled(): Boolean {
if (isStart2Coin) return false
return true
}
companion object {
const val START_2_COIN_ISSUER = "start2coin"
}
const val START_2_COIN_ISSUER = "start2coin"
}

View file

@ -4,6 +4,7 @@ import com.tangem.blockchain.common.Wallet
import com.tangem.commands.common.network.Result
import com.tangem.tap.common.redux.AppState
import com.tangem.tap.domain.PayIdManager
import com.tangem.tap.domain.TapWorkarounds
import com.tangem.tap.domain.isPayIdSupported
import com.tangem.tap.features.send.redux.AddressPayIdActionUi
import com.tangem.tap.features.send.redux.AddressPayIdVerifyAction
@ -48,7 +49,7 @@ internal class AddressPayIdMiddleware {
private fun setAddressAndCheck(data: String, isUserInput: Boolean, dispatch: (Action) -> Unit) {
val potentialPayId = data.toLowerCase()
if (PayIdManager.isPayId(potentialPayId)) {
if (PayIdManager.isPayId(potentialPayId) && TapWorkarounds.isPayIdEnabled()) {
dispatch(SetPayIdWalletAddress(potentialPayId, "", isUserInput))
} else {
dispatch(SetWalletAddress(data, isUserInput))
@ -62,7 +63,7 @@ internal class AddressPayIdMiddleware {
val addressPayId = sendState.addressPayIdState.normalFieldValue ?: return
val isUserInput = sendState.addressPayIdState.viewFieldValue.isFromUserInput
if (PayIdManager.isPayId(addressPayId)) {
if (PayIdManager.isPayId(addressPayId) && TapWorkarounds.isPayIdEnabled()) {
verifyPayId(addressPayId, wallet, isUserInput, dispatch)
} else {
verifyAddress(addressPayId, wallet, isUserInput, dispatch)
@ -149,7 +150,7 @@ internal class AddressPayIdMiddleware {
}
}
if (PayIdManager.isPayId(addressPayId)) {
if (PayIdManager.isPayId(addressPayId) && TapWorkarounds.isPayIdEnabled()) {
verifyPayId(addressPayId, wallet, false, internalDispatcher)
} else {
verifyAddress(addressPayId, wallet, false, internalDispatcher)

View file

@ -5,14 +5,12 @@ import android.content.Context
import android.text.SpannableStringBuilder
import android.view.ViewGroup
import androidx.core.text.bold
import com.tangem.tap.common.extensions.beginDelayedTransition
import com.tangem.tap.common.extensions.enableError
import com.tangem.tap.common.extensions.show
import com.tangem.tap.common.extensions.update
import com.tangem.tap.common.extensions.*
import com.tangem.tap.common.redux.getMessageString
import com.tangem.tap.common.text.DecimalDigitsInputFilter
import com.tangem.tap.common.toggleWidget.ProgressState
import com.tangem.tap.domain.MultiMessageError
import com.tangem.tap.domain.TapWorkarounds
import com.tangem.tap.domain.assembleErrors
import com.tangem.tap.features.send.BaseStoreFragment
import com.tangem.tap.features.send.redux.AddressPayIdVerifyAction.Error
@ -106,6 +104,12 @@ class SendStateSubscriber(fragment: BaseStoreFragment) : FragmentStateSubscriber
val til = fg.tilAddressOrPayId
val parsedError = parseError(til.context, state.error)
val hintResId = if (TapWorkarounds.isPayIdEnabled()) {
R.string.send_destination_hint_address_payid
}else {
R.string.send_destination_hint_address
}
til.hint = til.getString(hintResId)
til.parent?.parent?.beginDelayedTransition()
til.error = parsedError
til.isErrorEnabled = parsedError != null