Updated on 2026-08-14
This commit is contained in:
parent
09ac40e371
commit
12cb21135f
8 changed files with 24 additions and 70 deletions
|
|
@ -5,9 +5,7 @@ import com.tangem.datasource.api.stakekit.models.request.*
|
|||
import com.tangem.datasource.api.stakekit.models.response.EnabledYieldsResponse
|
||||
import com.tangem.datasource.api.stakekit.models.response.EnterActionResponse
|
||||
import com.tangem.datasource.api.stakekit.models.response.model.BalanceDTO
|
||||
import com.tangem.datasource.api.stakekit.models.response.model.TokenWithYieldDTO
|
||||
import com.tangem.datasource.api.stakekit.models.response.model.YieldBalanceWrapperDTO
|
||||
import com.tangem.datasource.api.stakekit.models.response.model.YieldDTO
|
||||
import com.tangem.datasource.api.stakekit.models.response.model.transaction.StakingGasEstimateDTO
|
||||
import com.tangem.datasource.api.stakekit.models.response.model.transaction.StakingTransactionDTO
|
||||
import retrofit2.http.*
|
||||
|
|
@ -26,12 +24,6 @@ interface StakeKitApi {
|
|||
@Query("limit") limit: Int? = null,
|
||||
): ApiResponse<EnabledYieldsResponse>
|
||||
|
||||
@GET("yields/{integrationId}")
|
||||
suspend fun getSingleYield(
|
||||
@Path("integrationId") integrationId: String,
|
||||
@Query("ledgerWalletAPICompatible") ledgerWalletAPICompatible: Boolean = false,
|
||||
): ApiResponse<YieldDTO>
|
||||
|
||||
@POST("yields/balances")
|
||||
suspend fun getMultipleYieldBalances(
|
||||
@Body body: List<YieldBalanceRequestBody>,
|
||||
|
|
@ -43,9 +35,6 @@ interface StakeKitApi {
|
|||
@Body body: YieldBalanceRequestBody,
|
||||
): ApiResponse<List<BalanceDTO>>
|
||||
|
||||
@GET("tokens")
|
||||
suspend fun getTokens(): ApiResponse<List<TokenWithYieldDTO>>
|
||||
|
||||
@POST("actions/enter")
|
||||
suspend fun createEnterAction(@Body body: ActionRequestBody): ApiResponse<EnterActionResponse>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
package com.tangem.datasource.api.stakekit.models.response.model
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class TokenWithYieldDTO(
|
||||
@Json(name = "token") val token: TokenDTO,
|
||||
@Json(name = "availableYields") val availableYieldIds: List<String>,
|
||||
)
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
package com.tangem.datasource.local.token
|
||||
|
||||
import com.tangem.domain.staking.model.StakingTokenWithYield
|
||||
|
||||
interface StakingTokensStore {
|
||||
|
||||
suspend fun getSyncOrNull(): List<StakingTokenWithYield>?
|
||||
|
||||
suspend fun store(items: List<StakingTokenWithYield>)
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.tangem.data.staking.converters
|
||||
|
||||
import com.tangem.datasource.api.stakekit.models.response.model.BalanceDTO.BalanceTypeDTO
|
||||
import com.tangem.domain.staking.model.stakekit.BalanceType
|
||||
import com.tangem.utils.converter.Converter
|
||||
|
||||
internal class BalanceTypeConverter : Converter<BalanceTypeDTO, BalanceType> {
|
||||
|
||||
override fun convert(value: BalanceTypeDTO): BalanceType {
|
||||
return when (value) {
|
||||
BalanceTypeDTO.AVAILABLE -> BalanceType.AVAILABLE
|
||||
BalanceTypeDTO.STAKED -> BalanceType.STAKED
|
||||
BalanceTypeDTO.PREPARING -> BalanceType.PREPARING
|
||||
BalanceTypeDTO.LOCKED -> BalanceType.LOCKED
|
||||
BalanceTypeDTO.UNSTAKING -> BalanceType.UNSTAKING
|
||||
BalanceTypeDTO.UNLOCKING -> BalanceType.UNLOCKING
|
||||
BalanceTypeDTO.UNSTAKED -> BalanceType.UNSTAKED
|
||||
BalanceTypeDTO.REWARDS -> BalanceType.REWARDS
|
||||
BalanceTypeDTO.UNKNOWN -> BalanceType.UNKNOWN
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
package com.tangem.data.staking.converters
|
||||
|
||||
import com.tangem.datasource.api.stakekit.models.response.model.TokenWithYieldDTO
|
||||
import com.tangem.domain.staking.model.StakingToken
|
||||
import com.tangem.domain.staking.model.StakingTokenWithYield
|
||||
import com.tangem.utils.converter.Converter
|
||||
|
||||
class StakingTokenConverter : Converter<TokenWithYieldDTO, StakingTokenWithYield> {
|
||||
|
||||
override fun convert(value: TokenWithYieldDTO): StakingTokenWithYield {
|
||||
return StakingTokenWithYield(
|
||||
token = StakingToken(
|
||||
name = value.token.name,
|
||||
symbol = value.token.symbol,
|
||||
decimals = value.token.decimals,
|
||||
contractAddress = value.token.address,
|
||||
coinGeckoId = value.token.coinGeckoId,
|
||||
),
|
||||
availableYieldIds = value.availableYieldIds,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,6 @@ package com.tangem.data.staking.converters
|
|||
import com.tangem.data.staking.converters.action.PendingActionConverter
|
||||
import com.tangem.datasource.api.stakekit.models.response.model.YieldBalanceWrapperDTO
|
||||
import com.tangem.domain.staking.model.stakekit.BalanceItem
|
||||
import com.tangem.domain.staking.model.stakekit.BalanceType
|
||||
import com.tangem.domain.staking.model.stakekit.YieldBalance
|
||||
import com.tangem.domain.staking.model.stakekit.YieldBalanceItem
|
||||
import com.tangem.utils.converter.Converter
|
||||
|
|
@ -13,6 +12,7 @@ internal class YieldBalanceConverter : Converter<YieldBalanceWrapperDTO, YieldBa
|
|||
private val pendingActionConverter by lazy(LazyThreadSafetyMode.NONE) { PendingActionConverter() }
|
||||
private val networkTypeConverter by lazy(LazyThreadSafetyMode.NONE) { StakingNetworkTypeConverter() }
|
||||
private val tokenConverter by lazy(LazyThreadSafetyMode.NONE) { TokenConverter(networkTypeConverter) }
|
||||
private val balanceTypeConverter by lazy(LazyThreadSafetyMode.NONE) { BalanceTypeConverter() }
|
||||
override fun convert(value: YieldBalanceWrapperDTO): YieldBalance {
|
||||
return if (value.balances.isEmpty()) {
|
||||
YieldBalance.Empty
|
||||
|
|
@ -24,7 +24,7 @@ internal class YieldBalanceConverter : Converter<YieldBalanceWrapperDTO, YieldBa
|
|||
BalanceItem(
|
||||
groupId = item.groupId,
|
||||
token = tokenConverter.convert(item.tokenDTO),
|
||||
type = BalanceType.valueOf(item.type.name),
|
||||
type = balanceTypeConverter.convert(item.type),
|
||||
amount = item.amount,
|
||||
rawCurrencyId = item.tokenDTO.coinGeckoId,
|
||||
// tron-specific. operates validatorAddresses instead of validatorAddress
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
package com.tangem.domain.staking.model
|
||||
|
||||
data class StakingToken(
|
||||
val name: String,
|
||||
val symbol: String,
|
||||
val decimals: Int,
|
||||
val contractAddress: String?,
|
||||
val coinGeckoId: String?,
|
||||
)
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
package com.tangem.domain.staking.model
|
||||
|
||||
data class StakingTokenWithYield(
|
||||
val token: StakingToken,
|
||||
val availableYieldIds: List<String>,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue