Skip to content

Commit f127281

Browse files
Merge pull request #96 from Web3Auth/feat/update-session-manager-changes
feat: updates session manager sdk and related changes.
2 parents fec8e3d + 512c61b commit f127281

File tree

13 files changed

+284
-225
lines changed

13 files changed

+284
-225
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ android {
1212
keyPassword 'torus123'
1313
}
1414
}
15-
compileSdkVersion 34
15+
compileSdk 34
1616

1717
defaultConfig {
1818
applicationId "com.web3auth.app"
19-
minSdkVersion 24
19+
minSdkVersion 26
2020
targetSdkVersion 34
2121
versionCode 1
2222
versionName "1.0"

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

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
122122
val signOutButton = findViewById<Button>(R.id.signOutButton)
123123
val launchWalletButton = findViewById<Button>(R.id.launchWalletButton)
124124
val signMsgButton = findViewById<Button>(R.id.signMsgButton)
125-
val signResultButton = findViewById<Button>(R.id.signResultButton)
126125
val btnSetUpMfa = findViewById<Button>(R.id.btnSetUpMfa)
127126
val spinner = findViewById<TextInputLayout>(R.id.verifierList)
128127
val hintEmailEditText = findViewById<EditText>(R.id.etEmailHint)
@@ -135,6 +134,7 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
135134
print(ex)
136135
}
137136

137+
138138
if (userInfo != null) {
139139
val jsonObject = JSONObject(gson.toJson(web3Auth.getWeb3AuthResponse()))
140140
contentTextView.text = jsonObject.toString(4) + "\n Private Key: " + key
@@ -155,7 +155,6 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
155155
btnSetUpMfa.visibility = View.GONE
156156
launchWalletButton.visibility = View.GONE
157157
signMsgButton.visibility = View.GONE
158-
signResultButton.visibility = View.GONE
159158
spinner.visibility = View.VISIBLE
160159
}
161160
}
@@ -165,7 +164,6 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
165164
setContentView(R.layout.activity_main)
166165

167166
val options = Web3AuthOptions(
168-
context = this,
169167
clientId = "BFuUqebV5I8Pz5F7a5A2ihW7YVmbv_OHXnHYDv6OltAD5NGr6e-ViNvde3U4BHdn6HvwfkgobhVu4VwC-OSJkik",
170168
network = Network.SAPPHIRE_DEVNET,
171169
redirectUrl = Uri.parse("torusapp://org.torusresearch.web3authexample"),
@@ -186,15 +184,15 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
186184
clientId = "d84f6xvbdV75VTGmHiMWfZLeSPk8M07C",
187185
)
188186
),
189-
buildEnv = BuildEnv.TESTING,
187+
buildEnv = BuildEnv.PRODUCTION,
190188
sessionTime = 86400,
191189
)
192190

193191
println("params: $options")
194192

195193
// Configure Web3Auth
196194
web3Auth = Web3Auth(
197-
options
195+
options, this
198196
)
199197

200198
web3Auth.setResultUrl(intent.data)
@@ -237,7 +235,6 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
237235
}
238236
}
239237

240-
val signResultButton = findViewById<Button>(R.id.signResultButton)
241238
val signMsgButton = findViewById<Button>(R.id.signMsgButton)
242239
signMsgButton.setOnClickListener {
243240
val credentials: Credentials = Credentials.create(web3Auth.getPrivkey())
@@ -251,24 +248,17 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
251248
chainId = "0x89",
252249
rpcTarget = "https://polygon-rpc.com/",
253250
chainNamespace = ChainNamespace.EIP155
254-
), "personal_sign", requestParams = params
251+
), "personal_sign", requestParams = params, appState = "web3Auth"
255252
)
256-
signMsgCompletableFuture.whenComplete { _, error ->
253+
signMsgCompletableFuture.whenComplete { signResult, error ->
257254
if (error == null) {
258-
Log.d("MainActivity_Web3Auth", "Message signed successfully")
259-
signResultButton.visibility = View.VISIBLE
255+
showAlertDialog("Sign Result", signResult.toString())
260256
} else {
261257
Log.d("MainActivity_Web3Auth", error.message ?: "Something went wrong")
262-
signResultButton.visibility = View.GONE
263258
}
264259
}
265260
}
266261

267-
signResultButton.setOnClickListener {
268-
val signResult = Web3Auth.getSignResponse()
269-
showAlertDialog("Sign Result", signResult.toString())
270-
}
271-
272262
val btnSetUpMfa = findViewById<Button>(R.id.btnSetUpMfa)
273263
btnSetUpMfa.setOnClickListener {
274264
val setupMfaCf = web3Auth.enableMFA()

app/src/main/res/layout/activity_main.xml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,6 @@
103103
app:layout_constraintStart_toStartOf="parent"
104104
app:layout_constraintTop_toBottomOf="@+id/launchWalletButton" />
105105

106-
<Button
107-
android:id="@+id/signResultButton"
108-
android:layout_width="wrap_content"
109-
android:layout_height="wrap_content"
110-
android:layout_marginEnd="10dp"
111-
android:text="@string/sign_result"
112-
android:textAllCaps="false"
113-
android:visibility="gone"
114-
app:layout_constraintEnd_toEndOf="parent"
115-
app:layout_constraintStart_toStartOf="parent"
116-
app:layout_constraintTop_toBottomOf="@+id/signMsgButton" />
117-
118106
<Button
119107
android:id="@+id/btnSetUpMfa"
120108
android:layout_width="wrap_content"

core/build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ plugins {
55
}
66

77
android {
8-
compileSdkVersion 34
8+
compileSdk 34
99

1010
defaultConfig {
11-
minSdkVersion 24
11+
minSdkVersion 26
1212
targetSdkVersion 34
1313

1414
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -51,7 +51,7 @@ dependencies {
5151
implementation 'androidx.browser:browser:1.6.0'
5252

5353
// Encoding
54-
implementation 'com.google.code.gson:gson:2.9.1'
54+
implementation 'com.google.code.gson:gson:2.10.1'
5555

5656
// retrofit
5757
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
@@ -69,14 +69,14 @@ dependencies {
6969
implementation 'org.web3j:core:4.8.8-android'
7070

7171
//session-manager-sdk
72-
implementation 'com.github.Web3Auth:session-manager-android:1.3.0'
72+
implementation 'com.github.Web3Auth:session-manager-android:3.0.0'
7373

7474
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01"
7575

7676
// Test
7777
testImplementation 'junit:junit:4.+'
78-
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
79-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
78+
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
79+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
8080
}
8181

8282
project.afterEvaluate {

0 commit comments

Comments
 (0)