Updated on 2026-08-14
This commit is contained in:
parent
587a0c8624
commit
88cf7ec1af
212 changed files with 1223 additions and 1128 deletions
|
|
@ -9,7 +9,7 @@ import com.tangem.domain.core.wallets.UserWalletsListRepository
|
|||
internal class DefaultAuthProvider(
|
||||
private val userWalletsListManager: UserWalletsListManager,
|
||||
private val userWalletsListRepository: UserWalletsListRepository,
|
||||
private val useNewListRepository: Boolean = false,
|
||||
private val shouldUseNewListRepository: Boolean = false,
|
||||
) : AuthProvider {
|
||||
|
||||
override suspend fun getCardPublicKey(): String {
|
||||
|
|
@ -39,7 +39,7 @@ internal class DefaultAuthProvider(
|
|||
}
|
||||
|
||||
private suspend fun getWallets(): List<UserWallet> {
|
||||
return if (useNewListRepository) {
|
||||
return if (shouldUseNewListRepository) {
|
||||
userWalletsListRepository.userWalletsSync()
|
||||
} else {
|
||||
userWalletsListManager.userWalletsSync
|
||||
|
|
@ -47,7 +47,7 @@ internal class DefaultAuthProvider(
|
|||
}
|
||||
|
||||
private suspend fun getSelectedWallet(): UserWallet? {
|
||||
return if (useNewListRepository) {
|
||||
return if (shouldUseNewListRepository) {
|
||||
userWalletsListRepository.selectedUserWalletSync()
|
||||
} else {
|
||||
userWalletsListManager.selectedUserWalletSync
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import java.util.concurrent.atomic.AtomicReference
|
|||
|
||||
internal class DefaultExpressAuthProvider : ExpressAuthProvider {
|
||||
|
||||
private var uuid = AtomicReference(UUID.randomUUID())
|
||||
private val uuid = AtomicReference(UUID.randomUUID())
|
||||
|
||||
override fun getSessionId(): String {
|
||||
return uuid.get().toString()
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ internal class AuthModule {
|
|||
return DefaultAuthProvider(
|
||||
userWalletsListManager = userWalletsListManager,
|
||||
userWalletsListRepository = userWalletsListRepository,
|
||||
useNewListRepository = hotWalletFeatureToggles.isHotWalletEnabled,
|
||||
shouldUseNewListRepository = hotWalletFeatureToggles.isHotWalletEnabled,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ internal class DefaultRampManager(
|
|||
sendUnavailabilityReason: ScenarioUnavailabilityReason?,
|
||||
): Either<ScenarioUnavailabilityReason, Unit> {
|
||||
return either {
|
||||
val sellSupportedByService = catch(
|
||||
val isSellSupportedByService = catch(
|
||||
block = {
|
||||
val serviceCurrency = cryptoCurrencyConverter.convertBack(status.currency)
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ internal class DefaultRampManager(
|
|||
}
|
||||
}
|
||||
|
||||
ensure(condition = sellSupportedByService) {
|
||||
ensure(condition = isSellSupportedByService) {
|
||||
ScenarioUnavailabilityReason.NotSupportedBySellService(status.currency.name)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ data class MoonPayUserStatus(
|
|||
val stateCode: String,
|
||||
)
|
||||
|
||||
@Suppress("BooleanPropertyNaming")
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class MoonPayCurrencies(
|
||||
@Json(name = "type") val type: String,
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import javax.crypto.spec.SecretKeySpec
|
|||
class MoonPayService(
|
||||
private val apiKey: String,
|
||||
private val secretKey: String,
|
||||
private val logEnabled: Boolean,
|
||||
private val isLogEnabled: Boolean,
|
||||
private val userWalletProvider: () -> UserWallet?,
|
||||
) : ExchangeService {
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ class MoonPayService(
|
|||
private val api: MoonPayApi by lazy {
|
||||
createRetrofitInstance(
|
||||
baseUrl = MoonPayApi.MOOONPAY_BASE_URL,
|
||||
logEnabled = logEnabled,
|
||||
logEnabled = isLogEnabled,
|
||||
).create(MoonPayApi::class.java)
|
||||
}
|
||||
|
||||
|
|
@ -104,24 +104,35 @@ class MoonPayService(
|
|||
|
||||
override fun availableForSell(currency: Currency): Boolean {
|
||||
val userWallet = userWalletProvider() ?: return false
|
||||
val checkCardExchange = userWallet !is UserWallet.Cold || !userWallet.scanResponse.card.isStart2Coin
|
||||
val isExchangeSupported = userWallet !is UserWallet.Cold || !userWallet.scanResponse.card.isStart2Coin
|
||||
|
||||
if (!checkCardExchange) return false
|
||||
if (!isExchangeSupported) return false
|
||||
|
||||
if (!isSellAllowed()) return false
|
||||
|
||||
val availableForSell = status?.availableForSell ?: return false
|
||||
|
||||
val supportedCurrency = currency.blockchain.moonPaySupportedCurrency ?: return false
|
||||
return availableForSell.any {
|
||||
return availableForSell.any { availableCurrency ->
|
||||
when (currency) {
|
||||
is Currency.Blockchain -> {
|
||||
it.networkCode.equals(other = supportedCurrency.networkCode, ignoreCase = true) &&
|
||||
it.currencyCode.equals(other = supportedCurrency.currencyCode, ignoreCase = true)
|
||||
availableCurrency.networkCode.equals(
|
||||
other = supportedCurrency.networkCode,
|
||||
ignoreCase = true,
|
||||
) && availableCurrency.currencyCode.equals(
|
||||
other = supportedCurrency.currencyCode,
|
||||
ignoreCase = true,
|
||||
)
|
||||
}
|
||||
is Currency.Token -> {
|
||||
it.networkCode.equals(other = supportedCurrency.networkCode, ignoreCase = true) &&
|
||||
it.contractAddress.equals(other = currency.token.contractAddress, ignoreCase = true)
|
||||
availableCurrency.networkCode.equals(
|
||||
other = supportedCurrency.networkCode,
|
||||
ignoreCase = true,
|
||||
) &&
|
||||
availableCurrency.contractAddress.equals(
|
||||
other = currency.token.contractAddress,
|
||||
ignoreCase = true,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -137,15 +148,18 @@ class MoonPayService(
|
|||
if (blockchain.isTestnet()) return blockchain.getTestnetTopUpUrl()
|
||||
|
||||
val supportedCurrency = blockchain.moonPaySupportedCurrency ?: return null
|
||||
val moonpayCurrency = status?.availableForSell?.firstOrNull {
|
||||
val moonpayCurrency = status?.availableForSell?.firstOrNull { availableCurrency ->
|
||||
when (cryptoCurrency) {
|
||||
is CryptoCurrency.Coin -> {
|
||||
it.networkCode.equals(other = supportedCurrency.networkCode, ignoreCase = true) &&
|
||||
it.currencyCode.equals(other = supportedCurrency.currencyCode, ignoreCase = true)
|
||||
availableCurrency.networkCode.equals(other = supportedCurrency.networkCode, ignoreCase = true) &&
|
||||
availableCurrency.currencyCode.equals(other = supportedCurrency.currencyCode, ignoreCase = true)
|
||||
}
|
||||
is CryptoCurrency.Token -> {
|
||||
it.networkCode.equals(other = supportedCurrency.networkCode, ignoreCase = true) &&
|
||||
it.contractAddress.equals(other = cryptoCurrency.contractAddress, ignoreCase = true)
|
||||
availableCurrency.networkCode.equals(other = supportedCurrency.networkCode, ignoreCase = true) &&
|
||||
availableCurrency.contractAddress.equals(
|
||||
other = cryptoCurrency.contractAddress,
|
||||
ignoreCase = true,
|
||||
)
|
||||
}
|
||||
}
|
||||
} ?: return null
|
||||
|
|
@ -184,7 +198,7 @@ class MoonPayService(
|
|||
}
|
||||
|
||||
private fun isSellAllowed(): Boolean {
|
||||
return status?.responseUserStatus?.isSellAllowed ?: false
|
||||
return status?.responseUserStatus?.isSellAllowed == true
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue