Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Improve auth-kit docs #298

Merged
merged 6 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
- `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 @@

**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 we have it deployed in the corresponding chain.

Check failure on line 134 in safe-core-sdk/auth-kit/reference/SafeAuthPack.md

View workflow job for this annotation

GitHub Actions / vale

[vale] safe-core-sdk/auth-kit/reference/SafeAuthPack.md#L134

[Vale.Terms] Use 'Safe Transaction Service' instead of 'Safe Transaction service'.
Raw output
{"message": "[Vale.Terms] Use 'Safe Transaction Service' instead of 'Safe Transaction service'.", "location": {"path": "safe-core-sdk/auth-kit/reference/SafeAuthPack.md", "range": {"start": {"line": 134, "column": 103}}}, "severity": "ERROR"}

Check failure on line 134 in safe-core-sdk/auth-kit/reference/SafeAuthPack.md

View workflow job for this annotation

GitHub Actions / vale

[vale] safe-core-sdk/auth-kit/reference/SafeAuthPack.md#L134

[Microsoft.Contractions] Use 'we've' instead of 'we have'.
Raw output
{"message": "[Microsoft.Contractions] Use 'we've' instead of 'we have'.", "location": {"path": "safe-core-sdk/auth-kit/reference/SafeAuthPack.md", "range": {"start": {"line": 134, "column": 151}}}, "severity": "ERROR"}
yagopv marked this conversation as resolved.
Show resolved Hide resolved
- ⚠️ 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
Loading