Skip to content

Commit 8cd60bf

Browse files
update mobile examples
1 parent 0862c5c commit 8cd60bf

File tree

27 files changed

+96
-169
lines changed

27 files changed

+96
-169
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.web3auth:web3auth-android-sdk:9.0.4'
40+
implementation 'com.github.grvgoel81:web3auth-android-sdk:0.0.6'
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: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ import android.widget.TextView
1111
import android.widget.Toast
1212
import androidx.appcompat.app.AppCompatActivity
1313
import com.google.firebase.auth.FirebaseAuth
14-
import com.google.firebase.auth.FirebaseUser
1514
import com.google.firebase.auth.GetTokenResult
1615
import com.google.firebase.auth.ktx.auth
1716
import com.google.firebase.ktx.Firebase
1817
import com.google.gson.Gson
19-
import com.google.gson.JsonArray
2018
import com.web3auth.core.Web3Auth
2119
import com.web3auth.core.types.*
2220
import org.web3j.crypto.Credentials
@@ -54,37 +52,28 @@ class MainActivity : AppCompatActivity() {
5452
auth = Firebase.auth
5553
web3 = Web3j.build(HttpService(rpcUrl))
5654

55+
val authConnectionConfig = ArrayList<AuthConnectionConfig>()
56+
authConnectionConfig.add(
57+
AuthConnectionConfig(
58+
authConnectionId = "w3a-firebase-demo",
59+
authConnection = AuthConnection.JWT,
60+
clientId = getString(R.string.web3auth_project_id),
61+
)
62+
)
63+
5764
web3Auth = Web3Auth(
5865
Web3AuthOptions(
5966
clientId = getString(R.string.web3auth_project_id), // pass over your Web3Auth Client ID from Developer Dashboard
6067
network = Network.SAPPHIRE_MAINNET, // pass over the network you want to use (MAINNET or TESTNET or CYAN, AQUA, SAPPHIRE_MAINNET or SAPPHIRE_TESTNET)
61-
buildEnv = BuildEnv.PRODUCTION,
68+
authBuildEnv = BuildEnv.TESTING,
6269
redirectUrl = Uri.parse("com.sbz.web3authdemoapp://auth"), // your app's redirect URL
63-
// Optional parameters
64-
whiteLabel = WhiteLabelData(
65-
"Web3Auth Android FireBase Example",
66-
null,
67-
"https://cryptologos.cc/logos/ethereum-eth-logo.png",
68-
"https://cryptologos.cc/logos/ethereum-eth-logo.png",
69-
Language.EN,
70-
ThemeModes.LIGHT,
71-
true,
72-
hashMapOf(
73-
"primary" to "#eb5424"
74-
)
75-
),
7670
mfaSettings = MfaSettings(
7771
deviceShareFactor = MfaSetting(true, 1, true),
7872
socialBackupFactor = MfaSetting(true, 2, true),
7973
passwordFactor = MfaSetting(true, 3, false),
8074
backUpShareFactor = MfaSetting(true, 4, false),
8175
),
82-
loginConfig = hashMapOf("jwt" to LoginConfigItem(
83-
verifier = "w3a-firebase-demo",
84-
typeOfLogin = TypeOfLogin.JWT,
85-
name = "Firebase login",
86-
clientId = getString(R.string.web3auth_project_id)
87-
))
76+
authConnectionConfig = authConnectionConfig
8877
), context = this
8978
)
9079

@@ -167,8 +156,8 @@ class MainActivity : AppCompatActivity() {
167156
val idToken = result.token
168157
//Do whatever
169158
Log.d(TAG, "GetTokenResult result = $idToken")
170-
val selectedLoginProvider = Provider.JWT
171-
val loginParams = LoginParams(selectedLoginProvider, extraLoginOptions = ExtraLoginOptions(domain= "firebase", id_token = idToken, verifierIdField = "sub"))
159+
val authConnection = AuthConnection.JWT
160+
val loginParams = LoginParams(authConnection, extraLoginOptions = ExtraLoginOptions(domain= "firebase", id_token = idToken, verifierIdField = "sub"))
172161
val loginCompletableFuture: CompletableFuture<Web3AuthResponse> = web3Auth.login(loginParams)
173162

174163
loginCompletableFuture.whenComplete { _, error ->
@@ -221,19 +210,24 @@ class MainActivity : AppCompatActivity() {
221210
}
222211

223212
private fun prepareLoginParams(result: GetTokenResult): LoginParams {
224-
val selectedLoginProvider = Provider.JWT
225-
return LoginParams(selectedLoginProvider, extraLoginOptions = ExtraLoginOptions(domain= "firebase", id_token = result.token, verifierIdField = "sub"))
213+
val authConnection = AuthConnection.JWT
214+
return LoginParams(authConnection, extraLoginOptions = ExtraLoginOptions(domain= "firebase", id_token = result.token, verifierIdField = "sub"))
226215
}
227216

228217
private fun launchWalletServices() {
229-
val completableFuture = web3Auth.launchWalletServices(
230-
ChainConfig(
218+
val chainsConfig = ArrayList<ChainsConfig>()
219+
chainsConfig.add(
220+
ChainsConfig(
231221
chainId = "0x1",
232222
rpcTarget = "https://1rpc.io/eth",
233223
ticker = "ETH",
234224
chainNamespace = ChainNamespace.EIP155
235225
)
236226
)
227+
val completableFuture = web3Auth.showWalletUI(
228+
chainConfig = chainsConfig,
229+
chainId = "0x1",
230+
)
237231

238232
completableFuture.whenComplete{_, error ->
239233
if(error == null) {

android/android-quick-start/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ dependencies {
4444
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
4545
implementation 'com.google.code.gson:gson:2.9.1'
4646
// IMP START - Installation
47-
implementation 'com.github.web3auth:web3auth-android-sdk:9.0.4'
47+
implementation 'com.github.grvgoel81:web3auth-android-sdk:0.0.6'
4848
// IMP END - Installation
4949
implementation 'org.web3j:core:4.8.7-android'
5050
testImplementation 'junit:junit:4.13.2'

android/android-quick-start/app/src/main/java/com/sbz/web3authdemoapp/MainActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class MainActivity : AppCompatActivity() {
5555
Web3AuthOptions(
5656
clientId = getString(R.string.web3auth_project_id),
5757
network = Network.SAPPHIRE_MAINNET, // pass over the network you want to use (MAINNET or TESTNET or CYAN, AQUA, SAPPHIRE_MAINNET or SAPPHIRE_TESTNET)
58-
buildEnv = BuildEnv.PRODUCTION,
58+
authBuildEnv = BuildEnv.TESTING,
5959
redirectUrl = Uri.parse("com.sbz.web3authdemoapp://auth")
6060
), this
6161
)
@@ -125,7 +125,7 @@ class MainActivity : AppCompatActivity() {
125125
private fun signIn() {
126126
val email = emailInput.text.toString()
127127
// IMP START - Login
128-
val selectedLoginProvider = Provider.EMAIL_PASSWORDLESS // Can be GOOGLE, FACEBOOK, TWITCH etc.
128+
val selectedLoginProvider = AuthConnection.EMAIL_PASSWORDLESS // Can be GOOGLE, FACEBOOK, TWITCH etc.
129129
val loginParams = LoginParams(selectedLoginProvider, extraLoginOptions = ExtraLoginOptions(login_hint = email))
130130
val loginCompletableFuture: CompletableFuture<Web3AuthResponse> =
131131
web3Auth.login(loginParams)

android/android-solana-example/app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ dependencies {
6363
implementation("androidx.compose.ui:ui-graphics")
6464
implementation("androidx.compose.ui:ui-tooling-preview")
6565
implementation("androidx.compose.material3:material3")
66-
implementation("com.github.Web3Auth:web3auth-android-sdk:9.0.4")
66+
implementation("com.github.grvgoel81:web3auth-android-sdk:0.0.6")
6767
testImplementation("junit:junit:4.13.2")
6868
androidTestImplementation("androidx.test.ext:junit:1.1.5")
6969
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")

android/android-solana-example/app/src/main/java/com/example/androidsolanaexample/di/appModule.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import com.example.androidsolanaexample.data.Web3AuthHelperImpl
88
import com.example.androidsolanaexample.domain.SolanaUseCase
99
import com.example.androidsolanaexample.viewmodel.MainViewModel
1010
import com.web3auth.core.Web3Auth
11+
import com.web3auth.core.types.BuildEnv
1112
import com.web3auth.core.types.Network
1213
import com.web3auth.core.types.Web3AuthOptions
1314
import org.koin.androidx.viewmodel.dsl.viewModel
@@ -34,6 +35,7 @@ private fun getWeb3AuthHelper(context: Context): Web3AuthHelper {
3435
Web3AuthOptions(
3536
clientId = "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ",
3637
network = Network.SAPPHIRE_MAINNET,
38+
authBuildEnv = BuildEnv.TESTING,
3739
redirectUrl = Uri.parse( "com.example.androidsolanaexample://auth")
3840
), context
3941
)

android/android-solana-example/app/src/main/java/com/example/androidsolanaexample/viewmodel/MainViewModel.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import androidx.lifecycle.ViewModel
55
import androidx.lifecycle.viewModelScope
66
import com.example.androidsolanaexample.data.Web3AuthHelper
77
import com.example.androidsolanaexample.domain.SolanaUseCase
8+
import com.web3auth.core.types.AuthConnection
89
import com.web3auth.core.types.LoginParams
9-
import com.web3auth.core.types.Provider
1010
import com.web3auth.core.types.UserInfo
1111
import kotlinx.coroutines.flow.MutableStateFlow
1212
import kotlinx.coroutines.flow.StateFlow
@@ -34,7 +34,7 @@ class MainViewModel(private val web3AuthHelper: Web3AuthHelper, private val sola
3434
solanaKeyPair = Keypair.fromSecretKey(solanaPrivateKey().hexToByteArray())
3535
}
3636
fun login(){
37-
val loginParams = LoginParams(loginProvider = Provider.GOOGLE)
37+
val loginParams = LoginParams(authConnection = AuthConnection.GOOGLE)
3838
viewModelScope.launch {
3939
try {
4040
web3AuthHelper.login(loginParams = loginParams).await()

ios/ios-aptos-example/ios-aptos-example.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,8 @@
665665
isa = XCRemoteSwiftPackageReference;
666666
repositoryURL = "https://github.com/Web3Auth/web3auth-swift-sdk/";
667667
requirement = {
668-
kind = upToNextMajorVersion;
669-
minimumVersion = 11.1.0;
668+
branch = feat/auth_service_v10_changes;
669+
kind = branch;
670670
};
671671
};
672672
A4DCEE6F2C8B36670048A663 /* XCRemoteSwiftPackageReference "aptos-swift-sdk" */ = {

ios/ios-aptos-example/ios-aptos-example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)