diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 068d233a86..ff205eefcf 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,3 +1,5 @@ +import com.tangem.plugin.configuration.configurations.extension.kaptForObfuscatingVariants + plugins { alias(deps.plugins.android.application) alias(deps.plugins.kotlin.android) @@ -232,6 +234,10 @@ dependencies { implementation(deps.walletConnectWeb3) implementation(deps.prettyLogger) + implementation(deps.moshi.kotlin) + kaptForObfuscatingVariants(deps.moshi.kotlin.codegen) + kaptForObfuscatingVariants(deps.retrofit.response.type.keeper) + /** Testing libraries */ testImplementation(deps.test.coroutine) testImplementation(deps.test.junit) @@ -270,5 +276,4 @@ dependencies { // excludes version 9999.0-empty-to-avoid-conflict-with-guava exclude(group = "com.google.guava", module = "listenablefuture") } - } diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 2f9dc5a47e..e35c88f75c 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,21 +1,181 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle.kts. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile +-optimizationpasses 5 +-dontusemixedcaseclassnames +-flattenpackagehierarchy +-adaptclassstrings +-verbose + +# firebase +-keep public class com.google.firebase.** { *; } +-keep class com.google.android.gms.internal.** { *; } +-keepclasseswithmembers class com.google.firebase.FirebaseException + +# hedera sdk +-keep class com.hedera.hashgraph.sdk.** { *; } +-keep interface com.hedera.hashgraph.sdk.** { *; } +-dontwarn com.esaulpaugh.headlong.** +-dontwarn edu.umd.cs.findbugs.annotations.SuppressFBWarnings +-dontwarn io.grpc.stub.** + +# trustwallet sdk +-keep class wallet.core.jni.** { *; } + +# solana +-keep class org.p2p.solanaj.** { *; } + +# kethereum +-keep class org.kethereum.bip32.model.ExtendedKey** +-keepclassmembers class org.kethereum.bip32.model.ExtendedKey** { *; } + +# some crypto +-dontwarn net.i2p.crypto.** +-dontwarn java.net.http.** +-dontwarn lombok.** + +-dontwarn org.apache.hc.core5.** +-dontwarn org.apache.hc.client5.** +-dontwarn org.apache.log4j.config.** + +-dontwarn javax.xml.stream.** +-dontwarn javax.script.** + +-dontwarn aQute.bnd.annotation.spi.ServiceProvider + +-dontwarn org.threeten.bp.** +-keep class org.threeten.bp.zone.* +-keep class org.threeten.bp.* +-keepclassmembers class org.threeten.bp.** { *; } + +# joda time +# These aren't necessary if including joda-convert +-dontwarn org.joda.convert.FromString +-dontwarn org.joda.convert.ToString + +-keepnames class org.joda.** implements java.io.Serializable +-keepclassmembers class org.joda.** implements java.io.Serializable { + static final long serialVersionUID; + private static final java.io.ObjectStreamField[] serialPersistentFields; + !static !transient ; + private void writeObject(java.io.ObjectOutputStream); + private void readObject(java.io.ObjectInputStream); + java.lang.Object writeReplace(); + java.lang.Object readResolve(); +} +# joda time + +# Enum field names are used by the integrated EnumJsonAdapter. +# values() is synthesized by the Kotlin compiler and is used by EnumJsonAdapter indirectly +# Annotate enums with @JsonClass(generateAdapter = false) to use them with Moshi. +-keepclassmembers @com.squareup.moshi.JsonClass class * extends java.lang.Enum { + ; + **[] values(); +} + +# Keep helper method to avoid R8 optimisation that would keep all Kotlin Metadata when unwanted +-keepclassmembers class com.squareup.moshi.internal.Util { + private static java.lang.String getKotlinMetadataClassName(); +} + +-keep class kotlin.Metadata { *; } +-keepclassmembers class kotlin.Metadata { + public ; +} + +-keepclasseswithmembers class * { + @com.squareup.moshi.* ; +} + +-keep @com.squareup.moshi.JsonQualifier interface * + +-keepclassmembers class * { + @com.squareup.moshi.FromJson ; + @com.squareup.moshi.ToJson ; +} + +# Proguard configuration for Jackson 2.x +-keep class com.fasterxml.** { *; } +-keep class com.fasterxml.jackson.databind.ObjectMapper { + public ; + protected ; +} +-keep class com.fasterxml.jackson.databind.ObjectWriter { + public ** writeValueAsString(**); +} +-keepnames class com.fasterxml.jackson.** { *; } +-dontwarn com.fasterxml.jackson.databind.** +-keep class * implements com.fasterxml.jackson.core.type.TypeReference + +-keep class kotlin.reflect.** +-keep public class kotlin.reflect.jvm.internal.impl.** { public *; } + +# Kotlin serialization looks up the generated serializer classes through a function on companion +# objects. The companions are looked up reflectively so we need to explicitly keep these functions. +-keepclasseswithmembers class **.*$Companion { + kotlinx.serialization.KSerializer serializer(...); +} +# If a companion has the serializer function, keep the companion field on the original type so that +# the reflective lookup succeeds. +-if class **.*$Companion { + kotlinx.serialization.KSerializer serializer(...); +} +-keepclassmembers class <1>.<2> { + <1>.<2>$Companion Companion; +} + +-keepnames class * implements android.os.Parcelable { + public static final ** CREATOR; +} +-keep class * implements android.os.Parcelable { + public static final android.os.Parcelable$Creator *; +} + +-dontwarn okhttp3.** +-dontwarn okio.** + +# Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and +# EnclosingMethod is required to use InnerClasses. +-keepattributes Signature, InnerClasses, EnclosingMethod, *Annotation*, Exceptions + +# Retrofit does reflection on method and parameter annotations. +-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations + +# Keep annotation default values (e.g., retrofit2.http.Field.encoded). +-keepattributes AnnotationDefault + +# Retain service method parameters when optimizing. +-keepclassmembers,allowshrinking,allowobfuscation interface * { + @retrofit2.http.* ; +} + +-keepclasseswithmembers class * { + @retrofit2.http.* ; +} +-keepclassmembernames interface * { + @retrofit.http.* ; +} + +# Ignore annotation used for build tooling. +-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement + +# Ignore JSR 305 annotations for embedding nullability information. +-dontwarn javax.annotation.** + +# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath. +-dontwarn kotlin.Unit + +# Top-level functions that can only be used by Kotlin. +-dontwarn retrofit2.KotlinExtensions +-dontwarn retrofit2.KotlinExtensions.* + +# With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy +# and replaces all potential values with null. Explicitly keeping the interfaces prevents this. +-if interface * { @retrofit2.http.* ; } +-keep,allowobfuscation interface <1> + +# Keep generic signature of Call, Response (R8 full mode strips signatures from non-kept items). +-keep,allowobfuscation,allowshrinking interface retrofit2.Call +-keep,allowobfuscation,allowshrinking class retrofit2.Response + +# With R8 full mode generic signatures are stripped for classes that are not +# kept. Suspend functions are wrapped in continuations where the type argument +# is used. +-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/model/UserWalletInformation.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/model/UserWalletInformation.kt index 850a558941..a50f29dae0 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/model/UserWalletInformation.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/model/UserWalletInformation.kt @@ -1,5 +1,6 @@ package com.tangem.tap.domain.userWalletList.model +import com.squareup.moshi.Json import com.squareup.moshi.JsonClass import com.tangem.domain.models.scan.CardDTO import com.tangem.domain.models.scan.ScanResponse @@ -7,16 +8,24 @@ import com.tangem.domain.wallets.models.UserWalletId @JsonClass(generateAdapter = true) internal data class UserWalletSensitiveInformation( + @Json(name = "wallets") val wallets: List, ) @JsonClass(generateAdapter = true) internal data class UserWalletPublicInformation( + @Json(name = "name") val name: String, + @Json(name = "walletId") val walletId: UserWalletId, + @Json(name = "artworkUrl") val artworkUrl: String, + @Json(name = "cardsInWallet") val cardsInWallet: Set, + @Json(name = "scanResponse") val scanResponse: ScanResponse, + @Json(name = "isMultiCurrency") val isMultiCurrency: Boolean, + @Json(name = "hasBackupError") val hasBackupError: Boolean = false, ) diff --git a/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/WcJrpcMethods.kt b/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/WcJrpcMethods.kt index 58edaee5b1..bc53c634ce 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/WcJrpcMethods.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/WcJrpcMethods.kt @@ -52,6 +52,8 @@ data class WcSignMessage( @Json(name = "type") val type: WCSignType, ) : WcRequestData { + + @JsonClass(generateAdapter = false) enum class WCSignType { MESSAGE, PERSONAL_MESSAGE, TYPED_MESSAGE, SOLANA_MESSAGE, } diff --git a/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/Account.kt b/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/Account.kt index d7222aa91d..80523daf26 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/Account.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/Account.kt @@ -1,3 +1,16 @@ package com.tangem.tap.domain.walletconnect2.domain.models -data class Account(val chainId: String, val walletAddress: String, val derivationPath: String?) +import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass + +@JsonClass(generateAdapter = true) +data class Account( + @Json(name = "chainId") + val chainId: String, + + @Json(name = "walletAddress") + val walletAddress: String, + + @Json(name = "derivationPath") + val derivationPath: String?, +) diff --git a/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/Session.kt b/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/Session.kt index 6cfeac030b..e69775cc68 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/Session.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/Session.kt @@ -1,6 +1,13 @@ package com.tangem.tap.domain.walletconnect2.domain.models +import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass + +@JsonClass(generateAdapter = true) data class Session( + @Json(name = "topic") val topic: String, + + @Json(name = "accounts") val accounts: List, ) diff --git a/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/binance/WcBinanceCancelOrder.kt b/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/binance/WcBinanceCancelOrder.kt index 1dc5cd5333..fd393301e9 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/binance/WcBinanceCancelOrder.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/binance/WcBinanceCancelOrder.kt @@ -2,29 +2,34 @@ package com.tangem.tap.domain.walletconnect2.domain.models.binance import com.squareup.moshi.Json import com.squareup.moshi.JsonClass +import com.tangem.tap.domain.walletconnect2.domain.WcRequestData @Suppress("LongParameterList") @JsonClass(generateAdapter = true) -class WcBinanceCancelOrder( +data class WcBinanceCancelOrder( @Json(name = "account_number") - accountNumber: String, + val accountNumber: String, @Json(name = "chain_id") - chainId: String, + val chainId: String, @Json(name = "data") - data: String?, + val data: String?, @Json(name = "memo") - memo: String?, + val memo: String?, @Json(name = "sequence") - sequence: String, + val sequence: String, @Json(name = "source") - source: String, + val source: String, @Json(name = "msgs") - msgs: List, -) : WcBinanceOrder(accountNumber, chainId, data, memo, sequence, source, msgs) { + val msgs: List, +) : WcRequestData { + @JsonClass(generateAdapter = true) data class Message( + @Json(name = "refid") val refid: String, + @Json(name = "sender") val sender: String, + @Json(name = "symbol") val symbol: String, ) } diff --git a/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/binance/WcBinanceOrder.kt b/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/binance/WcBinanceOrder.kt deleted file mode 100644 index b6cb87d90a..0000000000 --- a/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/binance/WcBinanceOrder.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.tangem.tap.domain.walletconnect2.domain.models.binance - -import com.tangem.tap.domain.walletconnect2.domain.WcRequestData - -@Suppress("LongParameterList") -open class WcBinanceOrder( - val accountNumber: String, - val chainId: String, - val data: String?, - val memo: String?, - val sequence: String, - val source: String, - val msgs: List, -) : WcRequestData - -data class WcBinanceTxConfirmParam( - val ok: Boolean, - val errorMsg: String?, -) : WcRequestData diff --git a/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/binance/WcBinanceTradeOrder.kt b/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/binance/WcBinanceTradeOrder.kt index 84befe7ca3..659e3e94fe 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/binance/WcBinanceTradeOrder.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/binance/WcBinanceTradeOrder.kt @@ -4,21 +4,28 @@ import com.github.salomonbrys.kotson.jsonSerializer import com.google.gson.JsonObject import com.squareup.moshi.Json import com.squareup.moshi.JsonClass +import com.tangem.tap.domain.walletconnect2.domain.WcRequestData @Suppress("LongParameterList") @JsonClass(generateAdapter = true) -class WcBinanceTradeOrder( +data class WcBinanceTradeOrder( @Json(name = "account_number") - accountNumber: String, + val accountNumber: String, @Json(name = "chain_id") - chainId: String, - data: String?, - memo: String?, - sequence: String, - source: String, - msgs: List, -) : WcBinanceOrder(accountNumber, chainId, data, memo, sequence, source, msgs) { + val chainId: String, + @Json(name = "data") + val data: String?, + @Json(name = "memo") + val memo: String?, + @Json(name = "sequence") + val sequence: String, + @Json(name = "source") + val source: String, + @Json(name = "msgs") + val msgs: List, +) : WcRequestData { + @JsonClass(generateAdapter = false) enum class MessageKey(val key: String) { ID("id"), ORDER_TYPE("ordertype"), @@ -30,14 +37,23 @@ class WcBinanceTradeOrder( TIME_INFORCE("timeinforce"), } + @JsonClass(generateAdapter = true) data class Message( + @Json(name = "id") val id: String, + @Json(name = "orderType") val orderType: Int, + @Json(name = "price") val price: Long, + @Json(name = "quantity") val quantity: Long, + @Json(name = "sender") val sender: String, + @Json(name = "side") val side: Int, + @Json(name = "symbol") val symbol: String, + @Json(name = "timeInforce") val timeInforce: Int, ) } diff --git a/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/binance/WcBinanceTransferOrder.kt b/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/binance/WcBinanceTransferOrder.kt index 303ad4527d..f01181cbf6 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/binance/WcBinanceTransferOrder.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/binance/WcBinanceTransferOrder.kt @@ -2,33 +2,48 @@ package com.tangem.tap.domain.walletconnect2.domain.models.binance import com.squareup.moshi.Json import com.squareup.moshi.JsonClass +import com.tangem.tap.domain.walletconnect2.domain.WcRequestData @Suppress("LongParameterList") @JsonClass(generateAdapter = true) -class WcBinanceTransferOrder( +data class WcBinanceTransferOrder( @Json(name = "account_number") - accountNumber: String, + val accountNumber: String, @Json(name = "chain_id") - chainId: String, - data: String?, - memo: String?, - sequence: String, - source: String, - msgs: List, -) : WcBinanceOrder(accountNumber, chainId, data, memo, sequence, source, msgs) { + val chainId: String, + @Json(name = "data") + val data: String?, + @Json(name = "memo") + val memo: String?, + @Json(name = "sequence") + val sequence: String, + @Json(name = "source") + val source: String, + @Json(name = "msgs") + val msgs: List, +) : WcRequestData { + @JsonClass(generateAdapter = true) data class Message( + @Json(name = "inputs") val inputs: List, + @Json(name = "outputs") val outputs: List, ) { + @JsonClass(generateAdapter = true) data class Item( + @Json(name = "address") val address: String, + @Json(name = "coins") val coins: List, ) { + @JsonClass(generateAdapter = true) data class Coin( + @Json(name = "amount") val amount: Long, + @Json(name = "denom") val denom: String, ) } diff --git a/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/binance/WcBinanceTxConfirmParam.kt b/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/binance/WcBinanceTxConfirmParam.kt new file mode 100644 index 0000000000..8b53911071 --- /dev/null +++ b/app/src/main/java/com/tangem/tap/domain/walletconnect2/domain/models/binance/WcBinanceTxConfirmParam.kt @@ -0,0 +1,13 @@ +package com.tangem.tap.domain.walletconnect2.domain.models.binance + +import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass +import com.tangem.tap.domain.walletconnect2.domain.WcRequestData + +@JsonClass(generateAdapter = true) +data class WcBinanceTxConfirmParam( + @Json(name = "ok") + val ok: Boolean, + @Json(name = "errorMsg") + val errorMsg: String?, +) : WcRequestData diff --git a/app/src/main/java/com/tangem/tap/network/exchangeServices/mercuryo/MercuryoApi.kt b/app/src/main/java/com/tangem/tap/network/exchangeServices/mercuryo/MercuryoApi.kt index 9687331cb5..dbfa5f3e5f 100644 --- a/app/src/main/java/com/tangem/tap/network/exchangeServices/mercuryo/MercuryoApi.kt +++ b/app/src/main/java/com/tangem/tap/network/exchangeServices/mercuryo/MercuryoApi.kt @@ -1,6 +1,7 @@ package com.tangem.tap.network.exchangeServices.mercuryo import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass import retrofit2.http.GET import retrofit2.http.Path @@ -20,21 +21,25 @@ interface MercuryoApi { suspend fun currencies(@Path("apiVersion") apiVersion: String): MercuryoCurrenciesResponse } +@JsonClass(generateAdapter = true) data class MercuryoCurrenciesResponse( val status: Int, val data: Data, ) { + @JsonClass(generateAdapter = true) data class Data( val fiat: List, val crypto: List, val config: Config, ) + @JsonClass(generateAdapter = true) data class Config( @Json(name = "crypto_currencies") val cryptoCurrencies: List, ) + @JsonClass(generateAdapter = true) data class MercuryoCryptoCurrency( @Json(name = "currency") val currencySymbol: String, diff --git a/core/datasource/build.gradle.kts b/core/datasource/build.gradle.kts index c2941ddbb1..eed66a2ac9 100644 --- a/core/datasource/build.gradle.kts +++ b/core/datasource/build.gradle.kts @@ -1,3 +1,5 @@ +import com.tangem.plugin.configuration.configurations.extension.kaptForObfuscatingVariants + plugins { alias(deps.plugins.android.library) alias(deps.plugins.kotlin.android) @@ -51,6 +53,8 @@ dependencies { implementation(deps.okHttp.prettyLogging) implementation(deps.retrofit) implementation(deps.retrofit.moshi) + kaptForObfuscatingVariants(deps.moshi.kotlin.codegen) + kaptForObfuscatingVariants(deps.retrofit.response.type.keeper) /** Time */ implementation(deps.jodatime) diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/stakekit/models/response/model/YieldDTO.kt b/core/datasource/src/main/java/com/tangem/datasource/api/stakekit/models/response/model/YieldDTO.kt index eac6f59846..d857516b1c 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/stakekit/models/response/model/YieldDTO.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/stakekit/models/response/model/YieldDTO.kt @@ -85,7 +85,7 @@ data class YieldDTO( @Json(name = "preferred") val preferred: Boolean?, ) { - @JsonClass(generateAdapter = true) + @JsonClass(generateAdapter = false) enum class ValidatorStatusDTO { @Json(name = "active") ACTIVE, diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/CoinsResponse.kt b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/CoinsResponse.kt index 866316079d..ee7a491d8d 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/CoinsResponse.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/CoinsResponse.kt @@ -1,14 +1,17 @@ package com.tangem.datasource.api.tangemTech.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass import java.math.BigDecimal +@JsonClass(generateAdapter = true) data class CoinsResponse( @Json(name = "imageHost") val imageHost: String?, @Json(name = "coins") val coins: List, @Json(name = "total") val total: Int, ) { + @JsonClass(generateAdapter = true) data class Coin( @Json(name = "id") val id: String, @Json(name = "name") val name: String, @@ -17,6 +20,7 @@ data class CoinsResponse( @Json(name = "networks") val networks: List = listOf(), ) { + @JsonClass(generateAdapter = true) data class Network( @Json(name = "networkId") val networkId: String, @Json(name = "contractAddress") val contractAddress: String? = null, diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/CreateUserTokensAccountBody.kt b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/CreateUserTokensAccountBody.kt index 7cbb3aa9ea..908d280c00 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/CreateUserTokensAccountBody.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/CreateUserTokensAccountBody.kt @@ -1,7 +1,9 @@ package com.tangem.datasource.api.tangemTech.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass +@JsonClass(generateAdapter = true) data class CreateUserTokensAccountBody( @Json(name = "accountId") val id: Int, diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/CurrenciesResponse.kt b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/CurrenciesResponse.kt index 7603314bf3..d9ed65f66f 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/CurrenciesResponse.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/CurrenciesResponse.kt @@ -17,7 +17,7 @@ data class CurrenciesResponse( @Json(name = "rateBTC") val rateBTC: String, @Json(name = "unit") val unit: String, // $, €, ₽ @Json(name = "type") val type: String, - val iconSmallUrl: String? = null, - val iconMediumUrl: String? = null, + @Json(name = "iconSmallUrl") val iconSmallUrl: String? = null, + @Json(name = "iconMediumUrl") val iconMediumUrl: String? = null, ) } diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/FeaturesResponse.kt b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/FeaturesResponse.kt index 46ebaa16cf..16691fcced 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/FeaturesResponse.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/FeaturesResponse.kt @@ -1,7 +1,9 @@ package com.tangem.datasource.api.tangemTech.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass +@JsonClass(generateAdapter = true) data class FeaturesResponse( @Json(name = "send") val isNewSendEnabled: Boolean, ) diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/QuotesResponse.kt b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/QuotesResponse.kt index 1c84a812d3..762f19899c 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/QuotesResponse.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/QuotesResponse.kt @@ -1,13 +1,16 @@ package com.tangem.datasource.api.tangemTech.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass import java.math.BigDecimal +@JsonClass(generateAdapter = true) data class QuotesResponse( @Json(name = "quotes") val quotes: Map, ) { + @JsonClass(generateAdapter = true) data class Quote( @Json(name = "price") val price: BigDecimal?, diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/RatesResponse.kt b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/RatesResponse.kt index 4223a2054e..0fda00772a 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/RatesResponse.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/RatesResponse.kt @@ -1,8 +1,10 @@ package com.tangem.datasource.api.tangemTech.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass // rates.keys = networkId's +@JsonClass(generateAdapter = true) data class RatesResponse( @Json(name = "rates") val rates: Map, ) diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/ReferralResponse.kt b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/ReferralResponse.kt index 584cbc1721..ff520d8d3e 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/ReferralResponse.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/ReferralResponse.kt @@ -1,30 +1,36 @@ package com.tangem.datasource.api.tangemTech.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass import org.joda.time.LocalDate +@JsonClass(generateAdapter = true) data class ReferralResponse( @Json(name = "conditions") val conditions: Conditions, @Json(name = "referral") val referral: Referral?, @Json(name = "expectedAwards") val expectedAwards: ExpectedAwards?, ) { + @JsonClass(generateAdapter = true) data class Conditions( @Json(name = "discount") val discount: Discount, @Json(name = "awards") val awards: List, @Json(name = "tosLink") val tosLink: String, ) { + @JsonClass(generateAdapter = true) data class Discount( @Json(name = "amount") val amount: Int, @Json(name = "type") val discountType: String, ) + @JsonClass(generateAdapter = true) data class Award( @Json(name = "amount") val amount: Int, @Json(name = "token") val token: Token, ) { + @JsonClass(generateAdapter = true) data class Token( @Json(name = "id") val id: String, @Json(name = "name") val name: String, @@ -36,6 +42,7 @@ data class ReferralResponse( } } + @JsonClass(generateAdapter = true) data class Referral( @Json(name = "shareLink") val shareLink: String, @Json(name = "address") val address: String, @@ -44,11 +51,13 @@ data class ReferralResponse( @Json(name = "termsAcceptedAt") val termsAcceptedAt: String?, ) + @JsonClass(generateAdapter = true) data class ExpectedAwards( @Json(name = "numberOfWallets") val numberOfWallets: Int, @Json(name = "list") val list: List, ) { + @JsonClass(generateAdapter = true) data class AwardItem( @Json(name = "currency") val currency: String, @Json(name = "paymentDate") val paymentDate: LocalDate, diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/SalesResponse.kt b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/SalesResponse.kt index ce6b28cc27..b51ba53ae1 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/SalesResponse.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/SalesResponse.kt @@ -1,10 +1,12 @@ package com.tangem.datasource.api.tangemTech.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass /** * Sales response */ +@JsonClass(generateAdapter = true) data class SalesResponse( @Json(name = "sales") val sales: List, ) @@ -17,6 +19,7 @@ data class SalesResponse( * @property product product that is sales * @property notification optional notification for product */ +@JsonClass(generateAdapter = true) data class Sales( @Json(name = "id") val id: String, @Json(name = "state") val state: String, @@ -31,12 +34,14 @@ data class Sales( * @property code code that shows what product it is * @property name product name */ +@JsonClass(generateAdapter = true) data class Product( @Json(name = "id") val id: String, @Json(name = "code") val code: String, @Json(name = "name") val name: String, ) +@JsonClass(generateAdapter = true) data class Notification( @Json(name = "type") val type: String, @Json(name = "title") val title: String, diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/ShopResponse.kt b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/ShopResponse.kt index 0c41bd21bb..3b7167ca52 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/ShopResponse.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/ShopResponse.kt @@ -1,6 +1,7 @@ package com.tangem.datasource.api.tangemTech.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass /** * Shop response @@ -9,6 +10,7 @@ import com.squareup.moshi.Json * * @author Andrew Khokhlov on 15/06/2023 */ +@JsonClass(generateAdapter = true) data class ShopResponse( @Json(name = "canOrder") val isOrderingAvailable: Boolean, ) diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/StartReferralBody.kt b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/StartReferralBody.kt index 1bd35840e2..ec261f085a 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/StartReferralBody.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/StartReferralBody.kt @@ -1,8 +1,10 @@ package com.tangem.datasource.api.tangemTech.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass /** Body for make user referral */ +@JsonClass(generateAdapter = true) data class StartReferralBody( @Json(name = "walletId") val walletId: String, @Json(name = "networkId") val networkId: String, diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/UpdateUserTokensAccountBody.kt b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/UpdateUserTokensAccountBody.kt index e596b3a4fd..85eb4e2ba2 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/UpdateUserTokensAccountBody.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/UpdateUserTokensAccountBody.kt @@ -1,7 +1,9 @@ package com.tangem.datasource.api.tangemTech.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass +@JsonClass(generateAdapter = true) data class UpdateUserTokensAccountBody( @Json(name = "accountTitle") val title: String, diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/UserTokensAccountResponse.kt b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/UserTokensAccountResponse.kt index aa8d29044a..a16e98d485 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/UserTokensAccountResponse.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/UserTokensAccountResponse.kt @@ -1,7 +1,9 @@ package com.tangem.datasource.api.tangemTech.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass +@JsonClass(generateAdapter = true) data class UserTokensAccountResponse( @Json(name = "accountId") val id: Int, diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/UserTokensResponse.kt b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/UserTokensResponse.kt index 5eb1b261b8..cdd44736ff 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/UserTokensResponse.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/UserTokensResponse.kt @@ -1,8 +1,10 @@ package com.tangem.datasource.api.tangemTech.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass import com.tangem.common.extensions.calculateHashCode +@JsonClass(generateAdapter = true) data class UserTokensResponse( @Json(name = "version") val version: Int = 0, @Json(name = "group") val group: GroupType, @@ -10,6 +12,7 @@ data class UserTokensResponse( @Json(name = "tokens") val tokens: List = emptyList(), ) { + @JsonClass(generateAdapter = true) data class Token( @Json(name = "id") val id: String? = null, @Json(name = "networkId") val networkId: String, @@ -36,6 +39,7 @@ data class UserTokensResponse( ) } + @JsonClass(generateAdapter = false) enum class GroupType { @Json(name = "none") NONE, @@ -47,6 +51,7 @@ data class UserTokensResponse( NETWORK, } + @JsonClass(generateAdapter = false) enum class SortType { @Json(name = "balance") BALANCE, diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/UserTokensSettingsResponse.kt b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/UserTokensSettingsResponse.kt index 64f89f8b2d..514856e099 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/UserTokensSettingsResponse.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/UserTokensSettingsResponse.kt @@ -1,7 +1,9 @@ package com.tangem.datasource.api.tangemTech.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass +@JsonClass(generateAdapter = true) data class UserTokensSettingsResponse( @Json(name = "group") val group: UserTokensResponse.GroupType, diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/v2/UserTokensResponseV2.kt b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/v2/UserTokensResponseV2.kt index ea5318255e..bfec407ec3 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/v2/UserTokensResponseV2.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/tangemTech/models/v2/UserTokensResponseV2.kt @@ -1,13 +1,16 @@ package com.tangem.datasource.api.tangemTech.models.v2 import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass import com.tangem.datasource.api.tangemTech.models.UserTokensResponse +@JsonClass(generateAdapter = true) data class UserTokensResponseV2( @Json(name = "accounts") val accounts: List, ) { + @JsonClass(generateAdapter = true) data class TokensAccount( @Json(name = "id") val id: Int, diff --git a/core/datasource/src/main/java/com/tangem/datasource/local/config/providers/models/ProviderModel.kt b/core/datasource/src/main/java/com/tangem/datasource/local/config/providers/models/ProviderModel.kt index ee1185b17a..d1e7223299 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/local/config/providers/models/ProviderModel.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/local/config/providers/models/ProviderModel.kt @@ -1,6 +1,7 @@ package com.tangem.datasource.local.config.providers.models import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass /** Config provider model */ sealed class ProviderModel { @@ -12,6 +13,7 @@ sealed class ProviderModel { * "url": "https://example.com" * } */ + @JsonClass(generateAdapter = true) data class Public( @Json(name = "url") val url: String, ) : ProviderModel() @@ -23,6 +25,7 @@ sealed class ProviderModel { * "name": "nownodes" * } */ + @JsonClass(generateAdapter = true) data class Private( @Json(name = "name") val name: String, ) : ProviderModel() diff --git a/core/featuretoggles/build.gradle.kts b/core/featuretoggles/build.gradle.kts index 32ce69fde2..97c51fa7fa 100644 --- a/core/featuretoggles/build.gradle.kts +++ b/core/featuretoggles/build.gradle.kts @@ -1,3 +1,5 @@ +import com.tangem.plugin.configuration.configurations.extension.kaptForObfuscatingVariants + plugins { alias(deps.plugins.android.library) alias(deps.plugins.kotlin.android) @@ -11,7 +13,6 @@ android { } dependencies { - /** DI */ implementation(deps.hilt.android) kapt(deps.hilt.kapt) @@ -23,6 +24,7 @@ dependencies { implementation(deps.moshi) implementation(deps.moshi.kotlin) implementation(deps.timber) + kaptForObfuscatingVariants(deps.moshi.kotlin.codegen) /** Core modules */ implementation(projects.core.datasource) diff --git a/data/manage-tokens/build.gradle.kts b/data/manage-tokens/build.gradle.kts index d2ff6fbc92..a8373e38ff 100644 --- a/data/manage-tokens/build.gradle.kts +++ b/data/manage-tokens/build.gradle.kts @@ -1,3 +1,5 @@ +import com.tangem.plugin.configuration.configurations.extension.kaptForObfuscatingVariants + plugins { alias(deps.plugins.android.library) alias(deps.plugins.kotlin.android) @@ -44,4 +46,6 @@ dependencies { /** Other */ implementation(deps.moshi.kotlin) implementation(deps.timber) + kaptForObfuscatingVariants(deps.moshi.kotlin.codegen) + kaptForObfuscatingVariants(deps.retrofit.response.type.keeper) } \ No newline at end of file diff --git a/data/markets/build.gradle.kts b/data/markets/build.gradle.kts index c8fe87aece..7d33a2ce33 100644 --- a/data/markets/build.gradle.kts +++ b/data/markets/build.gradle.kts @@ -1,3 +1,5 @@ +import com.tangem.plugin.configuration.configurations.extension.kaptForObfuscatingVariants + plugins { alias(deps.plugins.android.library) alias(deps.plugins.kotlin.android) @@ -38,6 +40,8 @@ dependencies { implementation(deps.moshi.kotlin) implementation(deps.timber) implementation(deps.tangem.blockchain) + kaptForObfuscatingVariants(deps.moshi.kotlin.codegen) + kaptForObfuscatingVariants(deps.retrofit.response.type.keeper) // endregion } diff --git a/data/onramp/build.gradle.kts b/data/onramp/build.gradle.kts index eeb856c7d5..3c99f9c8a0 100644 --- a/data/onramp/build.gradle.kts +++ b/data/onramp/build.gradle.kts @@ -1,3 +1,5 @@ +import com.tangem.plugin.configuration.configurations.extension.kaptForObfuscatingVariants + plugins { alias(deps.plugins.android.library) alias(deps.plugins.kotlin.android) @@ -37,6 +39,8 @@ dependencies { implementation(deps.moshi) implementation(deps.moshi.kotlin) implementation(deps.timber) + kaptForObfuscatingVariants(deps.moshi.kotlin.codegen) + kaptForObfuscatingVariants(deps.retrofit.response.type.keeper) implementation(projects.libs.blockchainSdk) implementation(projects.libs.crypto) diff --git a/data/settings/build.gradle.kts b/data/settings/build.gradle.kts index d5b81fe036..ffb0cdad49 100644 --- a/data/settings/build.gradle.kts +++ b/data/settings/build.gradle.kts @@ -1,3 +1,5 @@ +import com.tangem.plugin.configuration.configurations.extension.kaptForObfuscatingVariants + plugins { alias(deps.plugins.android.library) alias(deps.plugins.kotlin.android) @@ -32,6 +34,8 @@ dependencies { implementation(deps.moshi) implementation(deps.moshi.kotlin) implementation(deps.timber) + kaptForObfuscatingVariants(deps.moshi.kotlin.codegen) + kaptForObfuscatingVariants(deps.retrofit.response.type.keeper) // endregion } diff --git a/data/staking/build.gradle.kts b/data/staking/build.gradle.kts index 2e08d4171c..af4d4d6122 100644 --- a/data/staking/build.gradle.kts +++ b/data/staking/build.gradle.kts @@ -1,3 +1,5 @@ +import com.tangem.plugin.configuration.configurations.extension.kaptForObfuscatingVariants + plugins { alias(deps.plugins.android.library) alias(deps.plugins.kotlin.android) @@ -45,6 +47,8 @@ dependencies { implementation(deps.moshi) implementation(deps.moshi.kotlin) implementation(deps.timber) + kaptForObfuscatingVariants(deps.moshi.kotlin.codegen) + kaptForObfuscatingVariants(deps.retrofit.response.type.keeper) implementation(projects.libs.blockchainSdk) implementation(projects.libs.crypto) diff --git a/data/tokens/build.gradle.kts b/data/tokens/build.gradle.kts index 009d901b4e..a3f4b8c9d3 100644 --- a/data/tokens/build.gradle.kts +++ b/data/tokens/build.gradle.kts @@ -1,3 +1,5 @@ +import com.tangem.plugin.configuration.configurations.extension.kaptForObfuscatingVariants + plugins { alias(deps.plugins.android.library) alias(deps.plugins.kotlin.android) @@ -48,4 +50,6 @@ dependencies { implementation(deps.timber) implementation(deps.retrofit) // For HttpException implementation(deps.androidx.paging.runtime) + kaptForObfuscatingVariants(deps.moshi.kotlin.codegen) + kaptForObfuscatingVariants(deps.retrofit.response.type.keeper) } diff --git a/data/visa/build.gradle.kts b/data/visa/build.gradle.kts index ee7b6fe397..8529cc80d2 100644 --- a/data/visa/build.gradle.kts +++ b/data/visa/build.gradle.kts @@ -1,3 +1,5 @@ +import com.tangem.plugin.configuration.configurations.extension.kaptForObfuscatingVariants + plugins { alias(deps.plugins.android.library) alias(deps.plugins.kotlin.android) @@ -37,6 +39,8 @@ dependencies { implementation(deps.timber) implementation(deps.androidx.paging.runtime) implementation(deps.moshi.kotlin) + kaptForObfuscatingVariants(deps.moshi.kotlin.codegen) + kaptForObfuscatingVariants(deps.retrofit.response.type.keeper) /** Libs - Tangem */ implementation(deps.tangem.blockchain) diff --git a/domain/legacy/build.gradle.kts b/domain/legacy/build.gradle.kts index ff9909cea9..4575ada9b0 100644 --- a/domain/legacy/build.gradle.kts +++ b/domain/legacy/build.gradle.kts @@ -1,6 +1,9 @@ +import com.tangem.plugin.configuration.configurations.extension.kaptForObfuscatingVariants + plugins { alias(deps.plugins.android.library) alias(deps.plugins.kotlin.android) + alias(deps.plugins.kotlin.kapt) id("configuration") } @@ -38,6 +41,7 @@ dependencies { implementation(deps.moshi.kotlin) implementation(deps.reKotlin) implementation(deps.timber) + kaptForObfuscatingVariants(deps.moshi.kotlin.codegen) /** Testing libraries */ testImplementation(deps.test.junit) diff --git a/domain/legacy/src/main/java/com/tangem/domain/common/BlockchainNetwork.kt b/domain/legacy/src/main/java/com/tangem/domain/common/BlockchainNetwork.kt index 61c6e3f4ae..c452807610 100644 --- a/domain/legacy/src/main/java/com/tangem/domain/common/BlockchainNetwork.kt +++ b/domain/legacy/src/main/java/com/tangem/domain/common/BlockchainNetwork.kt @@ -1,5 +1,6 @@ package com.tangem.domain.common +import com.squareup.moshi.Json import com.squareup.moshi.JsonClass import com.tangem.blockchain.common.Blockchain import com.tangem.blockchain.common.Token @@ -8,8 +9,11 @@ import com.tangem.common.extensions.calculateHashCode @JsonClass(generateAdapter = true) @Deprecated("Use Network model") data class BlockchainNetwork( + @Json(name = "blockchain") val blockchain: Blockchain, + @Json(name = "derivationPath") val derivationPath: String?, + @Json(name = "tokens") val tokens: List, ) { diff --git a/domain/models/build.gradle.kts b/domain/models/build.gradle.kts index e310d2d210..3a969e2e1f 100644 --- a/domain/models/build.gradle.kts +++ b/domain/models/build.gradle.kts @@ -1,6 +1,9 @@ +import com.tangem.plugin.configuration.configurations.extension.kaptForObfuscatingVariants + plugins { alias(deps.plugins.kotlin.jvm) alias(deps.plugins.kotlin.serialization) + alias(deps.plugins.kotlin.kapt) id("configuration") } @@ -8,4 +11,5 @@ dependencies { implementation(deps.tangem.card.core) implementation(deps.moshi.kotlin) implementation(deps.kotlin.serialization) + kapt(deps.moshi.kotlin.codegen) } diff --git a/domain/models/src/main/kotlin/com/tangem/domain/models/scan/CardDTO.kt b/domain/models/src/main/kotlin/com/tangem/domain/models/scan/CardDTO.kt index f396961df3..3c5fd005f1 100644 --- a/domain/models/src/main/kotlin/com/tangem/domain/models/scan/CardDTO.kt +++ b/domain/models/src/main/kotlin/com/tangem/domain/models/scan/CardDTO.kt @@ -1,5 +1,6 @@ package com.tangem.domain.models.scan +import com.squareup.moshi.Json import com.squareup.moshi.JsonClass import com.tangem.common.card.Card import com.tangem.common.card.CardWallet @@ -17,20 +18,35 @@ import com.tangem.common.card.FirmwareVersion as SdkFirmwareVersion * */ @JsonClass(generateAdapter = true) data class CardDTO( + @Json(name = "cardId") val cardId: String, + @Json(name = "batchId") val batchId: String, + @Json(name = "cardPublicKey") val cardPublicKey: ByteArray, + @Json(name = "firmwareVersion") val firmwareVersion: FirmwareVersion, + @Json(name = "manufacturer") val manufacturer: Manufacturer, + @Json(name = "issuer") val issuer: Issuer, + @Json(name = "settings") val settings: Settings, + @Json(name = "userSettings") val userSettings: UserSettings?, + @Json(name = "linkedTerminalStatus") val linkedTerminalStatus: LinkedTerminalStatus, + @Json(name = "isAccessCodeSet") val isAccessCodeSet: Boolean, + @Json(name = "isPasscodeSet") val isPasscodeSet: Boolean?, + @Json(name = "supportedCurves") val supportedCurves: List, + @Json(name = "wallets") val wallets: List, + @Json(name = "attestation") val attestation: Attestation, + @Json(name = "backupStatus") val backupStatus: BackupStatus?, ) { constructor(card: Card) : this( @@ -92,16 +108,27 @@ data class CardDTO( @JsonClass(generateAdapter = true) data class Settings( + @Json(name = "securityDelay") val securityDelay: Int, + @Json(name = "maxWalletsCount") val maxWalletsCount: Int, + @Json(name = "isSettingAccessCodeAllowed") val isSettingAccessCodeAllowed: Boolean, + @Json(name = "isSettingPasscodeAllowed") val isSettingPasscodeAllowed: Boolean, + @Json(name = "isResettingUserCodesAllowed") val isResettingUserCodesAllowed: Boolean, + @Json(name = "isLinkedTerminalEnabled") val isLinkedTerminalEnabled: Boolean, + @Json(name = "isBackupAllowed") val isBackupAllowed: Boolean, + @Json(name = "supportedEncryptionModes") val supportedEncryptionModes: List, + @Json(name = "isFilesAllowed") val isFilesAllowed: Boolean, + @Json(name = "isHDWalletAllowed") val isHDWalletAllowed: Boolean, + @Json(name = "isKeysImportAllowed") val isKeysImportAllowed: Boolean = false, ) { constructor(settings: Card.Settings) : this( @@ -121,6 +148,7 @@ data class CardDTO( @JsonClass(generateAdapter = true) data class UserSettings( + @Json(name = "isUserCodeRecoveryAllowed") val isUserCodeRecoveryAllowed: Boolean, ) { constructor(userSettings: com.tangem.common.card.UserSettings) : this( @@ -130,9 +158,13 @@ data class CardDTO( @JsonClass(generateAdapter = true) data class FirmwareVersion( + @Json(name = "major") val major: Int, + @Json(name = "minor") val minor: Int, + @Json(name = "patch") val patch: Int, + @Json(name = "type") val type: SdkFirmwareVersion.FirmwareType, ) : Comparable { val stringValue: String @@ -161,8 +193,11 @@ data class CardDTO( @JsonClass(generateAdapter = true) data class Manufacturer( + @Json(name = "name") val name: String, + @Json(name = "manufactureDate") val manufactureDate: Date, + @Json(name = "signature") val signature: ByteArray?, ) { constructor(manufacturer: Card.Manufacturer) : this( @@ -195,7 +230,9 @@ data class CardDTO( @JsonClass(generateAdapter = true) data class Issuer( + @Json(name = "name") val name: String, + @Json(name = "publicKey") val publicKey: ByteArray, ) { constructor(issuer: Card.Issuer) : this( @@ -220,16 +257,27 @@ data class CardDTO( @JsonClass(generateAdapter = true) data class Wallet( + @Json(name = "publicKey") val publicKey: ByteArray, + @Json(name = "chainCode") val chainCode: ByteArray?, + @Json(name = "curve") val curve: EllipticCurve, + @Json(name = "settings") val settings: CardWallet.Settings, + @Json(name = "totalSignedHashes") val totalSignedHashes: Int?, + @Json(name = "remainingSignatures") val remainingSignatures: Int?, + @Json(name = "index") val index: Int, + @Json(name = "hasBackup") val hasBackup: Boolean, + @Json(name = "derivedKeys") val derivedKeys: Map, + @Json(name = "extendedPublicKey") val extendedPublicKey: ExtendedPublicKey?, + @Json(name = "isImported") val isImported: Boolean = false, ) { constructor(wallet: CardWallet) : this( @@ -281,9 +329,15 @@ data class CardDTO( } } + @JsonClass(generateAdapter = false) enum class LinkedTerminalStatus { + @Json(name = "Current") Current, + + @Json(name = "Other") Other, + + @Json(name = "None") None, ; diff --git a/domain/models/src/main/kotlin/com/tangem/domain/models/scan/ScanResponse.kt b/domain/models/src/main/kotlin/com/tangem/domain/models/scan/ScanResponse.kt index 85797daf62..dd297898d0 100644 --- a/domain/models/src/main/kotlin/com/tangem/domain/models/scan/ScanResponse.kt +++ b/domain/models/src/main/kotlin/com/tangem/domain/models/scan/ScanResponse.kt @@ -1,5 +1,7 @@ package com.tangem.domain.models.scan +import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass import com.tangem.common.card.WalletData import com.tangem.common.extensions.ByteArrayKey import com.tangem.operations.backup.PrimaryCard @@ -9,17 +11,44 @@ import com.tangem.operations.derivation.ExtendedPublicKeysMap /** * Created by Anton Zhilenkov on 07/04/2022. */ +@JsonClass(generateAdapter = true) data class ScanResponse( + @Json(name = "card") val card: CardDTO, + @Json(name = "productType") val productType: ProductType, + @Json(name = "walletData") val walletData: WalletData?, + @Json(name = "secondTwinPublicKey") val secondTwinPublicKey: String? = null, + @Json(name = "derivedKeys") val derivedKeys: Map = mapOf(), + @Json(name = "primaryCard") val primaryCard: PrimaryCard? = null, ) typealias KeyWalletPublicKey = ByteArrayKey +@JsonClass(generateAdapter = false) enum class ProductType { - Note, Twins, Wallet, Start2Coin, Wallet2, Ring, Visa, + @Json(name = "Note") + Note, + + @Json(name = "Twins") + Twins, + + @Json(name = "Wallet") + Wallet, + + @Json(name = "Start2Coin") + Start2Coin, + + @Json(name = "Wallet2") + Wallet2, + + @Json(name = "Ring") + Ring, + + @Json(name = "Visa") + Visa, } diff --git a/domain/wallets/models/build.gradle.kts b/domain/wallets/models/build.gradle.kts index f356c773f9..73e8a62c05 100644 --- a/domain/wallets/models/build.gradle.kts +++ b/domain/wallets/models/build.gradle.kts @@ -1,6 +1,7 @@ plugins { alias(deps.plugins.kotlin.jvm) alias(deps.plugins.kotlin.serialization) + alias(deps.plugins.kotlin.kapt) id("configuration") } @@ -15,5 +16,8 @@ dependencies { // region Other libraries implementation(deps.kotlin.serialization) + implementation(deps.moshi.kotlin) + implementation(deps.timber) + kapt(deps.moshi.kotlin.codegen) // endregion } diff --git a/domain/wallets/models/src/main/java/com/tangem/domain/wallets/models/UserWallet.kt b/domain/wallets/models/src/main/java/com/tangem/domain/wallets/models/UserWallet.kt index e100b14070..9da861d59c 100644 --- a/domain/wallets/models/src/main/java/com/tangem/domain/wallets/models/UserWallet.kt +++ b/domain/wallets/models/src/main/java/com/tangem/domain/wallets/models/UserWallet.kt @@ -1,5 +1,7 @@ package com.tangem.domain.wallets.models +import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass import com.tangem.domain.models.scan.CardDTO import com.tangem.domain.models.scan.ScanResponse @@ -14,13 +16,21 @@ import com.tangem.domain.models.scan.ScanResponse * @property isMultiCurrency Indicates whether this user wallet can work with more than one currency * @property scanResponse [ScanResponse] of primary user's wallet card. */ +@JsonClass(generateAdapter = true) data class UserWallet( + @Json(name = "name") val name: String, + @Json(name = "walletId") val walletId: UserWalletId, + @Json(name = "artworkUrl") val artworkUrl: String, + @Json(name = "cardsInWallet") val cardsInWallet: Set, + @Json(name = "isMultiCurrency") val isMultiCurrency: Boolean, + @Json(name = "hasBackupError") val hasBackupError: Boolean, + @Json(name = "scanResponse") val scanResponse: ScanResponse, // TODO: Replace with [com.tangem.domain.models.scan.CardDTO] ) { diff --git a/domain/wallets/models/src/main/java/com/tangem/domain/wallets/models/UserWalletId.kt b/domain/wallets/models/src/main/java/com/tangem/domain/wallets/models/UserWalletId.kt index 3ff1218b27..7df04d8df0 100644 --- a/domain/wallets/models/src/main/java/com/tangem/domain/wallets/models/UserWalletId.kt +++ b/domain/wallets/models/src/main/java/com/tangem/domain/wallets/models/UserWalletId.kt @@ -1,11 +1,17 @@ package com.tangem.domain.wallets.models +import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass import com.tangem.common.extensions.hexToBytes import com.tangem.common.extensions.toHexString import kotlinx.serialization.Serializable @Serializable -data class UserWalletId(val stringValue: String) { +@JsonClass(generateAdapter = true) +data class UserWalletId( + @Json(name = "stringValue") + val stringValue: String, +) { val value = stringValue.hexToBytes() diff --git a/features/swap/data/build.gradle.kts b/features/swap/data/build.gradle.kts index f7b2c4a924..021b2a2bb2 100644 --- a/features/swap/data/build.gradle.kts +++ b/features/swap/data/build.gradle.kts @@ -1,3 +1,5 @@ +import com.tangem.plugin.configuration.configurations.extension.kaptForObfuscatingVariants + plugins { alias(deps.plugins.android.library) alias(deps.plugins.kotlin.android) @@ -27,6 +29,8 @@ dependencies { implementation(deps.moshi) implementation(deps.moshi.kotlin) implementation(deps.arrow.core) + kaptForObfuscatingVariants(deps.moshi.kotlin.codegen) + kaptForObfuscatingVariants(deps.retrofit.response.type.keeper) /** Domain */ implementation(projects.domain.tokens.models) diff --git a/features/swap/domain/build.gradle.kts b/features/swap/domain/build.gradle.kts index d86f55eb76..b5109c40d7 100644 --- a/features/swap/domain/build.gradle.kts +++ b/features/swap/domain/build.gradle.kts @@ -1,3 +1,5 @@ +import com.tangem.plugin.configuration.configurations.extension.kaptForObfuscatingVariants + plugins { alias(deps.plugins.android.library) alias(deps.plugins.kotlin.android) @@ -51,4 +53,5 @@ dependencies { implementation(deps.tangem.blockchain) implementation(deps.tangem.card.core) implementation(deps.moshi) + kaptForObfuscatingVariants(deps.moshi.kotlin.codegen) } diff --git a/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/domain/Currency.kt b/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/domain/Currency.kt deleted file mode 100644 index 62aebfd8e3..0000000000 --- a/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/domain/Currency.kt +++ /dev/null @@ -1,36 +0,0 @@ -package com.tangem.feature.swap.domain.models.domain - -import kotlinx.serialization.Serializable - -@Serializable -sealed class Currency { - abstract val id: String - abstract val name: String - abstract val symbol: String - abstract val networkId: String - abstract val logoUrl: String - - @Serializable - data class NativeToken( - override val id: String, - override val name: String, - override val symbol: String, - override val networkId: String, - override val logoUrl: String, - ) : Currency() - - @Serializable - data class NonNativeToken( - override val id: String, - override val name: String, - override val symbol: String, - override val networkId: String, - override val logoUrl: String, - val contractAddress: String, - val decimalCount: Int, - ) : Currency() -} - -fun Currency.isNonNative(): Boolean { - return this is Currency.NonNativeToken -} diff --git a/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/domain/ExchangeQuote.kt b/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/domain/ExchangeQuote.kt deleted file mode 100644 index 66f7b6d287..0000000000 --- a/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/domain/ExchangeQuote.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.tangem.feature.swap.domain.models.domain - -data class ExchangeQuote( - val toAmount: String, - val allowanceContract: String?, -) diff --git a/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/domain/TransactionModel.kt b/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/domain/TransactionModel.kt deleted file mode 100644 index f7980215ae..0000000000 --- a/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/domain/TransactionModel.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.tangem.feature.swap.domain.models.domain - -/** - * Transaction model - * - * @property fromWalletAddress wallet from address (transactions will be sent from this address) - * @property toWalletAddress transactions will be sent to our(1inch) contract address - * @property data The encoded data to call the approve method on the swapped token contract - * @property value Native token value in WEI (for approve is always 0) - * @property gasPrice maximum amount of gas for a swap default: 11500000; max: 11500000 - * @property gas estimated amount of the gas limit, increase this value by 25% - */ -data class TransactionModel( - val fromWalletAddress: String, - val toWalletAddress: String, - val data: String, - val value: String, - val gasPrice: String, - val gas: String, -) diff --git a/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/ui/TokensDataState.kt b/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/ui/TokensDataState.kt deleted file mode 100644 index 2fcb993b1d..0000000000 --- a/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/ui/TokensDataState.kt +++ /dev/null @@ -1,28 +0,0 @@ -package com.tangem.feature.swap.domain.models.ui - -import com.tangem.feature.swap.domain.models.domain.Currency - -data class TokensDataState( - val preselectTokens: PreselectTokens, - val foundTokensState: FoundTokensState, -) - -data class FoundTokensState( - val tokensInWallet: List, - val loadedTokens: List, -) - -data class PreselectTokens( - val fromToken: Currency, - val toToken: Currency, -) - -data class TokenWithBalance( - val token: Currency, - val tokenBalanceData: TokenBalanceData? = null, -) - -data class TokenBalanceData( - val amount: String?, - val amountEquivalent: String?, -) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/VisaTxDetailsBottomSheet.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/VisaTxDetailsBottomSheet.kt index 44f7f65175..fe9b82b264 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/VisaTxDetailsBottomSheet.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/visa/VisaTxDetailsBottomSheet.kt @@ -107,32 +107,33 @@ private fun TransactionBlock(transaction: VisaTxDetailsBottomSheetConfig.Transac ) } +@Suppress("LongMethod") @Composable private fun BlockchainRequestBlock(request: VisaTxDetailsBottomSheetConfig.Request, modifier: Modifier = Modifier) { BlockContent( modifier = modifier, title = stringReference(value = "Blockchain request"), description = { - if (request.onExploreClick == null) return - - Row( - modifier = Modifier.clickable(onClick = request.onExploreClick), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(space = TangemTheme.dimens.spacing4), - ) { - Icon( - painter = painterResource(id = R.drawable.ic_compass_24), - contentDescription = null, - modifier = Modifier.size(size = TangemTheme.dimens.size18), - tint = TangemTheme.colors.icon.informative, - ) - Text( - text = "Explore", - color = TangemTheme.colors.text.tertiary, - style = TangemTheme.typography.caption1, - ) + if (request.onExploreClick != null) { + Row( + modifier = Modifier.clickable(onClick = request.onExploreClick), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(space = TangemTheme.dimens.spacing4), + ) { + Icon( + painter = painterResource(id = R.drawable.ic_compass_24), + contentDescription = null, + modifier = Modifier.size(size = TangemTheme.dimens.size18), + tint = TangemTheme.colors.icon.informative, + ) + Text( + text = "Explore", + color = TangemTheme.colors.text.tertiary, + style = TangemTheme.typography.caption1, + ) + } + SpacerW12() } - SpacerW12() }, content = { BlockItem( diff --git a/gradle/dependencies.toml b/gradle/dependencies.toml index 7e0c09dcdd..3cd302c219 100644 --- a/gradle/dependencies.toml +++ b/gradle/dependencies.toml @@ -3,7 +3,7 @@ [versions] # region Classpath -androidGradlePlugin = "8.2.2" +androidGradlePlugin = "8.6.1" firebaseCrashlytics = "3.0.1" googleServices = "4.4.1" kotlin = "1.9.22" @@ -56,11 +56,11 @@ jodatime = "2.12.1" kotlin-immutable-collections = "0.3.5" kotsonGsonExt = "2.5.0" lottie = "3.4.0" -moshi = "1.12.0" +moshi = "1.15.1" okhttp = "4.9.3" rekotlin = "1.0.4" -retrofit = "2.8.1" -retrofitMoshiConverter = "2.6.0" +retrofit = "2.11.0" +retrofitMoshiConverter = "2.9.0" spongycastleCryptoCore = "1.58.0.0" timber = "4.7.1" viewBindingDelegate = "1.5.9" @@ -236,11 +236,13 @@ material = { module = "com.google.android.material:material", version.ref = "goo moshi = { module = "com.squareup.moshi:moshi", version.ref = "moshi" } moshi-kotlin = { module = "com.squareup.moshi:moshi-kotlin", version.ref = "moshi" } moshi-adapters = { module = "com.squareup.moshi:moshi-adapters", version.ref = "moshi" } +moshi-kotlin-codegen = { module = "com.squareup.moshi:moshi-kotlin-codegen", version.ref = "moshi" } okHttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } okHttp-prettyLogging = { module = "com.github.ihsanbal:LoggingInterceptor", version.ref = "okHttp-prettyLogging" } spongecastle-core = { module = "com.madgag.spongycastle:core", version.ref = "spongycastleCryptoCore" } reKotlin = { module = "org.rekotlin:rekotlin", version.ref = "rekotlin" } retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" } +retrofit-response-type-keeper = { module = "com.squareup.retrofit2:response-type-keeper", version.ref = "retrofit" } retrofit-moshi = { module = "com.squareup.retrofit2:converter-moshi", version.ref = "retrofitMoshiConverter" } timber = { module = "com.jakewharton.timber:timber", version.ref = "timber" } viewBindingDelegate = { module = "com.github.kirich1409:viewbindingpropertydelegate-noreflection", version.ref = "viewBindingDelegate" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f5e4b2a14c..7d6922649d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue Feb 13 17:04:37 MSK 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/libs/blockchain-sdk/build.gradle.kts b/libs/blockchain-sdk/build.gradle.kts index 47b65e7313..b46d84e35a 100644 --- a/libs/blockchain-sdk/build.gradle.kts +++ b/libs/blockchain-sdk/build.gradle.kts @@ -1,3 +1,5 @@ +import com.tangem.plugin.configuration.configurations.extension.kaptForObfuscatingVariants + plugins { alias(deps.plugins.android.library) alias(deps.plugins.kotlin.android) @@ -31,6 +33,8 @@ dependencies { implementation(deps.moshi) implementation(deps.moshi.kotlin) implementation(deps.timber) + kaptForObfuscatingVariants(deps.moshi.kotlin.codegen) + kaptForObfuscatingVariants(deps.retrofit.response.type.keeper) // endregion // region Firebase libraries diff --git a/libs/visa/build.gradle.kts b/libs/visa/build.gradle.kts index dd4315dcaf..7b0cd05aea 100644 --- a/libs/visa/build.gradle.kts +++ b/libs/visa/build.gradle.kts @@ -1,6 +1,9 @@ +import com.tangem.plugin.configuration.configurations.extension.kaptForObfuscatingVariants + plugins { alias(deps.plugins.android.library) alias(deps.plugins.kotlin.android) + alias(deps.plugins.kotlin.kapt) id("configuration") } @@ -21,6 +24,8 @@ dependencies { implementation(deps.okHttp.prettyLogging) implementation(deps.retrofit) implementation(deps.retrofit.moshi) + kaptForObfuscatingVariants(deps.moshi.kotlin.codegen) + kaptForObfuscatingVariants(deps.retrofit.response.type.keeper) /** Libs - Other */ implementation(deps.web3j.core) diff --git a/libs/visa/src/main/kotlin/com/tangem/lib/visa/model/VisaTxHistoryResponse.kt b/libs/visa/src/main/kotlin/com/tangem/lib/visa/model/VisaTxHistoryResponse.kt index 0ca5a0272a..6667c3bd97 100644 --- a/libs/visa/src/main/kotlin/com/tangem/lib/visa/model/VisaTxHistoryResponse.kt +++ b/libs/visa/src/main/kotlin/com/tangem/lib/visa/model/VisaTxHistoryResponse.kt @@ -1,9 +1,11 @@ package com.tangem.lib.visa.model import com.squareup.moshi.Json +import com.squareup.moshi.JsonClass import org.joda.time.DateTime import java.math.BigDecimal +@JsonClass(generateAdapter = true) data class VisaTxHistoryResponse( @Json(name = "card_wallet_address") val cardWalletAddress: String, @@ -11,6 +13,7 @@ data class VisaTxHistoryResponse( val transactions: List, ) { + @JsonClass(generateAdapter = true) data class Transaction( @Json(name = "auth_code") val authCode: String?, @@ -52,6 +55,7 @@ data class VisaTxHistoryResponse( val transactionType: String, ) { + @JsonClass(generateAdapter = true) data class Request( @Json(name = "billing_amount") val billingAmount: BigDecimal, diff --git a/plugins/configuration/src/main/kotlin/com/tangem/plugin/configuration/configurations/extension/AppExtensionConfigurations.kt b/plugins/configuration/src/main/kotlin/com/tangem/plugin/configuration/configurations/extension/AppExtensionConfigurations.kt index 5fc302b255..27ea4298fb 100644 --- a/plugins/configuration/src/main/kotlin/com/tangem/plugin/configuration/configurations/extension/AppExtensionConfigurations.kt +++ b/plugins/configuration/src/main/kotlin/com/tangem/plugin/configuration/configurations/extension/AppExtensionConfigurations.kt @@ -71,12 +71,11 @@ private fun AndroidBuildType.configureBuildVariant(appExtension: AppExtension, b when (buildType) { BuildType.Release -> { isDebuggable = false - isMinifyEnabled = false proguardFiles(appExtension.getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") } BuildType.Debug -> { isDebuggable = true - isMinifyEnabled = false + proguardFiles(appExtension.getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") } BuildType.Internal, BuildType.External, @@ -95,6 +94,8 @@ private fun AndroidBuildType.configureBuildVariant(appExtension: AppExtension, b versionNameSuffix = buildType.versionSuffix?.let { "-$it" } applicationIdSuffix = buildType.appIdSuffix?.let { ".$it" } + isMinifyEnabled = buildType.obfuscating + isShrinkResources = buildType.obfuscating } private fun AppExtension.configurePackagingOptions() { @@ -104,6 +105,7 @@ private fun AppExtension.configurePackagingOptions() { excludes += "lib/x86_64/freebsd/libscrypt.so" excludes += "lib/x86_64/linux/libscrypt.so" excludes += "META-INF/gradle/incremental.annotation.processors" + pickFirsts += "google/protobuf/*" merges += "paymentrequest.proto" } diff --git a/plugins/configuration/src/main/kotlin/com/tangem/plugin/configuration/configurations/extension/DependencyHandler.kt b/plugins/configuration/src/main/kotlin/com/tangem/plugin/configuration/configurations/extension/DependencyHandler.kt new file mode 100644 index 0000000000..6b0c96219d --- /dev/null +++ b/plugins/configuration/src/main/kotlin/com/tangem/plugin/configuration/configurations/extension/DependencyHandler.kt @@ -0,0 +1,25 @@ +package com.tangem.plugin.configuration.configurations.extension + +import com.android.build.gradle.internal.plugins.AppPlugin +import com.android.build.gradle.internal.plugins.LibraryPlugin +import com.tangem.plugin.configuration.model.BuildType +import org.gradle.api.Project + +fun Project.kaptForObfuscatingVariants(dependencyNotation: Any) { + plugins.all { + when (this) { + is AppPlugin -> { + BuildType.values().filter { it.obfuscating }.forEach { + dependencies.add(it.createKaptConfiguration(), dependencyNotation) + } + } + is LibraryPlugin -> { + BuildType.values().filter { it.obfuscating }.forEach { + dependencies.add(it.createKaptConfiguration(), dependencyNotation) + } + } + } + } +} + +private fun BuildType.createKaptConfiguration() = "kapt" + name.replaceFirstChar(Char::titlecase) diff --git a/plugins/configuration/src/main/kotlin/com/tangem/plugin/configuration/configurations/extension/LibraryExtensionConfigurations.kt b/plugins/configuration/src/main/kotlin/com/tangem/plugin/configuration/configurations/extension/LibraryExtensionConfigurations.kt index e32c747eaa..d179bb9f49 100644 --- a/plugins/configuration/src/main/kotlin/com/tangem/plugin/configuration/configurations/extension/LibraryExtensionConfigurations.kt +++ b/plugins/configuration/src/main/kotlin/com/tangem/plugin/configuration/configurations/extension/LibraryExtensionConfigurations.kt @@ -45,6 +45,7 @@ private fun LibraryExtension.configurePackagingOptions() { excludes += "lib/x86_64/freebsd/libscrypt.so" excludes += "lib/x86_64/linux/libscrypt.so" excludes += "META-INF/gradle/incremental.annotation.processors" + pickFirsts += "google/protobuf/*" } } } diff --git a/plugins/configuration/src/main/kotlin/com/tangem/plugin/configuration/model/BuildType.kt b/plugins/configuration/src/main/kotlin/com/tangem/plugin/configuration/model/BuildType.kt index 713ce6adb9..ae594db534 100644 --- a/plugins/configuration/src/main/kotlin/com/tangem/plugin/configuration/model/BuildType.kt +++ b/plugins/configuration/src/main/kotlin/com/tangem/plugin/configuration/model/BuildType.kt @@ -4,6 +4,7 @@ internal enum class BuildType( val id: String, val appIdSuffix: String? = null, val versionSuffix: String? = null, + val obfuscating: Boolean = true, val configFields: List, ) { @@ -22,6 +23,7 @@ internal enum class BuildType( Debug( id = "debug", appIdSuffix = "debug", + obfuscating = false, configFields = listOf( BuildConfigField.Environment(value = "dev"), BuildConfigField.TestActionEnabled(isEnabled = true),