Skip to content

Commit

Permalink
Show block explorer URL for all chains in Coin page
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelekol committed Jul 6, 2023
1 parent 98d9581 commit 2e0d0e9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,22 @@ import androidx.compose.ui.graphics.Color
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.core.managers.RestoreSettingType
import io.horizontalsystems.bankwallet.core.providers.Translator
import io.horizontalsystems.bankwallet.entities.*
import io.horizontalsystems.bankwallet.entities.AccountType
import io.horizontalsystems.bankwallet.entities.BitcoinCashCoinType
import io.horizontalsystems.bankwallet.entities.CoinSettingType
import io.horizontalsystems.bankwallet.entities.CoinSettings
import io.horizontalsystems.bankwallet.entities.FeePriceScale
import io.horizontalsystems.bankwallet.entities.derivation
import io.horizontalsystems.hdwalletkit.ExtendedKeyCoinType
import io.horizontalsystems.hdwalletkit.HDWallet
import io.horizontalsystems.marketkit.models.*
import io.horizontalsystems.marketkit.models.Blockchain
import io.horizontalsystems.marketkit.models.BlockchainType
import io.horizontalsystems.marketkit.models.Coin
import io.horizontalsystems.marketkit.models.FullCoin
import io.horizontalsystems.marketkit.models.Token
import io.horizontalsystems.marketkit.models.TokenQuery
import io.horizontalsystems.marketkit.models.TokenType
import io.horizontalsystems.marketkit.models.TopPlatform
import io.horizontalsystems.nftkit.models.NftType

val Token.protocolType: String?
Expand Down Expand Up @@ -169,13 +181,7 @@ val Blockchain.description: String
else -> ""
}

fun Blockchain.eip20TokenUrl(address: String): String? {
return when (uid) {
"ethereum" -> "https://etherscan.io/token/$address"
"binance-smart-chain" -> "https://bscscan.com/token/$address"
else -> eip3091url?.let { "$it/token/$address" }
}
}
fun Blockchain.eip20TokenUrl(address: String) = eip3091url?.replace("\$ref", address)

fun Blockchain.bep2TokenUrl(symbol: String) = "https://explorer.binance.org/asset/$symbol"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ class CoinOverviewViewModel(
value = tokenType.reference?.shorten() ?: "",
copyValue = tokenType.reference,
imgUrl = token.blockchainType.imageUrl,
explorerUrl = null,
explorerUrl = tokenType.reference?.let { token.blockchain.eip20TokenUrl(it) },
name = token.blockchain.name,
configuredToken = configuredToken,
canAddToWallet = false,
Expand Down

0 comments on commit 2e0d0e9

Please sign in to comment.