Updated on 2026-08-14

This commit is contained in:
Tangem 2024-01-29 20:24:38 +03:00
commit 13cc35f1b2
10 changed files with 40 additions and 17 deletions

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

@ -3,7 +3,6 @@ package com.tangem.tap.features.tokens.impl.data.converters
import com.tangem.blockchain.common.Blockchain
import com.tangem.datasource.api.tangemTech.models.CoinsResponse
import com.tangem.domain.common.extensions.fromNetworkId
import com.tangem.domain.common.extensions.toNetworkId
import com.tangem.tap.features.tokens.impl.domain.models.Token
import com.tangem.utils.converter.Converter
@ -26,7 +25,8 @@ internal object CoinsResponseConverter : Converter<CoinsResponse, List<Token>> {
networks = token.networks.mapNotNull { network ->
val blockchain = Blockchain.fromNetworkId(network.networkId) ?: return@mapNotNull null
if (network.networkId != blockchain.toNetworkId() &&
// filter tokens, if contractAddress != null, assume that it is a token
if (network.contractAddress != null &&
!blockchain.canHandleTokens()
) {
return@mapNotNull null

View file

@ -239,4 +239,5 @@ private const val NODL_AMOUNT_TO_CREATE_ACCOUNT = 1.5
private val excludedBlockchains = listOf(
Blockchain.Unknown,
Blockchain.Ducatus,
Blockchain.Aptos,
)

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

@ -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-466"
#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 ^