@@ -12,11 +12,13 @@ import androidx.appcompat.app.AppCompatActivity
1212import com.google.gson.Gson
1313import com.web3auth.core.Web3Auth
1414import com.web3auth.core.types.*
15+ import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork
1516import org.web3j.crypto.Credentials
1617import org.web3j.crypto.Hash
1718import org.web3j.crypto.RawTransaction
1819import org.web3j.crypto.Sign
1920import org.web3j.crypto.TransactionEncoder
21+ import org.web3j.protocol.Network
2022import org.web3j.protocol.Web3j
2123import org.web3j.protocol.core.DefaultBlockParameterName
2224import org.web3j.protocol.core.methods.response.EthChainId
@@ -43,47 +45,34 @@ class MainActivity : AppCompatActivity() {
4345 setContentView(R .layout.activity_main)
4446 web3 = Web3j .build(HttpService (rpcUrl))
4547
48+ val authConnectionConfig = ArrayList <AuthConnectionConfig >()
49+ authConnectionConfig.add(
50+ AuthConnectionConfig (
51+ authConnectionId = " w3a-google" ,
52+ groupedAuthConnectionId = " aggregate-sapphire" ,
53+ authConnection = AuthConnection .GOOGLE ,
54+ clientId = getString(R .string.web3auth_google_client_id),
55+ )
56+ )
57+
58+ authConnectionConfig.add(
59+ AuthConnectionConfig (
60+ authConnectionId = " w3a-a0-email-passwordless" ,
61+ groupedAuthConnectionId = " aggregate-sapphire" ,
62+ authConnection = AuthConnection .CUSTOM ,
63+ clientId = getString(R .string.web3auth_auth0_client_id),
64+ )
65+ )
66+
4667 web3Auth = Web3Auth (
4768 Web3AuthOptions (
4869 clientId = getString(R .string.web3auth_project_id), // pass over your Web3Auth Client ID from Developer Dashboard
49- network = Network .SAPPHIRE_MAINNET , // pass over the network you want to use (MAINNET or TESTNET or CYAN, AQUA, SAPPHIRE_MAINNET or SAPPHIRE_TESTNET)
50- buildEnv = BuildEnv .PRODUCTION ,
51- redirectUrl = Uri .parse(" com.sbz.web3authdemoapp://auth" ), // your app's redirect URL
52- whiteLabel = WhiteLabelData (
53- " Web3Auth Android Example" ,
54- null ,
55- " https://cryptologos.cc/logos/ethereum-eth-logo.png" ,
56- " https://cryptologos.cc/logos/ethereum-eth-logo.png" ,
57- Language .EN ,
58- ThemeModes .LIGHT ,
59- true ,
60- hashMapOf(
61- " primary" to " #eb5424"
62- )
63- ),
64- mfaSettings = MfaSettings (
65- deviceShareFactor = MfaSetting (true , 1 , true ),
66- socialBackupFactor = MfaSetting (true , 2 , true ),
67- passwordFactor = MfaSetting (true , 3 , false ),
68- backUpShareFactor = MfaSetting (true , 4 , false ),
69- ),
70- loginConfig = hashMapOf(
71- " google" to LoginConfigItem (
72- verifier = " aggregate-sapphire" ,
73- verifierSubIdentifier= " w3a-google" ,
74- typeOfLogin = TypeOfLogin .GOOGLE ,
75- name = " Aggregate Login" ,
76- clientId = getString(R .string.web3auth_google_client_id)
77- ),
78- " jwt" to LoginConfigItem (
79- verifier = " aggregate-sapphire" ,
80- verifierSubIdentifier= " w3a-a0-email-passwordless" ,
81- typeOfLogin = TypeOfLogin .JWT ,
82- name = " Aggregate Login" ,
83- clientId = getString(R .string.web3auth_auth0_client_id)
84- )
85- )
70+ web3AuthNetwork = Web3AuthNetwork .SAPPHIRE_MAINNET , // pass over the network you want to use (MAINNET or TESTNET or CYAN, AQUA, SAPPHIRE_MAINNET or SAPPHIRE_TESTNET)
71+ authBuildEnv = BuildEnv .PRODUCTION ,
72+ redirectUrl = " com.sbz.web3authdemoapp://auth" , // your app's redirect URL
73+ authConnectionConfig = ArrayList <AuthConnectionConfig >()
8674 ), context = this
75+
8776 )
8877
8978 // Handle user signing in when app is not alive
@@ -94,10 +83,10 @@ class MainActivity : AppCompatActivity() {
9483 sessionResponse.whenComplete { _, error ->
9584 if (error == null ) {
9685 reRender()
97- println (" PrivKey: " + web3Auth.getPrivkey ())
98- println (" ed25519PrivKey: " + web3Auth.getEd25519PrivKey ())
86+ println (" PrivKey: " + web3Auth.getPrivateKey ())
87+ println (" ed25519PrivKey: " + web3Auth.getEd25519PrivateKey ())
9988 println (" Web3Auth UserInfo" + web3Auth.getUserInfo())
100- credentials = Credentials .create(web3Auth.getPrivkey ())
89+ credentials = Credentials .create(web3Auth.getPrivateKey ())
10190 Log .d(" MainActivity_Web3Auth" , web3Auth.getUserInfo().toString())
10291 } else {
10392 Log .d(" MainActivity_Web3Auth" , error.message ? : " Something went wrong" )
@@ -158,12 +147,23 @@ class MainActivity : AppCompatActivity() {
158147 }
159148
160149 private fun signInEP () {
161- val selectedLoginProvider = Provider .JWT
162- val loginCompletableFuture: CompletableFuture <Web3AuthResponse > = web3Auth.login(LoginParams (selectedLoginProvider, extraLoginOptions = ExtraLoginOptions (domain = " https://web3auth.au.auth0.com" , verifierIdField = " email" , isVerifierIdCaseSensitive = false )))
150+ val selectedLoginProvider = AuthConnection .CUSTOM
151+ val loginCompletableFuture: CompletableFuture <Web3AuthResponse > = web3Auth.connectTo(
152+ LoginParams (
153+ selectedLoginProvider,
154+ authConnectionId = " w3a-a0-email-passwordless" ,
155+ groupedAuthConnectionId = " aggregate-sapphire" ,
156+ extraLoginOptions = ExtraLoginOptions (
157+ domain = " https://web3auth.au.auth0.com" ,
158+ userIdField = " email" ,
159+ isUserIdCaseSensitive = false
160+ )
161+ )
162+ )
163163
164164 loginCompletableFuture.whenComplete { _, error ->
165165 if (error == null ) {
166- credentials = Credentials .create(web3Auth.getPrivkey ())
166+ credentials = Credentials .create(web3Auth.getPrivateKey ())
167167 reRender()
168168 } else {
169169 Log .d(" MainActivity_Web3Auth" , error.message ? : " Something went wrong" )
@@ -172,12 +172,13 @@ class MainActivity : AppCompatActivity() {
172172 }
173173
174174 private fun signInGoogle () {
175- val selectedLoginProvider = Provider .GOOGLE
176- val loginCompletableFuture: CompletableFuture <Web3AuthResponse > = web3Auth.login(LoginParams (selectedLoginProvider))
175+ val selectedLoginProvider = AuthConnection .GOOGLE
176+ val loginCompletableFuture: CompletableFuture <Web3AuthResponse > =
177+ web3Auth.connectTo(LoginParams (selectedLoginProvider, authConnectionId = " w3a-google" , groupedAuthConnectionId = " aggregate-sapphire" ))
177178
178179 loginCompletableFuture.whenComplete { _, error ->
179180 if (error == null ) {
180- credentials = Credentials .create(web3Auth.getPrivkey ())
181+ credentials = Credentials .create(web3Auth.getPrivateKey ())
181182 reRender()
182183 } else {
183184 Log .d(" MainActivity_Web3Auth" , error.message ? : " Something went wrong" )
@@ -200,23 +201,23 @@ class MainActivity : AppCompatActivity() {
200201 }
201202
202203 private fun prepareLoginParams (): LoginParams {
203- val loginParams = if (web3Auth.getUserInfo()!! .typeOfLogin == TypeOfLogin .GOOGLE .name) {
204- LoginParams (Provider .GOOGLE )
204+ val loginParams = if (web3Auth.getUserInfo()!! .authConnection == AuthConnection .GOOGLE .name) {
205+ LoginParams (AuthConnection .GOOGLE )
205206 } else {
206- LoginParams (Provider .JWT , extraLoginOptions = ExtraLoginOptions (domain = " https://web3auth.au.auth0.com" , verifierIdField = " email" , isVerifierIdCaseSensitive = false ))
207+ LoginParams (
208+ AuthConnection .CUSTOM ,
209+ extraLoginOptions = ExtraLoginOptions (
210+ domain = " https://web3auth.au.auth0.com" ,
211+ userIdField = " email" ,
212+ isUserIdCaseSensitive = false
213+ )
214+ )
207215 }
208216 return loginParams
209217 }
210218
211219 private fun launchWalletServices () {
212- val completableFuture = web3Auth.launchWalletServices(
213- ChainConfig (
214- chainId = " 0x1" ,
215- rpcTarget = " https://1rpc.io/eth" ,
216- ticker = " ETH" ,
217- chainNamespace = ChainNamespace .EIP155
218- )
219- )
220+ val completableFuture = web3Auth.showWalletUI()
220221
221222 completableFuture.whenComplete{_, error ->
222223 if (error == null ) {
@@ -320,7 +321,7 @@ class MainActivity : AppCompatActivity() {
320321 var key: String? = null
321322 var userInfo: UserInfo ? = null
322323 try {
323- key = web3Auth.getPrivkey ()
324+ key = web3Auth.getPrivateKey ()
324325 userInfo = web3Auth.getUserInfo()
325326 } catch (ex: Exception ) {
326327 print (ex)
0 commit comments