Updated on 2026-08-14

This commit is contained in:
Tangem 2024-02-01 17:00:48 +03:00
commit 0f336caa58
12 changed files with 52 additions and 27 deletions

View file

@ -405,7 +405,7 @@
{
"id" : "vechain",
"symbol" : "VET",
"name" : "Vechain",
"name" : "VeChain",
"networks" : [
{
"networkId" : "vechain/test"
@ -419,7 +419,7 @@
"networks": [
{
"networkId": "vechain/test",
"contractAddress": "0x0000000000000000000000000000456E65726779",
"contractAddress": "0x0000000000000000000000000000456e65726779",
"decimalCount": 18
}
]

View file

@ -20,7 +20,7 @@ object FoundTokenConverter : Converter<CoinsResponse.Coin, FoundToken> {
network = value.networks.firstOrNull()?.let { network ->
FoundToken.Network(
id = network.networkId,
address = requireNotNull(network.contractAddress),
contractAddress = requireNotNull(network.contractAddress),
decimalCount = requireNotNull(network.decimalCount).toString(),
)
} ?: error("Found token networks is empty"),

View file

@ -22,9 +22,9 @@ data class FoundToken(
/**
* Found token network
*
* @property id id
* @property address address
* @property decimalCount decimal count
* @property id id
* @property contractAddress address
* @property decimalCount decimal count
*/
data class Network(val id: String, val address: String, val decimalCount: String)
data class Network(val id: String, val contractAddress: String, val decimalCount: String)
}

View file

@ -827,11 +827,13 @@ internal class AddCustomTokenViewModel @Inject constructor(
val currency = when (getCustomTokenType()) {
CustomTokenType.TOKEN -> {
val contractAddress = foundToken?.network?.contractAddress
?: uiState.form.contractAddressInputField.value
CustomCurrency.CustomToken(
token = Token(
name = uiState.form.tokenNameInputField.value,
symbol = uiState.form.tokenSymbolInputField.value,
contractAddress = uiState.form.contractAddressInputField.value,
contractAddress = contractAddress,
decimals = requireNotNull(uiState.form.decimalsInputField.value.toIntOrNull()),
id = foundToken?.id,
),

View file

@ -7,6 +7,7 @@ import com.tangem.common.core.TangemSdkError
import com.tangem.common.core.UserCodeRequestPolicy
import com.tangem.common.extensions.guard
import com.tangem.core.analytics.Analytics
import com.tangem.core.analytics.models.Basic
import com.tangem.core.navigation.AppScreen
import com.tangem.core.navigation.NavigationAction
import com.tangem.core.ui.extensions.TextReference
@ -22,8 +23,6 @@ import com.tangem.domain.wallets.legacy.UserWalletsListManager
import com.tangem.domain.wallets.legacy.isLockedSync
import com.tangem.tap.*
import com.tangem.tap.common.analytics.events.AnalyticsParam
import com.tangem.core.analytics.models.AnalyticsParam as CoreAnalyticsParam
import com.tangem.core.analytics.models.Basic
import com.tangem.tap.common.analytics.events.Settings
import com.tangem.tap.common.extensions.dispatchDialogShow
import com.tangem.tap.common.extensions.dispatchOnMain
@ -48,6 +47,7 @@ import kotlinx.coroutines.withContext
import org.rekotlin.Action
import org.rekotlin.Middleware
import timber.log.Timber
import com.tangem.core.analytics.models.AnalyticsParam as CoreAnalyticsParam
class DetailsMiddleware {
private val eraseWalletMiddleware = EraseWalletMiddleware()
@ -522,7 +522,6 @@ class DetailsMiddleware {
onWalletNotCreated = {
// No need to rollback policy, continue with the policy set before the card scan
store.dispatchWithMain(DetailsAction.ScanAndSaveUserWallet.Success)
store.dispatchWithMain(NavigationAction.PopBackTo(AppScreen.Wallet))
},
disclaimerWillShow = {
store.dispatchOnMain(NavigationAction.PopBackTo())

View file

@ -101,7 +101,17 @@ internal class SaveWalletMiddleware {
val isFirstSavedWallet = !userWalletsListManager.hasUserWallets
saveAccessCodeIfNeeded(state.backupInfo?.accessCode, userWallet.cardsInWallet)
.flatMap { userWalletsListManager.save(userWallet, canOverride = true) }
.flatMap {
// Save wallet only at first time (SaveWalletBottomSheet).
// Otherwise (Example, add new wallet in Details) userWalletsListManager.wallets subscribers will
// receive useless updates.
// See: OnboardingHelper.trySaveWalletAndNavigateToWalletScreen()
if (isFirstSavedWallet) {
userWalletsListManager.save(userWallet, canOverride = true)
} else {
CompletionResult.Success(Unit)
}
}
.doOnFailure { error ->
store.dispatchWithMain(SaveWalletAction.Save.Error(error))
}
@ -118,8 +128,8 @@ internal class SaveWalletMiddleware {
)
}
store.dispatchWithMain(SaveWalletAction.Save.Success)
store.dispatchWithMain(NavigationAction.PopBackTo(AppScreen.Wallet))
store.dispatchOnMain(SaveWalletAction.Save.Success)
store.dispatchOnMain(NavigationAction.PopBackTo(AppScreen.Wallet))
}
}
}

View file

@ -76,8 +76,8 @@ fun Blockchain.Companion.fromNetworkId(networkId: String): Blockchain? {
"decimal/test" -> Blockchain.DecimalTestnet
"xdc-network" -> Blockchain.XDC
"xdc-network/test" -> Blockchain.XDCTestnet
"vechain" -> Blockchain.Vechain
"vechain/test" -> Blockchain.VechainTestnet
"vechain" -> Blockchain.VeChain
"vechain/test" -> Blockchain.VeChainTestnet
"aptos" -> Blockchain.Aptos
"aptos/test" -> Blockchain.AptosTestnet
else -> null
@ -157,8 +157,8 @@ fun Blockchain.toNetworkId(): String {
Blockchain.DecimalTestnet -> "decimal/test"
Blockchain.XDC -> "xdc-network"
Blockchain.XDCTestnet -> "xdc-network/test"
Blockchain.Vechain -> "vechain"
Blockchain.VechainTestnet -> "vechain/test"
Blockchain.VeChain -> "vechain"
Blockchain.VeChainTestnet -> "vechain/test"
Blockchain.Aptos -> "aptos"
Blockchain.AptosTestnet -> "aptos/test"
}
@ -209,7 +209,7 @@ fun Blockchain.toCoinId(): String {
Blockchain.NearTestnet -> "near/test"
Blockchain.Decimal, Blockchain.DecimalTestnet -> "decimal"
Blockchain.XDC, Blockchain.XDCTestnet -> "xdce-crowd-sale"
Blockchain.Vechain, Blockchain.VechainTestnet -> "vechain"
Blockchain.VeChain, Blockchain.VeChainTestnet -> "vechain"
Blockchain.Aptos -> "aptos"
Blockchain.AptosTestnet -> "aptos/test"
Blockchain.Unknown -> "unknown"

View file

@ -81,7 +81,18 @@ class AddCryptoCurrenciesUseCase(
.filter { hasCoinForToken(existingCurrencies, it) }
.mapTo(hashSetOf(), CryptoCurrency.Token::network)
catch({ networksRepository.getNetworkStatusesSync(userWalletId, networksToUpdate, refresh = true) }) {
val networkToUpdate = currenciesToAdd.map { it.network }
.subtract(existingCurrencies.map { it.network }.toSet())
catch(
{
networksRepository.getNetworkStatusesSync(
userWalletId = userWalletId,
networks = networksToUpdate + networkToUpdate,
refresh = true,
)
},
) {
raise(AddCurrencyError.DataError(it))
}
}

View file

@ -200,7 +200,8 @@ class GetCurrencyWarningsUseCase(
}
feePaidCurrency is FeePaidCurrency.Token -> {
val feePaidTokenBalance = feePaidCurrency.balance
if (!tokenStatus.value.amount.isZero() && feePaidTokenBalance.isZero()) {
val amount = tokenStatus.value.amount ?: return null
if (!amount.isZero() && feePaidTokenBalance.isZero()) {
constructTokenBalanceNotEnoughWarning(
userWalletId = userWalletId,
tokenStatus = tokenStatus,
@ -222,7 +223,9 @@ class GetCurrencyWarningsUseCase(
val token = currenciesRepository
.getMultiCurrencyWalletCurrenciesSync(userWalletId)
.find {
it is CryptoCurrency.Token && it.contractAddress.equals(feePaidToken.contractAddress, ignoreCase = true)
it is CryptoCurrency.Token &&
it.contractAddress.equals(feePaidToken.contractAddress, ignoreCase = true) &&
it.network.derivationPath == tokenStatus.currency.network.derivationPath
}
return if (token != null) {
CryptoCurrencyWarning.CustomTokenNotEnoughForFee(

View file

@ -655,9 +655,9 @@ internal class SwapInteractorImpl @Inject constructor(
gasPrice = (feeAmountWithDecimals / fee.gasLimit.toBigDecimal()).toBigInteger(),
)
}
blockchain == Blockchain.Vechain -> Fee.Vechain(
blockchain == Blockchain.VeChain -> Fee.VeChain(
amount = feeAmount,
gasPriceCoef = Fee.Vechain.getGasPriceCoef(fee.gasLimit.toLong(), fee.feeValue),
gasPriceCoef = Fee.VeChain.getGasPriceCoef(fee.gasLimit.toLong(), fee.feeValue),
gasLimit = fee.gasLimit.toLong(),
)
blockchain == Blockchain.Aptos -> {
@ -1354,7 +1354,7 @@ internal class SwapInteractorImpl @Inject constructor(
return when (this) {
is Fee.Common -> 0
is Fee.Ethereum -> gasLimit.toInt()
is Fee.Vechain -> gasLimit.toInt()
is Fee.VeChain -> gasLimit.toInt()
is Fee.Aptos -> amount.longValue?.div(gasUnitPrice)?.toInt() ?: 0
}
}

View file

@ -211,7 +211,7 @@ internal class WalletsUpdateActionResolverV2 @Inject constructor(
override fun toString(): String {
return """
Initialize(
InitializeWallets(
selectedWalletIndex = $selectedWalletIndex,
selectedWallet = ${selectedWallet.walletId},
wallets = ${wallets.joinToString { it.walletId.toString() }}

View file

@ -85,7 +85,7 @@ spr-client = "3.6.2"
# endregion Other libraries
# region Tangem
tangemBlockchainSdk = "release-app_5.5-465"
tangemBlockchainSdk = "release-app_5.5-469"
#tangemBlockchainSdk = "0.0.1" # Keep it! - used for local builds
tangemCardSdk = "release-app_5.5-323"
#tangemCardSdk = "0.0.1" # Keep it! - used for local builds ^