Skip to content

Commit 848a65c

Browse files
Merge pull request #113 from Web3Auth/feat/update_proguard_and_consumer_rules
Feat/update proguard and consumer rules
2 parents 0ae4879 + 2121235 commit 848a65c

32 files changed

+308
-124
lines changed

app/src/main/java/com/web3auth/app/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
187187
clientId = "d84f6xvbdV75VTGmHiMWfZLeSPk8M07C",
188188
)
189189
),
190-
buildEnv = BuildEnv.TESTING,
190+
buildEnv = BuildEnv.PRODUCTION,
191191
sessionTime = 86400,
192192
)
193193

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
buildscript {
2-
ext.kotlin_version = "1.7.10"
2+
ext.kotlin_version = "1.8.22"
33
repositories {
44
google()
55
mavenCentral()

core/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ plugins {
55
}
66

77
android {
8+
namespace 'com.web3auth.core'
89
compileSdk 34
910

1011
defaultConfig {
@@ -17,7 +18,7 @@ android {
1718

1819
buildTypes {
1920
release {
20-
minifyEnabled false
21+
minifyEnabled true
2122
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
2223
consumerProguardFiles 'proguard-rules.pro', 'gson.pro', 'retrofit2.pro'
2324
}

core/consumer-rules.pro

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Keep the Web3Auth core classes and methods
2+
-keep class com.web3auth.core.** { *; }
3+
-keep class com.web3auth.core.types.ChainConfig { *; }
4+
-keep class com.web3auth.core.types.** { *; }
5+
-keep class com.web3auth.core.api.** { *; }
6+
7+
-keepattributes *Annotation*
8+
-keep class com.google.gson.annotations.SerializedName
9+
-keepclassmembers class * {
10+
@com.google.gson.annotations.SerializedName <fields>;
11+
}
12+
13+
# Keep all JsonElement types from Gson
14+
-keep class com.google.gson.JsonArray { *; }
15+
-keep class com.google.gson.JsonObject { *; }
16+
-keep class com.google.gson.JsonElement { *; }
17+
18+
# Preserve annotations and parameter names
19+
-keepattributes *Annotation*, Signature, InnerClasses, EnclosingMethod
20+
21+
# If using Gson or any reflection-based serialization:
22+
-keepclassmembers class * {
23+
@com.google.gson.annotations.SerializedName <fields>;
24+
}
25+
26+
# Keep the Web3Auth class and prevent any obfuscation or stripping
27+
-keep class com.web3auth.core.Web3Auth {
28+
*;
29+
}
30+
31+
-keepclassmembers class com.web3auth.core.Web3Auth$Companion {
32+
public *;
33+
}
34+
-keep class com.web3auth.core.Web3Auth {
35+
public static final com.web3auth.core.Web3Auth$Companion Companion;
36+
}
37+
-keep interface com.web3auth.core.types.WebViewResultCallback {
38+
*;
39+
}
40+
41+
-keep class com.web3auth.core.types.Web3AuthError {
42+
*;
43+
}
44+
-keepclassmembers class com.web3auth.core.types.Web3AuthError {
45+
public static <methods>;
46+
}
47+
-keep enum com.web3auth.core.types.ErrorCode {
48+
*;
49+
}

core/proguard-rules.pro

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,48 @@
2222
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
2323
-keep class * implements com.google.gson.TypeAdapterFactory
2424
-keep class * implements com.google.gson.JsonSerializer
25-
-keep class * implements com.google.gson.JsonDeserializer
25+
-keep class * implements com.google.gson.JsonDeserializer
26+
27+
-keepattributes *Annotation*
28+
-keep class com.google.gson.annotations.SerializedName
29+
-keepclassmembers class * {
30+
@com.google.gson.annotations.SerializedName <fields>;
31+
}
32+
33+
# Keep all JsonElement types from Gson
34+
-keep class com.google.gson.JsonArray { *; }
35+
-keep class com.google.gson.JsonObject { *; }
36+
-keep class com.google.gson.JsonElement { *; }
37+
38+
# Preserve annotations and parameter names
39+
-keepattributes *Annotation*, Signature, InnerClasses, EnclosingMethod
40+
41+
# If using Gson or any reflection-based serialization:
42+
-keepclassmembers class * {
43+
@com.google.gson.annotations.SerializedName <fields>;
44+
}
45+
46+
# Keep the Web3Auth class and prevent any obfuscation or stripping
47+
-keep class com.web3auth.core.Web3Auth {
48+
*;
49+
}
50+
51+
-keepclassmembers class com.web3auth.core.Web3Auth$Companion {
52+
public *;
53+
}
54+
-keep class com.web3auth.core.Web3Auth {
55+
public static final com.web3auth.core.Web3Auth$Companion Companion;
56+
}
57+
-keep interface com.web3auth.core.types.WebViewResultCallback {
58+
*;
59+
}
60+
61+
-keep class com.web3auth.core.types.Web3AuthError {
62+
*;
63+
}
64+
-keepclassmembers class com.web3auth.core.types.Web3AuthError {
65+
public static <methods>;
66+
}
67+
-keep enum com.web3auth.core.types.ErrorCode {
68+
*;
69+
}

core/src/main/java/com/web3auth/core/Web3Auth.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,12 +748,15 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
748748
}
749749

750750
companion object {
751+
@JvmStatic
751752
private var isCustomTabsClosed: Boolean = false
752753

754+
@JvmStatic
753755
fun setCustomTabsClosed(_isCustomTabsClosed: Boolean) {
754756
isCustomTabsClosed = _isCustomTabsClosed
755757
}
756758

759+
@JvmStatic
757760
fun getCustomTabsClosed(): Boolean {
758761
return isCustomTabsClosed
759762
}
Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
package com.web3auth.core.types
22

3+
import androidx.annotation.Keep
4+
import java.io.Serializable
5+
6+
@Keep
37
data class ChainConfig(
4-
val chainNamespace: ChainNamespace = ChainNamespace.EIP155,
5-
val decimals: Int? = 18,
6-
val blockExplorerUrl: String? = null,
7-
val chainId: String,
8-
val displayName: String? = null,
9-
val logo: String? = null,
10-
val rpcTarget: String,
11-
val ticker: String? = null,
12-
val tickerName: String? = null,
13-
)
8+
@Keep val chainNamespace: ChainNamespace = ChainNamespace.EIP155,
9+
@Keep val decimals: Int? = 18,
10+
@Keep val blockExplorerUrl: String? = null,
11+
@Keep val chainId: String,
12+
@Keep val displayName: String? = null,
13+
@Keep val logo: String? = null,
14+
@Keep val rpcTarget: String,
15+
@Keep val ticker: String? = null,
16+
@Keep val tickerName: String? = null,
17+
) : Serializable

core/src/main/java/com/web3auth/core/types/ChainNamespace.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package com.web3auth.core.types
22

3+
import androidx.annotation.Keep
34
import com.google.gson.annotations.SerializedName
45

6+
@Keep
57
enum class ChainNamespace {
68
@SerializedName("eip155")
79
EIP155,

core/src/main/java/com/web3auth/core/types/Curve.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package com.web3auth.core.types
22

3+
import androidx.annotation.Keep
34
import com.google.gson.annotations.SerializedName
45

6+
@Keep
57
enum class Curve {
68
@SerializedName("secp256k1")
79
SECP256K1,

core/src/main/java/com/web3auth/core/types/Display.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.web3auth.core.types
22

3+
import androidx.annotation.Keep
4+
5+
@Keep
36
enum class Display(private val label: String) {
47
PAGE("page"), POPUP("popup"), TOUCH("touch"), WAP("wap");
58

0 commit comments

Comments
 (0)