Updated on 2026-08-14
This commit is contained in:
parent
09ac40e371
commit
12cb21135f
8 changed files with 24 additions and 70 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue