Updated on 2026-08-14
This commit is contained in:
parent
aea7f5f415
commit
c83ce2ada3
53 changed files with 1062 additions and 238 deletions
|
|
@ -3,43 +3,35 @@ package com.tangem.domain.nft.models
|
|||
import com.tangem.domain.models.StatusSource
|
||||
import com.tangem.domain.tokens.model.Network
|
||||
|
||||
sealed class NFTAsset {
|
||||
abstract val id: Identifier
|
||||
data class NFTAsset(
|
||||
val id: Identifier,
|
||||
val collectionId: NFTCollection.Identifier,
|
||||
val network: Network,
|
||||
val contractType: String,
|
||||
val owner: String?,
|
||||
val name: String?,
|
||||
val description: String?,
|
||||
val salePrice: NFTSalePrice,
|
||||
val rarity: Rarity?,
|
||||
val media: Media?,
|
||||
val traits: List<Trait>,
|
||||
val source: StatusSource,
|
||||
) {
|
||||
|
||||
data class Value(
|
||||
override val id: Identifier,
|
||||
val collectionId: NFTCollection.Identifier,
|
||||
val network: Network,
|
||||
val contractType: String,
|
||||
val owner: String?,
|
||||
val name: String?,
|
||||
val description: String?,
|
||||
val salePrice: NFTSalePrice,
|
||||
val rarity: Rarity?,
|
||||
val media: Media?,
|
||||
val traits: List<Trait>,
|
||||
val source: StatusSource,
|
||||
) : NFTAsset() {
|
||||
data class Media(
|
||||
val mimetype: String?,
|
||||
val url: String,
|
||||
)
|
||||
|
||||
data class Media(
|
||||
val mimetype: String,
|
||||
val url: String,
|
||||
)
|
||||
data class Rarity(
|
||||
val rank: String,
|
||||
val label: String,
|
||||
)
|
||||
|
||||
data class Rarity(
|
||||
val rank: String,
|
||||
val label: String,
|
||||
)
|
||||
|
||||
data class Trait(
|
||||
val name: String,
|
||||
val value: String,
|
||||
)
|
||||
}
|
||||
|
||||
data class Error(
|
||||
override val id: Identifier,
|
||||
) : NFTAsset()
|
||||
data class Trait(
|
||||
val name: String,
|
||||
val value: String,
|
||||
)
|
||||
|
||||
sealed class Identifier {
|
||||
data class EVM(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.domain.nft.models
|
||||
|
||||
import com.tangem.domain.models.StatusSource
|
||||
import com.tangem.domain.tokens.model.Network
|
||||
|
||||
data class NFTCollection(
|
||||
|
|
@ -9,8 +10,18 @@ data class NFTCollection(
|
|||
val description: String?,
|
||||
val logoUrl: String?,
|
||||
val count: Int,
|
||||
val assets: List<NFTAsset> = emptyList(),
|
||||
val assets: Assets,
|
||||
) {
|
||||
sealed class Assets {
|
||||
data object Empty : Assets()
|
||||
data object Loading : Assets()
|
||||
data object Failed : Assets()
|
||||
data class Value(
|
||||
val items: List<NFTAsset>,
|
||||
val source: StatusSource,
|
||||
) : Assets()
|
||||
}
|
||||
|
||||
sealed class Identifier {
|
||||
data class EVM(val tokenAddress: String) : Identifier()
|
||||
data class TON(val contractAddress: String?) : Identifier()
|
||||
|
|
|
|||
|
|
@ -27,4 +27,31 @@ data class NFTCollections(
|
|||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun List<NFTCollections>.allCollectionsFailed() = this.all {
|
||||
it.content is NFTCollections.Content.Error
|
||||
}
|
||||
|
||||
fun List<NFTCollections>.anyCollectionFailed() = this.any {
|
||||
it.content is NFTCollections.Content.Error ||
|
||||
it.content is NFTCollections.Content.Collections &&
|
||||
it.content.source == StatusSource.ONLY_CACHE
|
||||
}
|
||||
|
||||
fun List<NFTCollections>.allLoadedCollectionsEmpty() = this
|
||||
.map { it.content }
|
||||
.filterIsInstance<NFTCollections.Content.Collections>()
|
||||
.all { it.collections.isNullOrEmpty() }
|
||||
|
||||
fun List<NFTCollections>.allCollectionsLoaded() = this.all {
|
||||
val content = it.content
|
||||
content is NFTCollections.Content.Collections &&
|
||||
content.source != StatusSource.CACHE
|
||||
}
|
||||
|
||||
fun List<NFTCollections>.allCollectionsEmpty() = this.all {
|
||||
val content = it.content
|
||||
content is NFTCollections.Content.Collections &&
|
||||
content.collections.isNullOrEmpty()
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
package com.tangem.domain.nft.models
|
||||
|
||||
import com.tangem.domain.models.StatusSource
|
||||
import java.math.BigDecimal
|
||||
|
||||
sealed class NFTSalePrice {
|
||||
|
|
@ -10,6 +9,10 @@ sealed class NFTSalePrice {
|
|||
override val assetId: NFTAsset.Identifier,
|
||||
) : NFTSalePrice()
|
||||
|
||||
data class Loading(
|
||||
override val assetId: NFTAsset.Identifier,
|
||||
) : NFTSalePrice()
|
||||
|
||||
data class Error(
|
||||
override val assetId: NFTAsset.Identifier,
|
||||
) : NFTSalePrice()
|
||||
|
|
@ -18,6 +21,5 @@ sealed class NFTSalePrice {
|
|||
override val assetId: NFTAsset.Identifier,
|
||||
val value: BigDecimal,
|
||||
val symbol: String,
|
||||
val source: StatusSource,
|
||||
) : NFTSalePrice()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue