diff --git a/app/src/test/kotlin/com/tangem/tap/domain/card/CryptoCurrenciesMocks.kt b/app/src/test/kotlin/com/tangem/tap/domain/card/CryptoCurrenciesMocks.kt index 5ecd65378b..01faeadf30 100644 --- a/app/src/test/kotlin/com/tangem/tap/domain/card/CryptoCurrenciesMocks.kt +++ b/app/src/test/kotlin/com/tangem/tap/domain/card/CryptoCurrenciesMocks.kt @@ -68,6 +68,7 @@ internal class CryptoCurrenciesMocks(private val scanResponse: ScanResponse) { isTestnet = false, standardType = Network.StandardType.ERC20, hasFiatFeeRate = true, + canHandleTokens = true, ), name = "NEVER-MIND", symbol = "NEVER-MIND", diff --git a/data/common/src/main/kotlin/com/tangem/data/common/currency/NetworkOperations.kt b/data/common/src/main/kotlin/com/tangem/data/common/currency/NetworkOperations.kt index 6febfc5fb7..4cb4fb8d6e 100644 --- a/data/common/src/main/kotlin/com/tangem/data/common/currency/NetworkOperations.kt +++ b/data/common/src/main/kotlin/com/tangem/data/common/currency/NetworkOperations.kt @@ -23,6 +23,7 @@ fun getNetwork(networkId: Network.ID, derivationPath: Network.DerivationPath): N currencySymbol = blockchain.currency, standardType = getNetworkStandardType(blockchain), hasFiatFeeRate = blockchain.feePaidCurrency() !is FeePaidCurrency.FeeResource, + canHandleTokens = blockchain.canHandleTokens(), ) } @@ -45,6 +46,7 @@ fun getNetwork( currencySymbol = blockchain.currency, standardType = getNetworkStandardType(blockchain), hasFiatFeeRate = blockchain.feePaidCurrency() !is FeePaidCurrency.FeeResource, + canHandleTokens = blockchain.canHandleTokens(), ) } diff --git a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/Network.kt b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/Network.kt index 59d8d3a517..3543b7094b 100644 --- a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/Network.kt +++ b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/Network.kt @@ -29,6 +29,7 @@ data class Network( val isTestnet: Boolean, val standardType: StandardType, val hasFiatFeeRate: Boolean, + val canHandleTokens: Boolean, ) { init { diff --git a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockNetworks.kt b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockNetworks.kt index 091154dda9..cd410b3487 100644 --- a/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockNetworks.kt +++ b/domain/tokens/src/test/kotlin/com/tangem/domain/tokens/mock/MockNetworks.kt @@ -22,6 +22,7 @@ internal object MockNetworks { currencySymbol = "ETH", derivationPath = Network.DerivationPath.None, hasFiatFeeRate = true, + canHandleTokens = true, ) val network2 = Network( @@ -33,6 +34,7 @@ internal object MockNetworks { currencySymbol = "ETH", derivationPath = Network.DerivationPath.None, hasFiatFeeRate = true, + canHandleTokens = true, ) val network3 = Network( @@ -44,6 +46,7 @@ internal object MockNetworks { currencySymbol = "ETH", derivationPath = Network.DerivationPath.None, hasFiatFeeRate = true, + canHandleTokens = true, ) val networkStatus1 = NetworkStatus( diff --git a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/component/impl/DefaultAddCustomTokenComponent.kt b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/component/impl/DefaultAddCustomTokenComponent.kt index dd0faa0556..48e7a1b01f 100644 --- a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/component/impl/DefaultAddCustomTokenComponent.kt +++ b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/component/impl/DefaultAddCustomTokenComponent.kt @@ -124,8 +124,9 @@ internal class DefaultAddCustomTokenComponent @AssistedInject constructor( userWalletId = config.userWalletId, network = config.selectedNetwork ?: error("Network is not selected"), derivationPath = config.selectedDerivationPath ?: SelectedDerivationPath( + id = config.selectedNetwork.id, value = config.selectedNetwork.derivationPath, - name = resourceReference(R.string.custom_token_derivation_path_default), + networkName = resourceReference(R.string.custom_token_derivation_path_default), ), formValues = config.formValues, onSelectNetworkClick = ::showNetworkSelector, diff --git a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/component/impl/DefaultCustomTokenFormComponent.kt b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/component/impl/DefaultCustomTokenFormComponent.kt index 982e4979e1..2ca0b7e1a1 100644 --- a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/component/impl/DefaultCustomTokenFormComponent.kt +++ b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/component/impl/DefaultCustomTokenFormComponent.kt @@ -49,7 +49,7 @@ internal class DefaultCustomTokenFormComponent @AssistedInject constructor( tokenForm = getInitialTokenForm(), derivationPath = ClickableFieldUM( label = resourceReference(R.string.custom_token_derivation_path), - value = params.derivationPath.name, + value = params.derivationPath.networkName, onClick = ::selectDerivationPath, ), saveToken = { diff --git a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/component/preview/PreviewCustomTokenSelectorComponent.kt b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/component/preview/PreviewCustomTokenSelectorComponent.kt index 1e773cc319..7d596d3f8d 100644 --- a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/component/preview/PreviewCustomTokenSelectorComponent.kt +++ b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/component/preview/PreviewCustomTokenSelectorComponent.kt @@ -29,13 +29,15 @@ internal class PreviewCustomTokenSelectorComponent( when (params) { is Params.DerivationPathSelector -> { val d = SelectedDerivationPath( - value = "m/44'/0'/0'/0/$index", - name = stringReference(value = "Network $index"), + id = Network.ID(index.toString()), + value = Network.DerivationPath.Card("m/44'/0'/0'/0/$index"), + networkName = stringReference(value = "Network $index"), ) DerivationPathUM( - value = "m/44'/0'/0'/0/$index", - blockchainName = d.name, + id = d.id.value, + value = d.value.value.orEmpty(), + networkName = d.networkName, isSelected = d.value == params.selectedDerivationPath?.value, onSelectedStateChange = { params.onDerivationPathSelected(d) }, ) @@ -44,7 +46,8 @@ internal class PreviewCustomTokenSelectorComponent( val n = SelectedNetwork( id = Network.ID(index.toString()), name = stringReference(value = "Network $index"), - derivationPath = "m/44'/0'/0'/0/$index", + derivationPath = Network.DerivationPath.Card("m/44'/0'/0'/0/$index"), + canHandleTokens = false, ) CurrencyNetworkUM( diff --git a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/entity/customtoken/AddCustomTokenConfig.kt b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/entity/customtoken/AddCustomTokenConfig.kt index 417cd15585..6a43cdc40d 100644 --- a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/entity/customtoken/AddCustomTokenConfig.kt +++ b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/entity/customtoken/AddCustomTokenConfig.kt @@ -28,11 +28,13 @@ internal data class AddCustomTokenConfig( internal data class SelectedNetwork( val id: Network.ID, val name: TextReference, - val derivationPath: String, + val derivationPath: Network.DerivationPath, + val canHandleTokens: Boolean, ) @Serializable internal data class SelectedDerivationPath( - val value: String, - val name: TextReference, + val id: Network.ID, + val value: Network.DerivationPath, + val networkName: TextReference, ) \ No newline at end of file diff --git a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/entity/item/DerivationPathUM.kt b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/entity/item/DerivationPathUM.kt index 2190c50e4f..bf6387ff0d 100644 --- a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/entity/item/DerivationPathUM.kt +++ b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/entity/item/DerivationPathUM.kt @@ -3,11 +3,9 @@ package com.tangem.features.managetokens.entity.item import com.tangem.core.ui.extensions.TextReference internal data class DerivationPathUM( + override val id: String, val value: String, - val blockchainName: TextReference, + val networkName: TextReference, override val isSelected: Boolean, override val onSelectedStateChange: (Boolean) -> Unit, -) : SelectableItemUM { - - override val id: String = value -} \ No newline at end of file +) : SelectableItemUM \ No newline at end of file diff --git a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/ui/AddCustomTokenBottomSheet.kt b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/ui/AddCustomTokenBottomSheet.kt index b1b3cc0f0a..69ea2418d6 100644 --- a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/ui/AddCustomTokenBottomSheet.kt +++ b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/ui/AddCustomTokenBottomSheet.kt @@ -103,7 +103,8 @@ private class AddCustomTokenComponentPreviewProvider : PreviewParameterProvider< selectedNetwork = SelectedNetwork( id = Network.ID(value = "1"), name = stringReference("Ethereum"), - derivationPath = "m/44'/0'/0'/0/0", + derivationPath = Network.DerivationPath.None, + canHandleTokens = false, ), ), ), @@ -115,7 +116,8 @@ private class AddCustomTokenComponentPreviewProvider : PreviewParameterProvider< selectedNetwork = SelectedNetwork( id = Network.ID(value = "0"), name = stringReference("Ethereum"), - derivationPath = "m/44'/0'/0'/0/0", + derivationPath = Network.DerivationPath.None, + canHandleTokens = false, ), ), ), @@ -125,8 +127,9 @@ private class AddCustomTokenComponentPreviewProvider : PreviewParameterProvider< step = AddCustomTokenConfig.Step.DERIVATION_PATH_SELECTOR, popBack = {}, selectedDerivationPath = SelectedDerivationPath( - value = "m/44'/0'/0'/0/0", - name = stringReference("Ethereum"), + id = Network.ID(value = "0"), + value = Network.DerivationPath.None, + networkName = stringReference("Ethereum"), ), ), ), diff --git a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/ui/CustomTokenSelectorContent.kt b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/ui/CustomTokenSelectorContent.kt index f5545db44b..67c77ff303 100644 --- a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/ui/CustomTokenSelectorContent.kt +++ b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/ui/CustomTokenSelectorContent.kt @@ -24,6 +24,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameterProvider import com.tangem.core.ui.components.currency.icon.CurrencyIconState import com.tangem.core.ui.components.rows.ChainRow import com.tangem.core.ui.components.rows.model.ChainRowUM +import com.tangem.core.ui.extensions.resolveReference import com.tangem.core.ui.extensions.stringReference import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.res.TangemThemePreview @@ -154,7 +155,7 @@ private fun NetworkItem(model: CurrencyNetworkUM, modifier: Modifier = Modifier) icon = CurrencyIconState.CoinIcon( url = null, fallbackResId = model.iconResId, - isGrayscale = !model.isSelected, + isGrayscale = false, showCustomBadge = false, ), showCustom = false, @@ -205,7 +206,7 @@ private fun DerivationPathItem(model: DerivationPathUM, modifier: Modifier = Mod contentAlignment = Alignment.CenterStart, ) { Text( - text = "${model.value} ${if (model.isSelected) "- selected" else ""}", + text = "${model.networkName.resolveReference()}: ${model.value} ${if (model.isSelected) "<" else ""}", color = TangemTheme.colors.text.primary1, ) } @@ -235,7 +236,8 @@ private class CustomTokenNetworkSelectorComponentPreviewProvider : selectedNetwork = SelectedNetwork( id = Network.ID(value = "0"), name = stringReference(""), - derivationPath = "m/44'/0'/0'/0/0", + derivationPath = Network.DerivationPath.Card("m/44'/0'/0'/0/0"), + canHandleTokens = false, ), onNetworkSelected = {}, ), @@ -244,8 +246,9 @@ private class CustomTokenNetworkSelectorComponentPreviewProvider : params = CustomTokenSelectorComponent.Params.DerivationPathSelector( userWalletId = UserWalletId(stringValue = "321"), selectedDerivationPath = SelectedDerivationPath( - value = "m/44'/0'/0'/0/0", - name = stringReference(""), + id = Network.ID(value = "0"), + value = Network.DerivationPath.Card("m/44'/0'/0'/0/0"), + networkName = stringReference(""), ), onDerivationPathSelected = {}, ),