|
| 1 | +--- |
| 2 | +title: PnP Android SDK - v5 to v6 |
| 3 | +displayed_sidebar: sdk |
| 4 | +description: "PnP Android SDK - v5 to v6 | Documentation - Web3Auth" |
| 5 | +sidebar_label: v5 to v6 |
| 6 | +--- |
| 7 | + |
| 8 | +import TabItem from "@theme/TabItem"; |
| 9 | +import Tabs from "@theme/Tabs"; |
| 10 | + |
| 11 | +# Migration Guide from v5 to v6 for Web3Auth PnP Android SDK |
| 12 | + |
| 13 | +## Overview |
| 14 | + |
| 15 | +This migration guide provides steps for upgrading from version 5(v5) to version 6(v6) of the |
| 16 | +Web3Auth PnP Android SDK. The guide outlines significant changes and enhancements, including the |
| 17 | +introduction of `enableMFA` method to initiate MFA setup flow, and `launchWalletServices` method for |
| 18 | +template wallet interface. |
| 19 | + |
| 20 | +## Changes in Detail |
| 21 | + |
| 22 | +### `enableMFA` method |
| 23 | + |
| 24 | +From v6, developers can use the `enableMFA` method to initiate MFA setup flow for already logged in |
| 25 | +users. |
| 26 | + |
| 27 | +<Tabs |
| 28 | + defaultValue="default-verifier" |
| 29 | + values={[ |
| 30 | + { label: "Default Verifier", value: "default-verifier" }, |
| 31 | + { label: "Custom JWT Verifier", value: "custom-jwt-verifier" }, |
| 32 | + ]} |
| 33 | +> |
| 34 | + |
| 35 | +<TabItem value = "default-verifier"> |
| 36 | +```kotlin title="Usage" |
| 37 | +import android.widget.Button |
| 38 | +import com.web3auth.core.Web3Auth |
| 39 | +import android.os.Bundle |
| 40 | + |
| 41 | +class MainActivity : AppCompatActivity() { private lateinit var web3Auth: Web3Auth |
| 42 | + |
| 43 | + private fun enableMFA() { |
| 44 | + // highlight-next-line |
| 45 | + val completableFuture = web3Auth.enableMFA() |
| 46 | + |
| 47 | + completableFuture.whenComplete{_, error -> |
| 48 | + if (error == null) { |
| 49 | + Log.d("MainActivity_Web3Auth", "Launched successfully") |
| 50 | + // Add your logic |
| 51 | + } else { |
| 52 | + // Add your logic on error |
| 53 | + Log.d("MainActivity_Web3Auth", error.message ?: "Something went wrong") |
| 54 | + } |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + override fun onCreate(savedInstanceState: Bundle?) { |
| 59 | + ... |
| 60 | + // Setup UI and event handlers |
| 61 | + val enableMFAButton = findViewById<Button>(R.id.enableMFAButton) |
| 62 | + enableMFAButton.setOnClickListener { enableMFA() } |
| 63 | + ... |
| 64 | + } |
| 65 | + ... |
| 66 | + |
| 67 | +} |
| 68 | + |
| 69 | +```` |
| 70 | +</TabItem> |
| 71 | + |
| 72 | +<TabItem value="custom-jwt-verifier"> |
| 73 | +```kotlin title="Usage" |
| 74 | +import android.widget.Button |
| 75 | +import com.web3auth.core.Web3Auth |
| 76 | +import android.os.Bundle |
| 77 | + |
| 78 | +class MainActivity : AppCompatActivity() { private lateinit var web3Auth: Web3Auth |
| 79 | + |
| 80 | + private fun enableMFA() { |
| 81 | + val loginParams = LoginParams( |
| 82 | + Provider.JWT, |
| 83 | + extraLoginOptions = ExtraLoginOptions(id_token = "your_jwt_token") |
| 84 | + ) |
| 85 | + |
| 86 | + // highlight-next-line |
| 87 | + val completableFuture = web3Auth.enableMFA(loginParams) |
| 88 | + |
| 89 | + completableFuture.whenComplete{_, error -> |
| 90 | + if (error == null) { |
| 91 | + Log.d("MainActivity_Web3Auth", "Launched successfully") |
| 92 | + // Add your logic |
| 93 | + } else { |
| 94 | + // Add your logic on error |
| 95 | + Log.d("MainActivity_Web3Auth", error.message ?: "Something went wrong") |
| 96 | + } |
| 97 | + } |
| 98 | + } |
| 99 | + |
| 100 | + override fun onCreate(savedInstanceState: Bundle?) { |
| 101 | + ... |
| 102 | + // Setup UI and event handlers |
| 103 | + val enableMFAButton = findViewById<Button>(R.id.enableMFAButton) |
| 104 | + enableMFAButton.setOnClickListener { enableMFA() } |
| 105 | + ... |
| 106 | + } |
| 107 | + ... |
| 108 | + |
| 109 | +} |
| 110 | +```` |
| 111 | + |
| 112 | +</TabItem> |
| 113 | +</Tabs> |
| 114 | + |
| 115 | +### `launchWalletServices` method |
| 116 | + |
| 117 | +From v6, developers can use the `launchWalletServices` to launches a WebView which allows them to |
| 118 | +use the templated wallet UI services. Developers can pass the `ChainConfig` to open wallet services |
| 119 | +with a specific chain selected. |
| 120 | + |
| 121 | +:::note Minimum Scale plan required |
| 122 | + |
| 123 | +Access to Wallet Services is gated. You can use this feature in the development environment for |
| 124 | +free. The minimum [pricing plan](https://web3auth.io/pricing.html) to use this feature in a |
| 125 | +production environment is the **Scale Plan**. |
| 126 | + |
| 127 | +::: |
| 128 | + |
| 129 | +#### ChainConfig Arguments |
| 130 | + |
| 131 | +| Parameter | Description | |
| 132 | +| ------------------- | --------------------------------------------------------------------------------------------------------------------------- | |
| 133 | +| `chainNamespace` | Custom configuration for your preferred blockchain. As of now only EVM supported. Default value is `ChainNamespace.EIP155`. | |
| 134 | +| `decimals?` | Number of decimals for the currency ticker. Default value is 18, and accepts `Int` as value. | |
| 135 | +| `blockExplorerUrl?` | Blockchain's explorer URL. (eg: `https://etherscan.io`) | |
| 136 | +| `chainId` | The chain id of the selected blockchain in hex `String`. | |
| 137 | +| `displayName?` | Display Name for the chain. | |
| 138 | +| `logo?` | Logo for the selected `chainNamespace` & `chainId`. | |
| 139 | +| `rpcTarget` | RPC Target URL for the selected `chainNamespace` & `chainId`. | |
| 140 | +| `ticker?` | Default currency ticker of the network (e.g: `ETH`) | |
| 141 | +| `tickerName?` | Name for currency ticker (e.g: `Ethereum`) | |
| 142 | +
|
| 143 | +#### Usage |
| 144 | +
|
| 145 | +```kotlin title="Usage" |
| 146 | +// highlight-start |
| 147 | +val launchWalletCompletableFuture = web3Auth.launchWalletServices( |
| 148 | + loginParams = LoginParams( |
| 149 | + selectedLoginProvider, |
| 150 | + extraLoginOptions = null, |
| 151 | + mfaLevel = MFALevel.NONE, |
| 152 | + ), |
| 153 | +
|
| 154 | + chainConfig = ChainConfig( |
| 155 | + chainId = "0x1", |
| 156 | + rpcTarget = "https://mainnet.infura.io/v3/$key", |
| 157 | + ticker = "ETH", |
| 158 | + chainNamespace = ChainNamespace.EIP155 |
| 159 | + ) |
| 160 | +) |
| 161 | +// highlight-end |
| 162 | +
|
| 163 | +launchWalletCompletableFuture.whenComplete { _, error -> |
| 164 | + if (error == null) { |
| 165 | + Log.d("MainActivity_Web3Auth", "Wallet launched successfully") |
| 166 | + } else { |
| 167 | + Log.d("MainActivity_Web3Auth", error.message ?: "Something went wrong") |
| 168 | + } |
| 169 | +} |
| 170 | +``` |
0 commit comments