Updated on 2026-08-14
This commit is contained in:
parent
d992cc5c98
commit
a2425acf09
2 changed files with 9 additions and 4 deletions
|
|
@ -370,6 +370,8 @@ internal class AddCustomTokenViewModel @Inject constructor(
|
|||
viewModelScope.launch(dispatchers.main) {
|
||||
runCatching(dispatchers.io) {
|
||||
val tokenAddress = convertTokenAddress(selectedNetwork, address)
|
||||
?: error("TokenAddress is invalid")
|
||||
|
||||
featureInteractor.findToken(address = tokenAddress, blockchain = selectedNetwork)
|
||||
}
|
||||
.onSuccess { token ->
|
||||
|
|
@ -602,7 +604,8 @@ internal class AddCustomTokenViewModel @Inject constructor(
|
|||
val contractAddress = convertTokenAddress(
|
||||
blockchain = networkSelectorValue,
|
||||
address = uiState.form.contractAddressInputField.value,
|
||||
)
|
||||
) ?: return false // invalid address can't be "already added"
|
||||
|
||||
return currentCryptoCurrencies
|
||||
.filterIsInstance<CryptoCurrency.Token>()
|
||||
.any { token ->
|
||||
|
|
@ -859,7 +862,8 @@ internal class AddCustomTokenViewModel @Inject constructor(
|
|||
val contractAddress = convertTokenAddress(
|
||||
blockchain = blockchain,
|
||||
address = foundToken?.network?.contractAddress ?: uiState.form.contractAddressInputField.value,
|
||||
)
|
||||
) ?: error("Contract address is invalid") // impossible to add a token with invalid address
|
||||
|
||||
CustomCurrency.CustomToken(
|
||||
token = Token(
|
||||
name = uiState.form.tokenNameInputField.value,
|
||||
|
|
@ -897,7 +901,8 @@ internal class AddCustomTokenViewModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun convertTokenAddress(blockchain: Blockchain, address: String): String {
|
||||
/** Convert [address] to single address for specific [blockchain] or return null if invalid */
|
||||
private fun convertTokenAddress(blockchain: Blockchain, address: String): String? {
|
||||
return when (blockchain) {
|
||||
Blockchain.Hedera, Blockchain.HederaTestnet -> hederaAddressConverter.convertToTokenId(address)
|
||||
Blockchain.Cardano -> {
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ markdown = "0.7.2"
|
|||
# endregion Other libraries
|
||||
|
||||
# region Tangem
|
||||
tangemBlockchainSdk = "release-app_5.12-694"
|
||||
tangemBlockchainSdk = "release-app_5.12-697"
|
||||
#tangemBlockchainSdk = "0.0.1" # Keep it! - used for local builds
|
||||
tangemCardSdk = "release-app_5.12-369"
|
||||
#tangemCardSdk = "0.0.1" # Keep it! - used for local builds ^
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue