Updated on 2026-08-14
This commit is contained in:
parent
df32ea7ab6
commit
4ef7082504
24 changed files with 214 additions and 185 deletions
|
|
@ -4,7 +4,6 @@
|
|||
<CurrentIssues>
|
||||
<ID>CanBeNonNullable:FetchWalletAccountsErrorHandler.kt$FetchWalletAccountsErrorHandler$savedAccountsResponse: GetWalletAccountsResponse?</ID>
|
||||
<ID>MultilineLambdaItParameter:DefaultAccountsCRUDRepository.kt$DefaultAccountsCRUDRepository${ if (it is HttpException && it.code == HttpException.Code.NOT_MODIFIED) { null } else { throw it } }</ID>
|
||||
<ID>MultilineLambdaItParameter:FetchWalletAccountsErrorHandler.kt$FetchWalletAccountsErrorHandler${ it.copy( tokens = UserTokensResponseAccountIdEnricher(userWalletId = userWalletId, tokens = it.tokens), ) }</ID>
|
||||
<ID>MultilineLambdaItParameter:GetWalletAccountsResponseExt.kt${ enrichedTokensByAccountId[it].orEmpty().map { token -> // Tokens from unexisting accounts should be copied to the main account token.copy(accountId = accountDTO.id) } }</ID>
|
||||
<ID>NoNameShadowing:GetWalletAccountsResponseExt.kt$tokens</ID>
|
||||
<ID>NullableToStringCall:AccountListCryptoCurrenciesProducer.kt$AccountListCryptoCurrenciesProducer$${this::class.simpleName}</ID>
|
||||
|
|
|
|||
|
|
@ -11,15 +11,13 @@ import com.tangem.datasource.api.common.response.ApiResponseError.HttpException.
|
|||
import com.tangem.datasource.api.common.response.ETAG_HEADER
|
||||
import com.tangem.datasource.api.common.response.isNetworkError
|
||||
import com.tangem.datasource.api.tangemTech.TangemTechApi
|
||||
import com.tangem.datasource.api.tangemTech.converters.WalletIdBodyConverter
|
||||
import com.tangem.datasource.api.tangemTech.models.UserTokensResponse
|
||||
import com.tangem.datasource.api.tangemTech.models.WalletIdBody
|
||||
import com.tangem.datasource.api.tangemTech.models.WalletIdBody.WalletType
|
||||
import com.tangem.datasource.api.tangemTech.models.account.GetWalletAccountsResponse
|
||||
import com.tangem.datasource.api.tangemTech.models.account.WalletAccountDTO
|
||||
import com.tangem.datasource.api.tangemTech.models.account.toUserTokensResponse
|
||||
import com.tangem.datasource.local.token.UserTokensResponseStore
|
||||
import com.tangem.datasource.local.userwallet.UserWalletsStore
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import kotlinx.coroutines.withContext
|
||||
|
|
@ -110,9 +108,9 @@ internal class FetchWalletAccountsErrorHandler @Inject constructor(
|
|||
|
||||
private suspend fun getFromLegacyStore(userWalletId: UserWalletId): UserTokensResponse? {
|
||||
return userTokensResponseStore.getSyncOrNull(userWalletId)
|
||||
?.let {
|
||||
it.copy(
|
||||
tokens = UserTokensResponseAccountIdEnricher(userWalletId = userWalletId, tokens = it.tokens),
|
||||
?.let { response ->
|
||||
response.copy(
|
||||
tokens = UserTokensResponseAccountIdEnricher(userWalletId = userWalletId, tokens = response.tokens),
|
||||
)
|
||||
}
|
||||
.also { userTokensResponseStore.clear(userWalletId) }
|
||||
|
|
@ -129,14 +127,7 @@ internal class FetchWalletAccountsErrorHandler @Inject constructor(
|
|||
|
||||
val creationResponse = withContext(dispatchers.io) {
|
||||
tangemTechApi.createWallet(
|
||||
body = WalletIdBody(
|
||||
walletId = userWalletId.stringValue,
|
||||
name = userWallet.name,
|
||||
walletType = when (userWallet) {
|
||||
is UserWallet.Cold -> WalletType.COLD
|
||||
is UserWallet.Hot -> WalletType.HOT
|
||||
},
|
||||
),
|
||||
body = WalletIdBodyConverter.convert(userWallet),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import com.tangem.datasource.api.common.response.ETAG_HEADER
|
|||
import com.tangem.datasource.api.tangemTech.TangemTechApi
|
||||
import com.tangem.datasource.api.tangemTech.models.UserTokensResponse
|
||||
import com.tangem.datasource.api.tangemTech.models.WalletIdBody
|
||||
import com.tangem.datasource.api.tangemTech.models.WalletType
|
||||
import com.tangem.datasource.api.tangemTech.models.account.GetWalletAccountsResponse
|
||||
import com.tangem.datasource.api.tangemTech.models.account.WalletAccountDTO
|
||||
import com.tangem.datasource.api.tangemTech.models.account.toUserTokensResponse
|
||||
|
|
@ -124,7 +125,7 @@ class FetchWalletAccountsErrorHandlerTest {
|
|||
WalletIdBody(
|
||||
walletId = userWalletId.stringValue,
|
||||
name = walletName,
|
||||
walletType = WalletIdBody.WalletType.COLD,
|
||||
walletType = WalletType.COLD,
|
||||
),
|
||||
)
|
||||
} returns apiResponse
|
||||
|
|
@ -146,7 +147,7 @@ class FetchWalletAccountsErrorHandlerTest {
|
|||
WalletIdBody(
|
||||
walletId = userWalletId.stringValue,
|
||||
name = walletName,
|
||||
walletType = WalletIdBody.WalletType.COLD,
|
||||
walletType = WalletType.COLD,
|
||||
),
|
||||
)
|
||||
eTagsStore.store(userWalletId, ETagsStore.Key.WalletAccounts, eTagValue)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue