Skip to content

Commit 6aa4cab

Browse files
update swift sfa docs
1 parent ed18025 commit 6aa4cab

File tree

6 files changed

+181
-25
lines changed

6 files changed

+181
-25
lines changed

docs/sdk/pnp/ios/usage.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ do {
423423
// focus-start
424424
try await web3Auth!.launchWalletServices(
425425
chainConfig: ChainConfig(
426-
chainId: "11155111",
426+
chainId: "0xaa36a7",
427427
rpcTarget: "https://eth-sepolia.public.blastapi.io"
428428
)
429429
)
@@ -467,7 +467,7 @@ do {
467467
// focus-start
468468
let response = try await self.web3Auth?.request(
469469
chainConfig: ChainConfig(
470-
chainId: "11155111",
470+
chainId: "0xaa36a7",
471471
rpcTarget: "https://eth-sepolia.public.blastapi.io"
472472
),
473473
method: "personal_sign",

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ according to the preference of your project.
1515
The `SingleFactoreAuth` constructor takes an object called `Web3AuthOptions` as input. The
1616
constructor parameters are listed below
1717

18-
| Parameter | Description |
19-
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
20-
| `clientId` | Your Web3Auth Client Id from [Web3Auth Dashboard](https://dashboard.web3auth.io/). |
21-
| `web3AuthNetwork` | The Web3auth network to be used by the SDK. Supported values are `.SAPPHIRE_MAINNET`, `.SAPPHIRE_DEVNET`, `.MAINNET`, `.TESTNET`, `.CYAN`, and `.AQUA` |
22-
| `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. |
23-
| `serverTimeOffset` | Specifies the server time offset in seconds. This parameter is used to adjust the server time to the local time. The default value is 0 seconds. |
24-
| `storageServerUrl?` | Specifies the storage server URL. The default value is `https://session.web3auth.io`. |
18+
| Parameter | Description |
19+
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
20+
| `clientId` | Your Web3Auth Client Id from [Web3Auth Dashboard](https://dashboard.web3auth.io/). |
21+
| `web3AuthNetwork` | The Web3auth network to be used by the SDK. Supported values are `.SAPPHIRE_MAINNET`, `.SAPPHIRE_DEVNET`, `.MAINNET`, `.TESTNET`, `.CYAN`, and `.AQUA` |
22+
| `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. |
23+
| `serverTimeOffset` | Specifies the server time offset in seconds. This parameter is used to adjust the server time to the local time. The default value is 0 seconds. |
24+
| `storageServerUrl?` | Specifies the storage server URL. The default value is `https://session.web3auth.io`. |
25+
| `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 and request signature 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). |
26+
| `redirectUrl?` | URL that Web3Auth will redirect API responses upon successful `request` method call. Please note, that it's mandatory to configure the `redirectUrl` if you are using the `request` method. Redirect Url shoudl be your bundle identifier. |
2527

2628
## Create instance
2729

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

Lines changed: 167 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ you'll see an Error message.
2121

2222
The SingleFactorAuth instance natively provides the following methods:
2323

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

3133
## Login User
3234

@@ -162,11 +164,163 @@ if(sessionData != nil) {
162164

163165
### Response
164166

165-
The `SessionData` has the following four functions to retrive the relevant session information.
167+
The `SessionData` has the following four properties to retrive the relevant session information.
166168

167-
| Function Name | Description |
168-
| ------------------ | ------------------------------------------------------------------------- |
169-
| `getPrivateKey` | Retrieves the user's private key. |
170-
| `getPublicAddress` | Retrieves the user's public address. |
171-
| `getUserInfo` | Retrieves the user's information like email, name, verifier id, and more. |
172-
| `getSignatures` | Retrieves the node's signatures that are returned for request. |
169+
| Name | Description |
170+
| --------------- | ------------------------------------------------------------------------- |
171+
| `privateKey` | Retrieves the user's private key. |
172+
| `publicAddress` | Retrieves the user's public address. |
173+
| `userInfo` | Retrieves the user's information like email, name, verifier id, and more. |
174+
| `signatures` | Retrieves the node's signatures that are returned for request. |
175+
176+
## Show Wallet UI
177+
178+
The `showWalletUI` method launches a WebView which allows you to use the templated wallet UI
179+
services. The method takes `ChainConfig` as the required input. Wallet Services is currently only
180+
available for EVM chains.
181+
182+
:::note
183+
184+
Access to Wallet Services is gated. You can use this feature in `sapphire_devnet` for free. The
185+
minimum [pricing plan](https://web3auth.io/pricing.html) to use this feature in a production
186+
environment is the **Scale Plan**.
187+
188+
:::
189+
190+
![Wallet Services](/images/mobile-wallet-services.png)
191+
192+
### Parameters
193+
194+
<Tabs
195+
defaultValue="table"
196+
values={[
197+
{ label: "Table", value: "table" },
198+
{ label: "Class", value: "class" },
199+
]}
200+
>
201+
202+
<TabItem value="table">
203+
204+
| Parameter | Description |
205+
| ------------------- | --------------------------------------------------------------------------------------------------------------------------- |
206+
| `chainNamespace` | Custom configuration for your preferred blockchain. As of now only EVM supported. Default value is `ChainNamespace.eip155`. |
207+
| `decimals?` | Number of decimals for the currency ticker. Default value is 18, and accepts `Int` as value. |
208+
| `blockExplorerUrl?` | Blockchain's explorer URL. (eg: `https://etherscan.io`) |
209+
| `chainId` | The chain id of the selected blockchain in hex string format. |
210+
| `displayName?` | Display Name for the chain. |
211+
| `logo?` | Logo for the selected `chainNamespace` & `chainId`. |
212+
| `rpcTarget` | RPC Target URL for the selected `chainNamespace` & `chainId`. |
213+
| `ticker?` | Default currency ticker of the network (e.g: `ETH`) |
214+
| `tickerName?` | Name for currency ticker (e.g: `Ethereum`) |
215+
216+
</TabItem>
217+
218+
<TabItem value="class">
219+
220+
```swift
221+
public enum ChainNamespace: String, Codable {
222+
case eip155
223+
case solana
224+
}
225+
226+
public struct ChainConfig: Codable {
227+
public init(chainNamespace: ChainNamespace = ChainNamespace.eip155, decimals: Int? = 18, blockExplorerUrl: String? = nil, chainId: String, displayName: String? = nil, logo: String? = nil, rpcTarget: String, ticker: String? = nil, tickerName: String? = nil) {
228+
self.chainNamespace = chainNamespace
229+
self.decimals = decimals
230+
self.blockExplorerUrl = blockExplorerUrl
231+
self.chainId = chainId
232+
self.displayName = displayName
233+
self.logo = logo
234+
self.rpcTarget = rpcTarget
235+
self.ticker = ticker
236+
self.tickerName = tickerName
237+
}
238+
}
239+
```
240+
241+
</TabItem>
242+
</Tabs>
243+
244+
### Usage
245+
246+
```swift
247+
do {
248+
try await web3Auth.showWalletUI(
249+
chainConfig: ChainConfig(
250+
chainId: "0xaa36a7",
251+
rpcTarget: "https://eth-sepolia.public.blastapi.io"
252+
)
253+
)
254+
} catch {
255+
// Handle error
256+
}
257+
```
258+
259+
## Request signature
260+
261+
The `request` method facilitates the use of templated transaction screens for signing transactions.
262+
The method will return [SignResponse](#signresponse). It can be used to sign transactions for any
263+
EVM chain and screens can be whitelabeled to your branding.
264+
265+
Please check the list of
266+
[JSON RPC methods](https://docs.metamask.io/wallet/reference/json-rpc-api/), noting that the request
267+
method currently supports only the signing methods.
268+
269+
:::note
270+
271+
Please note, to use the `request` method, you need to configure the `redirectUrl` in the
272+
[`Web3AuthOptions`](/docs/sdk/sfa/sfa-ios/initialize#parameters) while initializing the SDK.
273+
274+
:::
275+
276+
![Request Method](/images/mobile-request-method.png)
277+
278+
### Parameters
279+
280+
| Parameter | Description |
281+
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
282+
| `chainConfig` | Defines the chain to be used for signature. |
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+
```swift
289+
do {
290+
var params = [Any]()
291+
// Message to be signed
292+
params.append("Hello, Web3Auth from iOS!")
293+
// User's EOA address
294+
params.append(address)
295+
296+
// focus-start
297+
let response = try await web3Auth.request(
298+
chainConfig: ChainConfig(
299+
chainId: "0xaa36a7",
300+
rpcTarget: "https://eth-sepolia.public.blastapi.io"
301+
),
302+
method: "personal_sign",
303+
requestParams: params
304+
)
305+
// focus-end
306+
307+
if response!.success {
308+
print(response!.result!)
309+
} else {
310+
// Handle Error
311+
print(response!.error!)
312+
}
313+
314+
} catch {
315+
print(error.localizedDescription)
316+
// Handle error
317+
}
318+
```
319+
320+
### SignResponse
321+
322+
| Name | Description |
323+
| --------- | ------------------------------------------------------------- |
324+
| `success` | Determines whether the request was successful or not. |
325+
| `result?` | Holds the signature for the request when `success` is `true`. |
326+
| `error?` | Holds the error for the request when `success` is `false`. |

src/common/sdk/sfa/ios/_sfa-ios-cocoapods.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ To install the Web3Auth SingleFactorAuth SDK using Cocoapods, follow the below s
33
1. Open the Podfile, and add the SingleFactorAuth pod:
44

55
```sh
6-
pod 'SingleFactorAuth', '~> 9.0.4'
6+
pod 'SingleFactorAuth', '~> 9.1.0'
77
```
88

99
2. Once added, use `pod install` command to download the SingleFactorAuth dependency.

src/common/sdk/sfa/ios/_sfa-ios-spm.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
https://github.com/Web3Auth/single-factor-auth-swift
77
```
88

9-
From the `Dependency Rule` dropdown, select `Exact Version` and enter `9.0.4` as the version.
9+
From the `Dependency Rule` dropdown, select `Exact Version` and enter `9.1.0` as the version.
1010

1111
1. When finished, Xcode will automatically begin resolving and downloading your dependencies in the
1212
background.

src/common/versions.ts

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

99
export const sfaWebVersion = `9.2.x`;
1010
export const sfaAndroidVersion = `4.0.0`;
11-
export const sfaIOSVersion = `9.0.4`;
11+
export const sfaIOSVersion = `9.1.0`;
1212
export const sfaRNVersion = `2.0.x`;
1313
export const sfaFlutterVersion = `6.0.0`;
1414
export const sfaNodeJSVersion = `7.4.x`;

0 commit comments

Comments
 (0)