Updated on 2026-08-14

This commit is contained in:
Tangem 2025-05-15 23:47:29 +05:00
parent 4cd56a1588
commit 17ae97606e
13 changed files with 119 additions and 64 deletions

View file

@ -122,7 +122,7 @@ internal class DefaultNFTRuntimeStore(
)
}
?.filter { it.count > 0 }
?.sortedBy { it.name },
?.sortedBy { it.name?.lowercase() },
source = this.source,
)

View file

@ -1,5 +1,7 @@
package com.tangem.datasource.local.nft.converter
import android.content.res.Resources
import com.tangem.datasource.R
import com.tangem.domain.models.StatusSource
import com.tangem.domain.nft.models.NFTAsset
import com.tangem.domain.nft.models.NFTCollection
@ -7,14 +9,31 @@ import com.tangem.domain.tokens.model.Network
import com.tangem.utils.converter.Converter
import com.tangem.blockchain.nft.models.NFTCollection as SdkNFTCollection
object NFTSdkCollectionConverter : Converter<Pair<Network, SdkNFTCollection>, NFTCollection> {
class NFTSdkCollectionConverter(
private val resources: Resources,
) : Converter<Pair<Network, SdkNFTCollection>, NFTCollection> {
override fun convert(value: Pair<Network, SdkNFTCollection>): NFTCollection {
val (network, collection) = value
val collectionId = NFTSdkCollectionIdentifierConverter.convert(collection.identifier)
return NFTCollection(
id = collectionId,
network = network,
name = collection.name,
// We use localised strings from resources here to proceed sorting and searching correctly
// Sorting is invoked on data layer, searching is simplified to filtering for now and invoked in Model
name = when (collectionId) {
is NFTCollection.Identifier.EVM -> collection.name
is NFTCollection.Identifier.TON -> when {
collectionId.contractAddress == null -> resources.getString(R.string.nft_no_collection)
collection.name.isNullOrEmpty() -> resources.getString(R.string.nft_untitled_collection)
else -> collection.name
}
is NFTCollection.Identifier.Solana -> when {
collectionId.collectionAddress == null -> resources.getString(R.string.nft_no_collection)
collection.name.isNullOrEmpty() -> resources.getString(R.string.nft_untitled_collection)
else -> collection.name
}
NFTCollection.Identifier.Unknown -> null
},
description = collection.description,
logoUrl = collection.logoUrl,
count = collection.count,

View file

@ -13,7 +13,7 @@ object NFTSdkCollectionIdentifierConverter : TwoWayConverter<SdkNFTCollection.Id
contractAddress = value.contractAddress,
)
is SdkNFTCollection.Identifier.Solana -> NFTCollection.Identifier.Solana(
collection = value.collection,
collectionAddress = value.collectionAddress,
)
is SdkNFTCollection.Identifier.Unknown -> NFTCollection.Identifier.Unknown
}
@ -26,7 +26,7 @@ object NFTSdkCollectionIdentifierConverter : TwoWayConverter<SdkNFTCollection.Id
contractAddress = value.contractAddress,
)
is NFTCollection.Identifier.Solana -> SdkNFTCollection.Identifier.Solana(
collection = value.collection,
collectionAddress = value.collectionAddress,
)
is NFTCollection.Identifier.Unknown -> SdkNFTCollection.Identifier.Unknown
}