Updated on 2026-08-14

This commit is contained in:
Tangem 2026-03-20 21:54:46 +04:00
parent 8b75e37e30
commit a9bca131c3
386 changed files with 1369 additions and 1347 deletions

View file

@ -45,7 +45,6 @@ dependencies {
implementation(deps.arrow.core)
implementation(deps.jodatime)
implementation(deps.kotlin.coroutines)
implementation(deps.timber)
/* Test */
testImplementation(projects.common.test)

View file

@ -4,8 +4,8 @@ import arrow.core.raise.Raise
import arrow.core.raise.recover
import com.tangem.datasource.api.common.response.ApiResponse
import com.tangem.datasource.api.common.response.ApiResponseError
import com.tangem.utils.logging.TangemLogger
import kotlinx.coroutines.withTimeoutOrNull
import timber.log.Timber
import kotlin.time.Duration
/**
@ -67,7 +67,7 @@ suspend inline fun <T> safeApiCall(
): T = recover(
block = { call(ApiResponseRaise(raise = this)) },
recover = { error ->
Timber.e(error, "Unable to perform safe API call")
TangemLogger.e("Unable to perform safe API call", error)
onError(error)
},
)

View file

@ -2,13 +2,13 @@ package com.tangem.data.common.cache
import com.tangem.datasource.local.cache.CacheKeysStore
import com.tangem.datasource.local.cache.model.CacheKey
import com.tangem.utils.logging.TangemLogger
import kotlinx.coroutines.NonCancellable
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.withContext
import org.joda.time.Duration
import org.joda.time.LocalDateTime
import timber.log.Timber
import java.util.concurrent.ConcurrentHashMap
internal class DefaultCacheRegistry(
@ -26,17 +26,17 @@ internal class DefaultCacheRegistry(
}
override suspend fun invalidate(key: String) {
Timber.d("Invalidate the cache key: $key")
TangemLogger.d("Invalidate the cache key: $key")
withContext(NonCancellable) { cacheKeysStore.remove(key) }
}
override suspend fun invalidate(keys: Collection<String>) {
Timber.d("Invalidate cache keys: $keys")
TangemLogger.d("Invalidate cache keys: $keys")
withContext(NonCancellable) { cacheKeysStore.remove(keys) }
}
override suspend fun invalidateAll() {
Timber.d("Invalidate all cache keys")
TangemLogger.d("Invalidate all cache keys")
withContext(NonCancellable) { cacheKeysStore.clear() }
}
@ -58,7 +58,7 @@ internal class DefaultCacheRegistry(
}
try {
Timber.d("Invoke the action associated with the cache key: $key")
TangemLogger.d("Invoke the action associated with the cache key: $key")
cacheKeysStore.store(
key = CacheKey(
@ -70,7 +70,7 @@ internal class DefaultCacheRegistry(
block()
} catch (e: Throwable) {
Timber.e(e, "The action related to the cache key has failed: $key")
TangemLogger.e("The action related to the cache key has failed: $key", e)
invalidate(key)

View file

@ -6,7 +6,7 @@ import com.tangem.datasource.local.preferences.AppPreferencesStore
import com.tangem.datasource.local.preferences.utils.getSyncOrNull
import com.tangem.datasource.local.preferences.utils.store
import com.tangem.domain.models.wallet.UserWalletId
import timber.log.Timber
import com.tangem.utils.logging.TangemLogger
/**
* Default implementation of the [ETagsStore] interface for managing ETag values
@ -25,7 +25,7 @@ internal class DefaultETagsStore(
override suspend fun store(userWalletId: UserWalletId, key: ETagsStore.Key, value: String) {
if (value.isBlank()) {
Timber.e("ETag value is blank, not storing it. userWalletId: $userWalletId, key: $key")
TangemLogger.e("ETag value is blank, not storing it. userWalletId: $userWalletId, key: $key")
return
}

View file

@ -11,7 +11,7 @@ import com.tangem.domain.models.account.DerivationIndex
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.network.Network
import com.tangem.domain.models.wallet.UserWallet
import timber.log.Timber
import com.tangem.utils.logging.TangemLogger
import com.tangem.blockchain.common.Token as SdkToken
// FIXME: Make internal
@ -52,7 +52,7 @@ class CryptoCurrencyFactory(
accountIndex: DerivationIndex? = null,
): CryptoCurrency.Token? {
if (blockchain == Blockchain.Unknown) {
Timber.e("Unable to map the SDK token to the domain token with Unknown blockchain")
TangemLogger.e("Unable to map the SDK token to the domain token with Unknown blockchain")
return null
}
@ -93,7 +93,7 @@ class CryptoCurrencyFactory(
accountIndex = accountIndex,
)
} else {
Timber.e("Unable to get blockchain from chainId == $chainId")
TangemLogger.e("Unable to get blockchain from chainId == $chainId")
null
}
}
@ -105,7 +105,7 @@ class CryptoCurrencyFactory(
accountIndex: DerivationIndex? = null,
): CryptoCurrency.Coin? {
if (blockchain == Blockchain.Unknown) {
Timber.e("Unable to map the SDK token to the domain token with Unknown blockchain")
TangemLogger.e("Unable to map the SDK token to the domain token with Unknown blockchain")
return null
}

View file

@ -11,7 +11,7 @@ import com.tangem.domain.models.account.DerivationIndex
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.network.Network
import com.tangem.domain.models.wallet.UserWallet
import timber.log.Timber
import com.tangem.utils.logging.TangemLogger
import javax.inject.Inject
import com.tangem.blockchain.common.Token as SdkToken
@ -46,7 +46,7 @@ class ResponseCryptoCurrenciesFactory @Inject constructor(
): CryptoCurrency? {
var blockchain = Blockchain.fromNetworkId(responseToken.networkId)
if (blockchain == null || blockchain == Blockchain.Unknown) {
Timber.e("Unable to find a blockchain with the network ID: ${responseToken.networkId}")
TangemLogger.e("Unable to find a blockchain with the network ID: ${responseToken.networkId}")
return null
}
@ -71,7 +71,7 @@ class ResponseCryptoCurrenciesFactory @Inject constructor(
): CryptoCurrency? {
var blockchain = Blockchain.fromNetworkId(responseToken.networkId)
if (blockchain == null || blockchain == Blockchain.Unknown) {
Timber.e("Unable to find a blockchain with the network ID: ${responseToken.networkId}")
TangemLogger.e("Unable to find a blockchain with the network ID: ${responseToken.networkId}")
return null
}

View file

@ -8,7 +8,7 @@ import com.tangem.domain.models.account.AccountId
import com.tangem.domain.models.account.DerivationIndex
import com.tangem.domain.models.wallet.UserWalletId
import com.tangem.lib.crypto.derivation.AccountNodeRecognizer
import timber.log.Timber
import com.tangem.utils.logging.TangemLogger
/**
* Enriches the [UserTokensResponse] with accountId values for tokens
@ -61,20 +61,20 @@ object UserTokensResponseAccountIdEnricher {
.groupBy { savedToken ->
val derivationPathValue = savedToken.derivationPath
if (derivationPathValue == null) {
Timber.e("Token $savedToken has no derivation path")
TangemLogger.e("Token $savedToken has no derivation path")
return@groupBy null
}
val blockchain = Blockchain.fromNetworkId(networkId = savedToken.networkId)
if (blockchain == null) {
Timber.e("Token $savedToken has unknown networkId")
TangemLogger.e("Token $savedToken has unknown networkId")
return@groupBy null
}
val accountNodeRecognizer = AccountNodeRecognizer(blockchain)
val accountIndex = accountNodeRecognizer.recognize(derivationPathValue)
if (accountIndex == null) {
Timber.e("Token $savedToken has unrecognized derivation path")
TangemLogger.e("Token $savedToken has unrecognized derivation path")
return@groupBy null
}
@ -89,7 +89,7 @@ object UserTokensResponseAccountIdEnricher {
if (accountIndex == null) return@mapKeys null
val derivationIndex = DerivationIndex.invoke(value = accountIndex.toInt()).getOrElse {
Timber.e("Failed to parse derivation index from account index: $accountIndex")
TangemLogger.e("Failed to parse derivation index from account index: $accountIndex")
return@mapKeys null
}

View file

@ -12,10 +12,10 @@ import com.tangem.domain.common.wallets.getSyncOrNull
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.models.wallet.UserWalletId
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import com.tangem.utils.logging.TangemLogger
import com.tangem.utils.retryer.Retryer
import com.tangem.utils.retryer.RetryerPool
import kotlinx.coroutines.withContext
import timber.log.Timber
@Suppress("LongParameterList")
class UserTokensSaver(
@ -36,7 +36,7 @@ class UserTokensSaver(
val userWallet = userWalletsListRepository.getSyncOrNull(id = userWalletId)
if (userWallet == null) {
Timber.e("UserWallet with id $userWalletId not found. Cannot push tokens.")
TangemLogger.e("UserWallet with id $userWalletId not found. Cannot push tokens.")
onFailSend()
return@withContext
}
@ -116,7 +116,7 @@ class UserTokensSaver(
userWalletId = userWalletId,
response = response,
onFailSend = {
Timber.e(
TangemLogger.e(
"Retryer: Failed to push updated tokens on attempt ${iteration + 1} for $userWalletId",
)

View file

@ -13,7 +13,7 @@ import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.wallets.derivations.DerivationStyleProvider
import com.tangem.domain.wallets.derivations.derivationStyleProvider
import com.tangem.lib.crypto.derivation.toMutable
import timber.log.Timber
import com.tangem.utils.logging.TangemLogger
import javax.inject.Inject
/**
@ -154,11 +154,11 @@ class NetworkFactory @Inject constructor(
private fun Blockchain.isBlockchainSupported(): Boolean {
if (this == Blockchain.Unknown) {
Timber.w("Unable to convert Unknown blockchain to the domain network model")
TangemLogger.w("Unable to convert Unknown blockchain to the domain network model")
return false
}
if (this in excludedBlockchains) {
Timber.w("Unable to convert excluded blockchain to the domain network model")
TangemLogger.w("Unable to convert excluded blockchain to the domain network model")
return false
}

View file

@ -15,11 +15,11 @@ import com.tangem.datasource.api.tangemTech.TangemTechApi
import com.tangem.datasource.api.tangemTech.models.QuotesResponse
import com.tangem.domain.core.utils.eitherOn
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import com.tangem.utils.logging.TangemLogger
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.withContext
import org.joda.time.DateTime
import timber.log.Timber
import java.util.concurrent.ConcurrentHashMap
import kotlin.time.Duration.Companion.seconds
@ -194,7 +194,7 @@ internal class DefaultQuotesFetcher(
return this
}
Timber.d("Some quotes are missing from the server response: $skippedIds")
TangemLogger.d("Some quotes are missing from the server response: $skippedIds")
val emptyQuotes = skippedIds.associateWith { QuotesResponse.Quote.EMPTY }

View file

@ -1,10 +1,10 @@
package com.tangem.data.common.utils
import com.tangem.utils.logging.TangemLogger
import kotlinx.coroutines.currentCoroutineContext
import kotlinx.coroutines.delay
import kotlinx.coroutines.ensureActive
import kotlinx.coroutines.yield
import timber.log.Timber
import kotlin.coroutines.cancellation.CancellationException
@Suppress("UnconditionalJumpStatementInLoop", "MagicNumber")
@ -19,7 +19,7 @@ suspend fun <T> retryOnError(priority: Boolean = false, startRetryDelay: Int = 5
currentCoroutineContext().ensureActive()
}
Timber.e(e, "Error occurred during retryOnError block")
TangemLogger.e("Error occurred during retryOnError block", e)
if (priority && priorityCounter > 0) {
--priorityCounter