Skip to content

Commit

Permalink
Merge pull request #1006 from Web3Auth/pnp-android-v9
Browse files Browse the repository at this point in the history
[Android PnP] Update docs for v9
  • Loading branch information
AyushBherwani1998 authored Dec 12, 2024
2 parents 52b6f1a + 0ea0a72 commit 559d296
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 14 deletions.
64 changes: 64 additions & 0 deletions docs/migration-guides/android-v8-to-v9.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
title: PnP Android SDK - v8 to v9
description: "PnP Android SDK - v8 to v9 | Documentation - Web3Auth"
sidebar_label: v8 to v9
---

This migration guide provides steps for upgrading from version v8 to v9 of the PnP Android SDK. The
guide outlines significant changes and enhancements, including the support of Web3Auth OpenLogin
version v9, and Wallet Services v3.

## Breaking Changes

### `getSignResponse` is now removed.

In v9, we try to improve the developer experience by removing the `getSignResponse` method and
returning the result in the `request` method itself.

Previously, after calling the `request` method, developers had to use the `getSignResponse` method
to retrieve the `SignResponse`. In the latest version v9, the `request` method will return the
`SignResponse` directly.

```kotlin
val params = JsonArray().apply {
// Message to be signed
add("Hello, World!")
// User's EOA address
add(address)
}

val chainConfig = ChainConfig(
chainId = "0x1",
rpcTarget = "https://rpc.ankr.com/eth",
ticker = "ETH",
chainNamespace = ChainNamespace.EIP155
)

val signMsgCompletableFuture = web3Auth.request(
chainConfig = chainConfig,
"personal_sign",
requestParams = params
)

// focus-start
// remove-next-line
signMsgCompletableFuture.whenComplete { _, error ->
// add-next-line
signMsgCompletableFuture.whenComplete { signResult, error ->
if (error == null) {
// remove-next-line
val signResult = Web3Auth.getSignResponse()
Log.d("Sign Result", signResult.toString())

} else {
Log.d("MainActivity_Web3Auth", error.message ?: "Something went wrong")
}
}
// focus-end
```

## Enhancements

In the latest version v9, we have added support for the Web3Auth Auth Service version v9, and Wallet
Services v3. In Wallet Services v3, the prebuilt wallet UI now supports the swap functionality
allowing users to swap to their favorite token from the app itself.
4 changes: 2 additions & 2 deletions docs/sdk/pnp/android/initialize.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ these methods will return an empty string; otherwise, they will return the respe
Note that if the API call to fetch the project configuration fails, the method will throw an error.

```kotlin
val sessionResponse: CompletableFuture<Void> = web3Auth.initialize()
sessionResponse.whenComplete { _, error ->
val initializeCF: CompletableFuture<Void> = web3Auth.initialize()
initializeCF.whenComplete { _, error ->
if (error == null) {
// Check for the active session
if(web3Auth.getPrivKey()isNotEmpty()) {
Expand Down
8 changes: 3 additions & 5 deletions docs/sdk/pnp/android/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -514,15 +514,13 @@ val signMsgCompletableFuture = web3Auth.request(
)
// focus-end

signMsgCompletableFuture.whenComplete { _, error ->
signMsgCompletableFuture.whenComplete { signResult, error ->
if (error == null) {
Log.d("MainActivity_Web3Auth", "Message signed successfully")
// focus-next-line
val signResult = Web3Auth.getSignResponse()
Log.d("MainActivity_Web3Auth", signResult.toString())
Log.d("Sign Result", signResult.toString())

} else {
Log.d("MainActivity_Web3Auth", error.message ?: "Something went wrong")
Log.d("Sign Error", error.message ?: "Something went wrong")
}
}
```
11 changes: 6 additions & 5 deletions sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1311,12 +1311,13 @@ const sidebars: SidebarsConfig = {
type: "category",
label: "Migration Guides",
items: [
"migration-guides/android-v4-to-v5",
"migration-guides/android-v5-to-v6",
"migration-guides/android-v6-to-v6.1",
"migration-guides/android-v7.1.1-to-v7.1.2",
"migration-guides/android-v7.1.2-to-v7.2",
"migration-guides/android-v8-to-v9",
"migration-guides/android-v7.2-to-v7.3",
"migration-guides/android-v7.1.2-to-v7.2",
"migration-guides/android-v7.1.1-to-v7.1.2",
"migration-guides/android-v6-to-v6.1",
"migration-guides/android-v5-to-v6",
"migration-guides/android-v4-to-v5",
],
},
...sdkQuickLinks,
Expand Down
2 changes: 1 addition & 1 deletion src/common/sdk/pnp/android/_installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
dependencies {
// ...
// focus-next-line
implementation 'com.github.web3auth:web3auth-android-sdk:8.0.3'
implementation 'com.github.web3auth:web3auth-android-sdk:9.0.1'
}
```
2 changes: 1 addition & 1 deletion src/common/versions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const pnpWebVersion = `9.3.x`;
export const pnpAndroidVersion = `8.0.3`;
export const pnpAndroidVersion = `9.0.1`;
export const pnpIOSVersion = `9.0.0`;
export const pnpRNVersion = `7.0.x`;
export const pnpFlutterVersion = `5.0.4`;
Expand Down

0 comments on commit 559d296

Please sign in to comment.