Updated on 2026-08-14

This commit is contained in:
Tangem 2025-11-20 17:25:27 +04:00
parent e3b857b79a
commit 02e44033c9
18 changed files with 266 additions and 316 deletions

View file

@ -1,14 +0,0 @@
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues/>
<CurrentIssues>
<ID>MultilineLambdaItParameter:ApiResponseRaise.kt${ Timber.e(it, "Unable to perform safe API call") onError(it) }</ID>
<ID>MultilineLambdaItParameter:DefaultCardCryptoCurrencyFactory.kt$DefaultCardCryptoCurrencyFactory${ cryptoCurrencyFactory.createCoin( blockchain = it, extraDerivationPath = null, userWallet = userWallet, ) }</ID>
<ID>MultilineLambdaItParameter:UserTokensResponseFactory.kt$UserTokensResponseFactory${ getDefaultWalletBlockchains(userWallet = it, demoConfig = DemoConfig) .map { blockchain -&gt; val derivationPath = networkFactory.createDerivationPath( blockchain = blockchain, extraDerivationPath = null, cardDerivationStyleProvider = userWallet.derivationStyleProvider, ).value UserTokensResponse.Token( id = blockchain.toCoinId(), accountId = accountId?.value, networkId = blockchain.toNetworkId(), derivationPath = derivationPath, name = blockchain.getCoinName(), symbol = blockchain.currency, decimals = blockchain.decimals(), contractAddress = null, ) } }</ID>
<ID>MultilineLambdaItParameter:UserTokensSaver.kt$UserTokensSaver${ if (accountsFeatureToggles.isFeatureEnabled) { it.enrichByAccountId(userWalletId = userWalletId) } else { it } }</ID>
<ID>NamedArguments:CryptoCurrencyFactory.kt$CryptoCurrencyFactory$createCoin(blockchain, extraDerivationPath, userWallet, accountIndex)</ID>
<ID>NoNameShadowing:DefaultETagsStore.kt$DefaultETagsStore$key</ID>
<ID>UnnecessaryLet:DefaultCardCryptoCurrencyFactory.kt$DefaultCardCryptoCurrencyFactory$let(::listOf)</ID>
<ID>UseOrEmpty:UserTokensResponseAddressesEnricher.kt$UserTokensResponseAddressesEnricher$withTimeoutOrNull( FETCH_TIMEOUT_SECONDS.seconds, { multiNetworkStatusSupplier.invoke(MultiNetworkStatusProducer.Params(userWalletId)).first() }, ) ?: emptySet()</ID>
</CurrentIssues>
</SmellBaseline>

View file

