Skip to content

Commit 640f958

Browse files
Merge branch 'master' into swift-pnp-v10
2 parents cf684d7 + 559d296 commit 640f958

File tree

12 files changed

+168
-67
lines changed

12 files changed

+168
-67
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
title: PnP Android SDK - v8 to v9
3+
description: "PnP Android SDK - v8 to v9 | Documentation - Web3Auth"
4+
sidebar_label: v8 to v9
5+
---
6+
7+
This migration guide provides steps for upgrading from version v8 to v9 of the PnP Android SDK. The
8+
guide outlines significant changes and enhancements, including the support of Web3Auth OpenLogin
9+
version v9, and Wallet Services v3.
10+
11+
## Breaking Changes
12+
13+
### `getSignResponse` is now removed.
14+
15+
In v9, we try to improve the developer experience by removing the `getSignResponse` method and
16+
returning the result in the `request` method itself.
17+
18+
Previously, after calling the `request` method, developers had to use the `getSignResponse` method
19+
to retrieve the `SignResponse`. In the latest version v9, the `request` method will return the
20+
`SignResponse` directly.
21+
22+
```kotlin
23+
val params = JsonArray().apply {
24+
// Message to be signed
25+
add("Hello, World!")
26+
// User's EOA address
27+
add(address)
28+
}
29+
30+
val chainConfig = ChainConfig(
31+
chainId = "0x1",
32+
rpcTarget = "https://rpc.ankr.com/eth",
33+
ticker = "ETH",
34+
chainNamespace = ChainNamespace.EIP155
35+
)
36+
37+
val signMsgCompletableFuture = web3Auth.request(
38+
chainConfig = chainConfig,
39+
"personal_sign",
40+
requestParams = params
41+
)
42+
43+
// focus-start
44+
// remove-next-line
45+
signMsgCompletableFuture.whenComplete { _, error ->
46+
// add-next-line
47+
signMsgCompletableFuture.whenComplete { signResult, error ->
48+
if (error == null) {
49+
// remove-next-line
50+
val signResult = Web3Auth.getSignResponse()
51+
Log.d("Sign Result", signResult.toString())
52+
53+
} else {
54+
Log.d("MainActivity_Web3Auth", error.message ?: "Something went wrong")
55+
}
56+
}
57+
// focus-end
58+
```
59+
60+
## Enhancements
61+
62+
In the latest version v9, we have added support for the Web3Auth Auth Service version v9, and Wallet
63+
Services v3. In Wallet Services v3, the prebuilt wallet UI now supports the swap functionality
64+
allowing users to swap to their favorite token from the app itself.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: SFA Android SDK - v2.0.0 to v3.0.0
3+
description: "SFA Android SDK - v2.0.0 to v3.0.0 | Documentation - Web3Auth"
4+
sidebar_label: v2.0.0 to v3.0.0
5+
---
6+
7+
This migration guide provides steps for upgrading from version v2.0.0 to v3.0.0 of the SFA Android
8+
SDK. The guide outlines significant changes and enhancements.
9+
10+
## Breaking Changes
11+
12+
### initialize Method Changes
13+
14+
In v3, the `initialize` method will now return void upon successful initialization instead of
15+
returning `SessionData`. After successful initialization, you can use the
16+
[getSessionData](/docs/sdk/sfa/sfa-android/usage/#get-session-data) method to check if the user is
17+
logged in or not.
18+
19+
```kotlin
20+
val initializeCF = singleFactoreAuth.initialize(this.applicationContext)
21+
22+
// remove-next-line
23+
initializeCF.whenComplete { sessionData, error ->
24+
// add-next-line
25+
initializeCF.whenComplete {_, error ->
26+
if (error != null) {
27+
// Handle error
28+
}
29+
// remove-start
30+
else if (sessionData != null) {
31+
// User is logged in
32+
} else {
33+
// User is not logged in
34+
}
35+
// remove-end
36+
// add-start
37+
let sessionData = singleFactorAuth.getSessionData()
38+
if(sessionData != null) {
39+
// User is logged in
40+
} else {
41+
// User is not logged in
42+
}
43+
// add-end
44+
}
45+
```

docs/sdk/pnp/android/initialize.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ these methods will return an empty string; otherwise, they will return the respe
125125
Note that if the API call to fetch the project configuration fails, the method will throw an error.
126126

127127
```kotlin
128-
val sessionResponse: CompletableFuture<Void> = web3Auth.initialize()
129-
sessionResponse.whenComplete { _, error ->
128+
val initializeCF: CompletableFuture<Void> = web3Auth.initialize()
129+
initializeCF.whenComplete { _, error ->
130130
if (error == null) {
131131
// Check for the active session
132132
if(web3Auth.getPrivKey()isNotEmpty()) {

docs/sdk/pnp/android/usage.mdx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -514,15 +514,13 @@ val signMsgCompletableFuture = web3Auth.request(
514514
)
515515
// focus-end
516516

517-
signMsgCompletableFuture.whenComplete { _, error ->
517+
signMsgCompletableFuture.whenComplete { signResult, error ->
518518
if (error == null) {
519-
Log.d("MainActivity_Web3Auth", "Message signed successfully")
520519
// focus-next-line
521-
val signResult = Web3Auth.getSignResponse()
522-
Log.d("MainActivity_Web3Auth", signResult.toString())
520+
Log.d("Sign Result", signResult.toString())
523521

524522
} else {
525-
Log.d("MainActivity_Web3Auth", error.message ?: "Something went wrong")
523+
Log.d("Sign Error", error.message ?: "Something went wrong")
526524
}
527525
}
528526
```

docs/sdk/sfa/sfa-android/initialize.mdx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ description: "Web3Auth Single Factor Auth Android SDK - Initialize | Documentati
77
import TabItem from "@theme/TabItem";
88
import Tabs from "@theme/Tabs";
99

10+
import Instantiation from "@site/src/common/sdk/sfa/android/_sfa-android-instantiation.mdx";
1011
import Initialization from "@site/src/common/sdk/sfa/android/_sfa-android-initialization.mdx";
11-
import SessionManagement from "@site/src/common/sdk/sfa/android/_sfa-android-session-management.mdx";
1212

1313
Once you have installed the Web3Auth SDK, the next crucial step is to initialize it. This step
1414
requires passing various parameters that align with your project preferences. It's important to note
@@ -29,13 +29,12 @@ Web3Auth network, client id, and other parameters during initialization.
2929

3030
## Create Instance
3131

32-
<Initialization />
32+
<Instantiation />
3333

3434
## Initialize
3535

36-
To initialize the SDK, you can use the `initialize` method. We have included Session Management in
37-
this SDK, so you can use the method to get the `SessionData` without re-logging in the user. If a
38-
user has an active session, it will return the `SessionData`, otherwise, it will throw an error for
39-
inactive session.
36+
To initialize the SDK, you can use the `initialize` method. This method helps you initialize the SDK
37+
with existing session. After successful initialization, you can use the
38+
[getSessionData](./usage/#get-session-data) method to check if the user is logged in or not.
4039

41-
<SessionManagement />
40+
<Initialization />

sidebars.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,12 +1311,13 @@ const sidebars: SidebarsConfig = {
13111311
type: "category",
13121312
label: "Migration Guides",
13131313
items: [
1314-
"migration-guides/android-v4-to-v5",
1315-
"migration-guides/android-v5-to-v6",
1316-
"migration-guides/android-v6-to-v6.1",
1317-
"migration-guides/android-v7.1.1-to-v7.1.2",
1318-
"migration-guides/android-v7.1.2-to-v7.2",
1314+
"migration-guides/android-v8-to-v9",
13191315
"migration-guides/android-v7.2-to-v7.3",
1316+
"migration-guides/android-v7.1.2-to-v7.2",
1317+
"migration-guides/android-v7.1.1-to-v7.1.2",
1318+
"migration-guides/android-v6-to-v6.1",
1319+
"migration-guides/android-v5-to-v6",
1320+
"migration-guides/android-v4-to-v5",
13201321
],
13211322
},
13221323
...sdkQuickLinks,
@@ -1648,6 +1649,7 @@ const sidebars: SidebarsConfig = {
16481649
type: "category",
16491650
label: "Migration Guides",
16501651
items: [
1652+
"migration-guides/sfa-android-v2-to-v3",
16511653
"migration-guides/sfa-android-v1.2.0-to-v2.0.0",
16521654
"migration-guides/sfa-android-v0.4.0-to-v1",
16531655
"migration-guides/sfa-android-v0.1.0-to-v0.3.0",

src/common/sdk/pnp/android/_installation.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
dependencies {
33
// ...
44
// focus-next-line
5-
implementation 'com.github.web3auth:web3auth-android-sdk:8.0.3'
5+
implementation 'com.github.web3auth:web3auth-android-sdk:9.0.1'
66
}
77
```
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
```kotlin
22
import android.content.Context
3-
import com.web3auth.singlefactorauth.SingleFactorAuth
4-
import com.web3auth.singlefactorauth.types.Web3AuthOptions
5-
import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork
6-
7-
// You can get the client id for your Web3Auth project from Web3Auth dashboard.
8-
val web3AuthOptions = Web3AuthOptions(
9-
"YOUR_WEB3AUTH_CLIENT_ID",
10-
Web3AuthNetwork.SAPPHIRE_MAINNET
11-
)
123

134
val context: Context = "YOUR_APPLICATION_CONTEXT"
5+
val sessionDataCF = singleFactorAuth.initialize(context)
146

15-
val singleFactorAuth = SingleFactorAuth(web3AuthOptions, context)
7+
sessionDataCF.whenComplete {sessionData, error ->
8+
if(error != null) {
9+
// Something went wrong
10+
// Initiate the login flow again
11+
} else {
12+
// You can use the SessionData to check if the user is
13+
//logged in or not
14+
}
15+
}
1616
```
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
```kotlin
2+
import android.content.Context
3+
import com.web3auth.singlefactorauth.SingleFactorAuth
4+
import com.web3auth.singlefactorauth.types.Web3AuthOptions
5+
import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork
6+
7+
// You can get the client id for your Web3Auth project from Web3Auth dashboard.
8+
val web3AuthOptions = Web3AuthOptions(
9+
"YOUR_WEB3AUTH_CLIENT_ID",
10+
Web3AuthNetwork.SAPPHIRE_MAINNET
11+
)
12+
13+
val context: Context = "YOUR_APPLICATION_CONTEXT"
14+
15+
val singleFactorAuth = SingleFactorAuth(web3AuthOptions, context)
16+
```

src/common/sdk/sfa/android/_sfa-android-session-management.mdx

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)