Skip to content

Commit 1bbab89

Browse files
Merge pull request #1062 from Web3Auth/sfa-android-v4
[SFA Android] Update docs to v4
2 parents 8e5e76a + c750bd2 commit 1bbab89

File tree

4 files changed

+169
-13
lines changed

4 files changed

+169
-13
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ that the initialization process is critical to the successful use of Web3Auth.
1919
In your activity, create a `SingleFactorAuth` instance with `Web3AuthOptions`. You can define the
2020
Web3Auth network, client id, and other parameters during initialization.
2121

22-
| Parameter | Description |
23-
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
24-
| `network` | The Web3auth network is to be used by the SDK. Supported values are `Web3AuthNetwork.SAPPHIRE_MAINNET`, `Web3AuthNetwork.SAPPHIRE_DEVNET` ,`Web3AuthNetwork.MAINNET`, `Web3AuthNetwork.TESTNET`, `Web3AuthNetwork.CYAN`, and `Web3AuthNetwork.AQUA` |
25-
| `clientId` | The clientId for your Web3Auth project. You can get it from [Web3Auth dashboard](https://dashboard.web3auth.io/). |
26-
| `sessionTime` | Specifies the session duration in seconds. By default, the value is set to 86400 seconds (1 day), with a maximum session duration of up to 30 days. |
27-
| `serverTimeOffset` | Specify a custom server time offset. The default value is 0. |
28-
| `storageServerUrl?` | Specifies the storage server URL. The default value is `https://session.web3auth.io`. |
22+
| Parameter | Description |
23+
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
24+
| `network` | The Web3auth network is to be used by the SDK. Supported values are `Web3AuthNetwork.SAPPHIRE_MAINNET`, `Web3AuthNetwork.SAPPHIRE_DEVNET` ,`Web3AuthNetwork.MAINNET`, `Web3AuthNetwork.TESTNET`, `Web3AuthNetwork.CYAN`, and `Web3AuthNetwork.AQUA` |
25+
| `clientId` | The clientId for your Web3Auth project. You can get it from [Web3Auth dashboard](https://dashboard.web3auth.io/). |
26+
| `sessionTime` | Specifies the session duration in seconds. By default, the value is set to 86400 seconds (1 day), with a maximum session duration of up to 30 days. |
27+
| `serverTimeOffset` | Specify a custom server time offset. The default value is 0. |
28+
| `storageServerUrl?` | Specifies the storage server URL. The default value is `https://session.web3auth.io`. |
29+
| `whiteLabel?` | You can pass the white labeling options for web3auth. It helps you define your brand app's custom UI, and branding for the Wallet Services feature. The recommended way to configure the `whiteLabel` is through the Web3Auth Dashboard. [Learn how to configure the `whiteLabel` via Web3Auth Dashboard](/docs/features/whitelabel#new-whitelabeling-via-the-dashboard). |
30+
| `redirectUri?` | URL that Web3Auth will redirect API responses upon successful `request` method call. Please note, that it's mandatory to configure the `redirectUri` if you are using the `request` method. |
2931

3032
## Create Instance
3133

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

Lines changed: 158 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@ you'll see an Error message.
1919

2020
The SingleFactorAuth instance natively provides the following methods:
2121

22-
- [connect](#login-user) - Use to login user and retrive private key pair.
23-
- [logout](#logout-user) - Use to logout existing user.
24-
- [connected](#check-users-logged-in-status) - Use to check whether the user is logged in or not.
25-
- [getSessionData](#get-session-data) - This method helps to get the session data for valid session.
22+
| Method | Description |
23+
| ------------------------------------------ | ------------------------------------------------------------------- |
24+
| [connect](#login-user) | Use to login user and retrieve private key pair. |
25+
| [logout](#logout-user) | Use to logout existing user. |
26+
| [connected](#check-users-logged-in-status) | Use to check whether the user is logged in or not. |
27+
| [getSessionData](#get-session-data) | This method helps to get the session data for valid session. |
28+
| [showWalletUI ](#show-wallet-ui) | Use to open templated the wallet UI in WebView. |
29+
| [request](#request-signature) | Use to open templated transaction screens for signing transactions. |
2630

2731
## Login User
2832

@@ -172,3 +176,153 @@ The `SessionData` has the following properties to retrive the relevant session i
172176
| `publicAddress` | Retrieves the user's public address. |
173177
| `userInfo?` | Retrieves the user's information like email, name, verifier id, and more. |
174178
| `signatures?` | Retrieves the node's signatures that are returned for request. |
179+
180+
## Show Wallet UI
181+
182+
The `showWalletUI` method launches a WebView which allows you to use the templated wallet UI
183+
services. The method takes `ChainConfig` as the required input. Wallet Services is currently only
184+
available for EVM chains.
185+
186+
:::note
187+
188+
Access to Wallet Services is gated. You can use this feature in `sapphire_devnet` for free. The
189+
minimum [pricing plan](https://web3auth.io/pricing.html) to use this feature in a production
190+
environment is the **Scale Plan**.
191+
192+
:::
193+
194+
![Wallet Services](/images/mobile-wallet-services.png)
195+
196+
### Parameters
197+
198+
<Tabs
199+
defaultValue="table"
200+
values={[
201+
{ label: "Table", value: "table" },
202+
{ label: "Class", value: "class" },
203+
]}
204+
>
205+
206+
<TabItem value="table">
207+
208+
| Parameter | Description |
209+
| ------------------- | --------------------------------------------------------------------------------------------------------------------------- |
210+
| `chainNamespace` | Custom configuration for your preferred blockchain. As of now only EVM supported. Default value is `ChainNamespace.EIP155`. |
211+
| `decimals?` | Number of decimals for the currency ticker. Default value is 18, and accepts `Int` as value. |
212+
| `blockExplorerUrl?` | Blockchain's explorer URL. (eg: `https://etherscan.io`) |
213+
| `chainId` | The chain id of the selected blockchain in hex `String`. |
214+
| `displayName?` | Display Name for the chain. |
215+
| `logo?` | Logo for the selected `chainNamespace` & `chainId`. |
216+
| `rpcTarget` | RPC Target URL for the selected `chainNamespace` & `chainId`. |
217+
| `ticker?` | Default currency ticker of the network (e.g: `ETH`) |
218+
| `tickerName?` | Name for currency ticker (e.g: `Ethereum`) |
219+
220+
</TabItem>
221+
222+
<TabItem value="class">
223+
224+
```kotlin
225+
data class ChainConfig(
226+
val chainNamespace: ChainNamespace = ChainNamespace.EIP155,
227+
val decimals: Int? = 18,
228+
val blockExplorerUrl: String? = null,
229+
val chainId: String,
230+
val displayName: String? = null,
231+
val logo: String? = null,
232+
val rpcTarget: String,
233+
val ticker: String? = null,
234+
val tickerName: String? = null,
235+
)
236+
```
237+
238+
</TabItem>
239+
</Tabs>
240+
241+
### Usage
242+
243+
```kotlin
244+
val chainConfig = ChainConfig(
245+
chainId = "0x1",
246+
rpcTarget = "https://rpc.ankr.com/eth",
247+
ticker = "ETH",
248+
chainNamespace = ChainNamespace.EIP155
249+
)
250+
251+
// focus-start
252+
val completableFuture = singleFactorAuth.showWalletUI(
253+
chainConfig
254+
)
255+
// focus-end
256+
257+
completableFuture.whenComplete { _, error ->
258+
if (error == null) {
259+
Log.d("Successful", "Wallet launched successfully")
260+
} else {
261+
Log.d("Error", error.message ?: "Something went wrong")
262+
}
263+
}
264+
```
265+
266+
## Request signature
267+
268+
The `request` method facilitates the use of templated transaction screens for signing transactions.
269+
These screens can be used to sign transactions for any EVM chain and can be whitelabeled to your
270+
branding.
271+
272+
Please check the list of
273+
[JSON RPC methods](https://docs.metamask.io/wallet/reference/json-rpc-api/), noting that the request
274+
method currently supports only the signing methods.
275+
276+
![Request Method](/images/mobile-request-method.png)
277+
278+
### Parameters
279+
280+
| Parameter | Description |
281+
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
282+
| `chainConifg` | Defines the chain to be used for signature request. Learn more about [ChainConfig](#parameters-1). |
283+
| `method` | JSON RPC method name in `String`. Currently, the request method only supports the singing methods. |
284+
| `requestParams` | Parameters for the corresponding method. The parameters should be in the list and correct sequence. Take a look at [RPC methods](https://docs.metamask.io/wallet/reference/json-rpc-api/) to know more. |
285+
286+
### Usage
287+
288+
```kotlin
289+
val params = JsonArray().apply {
290+
// Message to be signed
291+
add("Hello, World!")
292+
// User's EOA address
293+
add(address)
294+
}
295+
296+
val chainConfig = ChainConfig(
297+
chainId = "0x1",
298+
rpcTarget = "https://rpc.ankr.com/eth",
299+
ticker = "ETH",
300+
chainNamespace = ChainNamespace.EIP155
301+
)
302+
303+
// focus-start
304+
val signMsgCompletableFuture = singleFactorAuth.request(
305+
chainConfig = chainConfig,
306+
"personal_sign",
307+
requestParams = params
308+
)
309+
// focus-end
310+
311+
signMsgCompletableFuture.whenComplete { signResult, error ->
312+
if (error == null) {
313+
// focus-next-line
314+
Log.d("Sign Result", signResult.toString())
315+
316+
} else {
317+
Log.d("Sign Error", error.message ?: "Something went wrong")
318+
}
319+
}
320+
```
321+
322+
### SignResponse
323+
324+
| Name | Description |
325+
| --------- | ------------------------------------------------------------- |
326+
| `success` | Determines whether the request was successful or not. |
327+
| `result?` | Holds the signature for the request when `success` is `true`. |
328+
| `error?` | Holds the error for the request when `success` is `false`. |

src/common/sdk/sfa/android/_sfa-android-install.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ Then, in your app-level `build.gradle` dependencies section, add the following:
1818
dependencies {
1919
// ...
2020
// focus-next-line
21-
implementation 'com.github.web3auth:single-factor-auth-android:3.0.1'
21+
implementation 'com.github.web3auth:single-factor-auth-android:4.0.0'
2222
}
2323
```

src/common/versions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const pnpUnityVersion = `5.x.x`;
77
export const pnpUnrealVersion = `4.1.x`;
88

99
export const sfaWebVersion = `9.2.x`;
10-
export const sfaAndroidVersion = `3.0.1`;
10+
export const sfaAndroidVersion = `4.0.0`;
1111
export const sfaIOSVersion = `9.0.4`;
1212
export const sfaRNVersion = `2.0.x`;
1313
export const sfaFlutterVersion = `5.3.0`;

0 commit comments

Comments
 (0)