Skip to content

Commit 512c61b

Browse files
committed
Use contextWrapper to use context everywhere.
Signed-off-by: Gaurav Goel <[email protected]>
1 parent 9735f1c commit 512c61b

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
145145
Uri.Builder().scheme(sdkUrl.scheme).encodedAuthority(sdkUrl.encodedAuthority)
146146
.encodedPath(sdkUrl.encodedPath).appendPath("start").fragment(hash).build()
147147
//print("url: => $url")
148-
val intent = Intent(this, CustomChromeTabsActivity::class.java)
148+
val intent = Intent(baseContext, CustomChromeTabsActivity::class.java)
149149
intent.putExtra(WEBVIEW_URL, url.toString())
150-
this.startActivity(intent)
150+
baseContext.startActivity(intent)
151151
}
152152
}
153153
}
@@ -159,7 +159,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
159159
*/
160160
fun initialize(): CompletableFuture<Void> {
161161
val initializeCf = CompletableFuture<Void>()
162-
KeyStoreManagerUtils.initializePreferences(this.applicationContext)
162+
KeyStoreManagerUtils.initializePreferences(baseContext.applicationContext)
163163

164164
//initiate keyStore
165165
initiateKeyStoreManager()
@@ -169,7 +169,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
169169
if (err == null) {
170170
//authorize session
171171
sessionManager.setSessionId(SessionManager.getSessionIdFromStorage())
172-
this.authorizeSession(web3AuthOption.redirectUrl.toString(), this)
172+
this.authorizeSession(web3AuthOption.redirectUrl.toString(), baseContext)
173173
.whenComplete { resp, error ->
174174
runOnUIThread {
175175
if (error == null) {
@@ -225,7 +225,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
225225
sessionManager.setSessionId(sessionId)
226226

227227
//Rehydrate Session
228-
this.authorizeSession(web3AuthOption.redirectUrl.toString(), this)
228+
this.authorizeSession(web3AuthOption.redirectUrl.toString(), baseContext)
229229
.whenComplete { resp, error ->
230230
runOnUIThread {
231231
if (error == null) {
@@ -295,7 +295,8 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
295295
*/
296296
fun logout(): CompletableFuture<Void> {
297297
val logoutCompletableFuture: CompletableFuture<Void> = CompletableFuture()
298-
val sessionResponse: CompletableFuture<Boolean>? = sessionManager.invalidateSession(this)
298+
val sessionResponse: CompletableFuture<Boolean>? =
299+
sessionManager.invalidateSession(baseContext)
299300
sessionResponse?.whenComplete { _, error ->
300301
SessionManager.deleteSessionIdFromStorage()
301302
runOnUIThread {
@@ -387,7 +388,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
387388
val projectConfigCompletableFuture: CompletableFuture<Boolean> = CompletableFuture()
388389
val web3AuthApi =
389390
ApiHelper.getInstance(web3AuthOption.network.name).create(ApiService::class.java)
390-
if (!ApiHelper.isNetworkAvailable(this)) {
391+
if (!ApiHelper.isNetworkAvailable(baseContext)) {
391392
throw Exception(
392393
Web3AuthError.getError(ErrorCode.RUNTIME_ERROR)
393394
)
@@ -447,7 +448,7 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
447448
sessionManager.setSessionId(sessionId)
448449
return sessionManager.createSession(
449450
jsonObject.toString(),
450-
this,
451+
baseContext,
451452
)
452453
}
453454

@@ -498,9 +499,9 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
498499
.encodedPath(sdkUrl.encodedPath).appendPath(path)
499500
.fragment(walletHash).build()
500501
//print("wallet launch url: => $url")
501-
val intent = Intent(this, WebViewActivity::class.java)
502+
val intent = Intent(baseContext, WebViewActivity::class.java)
502503
intent.putExtra(WEBVIEW_URL, url.toString())
503-
this.startActivity(intent)
504+
baseContext.startActivity(intent)
504505
launchWalletServiceCF.complete(null)
505506
}
506507
}
@@ -565,10 +566,10 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions, context: Context) : WebViewResu
565566
.encodedPath(sdkUrl.encodedPath).appendEncodedPath(path)
566567
.fragment(signMessageHash).build()
567568
//print("message signing url: => $url")
568-
val intent = Intent(this, WebViewActivity::class.java)
569+
val intent = Intent(baseContext, WebViewActivity::class.java)
569570
intent.putExtra(WEBVIEW_URL, url.toString())
570571
intent.putExtra(REDIRECT_URL, web3AuthOption.redirectUrl.toString())
571-
this.startActivity(intent)
572+
baseContext.startActivity(intent)
572573
}
573574
}
574575
} else {

0 commit comments

Comments
 (0)