Updated on 2026-08-14
This commit is contained in:
parent
9cf90df510
commit
1c5519a702
19 changed files with 327 additions and 83 deletions
|
|
@ -0,0 +1,17 @@
|
|||
package com.tangem.lib.crypto
|
||||
|
||||
import com.tangem.lib.crypto.models.Currency
|
||||
import com.tangem.lib.crypto.models.transactions.SendTxResult
|
||||
import java.math.BigDecimal
|
||||
|
||||
interface TransactionManager {
|
||||
|
||||
suspend fun sendTransaction(
|
||||
networkId: String,
|
||||
amountToSend: BigDecimal,
|
||||
currencyToSend: Currency,
|
||||
feeAmount: BigDecimal,
|
||||
destinationAddress: String,
|
||||
dataToSign: String,
|
||||
): SendTxResult
|
||||
}
|
||||
|
|
@ -4,9 +4,25 @@ 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(
|
||||
sealed class Currency(
|
||||
open val id: String,
|
||||
open val name: String,
|
||||
open val symbol: String,
|
||||
open val networkId: String,
|
||||
)
|
||||
)
|
||||
|
||||
data class NativeToken(
|
||||
override val id: String,
|
||||
override val name: String,
|
||||
override val symbol: String,
|
||||
override val networkId: String,
|
||||
) : Currency(id, name, symbol, networkId)
|
||||
|
||||
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,8 +0,0 @@
|
|||
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)
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
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)
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.tangem.lib.crypto.models.transactions
|
||||
|
||||
sealed interface SendTxResult {
|
||||
|
||||
object Success : SendTxResult
|
||||
object UserCancelledError : SendTxResult
|
||||
data class TangemSdkError(val code: Int, val cause: Throwable?) : SendTxResult
|
||||
data class BlockchainSdkError(val code: Int, val cause: Throwable?) : SendTxResult
|
||||
data class UnknownError(val ex: Exception? = null) : SendTxResult
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue