Updated on 2026-08-14

This commit is contained in:
Tangem 2025-10-14 12:36:36 +04:00
parent 65e9a1cb40
commit 500bc90ca3
13 changed files with 126 additions and 26 deletions

View file

@ -1,18 +1,21 @@
package com.tangem.data.common.currency
import com.tangem.datasource.api.tangemTech.models.UserTokensResponse
import com.tangem.domain.models.account.AccountId
import com.tangem.domain.models.currency.CryptoCurrency
import javax.inject.Inject
// TODO: [REDACTED_JIRA]
class UserTokensResponseFactory @Inject constructor() {
fun createUserTokensResponse(
currencies: List<CryptoCurrency>,
isGroupedByNetwork: Boolean,
isSortedByBalance: Boolean,
accountId: AccountId? = null,
): UserTokensResponse {
return UserTokensResponse(
tokens = currencies.map(::createResponseToken),
tokens = currencies.map { createResponseToken(currency = it, accountId = accountId) },
group = if (isGroupedByNetwork) {
UserTokensResponse.GroupType.NETWORK
} else {
@ -26,10 +29,11 @@ class UserTokensResponseFactory @Inject constructor() {
)
}
fun createResponseToken(currency: CryptoCurrency): UserTokensResponse.Token {
fun createResponseToken(currency: CryptoCurrency, accountId: AccountId? = null): UserTokensResponse.Token {
return with(currency) {
UserTokensResponse.Token(
id = id.rawCurrencyId?.value,
accountId = accountId?.value,
networkId = network.backendId,
derivationPath = network.derivationPath.value,
name = name,