Updated on 2026-08-14

This commit is contained in:
Tangem 2023-05-02 08:00:37 +08:00
parent de449519a3
commit 64ac275eb3
14 changed files with 518 additions and 66 deletions

View file

@ -35,12 +35,40 @@ sealed class ManageTokens(
params: Map<String, String> = mapOf(),
) : ManageTokens(event, params) {
class ScreenOpened : ManageTokens("Custom Token Screen Opened")
object ScreenOpened : ManageTokens(event = "Custom Token Screen Opened")
class TokenWasAdded(customCurrency: CustomCurrency) : ManageTokens(
// TODO("Get rid of strong binding (CustomCurrency)
open class TokenWasAdded(customCurrency: CustomCurrency) : ManageTokens(
event = "Custom Token Was Added",
params = convertToParam(customCurrency),
) {
data class Token(
val symbol: String,
val derivationPath: String?,
val blockchain: com.tangem.blockchain.common.Blockchain,
val contractAddress: String,
) : ManageTokens(
event = "Custom Token Was Added",
params = mapOf(
"Token" to symbol,
"Derivation Path" to derivationPath,
"Network Id" to blockchain.currency,
"Contract Address" to contractAddress,
).filterNotNull(),
)
data class Blockchain(
val derivationPath: String?,
val blockchain: com.tangem.blockchain.common.Blockchain,
) : ManageTokens(
event = "Custom Token Was Added",
params = mapOf(
"Token" to blockchain.currency,
"Derivation Path" to derivationPath,
).filterNotNull(),
)
companion object {
private fun convertToParam(customCurrency: CustomCurrency): Map<String, String> = with(customCurrency) {
return when (this) {
@ -48,6 +76,7 @@ sealed class ManageTokens(
"Token" to network.currency,
"Derivation Path" to derivationPath?.rawPath,
).filterNotNull()
is CustomCurrency.CustomToken -> mapOf(
"Token" to token.symbol,
"Derivation Path" to derivationPath?.rawPath,