From dcb3f101a45c0858d745aa17853cf0068d425f63 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 8 Sep 2022 20:18:32 +0300 Subject: [PATCH 1/2] Updated on 2026-08-14 --- .../send/redux/reducers/FeeReducer.kt | 18 +++++++++++------- .../send/redux/reducers/ReceiptReducer.kt | 19 ++++++++++++++----- dependencies.gradle | 2 +- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/features/send/redux/reducers/FeeReducer.kt b/app/src/main/java/com/tangem/tap/features/send/redux/reducers/FeeReducer.kt index fd653557c7..155ef90584 100644 --- a/app/src/main/java/com/tangem/tap/features/send/redux/reducers/FeeReducer.kt +++ b/app/src/main/java/com/tangem/tap/features/send/redux/reducers/FeeReducer.kt @@ -3,7 +3,6 @@ package com.tangem.tap.features.send.redux.reducers import com.tangem.blockchain.common.Amount import com.tangem.blockchain.common.AmountType import com.tangem.blockchain.common.Blockchain -import com.tangem.tap.common.extensions.fullNameWithoutTestnet import com.tangem.tap.features.send.redux.FeeAction import com.tangem.tap.features.send.redux.FeeActionUi import com.tangem.tap.features.send.redux.SendScreenAction @@ -106,12 +105,17 @@ class FeeReducer : SendInternalReducer { private fun getFeePrecision(sendState: SendState): FeePrecision { val blockchain = sendState.walletManager?.wallet?.blockchain - return if ( - (blockchain?.fullNameWithoutTestnet == Blockchain.Arbitrum.fullName || - blockchain?.fullNameWithoutTestnet == Blockchain.Tron.fullName || - blockchain?.fullNameWithoutTestnet == Blockchain.Gnosis.fullName) && - sendState.amountState.typeOfAmount is AmountType.Token - ) { + val amountType = sendState.amountState.typeOfAmount + + val canBeLower = when (blockchain) { + Blockchain.Tron, Blockchain.TronTestnet -> amountType is AmountType.Token + Blockchain.Fantom, Blockchain.FantomTestnet -> amountType is AmountType.Token + Blockchain.Arbitrum, Blockchain.ArbitrumTestnet -> true + Blockchain.Stellar, Blockchain.StellarTestnet -> true + else -> false + } + + return if (canBeLower) { FeePrecision.CAN_BE_LOWER } else { FeePrecision.PRECISE diff --git a/app/src/main/java/com/tangem/tap/features/send/redux/reducers/ReceiptReducer.kt b/app/src/main/java/com/tangem/tap/features/send/redux/reducers/ReceiptReducer.kt index c15813fdaa..84f4ef8ce0 100644 --- a/app/src/main/java/com/tangem/tap/features/send/redux/reducers/ReceiptReducer.kt +++ b/app/src/main/java/com/tangem/tap/features/send/redux/reducers/ReceiptReducer.kt @@ -6,7 +6,17 @@ import com.tangem.tap.common.extensions.scaleToFiat import com.tangem.tap.common.extensions.stripZeroPlainString import com.tangem.tap.features.send.redux.ReceiptAction.RefreshReceipt import com.tangem.tap.features.send.redux.SendScreenAction -import com.tangem.tap.features.send.redux.states.* +import com.tangem.tap.features.send.redux.states.AmountState +import com.tangem.tap.features.send.redux.states.FeeState +import com.tangem.tap.features.send.redux.states.MainCurrencyType +import com.tangem.tap.features.send.redux.states.ReceiptCrypto +import com.tangem.tap.features.send.redux.states.ReceiptFiat +import com.tangem.tap.features.send.redux.states.ReceiptLayoutType +import com.tangem.tap.features.send.redux.states.ReceiptState +import com.tangem.tap.features.send.redux.states.ReceiptSymbols +import com.tangem.tap.features.send.redux.states.ReceiptTokenCrypto +import com.tangem.tap.features.send.redux.states.ReceiptTokenFiat +import com.tangem.tap.features.send.redux.states.SendState import com.tangem.tap.features.wallet.redux.WalletState.Companion.UNKNOWN_AMOUNT_SIGN import com.tangem.tap.store import java.math.BigDecimal @@ -91,7 +101,7 @@ class ReceiptReducer : SendInternalReducer { if (feeState.feeIsIncluded) { return ReceiptCrypto( amountCrypto = amountState.amountToSendCrypto.minus(feeCrypto).stripZeroPlainString(), - feeCrypto = feeCrypto.stripZeroPlainString(), + feeCrypto = feeCrypto.stripZeroPlainString().addPrecisionSign(), totalCrypto = amountState.amountToSendCrypto.stripZeroPlainString(), feeFiat = feeFiat, willSentFiat = convertToFiatPrecision(amountState.amountToSendCrypto), @@ -101,7 +111,7 @@ class ReceiptReducer : SendInternalReducer { val totalCrypto = amountState.amountToSendCrypto.plus(feeCrypto) return ReceiptCrypto( amountCrypto = amountState.amountToSendCrypto.stripZeroPlainString(), - feeCrypto = feeCrypto.stripZeroPlainString(), + feeCrypto = feeCrypto.stripZeroPlainString().addPrecisionSign(), totalCrypto = totalCrypto.stripZeroPlainString(), feeFiat = feeFiat, willSentFiat = convertToFiatPrecision(totalCrypto), @@ -125,8 +135,7 @@ class ReceiptReducer : SendInternalReducer { val totalFiat = amountFiat.plus(feeFiat) ReceiptTokenFiat( amountFiat = amountFiat.scaleToFiat(true).stripZeroPlainString(), - feeFiat = feeFiat.scaleToFiat(true) - .stripZeroPlainString().addPrecisionSign(), + feeFiat = feeFiat.scaleToFiat(true).stripZeroPlainString().addPrecisionSign(), totalFiat = totalFiat.scaleToFiat(true).stripZeroPlainString(), willSentToken = tokensToSend.stripZeroPlainString(), willSentFeeCoin = feeCoin.stripZeroPlainString(), diff --git a/dependencies.gradle b/dependencies.gradle index e1c383532f..0fdf41d259 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -2,7 +2,7 @@ ext.versions = [ kotlin : '1.6.10', build_gradle : '7.1.3', tangem_card_sdk : 'develop-159', - tangem_blockchain_sdk: 'develop-105', + tangem_blockchain_sdk: 'AND-2102-develop-105-hotfix_xlm-109', // tangem_blockchain_sdk: '0.0.1', ] From 9cd5ad281a6c834cd7e8b3c711c6f6d4609afa5e Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 12 Sep 2022 18:21:08 +0300 Subject: [PATCH 2/2] Updated on 2026-08-14 --- .../tap/features/wallet/redux/WalletAction.kt | 4 +--- .../wallet/redux/middlewares/WalletMiddleware.kt | 14 ++++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletAction.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletAction.kt index e079a6b114..0d6e8b528a 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletAction.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletAction.kt @@ -131,9 +131,7 @@ sealed class WalletAction : Action { object Scan : WalletAction() - data class Send(val amount: Amount? = null) : WalletAction() { - data class ChooseCurrency(val amounts: List?) : WalletAction() - } + data class Send(val amount: Amount? = null) : WalletAction() object EmptyField : WalletAction(), ErrorAction { override val error = TapError.PayIdEmptyField diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/WalletMiddleware.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/WalletMiddleware.kt index 7c63b551f9..ecf9579bb9 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/WalletMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/WalletMiddleware.kt @@ -12,7 +12,13 @@ import com.tangem.domain.common.extensions.withMainContext import com.tangem.operations.attestation.Attestation import com.tangem.operations.attestation.OnlineCardVerifier import com.tangem.tap.common.analytics.Analytics -import com.tangem.tap.common.extensions.* +import com.tangem.tap.common.extensions.copyToClipboard +import com.tangem.tap.common.extensions.dispatchDebugErrorNotification +import com.tangem.tap.common.extensions.dispatchOnMain +import com.tangem.tap.common.extensions.dispatchOpenUrl +import com.tangem.tap.common.extensions.onCardScanned +import com.tangem.tap.common.extensions.shareText +import com.tangem.tap.common.extensions.stripZeroPlainString import com.tangem.tap.common.redux.AppState import com.tangem.tap.common.redux.global.GlobalAction import com.tangem.tap.common.redux.navigation.AppScreen @@ -22,11 +28,11 @@ import com.tangem.tap.domain.loadedRates import com.tangem.tap.features.demo.DemoHelper import com.tangem.tap.features.home.redux.HomeAction import com.tangem.tap.features.send.redux.PrepareSendScreen +import com.tangem.tap.features.wallet.models.Currency import com.tangem.tap.features.wallet.models.PendingTransactionType import com.tangem.tap.features.wallet.models.filterByCoin import com.tangem.tap.features.wallet.models.getPendingTransactions import com.tangem.tap.features.wallet.models.getSendableAmounts -import com.tangem.tap.features.wallet.models.Currency import com.tangem.tap.features.wallet.redux.WalletAction import com.tangem.tap.features.wallet.redux.WalletData import com.tangem.tap.features.wallet.redux.WalletState @@ -36,7 +42,6 @@ import com.tangem.tap.preferencesStorage import com.tangem.tap.scope import com.tangem.tap.store import com.tangem.tap.tangemSdkManager -import java.math.BigDecimal import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.launch @@ -44,6 +49,7 @@ import org.rekotlin.Action import org.rekotlin.DispatchFunction import org.rekotlin.Middleware import timber.log.Timber +import java.math.BigDecimal class WalletMiddleware { private val tradeCryptoMiddleware = TradeCryptoMiddleware() @@ -276,7 +282,7 @@ class WalletMiddleware { } } else { if (amounts?.size ?: 0 > 1) { - WalletAction.Send.ChooseCurrency(amounts) + WalletAction.DialogAction.ChooseCurrency(amounts) } else { val amountToSend = amounts?.first() PrepareSendScreen(