Skip to content

Commit 602c0ed

Browse files
committed
enableMFA flow
1 parent 9076a4c commit 602c0ed

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

android-quick-start/app/src/main/java/com/sbz/web3authdemoapp/MainActivity.kt

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
package com.sbz.web3authdemoapp
33

4+
// IMP START - Quick Start
5+
// IMP END - Quick Start
46
import android.content.Intent
57
import android.os.Bundle
68
import android.util.Log
@@ -12,10 +14,14 @@ import android.widget.Toast
1214
import androidx.appcompat.app.AppCompatActivity
1315
import com.google.gson.Gson
1416
import com.google.gson.JsonArray
15-
// IMP START - Quick Start
1617
import com.web3auth.core.Web3Auth
17-
// IMP END - Quick Start
18-
import com.web3auth.core.types.*
18+
import com.web3auth.core.types.AuthConnection
19+
import com.web3auth.core.types.EmailFlowType
20+
import com.web3auth.core.types.ExtraLoginOptions
21+
import com.web3auth.core.types.LoginParams
22+
import com.web3auth.core.types.UserInfo
23+
import com.web3auth.core.types.Web3AuthOptions
24+
import com.web3auth.core.types.Web3AuthResponse
1925
import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork
2026
import org.web3j.crypto.Credentials
2127
import org.web3j.crypto.Hash
@@ -108,6 +114,18 @@ class MainActivity : AppCompatActivity() {
108114
}
109115
getAddressButton.visibility = View.GONE
110116

117+
val enableMFABtn = findViewById<Button>(R.id.enableMFA)
118+
enableMFABtn.setOnClickListener {
119+
val enableMfaCf = web3Auth.enableMFA()
120+
enableMfaCf.whenComplete { _, error ->
121+
if (error == null) {
122+
Log.d("MainActivity_Web3Auth", "MFA setup successfully")
123+
} else {
124+
Log.d("MainActivity_Web3Auth", error.message ?: "Something went wrong")
125+
}
126+
}
127+
}
128+
111129
val getBalanceButton = findViewById<Button>(R.id.getBalance)
112130
getBalanceButton.setOnClickListener { getBalance() }
113131
getBalanceButton.visibility = View.GONE
@@ -119,6 +137,8 @@ class MainActivity : AppCompatActivity() {
119137
val getTransactionButton = findViewById<Button>(R.id.getTransaction)
120138
getTransactionButton.setOnClickListener { sendTransaction(0.001, "0xeaA8Af602b2eDE45922818AE5f9f7FdE50cFa1A8") }
121139
getTransactionButton.visibility = View.GONE
140+
141+
122142
}
123143

124144
override fun onNewIntent(intent: Intent?) {

android-quick-start/app/src/main/res/layout/activity_main.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@
6767
android:layout_height="wrap_content"
6868
android:text="@string/balance" />
6969

70+
<Button
71+
android:id="@+id/enableMFA"
72+
android:layout_width="match_parent"
73+
android:layout_height="wrap_content"
74+
android:text="EnableMFA" />
75+
7076
<Button
7177
android:id="@+id/getTransaction"
7278
android:layout_width="match_parent"

0 commit comments

Comments
 (0)