@ -66,8 +66,8 @@ suspend inline fun <T> safeApiCall(
crossinline onError: suspend (ApiResponseError) -> T,
): T = recover(
block = { call(ApiResponseRaise(raise = this)) },
recover = {
Timber.e(it, "Unable to perform safe API call")
onError(it)
recover = { error ->
Timber.e(error, "Unable to perform safe API call")
onError(error)
},
)

View file

@ -18,9 +18,9 @@ internal class DefaultETagsStore(
) : ETagsStore {
override suspend fun getSyncOrNull(userWalletId: UserWalletId, key: ETagsStore.Key): String? {
val key = getAccountsETagKey(userWalletId = userWalletId, key = key)
val storeKey = getAccountsETagKey(userWalletId = userWalletId, key = key)
return appPreferencesStore.getSyncOrNull(key = key)
return appPreferencesStore.getSyncOrNull(key = storeKey)
}
override suspend fun store(userWalletId: UserWalletId, key: ETagsStore.Key, value: String) {
@ -29,14 +29,14 @@ internal class DefaultETagsStore(
return
}
val key = getAccountsETagKey(userWalletId = userWalletId, key = key)
val storeKey = getAccountsETagKey(userWalletId = userWalletId, key = key)
appPreferencesStore.store(key = key, value = value)
appPreferencesStore.store(key = storeKey, value = value)
}
override suspend fun clear(userWalletId: UserWalletId, key: ETagsStore.Key) {
val key = getAccountsETagKey(userWalletId = userWalletId, key = key)
appPreferencesStore.editData { it.remove(key) }
val storeKey = getAccountsETagKey(userWalletId = userWalletId, key = key)
appPreferencesStore.editData { it.remove(storeKey) }
}
private fun getAccountsETagKey(userWalletId: UserWalletId, key: ETagsStore.Key): Preferences.Key<String> {

View file

@ -86,7 +86,12 @@ class CryptoCurrencyFactory(
val blockchain: Blockchain? = Chain.entries.find { it.id == chainId }?.blockchain
return if (blockchain != null) {
createCoin(blockchain, extraDerivationPath, userWallet, accountIndex)
createCoin(
blockchain = blockchain,
extraDerivationPath = extraDerivationPath,
userWallet = userWallet,
accountIndex = accountIndex,
)
} else {
Timber.e("Unable to get blockchain from chainId == $chainId")
null

View file

@ -89,7 +89,7 @@ internal class DefaultCardCryptoCurrencyFactory(
}
// single-currency wallet
return createPrimaryCurrencyForSingleCurrencyCard(userWallet).let(::listOf)
return listOf(createPrimaryCurrencyForSingleCurrencyCard(userWallet))
}
override suspend fun createCurrenciesForMultiCurrencyCard(
@ -106,9 +106,9 @@ internal class DefaultCardCryptoCurrencyFactory(
val blockchains = getDefaultWalletBlockchains(userWallet, demoConfig)
return blockchains.mapNotNull {
return blockchains.mapNotNull { blockchain ->
cryptoCurrencyFactory.createCoin(
blockchain = it,
blockchain = blockchain,
extraDerivationPath = null,
userWallet = userWallet,
)

View file

@ -27,7 +27,7 @@ class UserTokensResponseAddressesEnricher @Inject constructor(
withTimeoutOrNull(
FETCH_TIMEOUT_SECONDS.seconds,
{ multiNetworkStatusSupplier.invoke(MultiNetworkStatusProducer.Params(userWalletId)).first() },
) ?: emptySet()
).orEmpty()
} else {
emptySet()
}

View file

@ -55,8 +55,8 @@ class UserTokensResponseFactory @Inject constructor() {
networkFactory: NetworkFactory,
accountId: AccountId?,
): UserTokensResponse {
val tokens = userWallet?.let {
getDefaultWalletBlockchains(userWallet = it, demoConfig = DemoConfig)
val tokens = if (userWallet != null) {
getDefaultWalletBlockchains(userWallet = userWallet, demoConfig = DemoConfig)
.map { blockchain ->
val derivationPath = networkFactory.createDerivationPath(
blockchain = blockchain,
@ -75,12 +75,14 @@ class UserTokensResponseFactory @Inject constructor() {
contractAddress = null,
)
}
} else {
emptyList()
}
return UserTokensResponse(
group = UserTokensResponse.GroupType.NONE,
sort = UserTokensResponse.SortType.MANUAL,
tokens = tokens.orEmpty(),
tokens = tokens,
)
}
}

View file

@ -91,11 +91,11 @@ class UserTokensSaver(
return this
.enrichByAddress(userWalletId = userWalletId)
.let {
.let { response ->
if (accountsFeatureToggles.isFeatureEnabled) {
it.enrichByAccountId(userWalletId = userWalletId)
response.enrichByAccountId(userWalletId = userWalletId)
} else {
it
response
}
}
}

View file

@ -53,6 +53,7 @@ class NetworkFactory @Inject constructor(
blockchain = blockchain,
excludedBlockchains = excludedBlockchains,
),
accountIndex = accountIndex,
)
}
@ -118,6 +119,7 @@ class NetworkFactory @Inject constructor(
accountIndex = accountIndex,
),
canHandleTokens = canHandleTokens,
accountIndex = accountIndex,
)
}
@ -125,8 +127,10 @@ class NetworkFactory @Inject constructor(
blockchain: Blockchain,
derivationPath: Network.DerivationPath,
canHandleTokens: Boolean,
accountIndex: DerivationIndex? = null,
): Network? {
if (!blockchain.isBlockchainSupported()) return null
if (blockchain == Blockchain.Chia && accountIndex != DerivationIndex.Main) return null
return runCatching {
Network(