Updated on 2026-08-14
This commit is contained in:
parent
41648e4ffc
commit
3dc6ff9548
12 changed files with 400 additions and 1 deletions
|
|
@ -0,0 +1,64 @@
|
|||
package com.tangem.domain.express.models
|
||||
|
||||
import java.math.BigDecimal
|
||||
|
||||
sealed class ExpressError {
|
||||
|
||||
abstract val code: Int
|
||||
|
||||
data class DataError(
|
||||
override val code: Int,
|
||||
val description: String?,
|
||||
) : ExpressError()
|
||||
|
||||
data class BadRequest(override val code: Int) : ExpressError()
|
||||
|
||||
data class Forbidden(override val code: Int) : ExpressError()
|
||||
|
||||
data class InternalError(override val code: Int) : ExpressError()
|
||||
|
||||
data class ProviderNotFoundError(override val code: Int) : ExpressError()
|
||||
|
||||
data class ProviderNotActiveError(override val code: Int) : ExpressError()
|
||||
|
||||
data class ProviderNotAvailableError(override val code: Int) : ExpressError()
|
||||
|
||||
data class ProviderInternalError(override val code: Int) : ExpressError()
|
||||
|
||||
data class ExchangeNotPossibleError(override val code: Int) : ExpressError()
|
||||
|
||||
data class NotEnoughBalanceError(override val code: Int) : ExpressError()
|
||||
|
||||
data class InvalidAddressError(override val code: Int) : ExpressError()
|
||||
|
||||
sealed class AmountError : ExpressError() {
|
||||
abstract val amount: BigDecimal
|
||||
|
||||
data class TooSmallError(override val code: Int, override val amount: BigDecimal) : AmountError()
|
||||
data class TooBigError(override val code: Int, override val amount: BigDecimal) : AmountError()
|
||||
data class NotEnoughAllowanceError(override val code: Int, override val amount: BigDecimal) : AmountError()
|
||||
}
|
||||
|
||||
data class ProviderDifferentAmountError(
|
||||
override val code: Int,
|
||||
val fromAmount: BigDecimal,
|
||||
val fromProviderAmount: BigDecimal,
|
||||
val decimals: Int,
|
||||
) : ExpressError()
|
||||
|
||||
data class InvalidFromDecimalsError(
|
||||
override val code: Int,
|
||||
val receivedFromDecimals: Int,
|
||||
val expressFromDecimals: Int,
|
||||
) : ExpressError()
|
||||
|
||||
data class InvalidSignatureError(override val code: Int = 990) : ExpressError()
|
||||
|
||||
data class InvalidRequestIdError(override val code: Int = 991) : ExpressError()
|
||||
|
||||
data class InvalidPayoutAddressError(override val code: Int = 992) : ExpressError()
|
||||
|
||||
data object UnknownError : ExpressError() {
|
||||
override val code: Int = -1
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.tangem.domain.express.models
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
import java.math.BigDecimal
|
||||
|
||||
/**
|
||||
* Express provider data model
|
||||
*
|
||||
* @property providerId provider id
|
||||
* @property rateTypes supported rate types
|
||||
* @property name provider name
|
||||
* @property type provider type
|
||||
* @property imageLarge provider large logo image
|
||||
* @property termsOfUse terms of use link
|
||||
* @property privacyPolicy privacy policy link
|
||||
* @property isRecommended flag that indicates if this provider is recommended
|
||||
* @property slippage provider slippage
|
||||
*
|
||||
* Uses to store transaction data in datastore, when extends - should always add default value
|
||||
* to support backward compatibility
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class ExpressProvider(
|
||||
@Json(name = "providerId")
|
||||
val providerId: String,
|
||||
@Json(name = "rateTypes")
|
||||
val rateTypes: List<ExpressRateType> = emptyList(),
|
||||
@Json(name = "name")
|
||||
val name: String,
|
||||
@Json(name = "type")
|
||||
val type: ExpressProviderType,
|
||||
@Json(name = "imageLarge")
|
||||
val imageLarge: String,
|
||||
@Json(name = "termsOfUse")
|
||||
val termsOfUse: String?,
|
||||
@Json(name = "privacyPolicy")
|
||||
val privacyPolicy: String?,
|
||||
@Json(name = "isRecommended")
|
||||
val isRecommended: Boolean = false,
|
||||
@Json(name = "slippage")
|
||||
val slippage: BigDecimal?,
|
||||
)
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.tangem.domain.express.models
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
/**
|
||||
* Express provider type
|
||||
*
|
||||
* @property typeName provider type name
|
||||
*/
|
||||
@JsonClass(generateAdapter = false)
|
||||
enum class ExpressProviderType(val typeName: String) {
|
||||
@Json(name = "DEX")
|
||||
DEX(typeName = "DEX"),
|
||||
|
||||
@Json(name = "CEX")
|
||||
CEX(typeName = "CEX"),
|
||||
|
||||
@Json(name = "DEX_BRIDGE")
|
||||
DEX_BRIDGE(typeName = "DEX/Bridge"),
|
||||
|
||||
@Json(name = "onramp")
|
||||
ONRAMP(typeName = "ONRAMP"),
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.tangem.domain.express.models
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
/**
|
||||
* Rate type.
|
||||
*
|
||||
* Current implementation contains only float type, fixed will be supported later.
|
||||
*/
|
||||
@JsonClass(generateAdapter = false)
|
||||
enum class ExpressRateType {
|
||||
@Json(name = "FLOAT")
|
||||
Float,
|
||||
|
||||
@Json(name = "FIXED")
|
||||
Fixed,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue