Updated on 2026-08-14

This commit is contained in:
Tangem 2022-10-21 13:11:56 +04:00
parent 5e42e64172
commit 55eb45a3a2
3 changed files with 7 additions and 5 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,
)
}