Updated on 2026-08-14

This commit is contained in:
Tangem 2022-10-01 20:16:49 +05:00
parent a642b39aa7
commit d9516b5316
9 changed files with 101 additions and 29 deletions

View file

@ -16,8 +16,15 @@ object TapWorkarounds {
val Card.isStart2Coin: Boolean
get() = isStart2CoinIssuer(issuer.name)
val Card.isSaltPay: Boolean
get() = saltPayCardIds.contains(cardId) || saltPayBatches.contains(batchId)
get() = isSaltPayVisa || isSaltPayTangem
val Card.isSaltPayVisa: Boolean
get() = saltPayVisaBatches.contains(batchId)
val Card.isSaltPayTangem: Boolean
get() = saltPayTangemCardIds.contains(cardId)
val Card.isTestCard: Boolean
get() = batchId == TEST_CARD_BATCH && cardId.startsWith(TEST_CARD_ID_STARTS_WITH)
@ -60,7 +67,7 @@ object TapWorkarounds {
)
private val excludedIssuers = listOf(
"TTM BANK"
"TTM BANK",
)
private val tangemWalletBatches = listOf("AC01")
@ -84,11 +91,9 @@ object TapWorkarounds {
"AC01", "AC02", "CB95",
)
val saltPayCardIds = listOf(
"AE02000000000194",
"AC03000000076195",
"AC79000000000012", // TODO: remove my testing CIDs
"AC79000000000004",// TODO: remove my testing CIDs
val saltPayTangemCardIds = listOf(
"AC01000000000015", // TODO: remove testing CIDs
"AC03000000000088", // TODO: remove testing CIDs
"AC03000000076070",
"AC03000000076088",
"AC03000000076096",
@ -105,17 +110,32 @@ object TapWorkarounds {
"AC03000000076203",
"AC03000000076211",
"AC03000000076229",
// TODO: add cids
// added 01.10.2022
"AC01000000033503",
"AC01000000033594",
"AC01000000033586",
"AC01000000034477",
"AC01000000032760",
"AC01000000033867",
"AC01000000032653",
"AC01000000032752",
"AC01000000034485",
"AC01000000033644",
"AC01000000037454",
"AC01000000037462",
)
val saltPayBatches = listOf("AE02")
private val saltPayVisaBatches = listOf(
"AE02",
"AE03",
)
val saltPayToken: Token
get() = Token(
name = "Wrapped xDAI",
"WxDAI",
"0x4346186e7461cB4DF06bCFCB4cD591423022e417",
18,
symbol = "WxDAI",
contractAddress = "0x4346186e7461cB4DF06bCFCB4cD591423022e417",
decimals = 18,
id = "xdai",
)
}

View file

@ -44,6 +44,7 @@ fun Blockchain.Companion.fromNetworkId(networkId: String): Blockchain? {
"optimistic-ethereum" -> Blockchain.Optimism
"optimistic-ethereum/test" -> Blockchain.OptimismTestnet
"dash" -> Blockchain.Dash
"wxdai" -> Blockchain.SaltPay
else -> null
}
}
@ -92,7 +93,7 @@ fun Blockchain.toNetworkId(): String {
Blockchain.Optimism -> "optimistic-ethereum"
Blockchain.OptimismTestnet -> "optimistic-ethereum/test"
Blockchain.Dash -> "dash"
Blockchain.SaltPay -> "xdai"//TODO
Blockchain.SaltPay -> "wxdai"
else -> "unknown" // TODO
}
}
@ -119,11 +120,10 @@ fun Blockchain.toCoinId(): String {
Blockchain.Tezos -> "tezos"
Blockchain.XRP -> "ripple"
Blockchain.Dogecoin -> "dogecoin"
Blockchain.Gnosis -> "xdai"
Blockchain.Gnosis, Blockchain.SaltPay -> "xdai"
Blockchain.Kusama -> "kusama"
Blockchain.Optimism, Blockchain.OptimismTestnet -> "ethereum"
Blockchain.Dash -> "dash"
Blockchain.SaltPay -> "xdai" //TODO
Blockchain.Unknown -> "unknown"
else -> "unknown" // TODO
}

View file

@ -1,7 +1,11 @@
package com.tangem.domain.common.extensions
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
/**
@ -9,4 +13,20 @@ import kotlinx.coroutines.withContext
*/
suspend fun <T> withMainContext(block: suspend CoroutineScope.() -> T): T = withContext(Dispatchers.Main, block)
suspend fun <T> withIOContext(block: suspend CoroutineScope.() -> T): T = withContext(Dispatchers.IO, block)
suspend fun <T> withIOContext(block: suspend CoroutineScope.() -> T): T = withContext(Dispatchers.IO, block)
fun <T> debounce(
waitMs: Long = 300L,
coroutineScope: CoroutineScope,
runDestinationOn: CoroutineDispatcher = Dispatchers.Unconfined,
destinationFunction: (T) -> Unit,
): (T) -> Unit {
var debounceJob: Job? = null
return { param: T ->
debounceJob?.cancel()
debounceJob = coroutineScope.launch {
delay(waitMs)
withContext(runDestinationOn) { destinationFunction(param) }
}
}
}