Skip to content

Commit 4776e6b

Browse files
committed
feat: Update AuthConnection nd example
Signed-off-by: Gaurav Goel <[email protected]>
1 parent 993d363 commit 4776e6b

File tree

6 files changed

+27
-86
lines changed

6 files changed

+27
-86
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.web3auth.app
22

3-
import com.web3auth.core.types.AUTH_CONNECTION
3+
import com.web3auth.core.types.AuthConnection
44

55
data class AuthConnectionLogin(
66
val name: String,
7-
val authConnection: AUTH_CONNECTION
7+
val authConnection: AuthConnection
88
)

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

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import com.google.gson.JsonArray
2121
import com.web3auth.core.Web3Auth
2222
import com.web3auth.core.isEmailValid
2323
import com.web3auth.core.isPhoneNumberValid
24-
import com.web3auth.core.types.AUTH_CONNECTION
2524
import com.web3auth.core.types.AuthConnection
2625
import com.web3auth.core.types.AuthConnectionConfig
2726
import com.web3auth.core.types.BuildEnv
@@ -45,30 +44,30 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
4544
private lateinit var web3Auth: Web3Auth
4645

4746
private val authConnectionList: List<AuthConnectionLogin> = listOf(
48-
AuthConnectionLogin("Google", AUTH_CONNECTION.GOOGLE),
49-
AuthConnectionLogin("Facebook", AUTH_CONNECTION.FACEBOOK),
50-
AuthConnectionLogin("Twitch", AUTH_CONNECTION.TWITCH),
51-
AuthConnectionLogin("Discord", AUTH_CONNECTION.DISCORD),
52-
AuthConnectionLogin("Reddit", AUTH_CONNECTION.REDDIT),
53-
AuthConnectionLogin("Apple", AUTH_CONNECTION.APPLE),
54-
AuthConnectionLogin("Github", AUTH_CONNECTION.GITHUB),
55-
AuthConnectionLogin("LinkedIn", AUTH_CONNECTION.LINKEDIN),
56-
AuthConnectionLogin("Twitter", AUTH_CONNECTION.TWITTER),
57-
AuthConnectionLogin("Line", AUTH_CONNECTION.LINE),
58-
AuthConnectionLogin("Hosted Email Passwordless", AUTH_CONNECTION.EMAIL_PASSWORDLESS),
59-
AuthConnectionLogin("SMS Passwordless", AUTH_CONNECTION.SMS_PASSWORDLESS),
60-
AuthConnectionLogin("JWT", AUTH_CONNECTION.JWT),
61-
AuthConnectionLogin("Farcaster", AUTH_CONNECTION.FARCASTER)
47+
AuthConnectionLogin("Google", AuthConnection.GOOGLE),
48+
AuthConnectionLogin("Facebook", AuthConnection.FACEBOOK),
49+
AuthConnectionLogin("Twitch", AuthConnection.TWITCH),
50+
AuthConnectionLogin("Discord", AuthConnection.DISCORD),
51+
AuthConnectionLogin("Reddit", AuthConnection.REDDIT),
52+
AuthConnectionLogin("Apple", AuthConnection.APPLE),
53+
AuthConnectionLogin("Github", AuthConnection.GITHUB),
54+
AuthConnectionLogin("LinkedIn", AuthConnection.LINKEDIN),
55+
AuthConnectionLogin("Twitter", AuthConnection.TWITTER),
56+
AuthConnectionLogin("Line", AuthConnection.LINE),
57+
AuthConnectionLogin("Hosted Email Passwordless", AuthConnection.EMAIL_PASSWORDLESS),
58+
AuthConnectionLogin("SMS Passwordless", AuthConnection.SMS_PASSWORDLESS),
59+
AuthConnectionLogin("JWT", AuthConnection.JWT),
60+
AuthConnectionLogin("Farcaster", AuthConnection.FARCASTER)
6261
)
6362

64-
private var selectedLoginProvider: AUTH_CONNECTION = AUTH_CONNECTION.GOOGLE
63+
private var selectedLoginProvider: AuthConnection = AuthConnection.GOOGLE
6564

6665
private val gson = Gson()
6766

6867
private fun signIn() {
6968
val hintEmailEditText = findViewById<EditText>(R.id.etEmailHint)
7069
var extraLoginOptions: ExtraLoginOptions? = null
71-
if (selectedLoginProvider == AUTH_CONNECTION.EMAIL_PASSWORDLESS) {
70+
if (selectedLoginProvider == AuthConnection.EMAIL_PASSWORDLESS) {
7271
val hintEmail = hintEmailEditText.text.toString()
7372
if (hintEmail.isBlank() || !hintEmail.isEmailValid()) {
7473
Toast.makeText(this, "Please enter a valid Email.", Toast.LENGTH_LONG).show()
@@ -77,7 +76,7 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
7776
extraLoginOptions = ExtraLoginOptions(login_hint = hintEmail)
7877
}
7978

80-
if (selectedLoginProvider == AUTH_CONNECTION.SMS_PASSWORDLESS) {
79+
if (selectedLoginProvider == AuthConnection.SMS_PASSWORDLESS) {
8180
val hintPhNo = hintEmailEditText.text.toString()
8281
if (hintPhNo.isBlank() || !hintPhNo.isPhoneNumberValid()) {
8382
Toast.makeText(this, "Please enter a valid Number.", Toast.LENGTH_LONG).show()
@@ -224,14 +223,14 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
224223
val launchWalletButton = findViewById<Button>(R.id.launchWalletButton)
225224
launchWalletButton.setOnClickListener {
226225
val launchWalletCompletableFuture = web3Auth.showWalletUI(
227-
chainId = "0x89",
228226
chainConfig = listOf(
229227
ChainsConfig(
230228
chainId = "0x89",
231229
rpcTarget = "https://1rpc.io/matic",
232230
chainNamespace = ChainNamespace.EIP155
233231
)
234-
)
232+
),
233+
chainId = "0x89",
235234
)
236235
launchWalletCompletableFuture.whenComplete { _, error ->
237236
if (error == null) {
@@ -319,13 +318,13 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
319318

320319
val hintEmailEditText = findViewById<EditText>(R.id.etEmailHint)
321320

322-
if (selectedLoginProvider == AUTH_CONNECTION.EMAIL_PASSWORDLESS) {
321+
if (selectedLoginProvider == AuthConnection.EMAIL_PASSWORDLESS) {
323322
hintEmailEditText.hint = "Enter Email"
324-
} else if (selectedLoginProvider == AUTH_CONNECTION.SMS_PASSWORDLESS) {
323+
} else if (selectedLoginProvider == AuthConnection.SMS_PASSWORDLESS) {
325324
hintEmailEditText.hint = "Enter Phone Number"
326325
}
327326

328-
if (selectedLoginProvider == AUTH_CONNECTION.EMAIL_PASSWORDLESS || selectedLoginProvider == AUTH_CONNECTION.SMS_PASSWORDLESS) {
327+
if (selectedLoginProvider == AuthConnection.EMAIL_PASSWORDLESS || selectedLoginProvider == AuthConnection.SMS_PASSWORDLESS) {
329328
hintEmailEditText.visibility = View.VISIBLE
330329
} else {
331330
hintEmailEditText.visibility = View.GONE

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,8 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
520520
* @return A CompletableFuture<Void> representing the asynchronous operation.
521521
*/
522522
fun showWalletUI(
523-
chainId: String,
524523
chainConfig: List<ChainsConfig>,
524+
chainId: String,
525525
path: String? = "wallet",
526526
): CompletableFuture<Void> {
527527
val launchWalletServiceCF: CompletableFuture<Void> = CompletableFuture()

core/src/main/java/com/web3auth/core/types/Provider.kt renamed to core/src/main/java/com/web3auth/core/types/AuthConnection.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import androidx.annotation.Keep
44
import com.google.gson.annotations.SerializedName
55

66
@Keep
7-
enum class AUTH_CONNECTION {
7+
enum class AuthConnection {
88
@SerializedName("google")
99
GOOGLE,
1010

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import androidx.annotation.Keep
55

66
@Keep
77
data class LoginParams(
8-
@Keep val authConnection: AUTH_CONNECTION,
8+
@Keep val authConnection: AuthConnection,
99
@Keep var dappShare: String? = null,
1010
@Keep val extraLoginOptions: ExtraLoginOptions? = null,
1111
@Keep @Transient var redirectUrl: Uri? = null,

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

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)