Skip to content

Commit cf5e125

Browse files
committed
feat: code refactored
Signed-off-by: Gaurav Goel <[email protected]>
1 parent bc36812 commit cf5e125

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import com.web3auth.core.types.REDIRECT_URL
2323
import com.web3auth.core.types.RequestData
2424
import com.web3auth.core.types.SessionResponse
2525
import com.web3auth.core.types.SignMessage
26+
import com.web3auth.core.types.SignResponse
2627
import com.web3auth.core.types.UnKnownException
2728
import com.web3auth.core.types.UserCancelledException
2829
import com.web3auth.core.types.UserInfo
@@ -45,7 +46,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
4546

4647
private lateinit var loginCompletableFuture: CompletableFuture<Web3AuthResponse>
4748
private lateinit var enableMfaCompletableFuture: CompletableFuture<Boolean>
48-
private lateinit var signMsgCF: CompletableFuture<JsonObject>
49+
private lateinit var signMsgCF: CompletableFuture<SignResponse>
4950

5051
private var web3AuthResponse: Web3AuthResponse? = null
5152
private var web3AuthOption = web3AuthOptions
@@ -517,7 +518,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
517518
path: String? = "wallet/request",
518519
appState: String? = null,
519520
context: Context,
520-
): CompletableFuture<JsonObject> {
521+
): CompletableFuture<SignResponse> {
521522
signMsgCF = CompletableFuture()
522523
WebViewActivity.webViewResultCallback = this
523524

@@ -676,7 +677,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
676677
}
677678
}
678679

679-
override fun onSignResponseReceived(signResponse: JsonObject?) {
680+
override fun onSignResponseReceived(signResponse: SignResponse?) {
680681
if (signResponse != null) {
681682
signMsgCF.complete(signResponse)
682683
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import android.webkit.WebViewClient
1515
import androidx.appcompat.app.AppCompatActivity
1616
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
1717
import com.google.gson.GsonBuilder
18-
import com.google.gson.JsonObject
1918
import com.web3auth.core.types.REDIRECT_URL
19+
import com.web3auth.core.types.SignResponse
2020
import com.web3auth.core.types.WEBVIEW_URL
2121
import com.web3auth.core.types.WebViewResultCallback
2222

@@ -54,7 +54,7 @@ class WebViewActivity : AppCompatActivity() {
5454
val b64ParamString =
5555
decodeBase64URLString(b64Params!!).toString(Charsets.UTF_8)
5656
val signResponse =
57-
gson.fromJson(b64ParamString, JsonObject::class.java)
57+
gson.fromJson(b64ParamString, SignResponse::class.java)
5858
webViewResultCallback?.onSignResponseReceived(signResponse)
5959
finish()
6060
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.web3auth.core.types
22

3-
import com.google.gson.JsonObject
4-
53
interface WebViewResultCallback {
6-
fun onSignResponseReceived(signResponse: JsonObject?)
4+
fun onSignResponseReceived(signResponse: SignResponse?)
75
fun onWebViewCancelled()
86
}

0 commit comments

Comments
 (0)