Updated on 2026-08-14
This commit is contained in:
parent
0d83ca1ea9
commit
b1e7add18e
4 changed files with 37 additions and 3 deletions
|
|
@ -0,0 +1,12 @@
|
|||
package com.tangem.domain.common.extensions
|
||||
|
||||
import com.tangem.common.card.FirmwareVersion
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
val FirmwareVersion.Companion.SolanaAvailable
|
||||
get() = FirmwareVersion(4, 12)
|
||||
|
||||
val FirmwareVersion.Companion.SolanaTokensAvailable
|
||||
get() = FirmwareVersion(4, 52)
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
package com.tangem.domain.features.addCustomToken
|
||||
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.common.services.Result
|
||||
import com.tangem.domain.common.extensions.toNetworkId
|
||||
import com.tangem.network.api.tangemTech.CoinsResponse
|
||||
import com.tangem.network.api.tangemTech.TangemTechService
|
||||
|
||||
|
|
@ -24,6 +26,8 @@ class AddCustomTokenService(
|
|||
val networksWithTheSameAddress = coin.networks
|
||||
.filter { it.contractAddress != null || it.decimalCount != null }
|
||||
.filter { it.contractAddress == contractAddress }
|
||||
//TODO: Solana token
|
||||
.filter { it.networkId != Blockchain.Solana.toNetworkId() }
|
||||
if (networksWithTheSameAddress.isNotEmpty()) {
|
||||
val newToken = coin.copy(networks = networksWithTheSameAddress)
|
||||
coinsList.add(newToken)
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ internal class AddCustomTokenHub : BaseStoreHub<AddCustomTokenState>("AddCustomT
|
|||
null -> {
|
||||
// valid contract address
|
||||
ContractAddress.removeError()
|
||||
changeBlockchainNetworkList()
|
||||
findTokenAndUpdateFields(contractAddress)
|
||||
}
|
||||
AddCustomTokenError.InvalidContractAddress -> {
|
||||
|
|
@ -126,6 +127,7 @@ internal class AddCustomTokenHub : BaseStoreHub<AddCustomTokenState>("AddCustomT
|
|||
null -> {
|
||||
// valid contract address
|
||||
ContractAddress.removeError()
|
||||
changeBlockchainNetworkList()
|
||||
findTokenAndUpdateFields(contractAddress)
|
||||
}
|
||||
else -> {
|
||||
|
|
@ -139,6 +141,7 @@ internal class AddCustomTokenHub : BaseStoreHub<AddCustomTokenState>("AddCustomT
|
|||
}
|
||||
}
|
||||
|
||||
//TODO: Solana token
|
||||
/**
|
||||
* This feature is only needed until Solana coins are added.
|
||||
* While they are not there - this function excludes the Solana blockchain if the user has
|
||||
|
|
@ -534,8 +537,10 @@ internal class AddCustomTokenHub : BaseStoreHub<AddCustomTokenState>("AddCustomT
|
|||
DerivationStyle.LEGACY -> derivationPathState.copy(isVisible = true)
|
||||
null, DerivationStyle.NEW -> derivationPathState.copy(isVisible = false)
|
||||
}
|
||||
val form = Form(AddCustomTokenState.createFormFields(CustomTokenType.Blockchain))
|
||||
state.copy(
|
||||
cardDerivationStyle = card.derivationStyle,
|
||||
form = form,
|
||||
tangemTechServiceManager = tangemTechServiceManager,
|
||||
screenState = state.screenState.copy(derivationPath = derivationPathState)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,18 +2,22 @@ package com.tangem.domain.features.addCustomToken.redux
|
|||
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchain.common.DerivationStyle
|
||||
import com.tangem.common.card.FirmwareVersion
|
||||
import com.tangem.domain.AddCustomTokenError
|
||||
import com.tangem.domain.DomainWrapped
|
||||
import com.tangem.domain.common.extensions.SolanaAvailable
|
||||
import com.tangem.domain.common.extensions.SolanaTokensAvailable
|
||||
import com.tangem.domain.common.form.*
|
||||
import com.tangem.domain.features.addCustomToken.*
|
||||
import com.tangem.domain.features.addCustomToken.CustomTokenFieldId.*
|
||||
import com.tangem.domain.redux.domainStore
|
||||
import org.rekotlin.StateType
|
||||
|
||||
data class AddCustomTokenState(
|
||||
val appSavedCurrencies: List<DomainWrapped.Currency>? = null,
|
||||
val onTokenAddCallback: ((CustomCurrency) -> Unit)? = null,
|
||||
val cardDerivationStyle: DerivationStyle? = null,
|
||||
val form: Form = Form(createFormFields(CustomTokenType.Blockchain)),
|
||||
val form: Form = Form(listOf()),
|
||||
val formValidators: Map<CustomTokenFieldId, CustomTokenValidator<out Any>> = createFormValidators(),
|
||||
val formErrors: Map<CustomTokenFieldId, AddCustomTokenError> = emptyMap(),
|
||||
val tokenId: String? = null,
|
||||
|
|
@ -146,7 +150,7 @@ data class AddCustomTokenState(
|
|||
else -> derivationNetwork
|
||||
}.derivationPath(derivationStyle)
|
||||
|
||||
private fun createFormFields(type: CustomTokenType): List<DataField<*>> {
|
||||
internal fun createFormFields(type: CustomTokenType): List<DataField<*>> {
|
||||
return listOf(
|
||||
TokenField(ContractAddress),
|
||||
TokenBlockchainField(Network, getSupportedNetworks(type)),
|
||||
|
|
@ -176,8 +180,17 @@ data class AddCustomTokenState(
|
|||
Blockchain.Avalanche,
|
||||
Blockchain.Fantom,
|
||||
Blockchain.Binance, // not evm
|
||||
Blockchain.Solana, // not evm. Should be unsupported for coins until they are added to the Blockchain SDK
|
||||
Blockchain.Solana, // not evm
|
||||
)
|
||||
//life hack
|
||||
val fwCardVersion = domainStore.state.globalState.scanResponse?.card?.firmwareVersion
|
||||
?: FirmwareVersion(0, 0)
|
||||
|
||||
val solanaUnsupportedByCard = fwCardVersion < FirmwareVersion.SolanaAvailable
|
||||
val solanaTokensUnsupportedByCard = fwCardVersion < FirmwareVersion.SolanaTokensAvailable
|
||||
if (solanaUnsupportedByCard || solanaTokensUnsupportedByCard) networks.remove(Blockchain.Solana)
|
||||
|
||||
//TODO: Solana
|
||||
if (type == CustomTokenType.Token) networks.remove(Blockchain.Solana)
|
||||
|
||||
return networks
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue