Updated on 2026-08-14

This commit is contained in:
Tangem 2022-10-22 18:28:27 +05:00
commit b8e40c6e73
5 changed files with 46 additions and 38 deletions

View file

@ -110,7 +110,9 @@ sealed interface Currency {
)
}
fun fromTokenResponse(tokenResponse: TokenResponse): Currency {
fun fromTokenResponse(tokenResponse: TokenResponse): Currency? {
val blockchain = com.tangem.blockchain.common.Blockchain.fromNetworkId(tokenResponse.networkId)
?: return null
return when {
tokenResponse.contractAddress != null -> Token(
com.tangem.blockchain.common.Token(
@ -120,11 +122,11 @@ sealed interface Currency {
decimals = tokenResponse.decimals,
id = tokenResponse.id,
),
blockchain = com.tangem.blockchain.common.Blockchain.fromNetworkId(tokenResponse.networkId)!!,
blockchain = blockchain,
derivationPath = tokenResponse.derivationPath,
)
else -> Blockchain(
blockchain = com.tangem.blockchain.common.Blockchain.fromNetworkId(tokenResponse.networkId)!!,
blockchain = blockchain,
derivationPath = tokenResponse.derivationPath,
)
}