Updated on 2026-08-14

This commit is contained in:
Tangem 2020-12-09 14:04:18 +00:00
commit 289f3db695
12 changed files with 40 additions and 15 deletions

View file

@ -3,6 +3,10 @@
"name": "isWalletPayIdEnabled",
"value": true
},
{
"name": "isSendingToPayIdEnabled",
"value": true
},
{
"name": "isTopUpEnabled",
"value": true

View file

@ -3,6 +3,10 @@
"name": "isWalletPayIdEnabled",
"value": true
},
{
"name": "isSendingToPayIdEnabled",
"value": true
},
{
"name": "isTopUpEnabled",
"value": true

View file

@ -1,5 +1,6 @@
package com.tangem.tap.domain
import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchain.common.Token
import com.tangem.blockchain.common.Wallet
import com.tangem.blockchain.common.WalletManager
@ -17,7 +18,6 @@ import com.tangem.tap.domain.extensions.amountToCreateAccount
import com.tangem.tap.domain.extensions.isNoAccountError
import com.tangem.tap.domain.tasks.ScanNoteResponse
import com.tangem.tap.domain.twins.TwinsHelper
import com.tangem.tap.features.send.redux.AddressPayIdActionUi
import com.tangem.tap.features.wallet.redux.WalletAction
import com.tangem.tap.network.NetworkConnectivity
import com.tangem.tap.network.coinmarketcap.CoinMarketCapService
@ -87,7 +87,11 @@ class TapWalletManager {
val configManager = store.state.globalState.configManager
if (TapWorkarounds.isStart2Coin) {
configManager?.turnOff(ConfigManager.isWalletPayIdEnabled)
configManager?.turnOff(ConfigManager.isSendingToPayIdEnabled)
configManager?.turnOff(ConfigManager.isTopUpEnabled)
} else if (data.walletManager?.wallet?.blockchain == Blockchain.Bitcoin
|| data.card.cardData?.blockchainName == Blockchain.Bitcoin.id){
configManager?.turnOff(ConfigManager.isWalletPayIdEnabled)
} else {
configManager?.resetToDefault(ConfigManager.isWalletPayIdEnabled)
configManager?.resetToDefault(ConfigManager.isTopUpEnabled)
@ -95,8 +99,6 @@ class TapWalletManager {
withContext(Dispatchers.Main) {
store.dispatch(WalletAction.ResetState)
store.dispatch(GlobalAction.SaveScanNoteResponse(data))
store.dispatch(AddressPayIdActionUi.ChangePayIdState(configManager?.config?.isWalletPayIdEnabled
?: false))
if (data.card.cardData?.productMask?.contains(Product.TwinCard) == true) {
val secondCardId = TwinsHelper.getTwinsCardId(data.card.cardId)
val cardNumber = TwinsHelper.getTwinCardNumber(data.card.cardId)

View file

@ -10,6 +10,7 @@ data class Config(
val moonPayApiKey: String = "pk_test_kc90oYTANy7UQdBavDKGfL4K9l6VEPE",
val moonPayApiSecretKey: String = "sk_test_V8w4M19LbDjjYOt170s0tGuvXAgyEb1C",
val isWalletPayIdEnabled: Boolean = true,
val isSendingToPayIdEnabled: Boolean = true,
val isTopUpEnabled: Boolean = false,
val isCreatingTwinCardsAllowed: Boolean = false
)
@ -39,6 +40,7 @@ class ConfigManager(
fun turnOff(name: String) {
when (name) {
isWalletPayIdEnabled -> config = config.copy(isWalletPayIdEnabled = false)
isSendingToPayIdEnabled -> config = config.copy(isSendingToPayIdEnabled = false)
isTopUpEnabled -> config = config.copy(isTopUpEnabled = false)
isCreatingTwinCardsAllowed -> config = config.copy(isCreatingTwinCardsAllowed = false)
}
@ -47,6 +49,7 @@ class ConfigManager(
fun resetToDefault(name: String) {
when (name) {
isWalletPayIdEnabled -> config = config.copy(isWalletPayIdEnabled = defaultConfig.isWalletPayIdEnabled)
isSendingToPayIdEnabled -> config = config.copy(isSendingToPayIdEnabled = defaultConfig.isSendingToPayIdEnabled)
isTopUpEnabled -> config = config.copy(isTopUpEnabled = defaultConfig.isTopUpEnabled)
isCreatingTwinCardsAllowed -> config =
config.copy(isCreatingTwinCardsAllowed = defaultConfig.isCreatingTwinCardsAllowed)
@ -61,6 +64,10 @@ class ConfigManager(
config = config.copy(isWalletPayIdEnabled = newValue)
defaultConfig = defaultConfig.copy(isWalletPayIdEnabled = newValue)
}
isSendingToPayIdEnabled -> {
config = config.copy(isSendingToPayIdEnabled = newValue)
defaultConfig = defaultConfig.copy(isSendingToPayIdEnabled = newValue)
}
isTopUpEnabled -> {
config = config.copy(isTopUpEnabled = newValue)
defaultConfig = defaultConfig.copy(isTopUpEnabled = newValue)
@ -91,6 +98,7 @@ class ConfigManager(
companion object {
const val isWalletPayIdEnabled = "isWalletPayIdEnabled"
const val isSendingToPayIdEnabled = "isSendingToPayIdEnabled"
const val isCreatingTwinCardsAllowed = "isCreatingTwinCardsAllowed"
const val isTopUpEnabled = "isTopUpEnabled"
const val coinMarketCapKey = "coinMarketCapKey"

View file

@ -116,8 +116,9 @@ class ScanNoteTask(val card: Card? = null) : CardSessionRunnable<ScanNoteRespons
}
private fun getErrorIfExcludedCard(card: Card): TangemError? {
val productMask = card.cardData?.productMask ?: return TangemSdkError.CardError()
if (!productMask.contains(Product.Note) && !productMask.contains(Product.TwinCard)) {
val productMask = card.cardData?.productMask
if (productMask != null && // product mask is on cards v2.30 and later
!productMask.contains(Product.Note) && !productMask.contains(Product.TwinCard)) {
return TapSdkError.CardForDifferentApp
}
if (excludedBatches.contains(card.cardData?.batchId)) {

View file

@ -33,7 +33,7 @@ sealed class AddressPayIdActionUi : SendScreenActionUi {
object CheckAddressPayId : AddressPayIdActionUi()
data class SetTruncateHandler(val handler: (String) -> String) : AddressPayIdActionUi()
data class TruncateOrRestore(val truncate: Boolean) : AddressPayIdActionUi()
data class ChangePayIdState(val walletPayIdEnabled: Boolean): AddressPayIdActionUi()
data class ChangePayIdState(val sendingToPayIdEnabled: Boolean): AddressPayIdActionUi()
}
sealed class AddressPayIdVerifyAction : SendScreenAction {

View file

@ -117,7 +117,7 @@ internal class AddressPayIdMiddleware {
private fun isValidBlockchainAddressAndNotTheSameAsWallet(wallet: Wallet, address: String): Error? {
return if (wallet.blockchain.validateAddress(address)) {
if (wallet.address != address) {
if (wallet.addresses.all { it.value != address } ) {
null
} else {
Error.ADDRESS_SAME_AS_WALLET
@ -160,6 +160,6 @@ internal class AddressPayIdMiddleware {
}
private fun isPayIdEnabled(): Boolean {
return store.state.globalState.configManager?.config?.isWalletPayIdEnabled ?: false
return store.state.globalState.configManager?.config?.isSendingToPayIdEnabled ?: false
}
}

View file

@ -39,6 +39,7 @@ val sendMiddleware: Middleware<AppState> = { dispatch, appState ->
is RequestFee -> RequestFeeMiddleware().handle(appState(), dispatch)
is SendActionUi.SendAmountToRecipient ->
verifyAndSendTransaction(action, appState(), dispatch)
is PrepareSendScreen -> setIfSendingToPayIdEnabled(appState(), dispatch)
}
nextDispatch(action)
}
@ -185,3 +186,9 @@ fun createValidateTransactionError(errorList: EnumSet<TransactionError>, walletM
return TapError.ValidateTransactionErrors(tapErrors) { it.joinToString("\r\n") }
}
private fun setIfSendingToPayIdEnabled(appState: AppState?, dispatch: (Action) -> Unit) {
val isSendingToPayIdEnabled =
appState?.globalState?.configManager?.config?.isSendingToPayIdEnabled ?: false
dispatch(AddressPayIdActionUi.ChangePayIdState(isSendingToPayIdEnabled))
}

View file

@ -30,7 +30,7 @@ class AddressPayIdReducer : SendInternalReducer {
is AddressPayIdActionUi.PasteAddressPayId -> return sendState
is AddressPayIdActionUi.CheckClipboard -> return sendState
is AddressPayIdActionUi.CheckAddressPayId -> return sendState
is AddressPayIdActionUi.ChangePayIdState -> state.copy(walletPayIdEnabled = action.walletPayIdEnabled)
is AddressPayIdActionUi.ChangePayIdState -> state.copy(sendingToPayIdEnabled = action.sendingToPayIdEnabled)
}
return updateLastState(sendState.copy(addressPayIdState = result), result)
}

View file

@ -9,7 +9,7 @@ data class AddressPayIdState(
val recipientWalletAddress: String? = null,
val error: AddressPayIdVerifyAction.Error? = null,
val truncateHandler: ((String) -> String)? = null,
val walletPayIdEnabled: Boolean = false,
val sendingToPayIdEnabled: Boolean = false,
val pasteIsEnabled: Boolean = false
) : SendScreenState {

View file

@ -104,7 +104,7 @@ class SendStateSubscriber(fragment: BaseStoreFragment) : FragmentStateSubscriber
val til = fg.tilAddressOrPayId
val parsedError = parseError(til.context, state.error)
val hintResId = if (state.walletPayIdEnabled) {
val hintResId = if (state.sendingToPayIdEnabled) {
R.string.send_destination_hint_address_payid
}else {
R.string.send_destination_hint_address

View file

@ -153,7 +153,8 @@
android:layout_margin="16dp"
android:src="@drawable/ic_payid"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/v_payid_divider" />
app:layout_constraintTop_toBottomOf="@id/v_payid_divider"
app:layout_constraintBottom_toBottomOf="parent"/>
<TextView
android:id="@+id/tv_create_payid"
@ -173,9 +174,7 @@
android:id="@+id/tv_payid_address"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="middle"
android:padding="16dp"
android:singleLine="true"
android:textAlignment="textEnd"
android:textColor="@color/darkGray1"
android:textSize="13sp"
@ -184,7 +183,7 @@
app:layout_constraintHorizontal_bias="1"
app:layout_constraintStart_toEndOf="@id/iv_payid_icon"
app:layout_constraintTop_toBottomOf="@id/v_payid_divider"
tools:text="roman$payid.tangem.com" />
tools:text="romafdffdfdfn$payid.tangem.com" />
<androidx.constraintlayout.widget.Group
android:id="@+id/group_payid"