Updated on 2026-08-14
This commit is contained in:
commit
590a533f33
3 changed files with 26 additions and 9 deletions
|
|
@ -26,10 +26,11 @@ class UserTokensRepository(
|
|||
private val networkService: UserTokensNetworkService,
|
||||
) {
|
||||
suspend fun getUserTokens(card: Card): List<Currency> {
|
||||
if (DemoHelper.isDemoCardId(card.cardId)) {
|
||||
return loadDemoCurrencies()
|
||||
}
|
||||
val userId = card.getUserId()
|
||||
if (DemoHelper.isDemoCardId(card.cardId)) {
|
||||
return loadTokensOffline(card, userId).ifEmpty { loadDemoCurrencies() }
|
||||
}
|
||||
|
||||
if (!NetworkConnectivity.getInstance().isOnlineOrConnecting()) {
|
||||
return loadTokensOffline(card, userId)
|
||||
}
|
||||
|
|
@ -68,9 +69,15 @@ class UserTokensRepository(
|
|||
}
|
||||
|
||||
suspend fun loadBlockchainsToDerive(card: Card): List<BlockchainNetwork> {
|
||||
return storageService.getUserTokens(card.getUserId())?.toBlockchainNetworks() ?: storageService.getUserTokens(
|
||||
card,
|
||||
).toBlockchainNetworks()
|
||||
val userId = card.getUserId()
|
||||
val blockchainNetworks = loadTokensOffline(card, userId).toBlockchainNetworks()
|
||||
|
||||
if (DemoHelper.isDemoCardId(card.cardId)) {
|
||||
return blockchainNetworks
|
||||
.ifEmpty { loadDemoCurrencies().toBlockchainNetworks() }
|
||||
}
|
||||
|
||||
return blockchainNetworks
|
||||
}
|
||||
|
||||
private fun loadDemoCurrencies(): List<Currency> {
|
||||
|
|
|
|||
|
|
@ -137,4 +137,13 @@ fun Blockchain.toCoinId(): String {
|
|||
Blockchain.SaltPay, Blockchain.SaltPayTestnet -> "xdai"
|
||||
Blockchain.Unknown -> "unknown"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Blockchain.isSupportedInApp(): Boolean {
|
||||
return !excludedBlockchains.contains(this)
|
||||
}
|
||||
|
||||
private val excludedBlockchains = listOf(
|
||||
Blockchain.Optimism, // TODO: remove when fee calculation is fixed
|
||||
Blockchain.SaltPay,
|
||||
)
|
||||
|
|
@ -21,8 +21,9 @@ fun Card.supportedBlockchains(): List<Blockchain> {
|
|||
(Blockchain.fromCurve(EllipticCurve.Secp256k1) + Blockchain.fromCurve(EllipticCurve.Ed25519)).distinct()
|
||||
}
|
||||
}
|
||||
val filtered = supportedBlockchains.filter { isTestCard == it.isTestnet() }
|
||||
return filtered
|
||||
return supportedBlockchains
|
||||
.filter { isTestCard == it.isTestnet() }
|
||||
.filter { it.isSupportedInApp() }
|
||||
}
|
||||
|
||||
fun Card.supportedTokens(): List<Blockchain> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue