Skip to content

Commit

Permalink
chore: Improve auth-kit docs (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
yagopv authored Dec 4, 2023
1 parent da1a510 commit 01bbe4f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
18 changes: 6 additions & 12 deletions safe-core-sdk/auth-kit/guides/safe-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,19 @@ import {
SafeAuthInitOptions,
} from '@safe-global/auth-kit'

const safeAuthConfig: SafeAuthConfig = {
txServiceUrl: 'https://safe-transaction-mainnet.safe.global',
}
const safeAuthInitOptions: SafeAuthInitOptions = {
enableLogging: true,
showWidgetButton: false,
chainConfig: {
blockExplorerUrl: 'https://etherscan.io',
chainId: '0x1',
displayName: 'Main Ethereum Network',
logo: 'eth.svg',
rpcTarget: `${rpcUrl}`,
ticker: 'ETH',
tickerName: 'Ethereum',
rpcTarget: `${rpcUrl}`
},
}

// You can also pass the SafeAuthConfig as a parameter to the SafeAuthPack constructor if you are using a custom txServiceUrl domain
// e.g. const safeAuthConfig: SafeAuthConfig = {
// txServiceUrl: 'https://safe-transaction-mainnet.safe.global'
// }
const safeAuthPack = new SafeAuthPack(safeAuthConfig)
await safeAuthPack.init(safeAuthInitOptions)
```
Expand Down Expand Up @@ -100,9 +96,7 @@ safeAuthPack.unsubscribe('accountsChanged', accountChangedHandler)
The `SafeAuthPack` instantiation will return the list of associated Safe addresses as part of the response from the `signIn()` method when the `txServiceUrl` is provided.

```typescript
const safeAuthPack = new SafeAuthPack({
txServiceUrl: 'https://safe-transaction-mainnet.safe.global',
})
const safeAuthPack = new SafeAuthPack()
```

## Signing and executing transactions using the SafeAuthPack and Protocol Kit
Expand Down
21 changes: 9 additions & 12 deletions safe-core-sdk/auth-kit/reference/SafeAuthPack.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,15 @@ safeAuthInitOptions {
buttonPosition?: "bottom-left" | "top-left" | "bottom-right" | "top-right"
buildEnv?: "production" | "development" | "testing"
chainConfig?: {
blockExplorerUrl: string
logo: string
tickerName: string
ticker: string
blockExplorerUrl?: string
logo?: string
tickerName?: string
ticker?: string
rpcTarget: string
wcTarget?: string
chainId: string
displayName: string
displayName?: string
isTestnet?: boolean
isErc20?: boolean
tokenAddress?: string
}
}
```
Expand All @@ -77,17 +75,16 @@ safeAuthInitOptions {
- `showWidgetButton` - Show the widget button. Defaults to `true`.
- `buttonPosition` - If `showWidgetButton` is true then this prop represent the position of the widget button. Defaults to `bottom-left`.
- `chainConfig` - The chain configuration. Defaults to `ethereum` if no configuration is provided.
- `chainId` - The chain ID to be used. Should be an hex with 0x prefix (e.g 0x1 for Mainnet).
- `rpcTarget` - The RPC URL to be used.
The following properties are optional:
- `blockExplorerUrl` - Block explorer URL of the chain (e.g `https://etherscan.io`).
- `logo` - Logo URL of the base token of the chain (e.g `https://eth.svg`).
- `tickerName` - Name for ticker (e.g Ethereum).
- `ticker` - Symbol for ticker (e.g ETH).
- `rpcTarget` - The RPC URL to be used.
- `wcTarget?` - The WebSocket URL to be used. Use this or `rpcTarget`.
- `chainId` - The chain ID to be used. Should be an hex with 0x prefix (e.g 0x1 for Mainnet).
- `displayName` - The display name for the network.
- `isTestnet?` - Whether the network is Testnet or not.
- `isErc20?`- Whether the token is an ERC20 token or not.
- `tokenAddress?` - The token address for the chain. Should be an hex with 0x prefix (e.g 0x6b175474e89094c44da98b954eedeac495271d0f for DAI).

**Caveats**

Expand Down Expand Up @@ -134,7 +131,7 @@ AuthKitSignInData {

**Caveats**

- To get the Safe addresses, instantiate the `authKit` with the `txServiceUrl` property in the config object. Otherwise, only the EOA will be returned.
- The `txServiceUrl` should be used with custom Transaction services endpoints. If empty, the default Safe Transaction Service domain will be used if it has been deployed in the corresponding chain.
- ⚠️ This method currently returns the Safe addresses where the EOA is an owner. It doesn't create a Safe. We're investigating ways to enhance the Auth Kit and the associated flows.

### `signOut(safeAuthSignOutOptions?)`
Expand Down

0 comments on commit 01bbe4f

Please sign in to comment.