Updated on 2026-08-14
This commit is contained in:
commit
e1ea317688
18 changed files with 170 additions and 112 deletions
|
|
@ -5,7 +5,7 @@ import com.tangem.blockchain.common.Blockchain
|
|||
fun Blockchain.Companion.fromNetworkId(networkId: String): Blockchain? {
|
||||
return when (networkId) {
|
||||
"arbitrum-one" -> Blockchain.Arbitrum
|
||||
"arbitrum-one/test" -> Blockchain.ArbitrumTestnet
|
||||
"arbitrum/test" -> Blockchain.ArbitrumTestnet
|
||||
"avalanche", "avalanche-2" -> Blockchain.Avalanche
|
||||
"avalanche/test", "avalanche-2/test" -> Blockchain.AvalancheTestnet
|
||||
"binancecoin" -> Blockchain.Binance
|
||||
|
|
@ -40,6 +40,7 @@ fun Blockchain.Companion.fromNetworkId(networkId: String): Blockchain? {
|
|||
"xdai" -> Blockchain.Gnosis
|
||||
"polkadot" -> Blockchain.Polkadot
|
||||
"polkadot/test" -> Blockchain.PolkadotTestnet
|
||||
"kusama" -> Blockchain.Kusama
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
|
@ -84,6 +85,7 @@ fun Blockchain.toNetworkId(): String {
|
|||
Blockchain.Gnosis -> "xdai"
|
||||
Blockchain.Polkadot -> "polkadot"
|
||||
Blockchain.PolkadotTestnet -> "polkadot/test"
|
||||
Blockchain.Kusama -> "kusama"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -101,15 +103,16 @@ fun Blockchain.toCoinId(): String {
|
|||
Blockchain.Avalanche, Blockchain.AvalancheTestnet -> "avalanche-2"
|
||||
Blockchain.Solana, Blockchain.SolanaTestnet -> "solana"
|
||||
Blockchain.Fantom, Blockchain.FantomTestnet -> "fantom"
|
||||
Blockchain.Tron, Blockchain.TronTestnet -> "tron"
|
||||
Blockchain.Polkadot, Blockchain.PolkadotTestnet -> "polkadot"
|
||||
Blockchain.Ducatus -> "ducatus"
|
||||
Blockchain.Litecoin -> "litecoin"
|
||||
Blockchain.RSK -> "rootstock"
|
||||
Blockchain.Tezos -> "tezos"
|
||||
Blockchain.XRP -> "ripple"
|
||||
Blockchain.Dogecoin -> "dogecoin"
|
||||
Blockchain.Tron, Blockchain.TronTestnet -> "tron"
|
||||
Blockchain.Gnosis -> "xdai"
|
||||
Blockchain.Polkadot, Blockchain.PolkadotTestnet -> "polkadot"
|
||||
Blockchain.Kusama -> "kusama"
|
||||
Blockchain.Unknown -> "unknown"
|
||||
}
|
||||
}
|
||||
|
|
@ -18,8 +18,7 @@ fun Card.supportedBlockchains(): List<Blockchain> {
|
|||
Blockchain.fromCurve(EllipticCurve.Secp256k1)
|
||||
}
|
||||
else -> {
|
||||
Blockchain.fromCurve(EllipticCurve.Secp256k1) +
|
||||
Blockchain.fromCurve(EllipticCurve.Ed25519)
|
||||
(Blockchain.fromCurve(EllipticCurve.Secp256k1) + Blockchain.fromCurve(EllipticCurve.Ed25519)).distinct()
|
||||
}
|
||||
}
|
||||
val filtered = supportedBlockchains.filter { isTestCard == it.isTestnet() }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package com.tangem.domain.features
|
||||
|
||||
import com.google.common.truth.Truth
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.domain.common.extensions.fromNetworkId
|
||||
import com.tangem.domain.common.extensions.toNetworkId
|
||||
import org.junit.Test
|
||||
|
||||
class BlockchainTests {
|
||||
@Test
|
||||
fun allNetworkIdsAreImplemented() {
|
||||
val unimplementedIds = Blockchain.values()
|
||||
.toMutableList()
|
||||
.apply { remove(Blockchain.Unknown) }
|
||||
.map { it to Blockchain.fromNetworkId(it.toNetworkId()) }
|
||||
.mapNotNull { if(it.second == null) it.first else null }
|
||||
|
||||
Truth.assertThat(unimplementedIds).isEmpty()
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
package com.tangem.domain.features
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
class ExampleUnitTest {
|
||||
@Test
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue