Updated on 2026-08-14

This commit is contained in:
Tangem 2025-10-17 10:37:51 +04:00
parent 321b764887
commit 33f9a0d452
21 changed files with 280 additions and 157 deletions

View file

@ -1,24 +1,10 @@
plugins {
alias(deps.plugins.android.library)
alias(deps.plugins.kotlin.android)
alias(deps.plugins.kotlin.jvm)
alias(deps.plugins.kotlin.serialization)
id("configuration")
}
android {
namespace = "com.tangem.domain.express.models"
}
dependencies {
/** Core */
implementation(projects.core.utils)
implementation(projects.core.datasource)
/** Domain */
implementation(projects.domain.express.models)
api(projects.domain.express.models)
api(projects.domain.models)
implementation(projects.domain.tokens.models)
/** Other */
implementation(deps.moshi.adapters)
}

View file

@ -1,12 +1,10 @@
plugins {
alias(deps.plugins.kotlin.jvm)
alias(deps.plugins.kotlin.serialization)
id("configuration")
}
dependencies {
/** Domain */
implementation(projects.domain.tokens.models)
/* Other */
implementation(deps.moshi.adapters)
implementation(deps.kotlin.serialization)
}

View file

@ -0,0 +1,48 @@
package com.tangem.domain.express.models
import kotlinx.serialization.Serializable
/**
* Express asset model.
*
* @property id The unique identifier of the Express asset.
* @property isExchangeAvailable Indicates if exchange is available for this asset.
* @property isOnrampAvailable Indicates if onramp is available for this asset (nullable).
*
[REDACTED_AUTHOR]
*/
@Serializable
data class ExpressAsset(
val id: ID,
val isExchangeAvailable: Boolean,
val isOnrampAvailable: Boolean?,
) {
/**
* Unique identifier for an Express asset, consisting of network ID and contract address.
*
* @property networkId The network ID of the asset.
* @property contractAddress The contract address of the asset.
*/
@Serializable
data class ID(val networkId: String, val contractAddress: String) {
companion object {
/**
* Creates an [ID] instance, defaulting the contract address to "0" if null.
*
* @param networkId The network ID of the asset.
* @param contractAddress The contract address of the asset, or null to default to "0".
* @return An [ID] instance with the specified network ID and contract address.
*/
operator fun invoke(networkId: String, contractAddress: String?): ID {
return ID(networkId = networkId, contractAddress = contractAddress ?: EMPTY_CONTRACT_ADDRESS_VALUE)
}
}
}
companion object {
const val EMPTY_CONTRACT_ADDRESS_VALUE = "0"
}
}

View file

@ -0,0 +1,38 @@
package com.tangem.domain.express
import arrow.core.Either
import com.tangem.domain.core.lce.Lce
import com.tangem.domain.express.models.ExpressAsset
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.models.wallet.UserWalletId
import kotlinx.coroutines.flow.Flow
/**
* Service interface to fetch Express assets data and monitor initialization status.
*/
interface ExpressServiceFetcher {
/**
* Fetches Express assets data for the given user wallet ID and asset IDs.
*
* @param userWalletId The ID of the user wallet.
* @param assetIds The list of Express asset IDs to fetch.
*/
suspend fun fetch(userWalletId: UserWalletId, assetIds: Set<ExpressAsset.ID>): Either<Throwable, Unit>
/**
* Fetches Express assets data for the given user wallet and asset IDs.
*
* @param userWallet The user wallet for which to fetch assets.
* @param assetIds The list of Express asset IDs to fetch.
*/
suspend fun fetch(userWallet: UserWallet, assetIds: Set<ExpressAsset.ID>): Either<Throwable, Unit>
/**
* Returns a flow that emits the initialization status of Express assets for the given user wallet ID.
*
* @param userWalletId The ID of the user wallet.
* @return A flow emitting Lce states containing either a list of Express assets or an error.
*/
fun getInitializationStatus(userWalletId: UserWalletId): Flow<Lce<Throwable, List<ExpressAsset>>>
}