Updated on 2026-08-14
This commit is contained in:
parent
62a032e3d1
commit
ebcf2f40e5
13 changed files with 222 additions and 81 deletions
|
|
@ -1,8 +1,18 @@
|
|||
package com.tangem.lib.crypto
|
||||
|
||||
import com.tangem.lib.crypto.models.Currency
|
||||
|
||||
interface DerivationManager {
|
||||
|
||||
suspend fun deriveMissingBlockchains(networkId: String)
|
||||
/**
|
||||
* Derives missing blockchain and returns flag true if did it successfully
|
||||
*
|
||||
* @param currency to derive (Native token or not)
|
||||
*/
|
||||
suspend fun deriveMissingBlockchains(currency: Currency): Boolean
|
||||
|
||||
/**
|
||||
* Checks that given [networkId] has derivations
|
||||
*/
|
||||
fun hasDerivation(networkId: String): Boolean
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.tangem.lib.crypto
|
||||
|
||||
import com.tangem.lib.crypto.models.Token
|
||||
import com.tangem.lib.crypto.models.Currency
|
||||
|
||||
/**
|
||||
* Provider for user tokens data
|
||||
|
|
@ -10,7 +10,7 @@ interface UserWalletManager {
|
|||
/**
|
||||
* Returns all user tokens (merged from local and backend)
|
||||
*/
|
||||
suspend fun getUserTokens(): List<Token>
|
||||
suspend fun getUserTokens(): List<Currency>
|
||||
|
||||
/**
|
||||
* Returns user walletId
|
||||
|
|
@ -20,21 +20,21 @@ interface UserWalletManager {
|
|||
/**
|
||||
* Checks that token added to user wallet
|
||||
*
|
||||
* @param token to receive referral payments
|
||||
* @param currency to receive referral payments
|
||||
*/
|
||||
suspend fun isTokenAdded(token: Token): Boolean
|
||||
suspend fun isTokenAdded(currency: Currency): Boolean
|
||||
|
||||
/**
|
||||
* Adds token to wallet if its not
|
||||
*
|
||||
* @param token to add to wallet
|
||||
* @param currency to add to wallet
|
||||
*/
|
||||
fun addToken(token: Token)
|
||||
fun addToken(currency: Currency)
|
||||
|
||||
/**
|
||||
* Returns wallet public address for token
|
||||
*
|
||||
* @param token for which find address
|
||||
* @param currency for which find address
|
||||
*/
|
||||
fun getWalletAddress(token: Token): String
|
||||
fun getWalletAddress(currency: Currency): String
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.tangem.lib.crypto.models
|
||||
|
||||
/**
|
||||
* Currency data class that can be native blockchain Token
|
||||
* or custom Token (used in this lib to replace and divide logic Currency from app module)
|
||||
*/
|
||||
abstract class Currency(
|
||||
open val id: String,
|
||||
open val name: String,
|
||||
open val symbol: String,
|
||||
open val networkId: String,
|
||||
)
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.tangem.lib.crypto.models
|
||||
|
||||
data class NativeToken(
|
||||
override val id: String,
|
||||
override val name: String,
|
||||
override val symbol: String,
|
||||
override val networkId: String,
|
||||
) : Currency(id, name, symbol, networkId)
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.tangem.lib.crypto.models
|
||||
|
||||
class NonNativeToken(
|
||||
override val id: String,
|
||||
override val name: String,
|
||||
override val symbol: String,
|
||||
override val networkId: String,
|
||||
val contractAddress: String,
|
||||
val decimalCount: Int,
|
||||
) : Currency(id, name, symbol, networkId)
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
package com.tangem.lib.crypto.models
|
||||
|
||||
data class Token(
|
||||
val id: String,
|
||||
val name: String,
|
||||
val symbol: String,
|
||||
val networkId: String,
|
||||
val contractAddress: String?,
|
||||
val decimalCount: Int?,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue