Updated on 2026-08-14
This commit is contained in:
parent
aefdfb1705
commit
b6a38918fc
2 changed files with 14 additions and 5 deletions
|
|
@ -1,11 +1,11 @@
|
|||
package com.tangem.domain.common.form
|
||||
|
||||
import com.tangem.blockchain.blockchains.binance.BinanceAddressService
|
||||
import com.tangem.blockchain.blockchains.ethereum.EthereumAddressService
|
||||
import com.tangem.blockchain.blockchains.solana.SolanaAddressService
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchain.common.address.AddressService
|
||||
import com.tangem.common.Validator
|
||||
import com.tangem.common.card.EllipticCurve
|
||||
import com.tangem.domain.AddCustomTokenError
|
||||
import timber.log.Timber
|
||||
|
||||
|
|
@ -48,10 +48,9 @@ class TokenContractAddressValidator : CustomTokenValidator<String>() {
|
|||
|
||||
private fun getAddressService(): AddressService {
|
||||
return when (blockchain) {
|
||||
Blockchain.Unknown -> EthereumAddressService()
|
||||
Blockchain.Unknown -> successAddressValidator
|
||||
Blockchain.Binance, Blockchain.BinanceTestnet -> successAddressValidator
|
||||
Blockchain.Solana, Blockchain.SolanaTestnet -> SolanaAddressService()
|
||||
Blockchain.Binance -> BinanceAddressService()
|
||||
Blockchain.BinanceTestnet -> BinanceAddressService(true)
|
||||
else -> {
|
||||
if (blockchain.isEvm()) {
|
||||
EthereumAddressService()
|
||||
|
|
@ -62,6 +61,14 @@ class TokenContractAddressValidator : CustomTokenValidator<String>() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val successAddressValidator = object : AddressService() {
|
||||
override fun makeAddress(walletPublicKey: ByteArray, curve: EllipticCurve?): String {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun validate(address: String): Boolean = true
|
||||
}
|
||||
}
|
||||
|
||||
class TokenNetworkValidator : CustomTokenValidator<Blockchain>() {
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ internal class AddCustomTokenHub : BaseStoreHub<AddCustomTokenState>("AddCustomT
|
|||
val contractAddress = ContractAddress.getFieldValue<String>()
|
||||
validateContractAddressAndNotify(contractAddress)
|
||||
|
||||
if (!hubState.tokensAnyFieldsIsFilled()){
|
||||
if (!hubState.tokensAnyFieldsIsFilled()) {
|
||||
val isAlreadyAdded = isBlockchainPersistIntoAppSavedTokensList(
|
||||
selectedNetwork = action.blockchainNetwork.value
|
||||
)
|
||||
|
|
@ -120,6 +120,8 @@ internal class AddCustomTokenHub : BaseStoreHub<AddCustomTokenState>("AddCustomT
|
|||
}
|
||||
|
||||
private suspend fun validateContractAddressAndNotify(contractAddress: String): AddCustomTokenError? {
|
||||
if (!Network.isFilled()) return null
|
||||
|
||||
val error = ContractAddress.validateValue(contractAddress)
|
||||
when (error) {
|
||||
null -> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue