Updated on 2026-08-14
This commit is contained in:
parent
b88de49ba3
commit
664e71b782
11 changed files with 307 additions and 4 deletions
|
|
@ -2,8 +2,6 @@ package com.tangem.datasource.local.network.entity
|
|||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
import com.tangem.datasource.local.network.entity.NetworkStatusDM.NoAccount
|
||||
import com.tangem.datasource.local.network.entity.NetworkStatusDM.Verified
|
||||
import dev.onenowy.moshipolymorphicadapter.PolymorphicAdapterType
|
||||
import dev.onenowy.moshipolymorphicadapter.annotations.NameLabel
|
||||
import java.math.BigDecimal
|
||||
|
|
@ -44,6 +42,7 @@ sealed interface NetworkStatusDM {
|
|||
@Json(name = "selected_address") override val selectedAddress: String,
|
||||
@Json(name = "available_addresses") override val availableAddresses: Set<Address>,
|
||||
@Json(name = "amounts") val amounts: Map<String, BigDecimal>,
|
||||
@Json(name = "yield_supply_statuses") val yieldSupplyStatuses: Map<String, YieldSupplyStatus?> = emptyMap(),
|
||||
) : NetworkStatusDM
|
||||
|
||||
/**
|
||||
|
|
@ -107,4 +106,11 @@ sealed interface NetworkStatusDM {
|
|||
Secondary,
|
||||
}
|
||||
}
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class YieldSupplyStatus(
|
||||
@Json(name = "is_active") val isActive: Boolean,
|
||||
@Json(name = "is_initialized") val isInitialized: Boolean,
|
||||
@Json(name = "is_allowed_to_spend") val isAllowedToSpend: Boolean,
|
||||
)
|
||||
}
|
||||
|
|
@ -42,7 +42,10 @@ class NetworkStatusDMSerializationTest {
|
|||
{ "value": "0x123456", "type": "primary" },
|
||||
{ "value": "0xabcdef", "type": "secondary" }
|
||||
],
|
||||
"amounts": { "ETH": "1.2345" }
|
||||
"amounts": { "ETH": "1.2345" },
|
||||
"yield_supply_statuses": {
|
||||
"ETH": { "is_active": false, "is_initialized": false, "is_allowed_to_spend": false }
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
|
||||
|
|
@ -62,6 +65,13 @@ class NetworkStatusDMSerializationTest {
|
|||
NetworkStatusDM.Address("0xabcdef", NetworkStatusDM.Address.Type.Secondary),
|
||||
),
|
||||
amounts = mapOf("ETH" to BigDecimal("1.2345")),
|
||||
yieldSupplyStatuses = mapOf(
|
||||
"ETH" to NetworkStatusDM.YieldSupplyStatus(
|
||||
isActive = false,
|
||||
isInitialized = false,
|
||||
isAllowedToSpend = false,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
Truth.assertThat(result).isEqualTo(expected)
|
||||
|
|
@ -82,6 +92,13 @@ class NetworkStatusDMSerializationTest {
|
|||
NetworkStatusDM.Address("0xabcdef", NetworkStatusDM.Address.Type.Secondary),
|
||||
),
|
||||
amounts = mapOf("ETH" to BigDecimal("1.2345")),
|
||||
yieldSupplyStatuses = mapOf(
|
||||
"ETH" to NetworkStatusDM.YieldSupplyStatus(
|
||||
isActive = false,
|
||||
isInitialized = false,
|
||||
isAllowedToSpend = false,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
// Act
|
||||
|
|
@ -100,7 +117,10 @@ class NetworkStatusDMSerializationTest {
|
|||
{ "value": "0x123456", "type": "primary" },
|
||||
{ "value": "0xabcdef", "type": "secondary" }
|
||||
],
|
||||
"amounts": { "ETH": "1.2345" }
|
||||
"amounts": { "ETH": "1.2345" },
|
||||
"yield_supply_statuses": {
|
||||
"ETH": { "is_active": false, "is_initialized": false, "is_allowed_to_spend": false }
|
||||
}
|
||||
}
|
||||
""".stripJsonWhitespace()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue