Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: updates session manager sdk and related changes. #96

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
8554ad2
feat: updates session manager sdk and related changes.
grvgoel81 Sep 3, 2024
3716a1e
feat: PR comments addressed
Sep 3, 2024
ac750f4
cleanup
metalurgical Sep 3, 2024
f0dad11
remove network checking where underlying library already does this, a…
metalurgical Sep 3, 2024
9890858
additional todos
metalurgical Sep 3, 2024
bebb70b
feat: Resolved TODO's
grvgoel81 Sep 3, 2024
8eda6d0
feat: Resolved more TODO's
grvgoel81 Sep 3, 2024
1dc8474
feat: update session-manager-android sdk version
grvgoel81 Sep 3, 2024
b005d68
feat: update session-manager-android sdk version
grvgoel81 Sep 5, 2024
96f0717
feat: resolved PR comments
grvgoel81 Sep 10, 2024
fdfb714
feat: update session-manager-sdk version
Sep 11, 2024
4d30233
feat: update authServiceVersion to v9 and walletServicesVersion to v3
grvgoel81 Sep 11, 2024
5877ad5
feat: update session manager changes
grvgoel81 Sep 17, 2024
a482671
feat: update session manager changes
grvgoel81 Sep 17, 2024
705f718
feat: remove runOnUiThread from example and code cleanup
grvgoel81 Sep 19, 2024
1d3b3ac
feat: code cleanup
grvgoel81 Sep 19, 2024
2db034e
feat: code cleanup
grvgoel81 Sep 19, 2024
e6a1f22
feat: Update session-manager-sdk
grvgoel81 Sep 19, 2024
6be5463
feat: Update session-manager-sdk
grvgoel81 Sep 23, 2024
57e779c
feat: code refactored
grvgoel81 Sep 23, 2024
1421cc5
feat: code refactored
grvgoel81 Sep 23, 2024
d48e4a9
feat: code refactored
grvgoel81 Sep 24, 2024
22df356
Merge branch 'master' into feat/update-session-manager-changes
Oct 9, 2024
c07c2c7
feat: Resolve conflicts
grvgoel81 Oct 9, 2024
e73750a
feat: code refactored
grvgoel81 Oct 9, 2024
2adec20
feat: Update fetchProjectConfig API inout params
grvgoel81 Oct 18, 2024
695a354
feat: Add appState in SignMessage.kt
Oct 18, 2024
2b474a9
feat: code refactored
Oct 18, 2024
91dd944
feat: code refactored for request method an update example
grvgoel81 Oct 23, 2024
af4c2d2
feat: add webview cancelled event.
grvgoel81 Oct 24, 2024
bc36812
feat: update request function return type from SignResponse to generi…
grvgoel81 Oct 28, 2024
cf5e125
feat: code refactored
grvgoel81 Oct 29, 2024
6e33a62
feat: updated code for session-manager changes
grvgoel81 Oct 30, 2024
6c3e8c5
feat: updated code for session-manager changes
grvgoel81 Oct 30, 2024
ee1bb79
feat: updated session-manager dep
Nov 6, 2024
225eed9
code refactor
grvgoel81 Nov 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ android {
keyPassword 'torus123'
}
}
compileSdkVersion 34
compileSdk 34

defaultConfig {
applicationId "com.web3auth.app"
minSdkVersion 24
minSdkVersion 26
targetSdkVersion 34
versionCode 1
versionName "1.0"
Expand Down
38 changes: 14 additions & 24 deletions app/src/main/java/com/web3auth/app/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
selectedLoginProvider,
extraLoginOptions = extraLoginOptions,
mfaLevel = MFALevel.OPTIONAL
)
), this
)
loginCompletableFuture.whenComplete { _, error ->
if (error == null) {
Expand All @@ -106,7 +106,7 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
}

private fun signOut() {
val logoutCompletableFuture = web3Auth.logout()
val logoutCompletableFuture = web3Auth.logout(this)
logoutCompletableFuture.whenComplete { _, error ->
if (error == null) {
reRender()
Expand All @@ -122,7 +122,6 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
val signOutButton = findViewById<Button>(R.id.signOutButton)
val launchWalletButton = findViewById<Button>(R.id.launchWalletButton)
val signMsgButton = findViewById<Button>(R.id.signMsgButton)
val signResultButton = findViewById<Button>(R.id.signResultButton)
val btnSetUpMfa = findViewById<Button>(R.id.btnSetUpMfa)
val spinner = findViewById<TextInputLayout>(R.id.verifierList)
val hintEmailEditText = findViewById<EditText>(R.id.etEmailHint)
Expand All @@ -135,6 +134,7 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
print(ex)
}


if (userInfo != null) {
val jsonObject = JSONObject(gson.toJson(web3Auth.getWeb3AuthResponse()))
contentTextView.text = jsonObject.toString(4) + "\n Private Key: " + key
Expand All @@ -155,7 +155,6 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
btnSetUpMfa.visibility = View.GONE
launchWalletButton.visibility = View.GONE
signMsgButton.visibility = View.GONE
signResultButton.visibility = View.GONE
spinner.visibility = View.VISIBLE
}
}
Expand All @@ -165,7 +164,6 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
setContentView(R.layout.activity_main)

val options = Web3AuthOptions(
context = this,
clientId = "BFuUqebV5I8Pz5F7a5A2ihW7YVmbv_OHXnHYDv6OltAD5NGr6e-ViNvde3U4BHdn6HvwfkgobhVu4VwC-OSJkik",
network = Network.SAPPHIRE_DEVNET,
redirectUrl = Uri.parse("torusapp://org.torusresearch.web3authexample"),
Expand All @@ -186,21 +184,21 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
clientId = "d84f6xvbdV75VTGmHiMWfZLeSPk8M07C",
)
),
buildEnv = BuildEnv.TESTING,
buildEnv = BuildEnv.PRODUCTION,
sessionTime = 86400,
)

println("params: $options")

// Configure Web3Auth
web3Auth = Web3Auth(
options
options, this
)

web3Auth.setResultUrl(intent.data)
web3Auth.setResultUrl(intent.data, this)

// for session response
val sessionResponse: CompletableFuture<Void> = web3Auth.initialize()
val sessionResponse: CompletableFuture<Void> = web3Auth.initialize(this)
sessionResponse.whenComplete { _, error ->
if (error == null) {
reRender()
Expand All @@ -226,7 +224,7 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
chainId = "0x89",
rpcTarget = "https://1rpc.io/matic",
chainNamespace = ChainNamespace.EIP155
)
), context = this
)
launchWalletCompletableFuture.whenComplete { _, error ->
if (error == null) {
Expand All @@ -237,7 +235,6 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
}
}

val signResultButton = findViewById<Button>(R.id.signResultButton)
val signMsgButton = findViewById<Button>(R.id.signMsgButton)
signMsgButton.setOnClickListener {
val credentials: Credentials = Credentials.create(web3Auth.getPrivkey())
Expand All @@ -251,27 +248,20 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
chainId = "0x89",
rpcTarget = "https://polygon-rpc.com/",
chainNamespace = ChainNamespace.EIP155
), "personal_sign", requestParams = params
), "personal_sign", requestParams = params, appState = "web3Auth", context = this
)
signMsgCompletableFuture.whenComplete { _, error ->
signMsgCompletableFuture.whenComplete { signResult, error ->
if (error == null) {
Log.d("MainActivity_Web3Auth", "Message signed successfully")
signResultButton.visibility = View.VISIBLE
showAlertDialog("Sign Result", signResult.toString())
} else {
Log.d("MainActivity_Web3Auth", error.message ?: "Something went wrong")
signResultButton.visibility = View.GONE
}
}
}

signResultButton.setOnClickListener {
val signResult = Web3Auth.getSignResponse()
showAlertDialog("Sign Result", signResult.toString())
}

val btnSetUpMfa = findViewById<Button>(R.id.btnSetUpMfa)
btnSetUpMfa.setOnClickListener {
val setupMfaCf = web3Auth.enableMFA()
val setupMfaCf = web3Auth.enableMFA(context = this)
setupMfaCf.whenComplete { _, error ->
if (error == null) {
Log.d("MainActivity_Web3Auth", "MFA setup successfully")
Expand All @@ -293,14 +283,14 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {

override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
web3Auth.setResultUrl(intent?.data)
web3Auth.setResultUrl(intent?.data, this)
}

override fun onResume() {
super.onResume()
if (Web3Auth.getCustomTabsClosed()) {
Toast.makeText(this, "User closed the browser.", Toast.LENGTH_SHORT).show()
web3Auth.setResultUrl(null)
web3Auth.setResultUrl(null, this)
Web3Auth.setCustomTabsClosed(false)
}
}
Expand Down
12 changes: 0 additions & 12 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,6 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/launchWalletButton" />

<Button
android:id="@+id/signResultButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:text="@string/sign_result"
android:textAllCaps="false"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/signMsgButton" />

<Button
android:id="@+id/btnSetUpMfa"
android:layout_width="wrap_content"
Expand Down
12 changes: 6 additions & 6 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ plugins {
}

android {
compileSdkVersion 34
compileSdk 34

defaultConfig {
minSdkVersion 24
minSdkVersion 26
targetSdkVersion 34

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -51,7 +51,7 @@ dependencies {
implementation 'androidx.browser:browser:1.6.0'

// Encoding
implementation 'com.google.code.gson:gson:2.9.1'
implementation 'com.google.code.gson:gson:2.10.1'

// retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
Expand All @@ -69,14 +69,14 @@ dependencies {
implementation 'org.web3j:core:4.8.8-android'

//session-manager-sdk
implementation 'com.github.Web3Auth:session-manager-android:1.3.0'
implementation 'com.github.Web3Auth:session-manager-android:3.0.0'

implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01"

// Test
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
}

project.afterEvaluate {
Expand Down
Loading