Skip to content

Commit 308eb43

Browse files
committed
feat: mid commit.
Signed-off-by: Gaurav Goel <[email protected]>
1 parent 8cd60bf commit 308eb43

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

android/android-firebase-example/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ dependencies {
3737
implementation 'com.google.android.material:material:1.7.0'
3838
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
3939
implementation 'com.google.code.gson:gson:2.9.1'
40-
implementation 'com.github.grvgoel81:web3auth-android-sdk:0.0.6'
40+
implementation 'com.github.grvgoel81:web3auth-android-sdk:0.0.0.2'
4141
implementation 'org.web3j:core:4.8.7-android'
4242
implementation platform('com.google.firebase:firebase-bom:31.0.2')
4343
implementation 'com.google.firebase:firebase-auth-ktx'

android/android-firebase-example/app/src/main/java/com/sbz/web3authdemoapp/MainActivity.kt

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,19 @@ import com.google.firebase.auth.ktx.auth
1616
import com.google.firebase.ktx.Firebase
1717
import com.google.gson.Gson
1818
import com.web3auth.core.Web3Auth
19-
import com.web3auth.core.types.*
19+
import com.web3auth.core.types.AuthConnection
20+
import com.web3auth.core.types.AuthConnectionConfig
21+
import com.web3auth.core.types.BuildEnv
22+
import com.web3auth.core.types.ChainConfig
23+
import com.web3auth.core.types.ChainNamespace
24+
import com.web3auth.core.types.ExtraLoginOptions
25+
import com.web3auth.core.types.LoginParams
26+
import com.web3auth.core.types.MfaSetting
27+
import com.web3auth.core.types.MfaSettings
28+
import com.web3auth.core.types.UserInfo
29+
import com.web3auth.core.types.Web3AuthNetwork
30+
import com.web3auth.core.types.Web3AuthOptions
31+
import com.web3auth.core.types.Web3AuthResponse
2032
import org.web3j.crypto.Credentials
2133
import org.web3j.crypto.Hash
2234
import org.web3j.crypto.RawTransaction
@@ -56,15 +68,15 @@ class MainActivity : AppCompatActivity() {
5668
authConnectionConfig.add(
5769
AuthConnectionConfig(
5870
authConnectionId = "w3a-firebase-demo",
59-
authConnection = AuthConnection.JWT,
71+
authConnection = AuthConnection.CUSTOM,
6072
clientId = getString(R.string.web3auth_project_id),
6173
)
6274
)
6375

6476
web3Auth = Web3Auth(
6577
Web3AuthOptions(
6678
clientId = getString(R.string.web3auth_project_id), // pass over your Web3Auth Client ID from Developer Dashboard
67-
network = Network.SAPPHIRE_MAINNET, // pass over the network you want to use (MAINNET or TESTNET or CYAN, AQUA, SAPPHIRE_MAINNET or SAPPHIRE_TESTNET)
79+
web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET, // pass over the network you want to use (MAINNET or TESTNET or CYAN, AQUA, SAPPHIRE_MAINNET or SAPPHIRE_TESTNET)
6880
authBuildEnv = BuildEnv.TESTING,
6981
redirectUrl = Uri.parse("com.sbz.web3authdemoapp://auth"), // your app's redirect URL
7082
mfaSettings = MfaSettings(
@@ -156,8 +168,15 @@ class MainActivity : AppCompatActivity() {
156168
val idToken = result.token
157169
//Do whatever
158170
Log.d(TAG, "GetTokenResult result = $idToken")
159-
val authConnection = AuthConnection.JWT
160-
val loginParams = LoginParams(authConnection, extraLoginOptions = ExtraLoginOptions(domain= "firebase", id_token = idToken, verifierIdField = "sub"))
171+
val authConnection = AuthConnection.CUSTOM
172+
val loginParams = LoginParams(
173+
authConnection,
174+
extraLoginOptions = ExtraLoginOptions(
175+
domain = "firebase",
176+
id_token = idToken,
177+
verifierIdField = "sub"
178+
)
179+
)
161180
val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.login(loginParams)
162181

163182
loginCompletableFuture.whenComplete { _, error ->
@@ -210,14 +229,14 @@ class MainActivity : AppCompatActivity() {
210229
}
211230

212231
private fun prepareLoginParams(result: GetTokenResult): LoginParams {
213-
val authConnection = AuthConnection.JWT
232+
val authConnection = AuthConnection.CUSTOM
214233
return LoginParams(authConnection, extraLoginOptions = ExtraLoginOptions(domain= "firebase", id_token = result.token, verifierIdField = "sub"))
215234
}
216235

217236
private fun launchWalletServices() {
218-
val chainsConfig = ArrayList<ChainsConfig>()
237+
val chainsConfig = ArrayList<ChainConfig>()
219238
chainsConfig.add(
220-
ChainsConfig(
239+
ChainConfig(
221240
chainId = "0x1",
222241
rpcTarget = "https://1rpc.io/eth",
223242
ticker = "ETH",

0 commit comments

Comments
 (0)