Updated on 2026-08-14

This commit is contained in:
Tangem 2024-09-09 14:46:54 +03:00
parent fcd594dcd3
commit 830bd01428
10 changed files with 39 additions and 20 deletions

View file

@ -89,7 +89,7 @@ class WalletConnectSdkHelper {
} else {
feeAmount
}
Fee.Ethereum(patchedAmount, gasLimit.toBigInteger(), gasPrice.toBigInteger())
Fee.Ethereum.Legacy(patchedAmount, gasLimit.toBigInteger(), gasPrice.toBigInteger())
} else {
Fee.Common(feeAmount)
}

View file

@ -34,5 +34,9 @@
{
"name": "NEW_MANAGE_TOKENS",
"version": "5.15.0"
},
{
"name": "IS_ETHEREUM_EIP_1559_ENABLED",
"version": "5.16.0"
}
]

View file

@ -73,7 +73,10 @@ internal class FeeConverter(
normalFee
} else {
when (normalFee) {
is Fee.Ethereum -> ethereumCustomFeeConverter.convertBack(normalFee = normalFee, value = customValues)
is Fee.Ethereum.Legacy -> ethereumCustomFeeConverter.convertBack(
normalFee = normalFee,
value = customValues,
)
is Fee.Bitcoin -> bitcoinCustomFeeConverter.convertBack(normalFee = normalFee, value = customValues)
is Fee.Kaspa -> kaspaCustomFeeConverter.convertBack(normalFee = normalFee, value = customValues)
else -> {

View file

@ -50,7 +50,7 @@ internal class SendFeeCustomFieldConverter(
override fun convert(value: Fee): ImmutableList<SendTextField.CustomFee> {
return when (value) {
is Fee.Ethereum -> ethereumCustomFeeConverter.convert(value)
is Fee.Ethereum.Legacy -> ethereumCustomFeeConverter.convert(value)
is Fee.Bitcoin -> bitcoinCustomFeeConverter.convert(value)
is Fee.Kaspa -> kaspaCustomFeeConverter.convert(value)
else -> persistentListOf()

View file

@ -27,9 +27,9 @@ internal class EthereumCustomFeeConverter(
private val stateRouterProvider: Provider<StateRouter>,
private val appCurrencyProvider: Provider<AppCurrency>,
private val feeCryptoCurrencyStatusProvider: Provider<CryptoCurrencyStatus?>,
) : CustomFeeConverter<Fee.Ethereum> {
) : CustomFeeConverter<Fee.Ethereum.Legacy> {
override fun convert(value: Fee.Ethereum): ImmutableList<SendTextField.CustomFee> {
override fun convert(value: Fee.Ethereum.Legacy): ImmutableList<SendTextField.CustomFee> {
val feeValue = value.amount.value
val feeCurrency = feeCryptoCurrencyStatusProvider()?.value
return persistentListOf(
@ -91,7 +91,10 @@ internal class EthereumCustomFeeConverter(
)
}
override fun convertBack(normalFee: Fee.Ethereum, value: ImmutableList<SendTextField.CustomFee>): Fee.Ethereum {
override fun convertBack(
normalFee: Fee.Ethereum.Legacy,
value: ImmutableList<SendTextField.CustomFee>,
): Fee.Ethereum.Legacy {
val feeAmount = value[FEE_AMOUNT].value.parseToBigDecimal(value[FEE_AMOUNT].decimals)
val gasPrice = value[GAS_PRICE].value.parseToBigDecimal(GAS_DECIMALS).toBigInteger()
val gasLimit = value[GAS_LIMIT].value.parseToBigDecimal(GAS_DECIMALS).toBigInteger()

View file

@ -879,7 +879,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
return when {
blockchain.isEvm() -> {
val feeAmountWithDecimals = feeAmountValue.movePointRight(fee.decimals)
Fee.Ethereum(
Fee.Ethereum.Legacy(
amount = feeAmount,
gasLimit = fee.gasLimit.toBigInteger(),
gasPrice = (feeAmountWithDecimals / fee.gasLimit.toBigDecimal()).toBigInteger(),
@ -1308,7 +1308,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
networkId = networkId,
transaction = transaction,
fromToken = fromToken.currency,
cardId = userWallet?.scanResponse?.card?.cardId,
cardId = userWallet.scanResponse.card.cardId,
)
) {
is ProxyFees.MultipleFees -> feeData.proxyFeesToFeeState(fromToken.currency, otherNativeFee)
@ -1503,8 +1503,8 @@ internal class SwapInteractorImpl @AssistedInject constructor(
swapAmount = swapAmount,
spenderAddress = requireNotNull(spenderAddress) { "Spender address is null" },
)
val cardId = userWallet?.scanResponse?.card?.cardId
val feeData = if (cardId != null && isDemoCardUseCase(cardId)) {
val cardId = userWallet.scanResponse.card.cardId
val feeData = if (isDemoCardUseCase(cardId)) {
getDemoFees(fromTokenStatus.currency)
} else {
try {
@ -1805,10 +1805,10 @@ internal class SwapInteractorImpl @AssistedInject constructor(
val increasedAmount = this.amount.copy(
value = increasedGasLimit.toBigDecimal().multiply(increasedGasPrice).movePointLeft(this.amount.decimals),
)
return this.copy(
amount = increasedAmount,
gasLimit = increasedGasLimit,
)
return when (this) {
is Fee.Ethereum.EIP1559 -> copy(amount = increasedAmount, gasLimit = increasedGasLimit)
is Fee.Ethereum.Legacy -> copy(amount = increasedAmount, gasLimit = increasedGasLimit)
}
}
private fun hasOutgoingTransaction(cryptoCurrencyStatuses: CryptoCurrencyStatus): Boolean {

View file

@ -89,7 +89,7 @@ markdownComposeView = "0.5.4"
# endregion Other libraries
# region Tangem
tangemBlockchainSdk = "develop-759"
tangemBlockchainSdk = "develop-762"
#tangemBlockchainSdk = "0.0.1" # Keep it! - used for local builds
tangemCardSdk = "develop-380"
#tangemCardSdk = "0.0.1" # Keep it! - used for local builds ^

View file

@ -23,7 +23,7 @@ internal class WalletManagerFactoryCreator @Inject constructor(
private val accountCreator: AccountCreator,
private val blockchainDataStorage: BlockchainDataStorage,
private val blockchainSDKLogger: BlockchainSDKLogger,
@Suppress("UnusedPrivateMember") private val blockchainSDKFeatureToggles: BlockchainSDKFeatureToggles,
private val blockchainSDKFeatureToggles: BlockchainSDKFeatureToggles,
) {
fun create(config: BlockchainSdkConfig, blockchainProviderTypes: BlockchainProviderTypes): WalletManagerFactory {
@ -33,7 +33,9 @@ internal class WalletManagerFactoryCreator @Inject constructor(
config = config,
blockchainProviderTypes = blockchainProviderTypes,
accountCreator = accountCreator,
featureToggles = BlockchainFeatureToggles(isCardanoTokenSupport = true),
featureToggles = BlockchainFeatureToggles(
isEthereumEIP1559Enabled = blockchainSDKFeatureToggles.isEthereumEIP1559Enabled,
),
blockchainDataStorage = blockchainDataStorage,
loggers = listOf(blockchainSDKLogger),
)

View file

@ -1,3 +1,6 @@
package com.tangem.blockchainsdk.featuretoggles
internal interface BlockchainSDKFeatureToggles
internal interface BlockchainSDKFeatureToggles {
val isEthereumEIP1559Enabled: Boolean
}

View file

@ -3,5 +3,9 @@ package com.tangem.blockchainsdk.featuretoggles
import com.tangem.core.featuretoggle.manager.FeatureTogglesManager
internal class DefaultBlockchainSDKFeatureToggles(
@Suppress("UnusedPrivateMember") private val featureTogglesManager: FeatureTogglesManager,
) : BlockchainSDKFeatureToggles
private val featureTogglesManager: FeatureTogglesManager,
) : BlockchainSDKFeatureToggles {
override val isEthereumEIP1559Enabled: Boolean
get() = featureTogglesManager.isFeatureEnabled(name = "IS_ETHEREUM_EIP_1559_ENABLED")
}