Skip to content

Commit

Permalink
feat(delegated_self_custody): AND-6683 Create New Asset Category for …
Browse files Browse the repository at this point in the history
…Self-Custody (#4131)
  • Loading branch information
dtverdota-bc committed Nov 22, 2022
1 parent 7f2a7c1 commit c3c888f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
Expand Up @@ -130,6 +130,8 @@ class TransactionFlowInfoBottomSheetCustomiserImpl(
when (state.sourceAccountType) {
AssetCategory.CUSTODIAL -> R.string.swap_enter_amount_max_limit_from_custodial_info
AssetCategory.NON_CUSTODIAL -> R.string.swap_enter_amount_max_limit_from_noncustodial_info
AssetCategory.DELEGATED_NON_CUSTODIAL ->
R.string.swap_enter_amount_max_limit_from_noncustodial_info
},
effectiveLimitAmount,
limitPeriodText,
Expand Down
Expand Up @@ -5,7 +5,8 @@ import java.io.Serializable

enum class AssetCategory {
CUSTODIAL,
NON_CUSTODIAL
NON_CUSTODIAL,
DELEGATED_NON_CUSTODIAL
}

interface AssetInfo : Currency, Serializable {
Expand All @@ -32,8 +33,11 @@ val Currency.isCustodialOnly: Boolean
val AssetInfo.isNonCustodialOnly: Boolean
get() = categories.size == 1 && categories.contains(AssetCategory.NON_CUSTODIAL)

val AssetInfo.isDelegatedNonCustodial: Boolean
get() = categories.contains(AssetCategory.DELEGATED_NON_CUSTODIAL)

val AssetInfo.isNonCustodial: Boolean
get() = categories.contains(AssetCategory.NON_CUSTODIAL)
get() = categories.contains(AssetCategory.NON_CUSTODIAL) || isDelegatedNonCustodial

fun AssetInfo.l1chain(assetCatalogue: AssetCatalogue): AssetInfo? =
l1chainTicker?.let { ticker ->
Expand Down
Expand Up @@ -45,7 +45,7 @@ import info.blockchain.balance.Currency
import info.blockchain.balance.FiatCurrency
import info.blockchain.balance.isCustodial
import info.blockchain.balance.isCustodialOnly
import info.blockchain.balance.isNonCustodial
import info.blockchain.balance.isDelegatedNonCustodial
import io.reactivex.rxjava3.core.Completable
import io.reactivex.rxjava3.core.Single
import io.reactivex.rxjava3.kotlin.Singles
Expand Down Expand Up @@ -98,7 +98,7 @@ internal class DynamicAssetLoader(
when {
currency.isErc20() -> loadErc20Asset(currency)
(currency as? AssetInfo)?.isCustodialOnly == true -> loadCustodialOnlyAsset(currency)
(currency as? AssetInfo)?.isNonCustodial == true -> loadSelfCustodialAsset(currency)
(currency as? AssetInfo)?.isDelegatedNonCustodial == true -> loadSelfCustodialAsset(currency)
currency is FiatCurrency -> FiatAsset(currency)
else -> throw IllegalStateException("Unknown asset type enabled: ${currency.networkTicker}")
}.also {
Expand Down Expand Up @@ -326,7 +326,11 @@ internal class DynamicAssetLoader(
emit(
result.value.mapNotNull {
assetCatalogue.assetInfoFromNetworkTicker(it)?.let { asset ->
loadSelfCustodialAsset(asset)
if (asset.isDelegatedNonCustodial) {
loadSelfCustodialAsset(asset)
} else {
null
}
}
}
)
Expand Down
Expand Up @@ -85,7 +85,7 @@ private fun mapCategories(products: Set<DynamicAssetProducts>): Set<AssetCategor
DynamicAssetProducts.PrivateKey -> AssetCategory.NON_CUSTODIAL
DynamicAssetProducts.CustodialWalletBalance -> AssetCategory.CUSTODIAL
DynamicAssetProducts.InterestBalance -> AssetCategory.CUSTODIAL
DynamicAssetProducts.DynamicSelfCustody -> AssetCategory.NON_CUSTODIAL
DynamicAssetProducts.DynamicSelfCustody -> AssetCategory.DELEGATED_NON_CUSTODIAL
else -> null
}
}.toSet()
Expand Down

0 comments on commit c3c888f

Please sign in to comment.