Updated on 2026-08-14
This commit is contained in:
parent
9a8ff1830d
commit
a0798cfef2
252 changed files with 247 additions and 5857 deletions
|
|
@ -1,35 +0,0 @@
|
|||
package com.tangem.datasource.api.oneinch
|
||||
|
||||
import com.squareup.moshi.Moshi
|
||||
import com.tangem.datasource.api.oneinch.errors.OneIncResponseException
|
||||
import com.tangem.datasource.api.oneinch.models.SwapErrorDto
|
||||
import com.tangem.datasource.di.NetworkMoshi
|
||||
import retrofit2.HttpException
|
||||
import retrofit2.Response
|
||||
import javax.inject.Inject
|
||||
|
||||
class OneInchErrorsHandler @Inject constructor(@NetworkMoshi moshi: Moshi) {
|
||||
|
||||
private val errorMoshiAdapter = moshi.adapter(SwapErrorDto::class.java)
|
||||
|
||||
@Throws(OneIncResponseException::class)
|
||||
fun <T> handleOneInchResponse(response: Response<T>): T {
|
||||
return if (response.isSuccessful) {
|
||||
response.body() ?: error("response body is null")
|
||||
} else {
|
||||
when (response.code()) {
|
||||
HTTP_CODE_400 -> {
|
||||
val swapErrorDto = errorMoshiAdapter.fromJson(response.errorBody()?.string() ?: "")
|
||||
throw OneIncResponseException(swapErrorDto ?: throw HttpException(response))
|
||||
}
|
||||
else -> {
|
||||
throw HttpException(response)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val HTTP_CODE_400 = 400
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
package com.tangem.datasource.api.oneinch.models
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
|
||||
/**
|
||||
* Path view dto
|
||||
*/
|
||||
data class PathViewDto(
|
||||
@Json(name = "name") val name: String,
|
||||
@Json(name = "part") val part: Int,
|
||||
@Json(name = "fromTokenAddress") val fromTokenAddress: String,
|
||||
@Json(name = "toTokenAddress") val toTokenAddress: String,
|
||||
)
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
package com.tangem.datasource.api.paymentology.models.request
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
data class CheckRegistrationRequests(
|
||||
@Json(name = "requests") val requests: List<Item>,
|
||||
) {
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class Item(
|
||||
@Json(name = "CID") val cardId: String = "",
|
||||
@Json(name = "publicKey") val publicKey: String = "",
|
||||
)
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
package com.tangem.datasource.api.paymentology.models.request
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.tangem.common.extensions.calculateHashCode
|
||||
|
||||
data class RegisterKYCRequest(
|
||||
@Json(name = "CID") val cardId: String,
|
||||
@Json(name = "publicKey") val publicKey: ByteArray,
|
||||
@Json(name = "kycProvider") val kycProvider: String,
|
||||
@Json(name = "kycRefId") val kycRefId: String,
|
||||
) {
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as RegisterKYCRequest
|
||||
|
||||
if (cardId != other.cardId) return false
|
||||
if (!publicKey.contentEquals(other.publicKey)) return false
|
||||
if (kycProvider != other.kycProvider) return false
|
||||
if (kycRefId != other.kycRefId) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int = calculateHashCode(
|
||||
cardId.hashCode(),
|
||||
publicKey.contentHashCode(),
|
||||
kycProvider.hashCode(),
|
||||
kycRefId.hashCode(),
|
||||
)
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
package com.tangem.datasource.api.paymentology.models.request
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.tangem.common.extensions.calculateHashCode
|
||||
|
||||
data class RegisterWalletRequest(
|
||||
@Json(name = "CID") val cardId: String,
|
||||
@Json(name = "publicKey") val publicKey: ByteArray,
|
||||
@Json(name = "walletPublicKey") val walletPublicKey: ByteArray,
|
||||
@Json(name = "walletSalt") val walletSalt: ByteArray,
|
||||
@Json(name = "walletSignature") val walletSignature: ByteArray,
|
||||
@Json(name = "cardSalt") val cardSalt: ByteArray,
|
||||
@Json(name = "cardSignature") val cardSignature: ByteArray,
|
||||
@Json(name = "PIN") val pin: String,
|
||||
) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as RegisterWalletRequest
|
||||
|
||||
if (cardId != other.cardId) return false
|
||||
if (!publicKey.contentEquals(other.publicKey)) return false
|
||||
if (!walletPublicKey.contentEquals(other.walletPublicKey)) return false
|
||||
if (!walletSalt.contentEquals(other.walletSalt)) return false
|
||||
if (!walletSignature.contentEquals(other.walletSignature)) return false
|
||||
if (!cardSalt.contentEquals(other.cardSalt)) return false
|
||||
if (!cardSignature.contentEquals(other.cardSignature)) return false
|
||||
if (pin != other.pin) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int = calculateHashCode(
|
||||
cardId.hashCode(),
|
||||
publicKey.contentHashCode(),
|
||||
walletPublicKey.contentHashCode(),
|
||||
walletSalt.contentHashCode(),
|
||||
walletSignature.contentHashCode(),
|
||||
cardSalt.contentHashCode(),
|
||||
cardSignature.contentHashCode(),
|
||||
pin.hashCode(),
|
||||
)
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
package com.tangem.datasource.api.paymentology.models.response
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.tangem.common.extensions.calculateHashCode
|
||||
|
||||
data class AttestationResponse(
|
||||
@Json(name = "challenge") val challenge: ByteArray?,
|
||||
@Json(name = "success") override val success: Boolean,
|
||||
@Json(name = "error") override val error: String?,
|
||||
@Json(name = "errorCode") override val errorCode: Int?,
|
||||
) : ResponseError {
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as AttestationResponse
|
||||
|
||||
if (!challenge.contentEquals(other.challenge)) return false
|
||||
if (success != other.success) return false
|
||||
if (error != other.error) return false
|
||||
if (errorCode != other.errorCode) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int = calculateHashCode(
|
||||
challenge.contentHashCode(),
|
||||
success.hashCode(),
|
||||
error.hashCode(),
|
||||
errorCode.hashCode(),
|
||||
)
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
package com.tangem.datasource.api.paymentology.models.response
|
||||
|
||||
enum class KYCStatus {
|
||||
NOT_STARTED,
|
||||
STARTED,
|
||||
WAITING_FOR_APPROVAL,
|
||||
CORRECTION_REQUESTED,
|
||||
REJECTED,
|
||||
APPROVED,
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
package com.tangem.datasource.api.paymentology.models.response
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
|
||||
data class RegisterWalletResponse(
|
||||
@Json(name = "success") override val success: Boolean,
|
||||
@Json(name = "error") override val error: String?,
|
||||
@Json(name = "errorCode") override val errorCode: Int?,
|
||||
) : ResponseError
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
package com.tangem.datasource.api.paymentology.models.response
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
|
||||
data class RegistrationResponse(
|
||||
@Json(name = "results") val results: List<Item> = listOf(),
|
||||
@Json(name = "success") override val success: Boolean,
|
||||
@Json(name = "error") override val error: String?,
|
||||
@Json(name = "errorCode") override val errorCode: Int?,
|
||||
) : ResponseError {
|
||||
|
||||
data class Item(
|
||||
@Json(name = "CID") val cardId: String,
|
||||
@Json(name = "passed") val passed: Boolean?,
|
||||
@Json(name = "active") val active: Boolean?,
|
||||
@Json(name = "pin_set") val pinSet: Boolean?,
|
||||
@Json(name = "blockchain_init") val blockchainInit: Boolean?,
|
||||
@Json(name = "kyc_passed") val kycPassed: Boolean?,
|
||||
@Json(name = "kyc_provider") val kycProvider: String?,
|
||||
@Json(name = "kyc_date") val kycDate: String?,
|
||||
@Json(name = "kyc_status") val kycStatus: KYCStatus?,
|
||||
@Json(name = "disabled_by_admin") val disabledByAdmin: Boolean?,
|
||||
@Json(name = "error") val error: String?,
|
||||
)
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
package com.tangem.datasource.api.paymentology.models.response
|
||||
|
||||
import com.tangem.common.services.Result
|
||||
|
||||
interface ResponseError {
|
||||
val success: Boolean
|
||||
val error: String?
|
||||
val errorCode: Int?
|
||||
|
||||
fun makeErrorMessage(): String = error ?: "unknown error"
|
||||
}
|
||||
|
||||
inline fun <reified T> ResponseError.tryExtractError(): Result<T> = when (success) {
|
||||
true -> Result.Success(this as T)
|
||||
else -> Result.Failure(Throwable(makeErrorMessage()))
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
package com.tangem.datasource.local.datastore.core
|
||||
|
||||
internal abstract class KeylessDataStoreDecorator<Value : Any>(
|
||||
wrappedDataStore: StringKeyDataStore<Value>,
|
||||
private val key: String = DEFAULT_STRING_KEY,
|
||||
) : StringKeyDataStoreDecorator<String, Value>(wrappedDataStore) {
|
||||
|
||||
override fun provideStringKey(key: String) = key
|
||||
|
||||
open fun get() = get(key)
|
||||
|
||||
open suspend fun getSyncOrNull() = getSyncOrNull(key)
|
||||
|
||||
open suspend fun store(item: Value) = store(key, item)
|
||||
|
||||
override suspend fun isEmpty(): Boolean = getSyncOrNull() == null
|
||||
|
||||
private companion object {
|
||||
const val DEFAULT_STRING_KEY = "key"
|
||||
}
|
||||
}
|
||||
|
|
@ -3,10 +3,6 @@
|
|||
"name": "NEW_CARD_SCANNING_ENABLED",
|
||||
"version": "undefined"
|
||||
},
|
||||
{
|
||||
"name": "1INCH_LEARN_2_EARN_ENABLED",
|
||||
"version": "undefined"
|
||||
},
|
||||
{
|
||||
"name": "SHOPIFY_DYNAMIC_ENABLED",
|
||||
"version": "undefined"
|
||||
|
|
|
|||
|
|
@ -2,40 +2,18 @@
|
|||
|
||||
package com.tangem.core.ui.components
|
||||
|
||||
import androidx.annotation.DimenRes
|
||||
import androidx.compose.foundation.layout.ColumnScope
|
||||
import androidx.compose.foundation.layout.RowScope
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.dimensionResource
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@Composable
|
||||
fun VerticalSpacer(@DimenRes spaceResId: Int) {
|
||||
Spacer(modifier = Modifier.height(dimensionResource(id = spaceResId)))
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun HorizontalSpacer(@DimenRes spaceResId: Int) {
|
||||
Spacer(modifier = Modifier.width(dimensionResource(id = spaceResId)))
|
||||
}
|
||||
|
||||
// region Horizontal
|
||||
@Composable
|
||||
fun SpacerH(height: Dp, modifier: Modifier = Modifier) {
|
||||
Spacer(modifier = modifier.height(height))
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SpacerH2(modifier: Modifier = Modifier) {
|
||||
SpacerH(2.dp, modifier)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SpacerH4(modifier: Modifier = Modifier) {
|
||||
SpacerH(4.dp, modifier)
|
||||
|
|
@ -76,11 +54,6 @@ fun SpacerH32(modifier: Modifier = Modifier) {
|
|||
SpacerH(32.dp, modifier)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SpacerH50(modifier: Modifier = Modifier) {
|
||||
SpacerH(50.dp, modifier)
|
||||
}
|
||||
|
||||
// TODO: Refactor with context receivers
|
||||
@Composable
|
||||
fun ColumnScope.SpacerHMax(modifier: Modifier = Modifier) {
|
||||
|
|
@ -146,36 +119,4 @@ fun SpacerW32(modifier: Modifier = Modifier) {
|
|||
fun RowScope.SpacerWMax(modifier: Modifier = Modifier) {
|
||||
Spacer(modifier = modifier.weight(1f))
|
||||
}
|
||||
// endregion Vertical
|
||||
|
||||
// region Size
|
||||
@Composable
|
||||
fun SpacerS(size: Dp, modifier: Modifier = Modifier) {
|
||||
Spacer(modifier = modifier.size(size))
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SpacerS4(modifier: Modifier = Modifier) {
|
||||
SpacerS(4.dp, modifier)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SpacerS8(modifier: Modifier = Modifier) {
|
||||
SpacerS(8.dp, modifier)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SpacerS16(modifier: Modifier = Modifier) {
|
||||
SpacerS(16.dp, modifier)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SpacerS24(modifier: Modifier = Modifier) {
|
||||
SpacerS(24.dp, modifier)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SpacerS32(modifier: Modifier = Modifier) {
|
||||
SpacerS(32.dp, modifier)
|
||||
}
|
||||
// endregion Size
|
||||
// endregion Vertical
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
package com.tangem.core.ui.components.currency.tokenicon.converter
|
||||
|
||||
import com.tangem.common.Converter
|
||||
import com.tangem.core.ui.components.currency.tokenicon.TokenIconState
|
||||
import com.tangem.core.ui.extensions.getTintForTokenIcon
|
||||
import com.tangem.core.ui.extensions.networkIconResId
|
||||
import com.tangem.core.ui.extensions.tryGetBackgroundForTokenIcon
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.utils.converter.Converter
|
||||
|
||||
/**
|
||||
* Converts [CryptoCurrencyStatus] to [TokenIconState]
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
package com.tangem.core.ui.utils
|
||||
|
||||
import android.os.SystemClock
|
||||
import android.view.View
|
||||
|
||||
/**
|
||||
* Implementation of click listener for preventing multiple click events
|
||||
*
|
||||
* @property action action that called when a view has been clicked
|
||||
*/
|
||||
class OneTouchClickListener(private val action: () -> Unit) : View.OnClickListener {
|
||||
|
||||
private var lastClickTimeMs: Long = 0L
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
if (SystemClock.elapsedRealtime() - lastClickTimeMs > CLICK_DELAY_MS) {
|
||||
lastClickTimeMs = SystemClock.elapsedRealtime()
|
||||
action()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val CLICK_DELAY_MS = 500L
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.2 KiB |
|
|
@ -1,27 +0,0 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<group>
|
||||
<clip-path android:pathData="M0,0h24v24h-24z" />
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:pathData="M12,7m-1.25,0a1.25,1.25 0,1 1,2.5 0a1.25,1.25 0,1 1,-2.5 0" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M14.5,9.5C15.881,8.119 15.881,5.881 14.5,4.5M9.5,9.5C8.119,8.119 8.119,5.881 9.5,4.5"
|
||||
android:strokeWidth="2"
|
||||
android:strokeColor="#000000" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M17,12C19.761,9.239 19.761,4.761 17,2M7,12C4.239,9.239 4.239,4.761 7,2"
|
||||
android:strokeWidth="2"
|
||||
android:strokeColor="#000000" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M12.485,12.121L22.577,22.213A1,1 51.198,0 1,22.577 23.627L17.627,28.577A1,1 128.802,0 1,16.213 28.577L6.121,18.485A1,1 0,0 1,6.121 17.071L11.071,12.121A1,1 77.649,0 1,12.485 12.121z"
|
||||
android:strokeWidth="2"
|
||||
android:strokeColor="#000000" />
|
||||
</group>
|
||||
</vector>
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M6,19C6,19.53 6.211,20.039 6.586,20.414C6.961,20.789 7.47,21 8,21H16C16.53,21 17.039,20.789 17.414,20.414C17.789,20.039 18,19.53 18,19V7H6V19ZM8,9H16V19H8V9ZM15.5,4L14.5,3H9.5L8.5,4H5V6H19V4H15.5Z"
|
||||
android:fillColor="#000000"/>
|
||||
</vector>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 26 KiB |
File diff suppressed because one or more lines are too long
|
|
@ -1,13 +1,6 @@
|
|||
package com.tangem.utils.coroutines
|
||||
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.coroutines.*
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
|
||||
|
|
@ -17,12 +10,6 @@ suspend fun <R> runCatching(dispatcher: CoroutineDispatcher, block: suspend () -
|
|||
}
|
||||
}
|
||||
|
||||
suspend inline fun ifActive(crossinline block: suspend () -> Unit) = coroutineScope {
|
||||
if (isActive) {
|
||||
block()
|
||||
}
|
||||
}
|
||||
|
||||
class Debouncer {
|
||||
|
||||
private var debounceJob: Job? = null
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
package com.tangem.utils.extensions
|
||||
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
fun <T> T.toWeakReference(): WeakReference<T> {
|
||||
return WeakReference(this)
|
||||
}
|
||||
|
|
@ -3,6 +3,4 @@ package com.tangem.utils.extensions
|
|||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
fun Int.isEven(): Boolean = this % 2 == 0
|
||||
|
||||
fun Int.isOdd(): Boolean = !this.isEven()
|
||||
fun Int.isEven(): Boolean = this % 2 == 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue