Skip to content

Commit

Permalink
Update owners management descriptions and code snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
germartinez committed Oct 16, 2024
1 parent 91eda2f commit 901c311
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 33 deletions.
27 changes: 16 additions & 11 deletions pages/reference-sdk-react-hooks/useupdateowners/add.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { Tabs } from "nextra/components"

# `add`

- The react-query [`UseMutationResult`](https://tanstack.com/query/latest/docs/framework/react/reference/useMutation).
- The `mutate` and `mutateAsync` functions have been renamed to `addOwner` and `addOwnerAsync` respectively.
Executes a Safe transaction to add a new owner to the Safe connected to the [`SafeProvider`](./safeprovider.mdx) or sends it to the Safe Transaction Service if it isn't executable.

- If the `threshold` of the connected Safe is greater than `1`, it creates the Safe transaction and submits it to the Safe Transaction Service to collect the signatures from the Safe owners.
- If the `threshold` of the connected Safe is `1`, it executes the Safe transaction.

## Usage

Expand All @@ -12,24 +14,27 @@ import { Tabs } from "nextra/components"
<Tabs items={['App.tsx', 'main.tsx']}>
<Tabs.Tab>
```typescript
import { useUpdateOwners } from '@safe-global/safe-react-hooks'
import { useUpdateOwners, AddOwnerVariables } from '@safe-global/safe-react-hooks'

function App() {
const { add } = useUpdateOwners()
const { addOwner, data, error, isLoading } = add

const ownerAddress = '0x...'

if (isLoading) return <>Loading...</>
const {
addOwner,
data,
// ...
} = add

if (error) return <>Error: {error.message}</>
const addOwnerParams: AddOwnerVariables = {
ownerAddress: '0x...',
threshold: 2 // Optional
}

return (
<>
<button onClick={() => addOwner({ ownerAddress })} disabled={isLoading}>
<button onClick={() => addOwner(addOwnerParams)}>
Add Owner
</button>
{data && JSON.stringify(data, null, 2)}
{data && JSON.stringify(data)}
</>
)
}
Expand Down
27 changes: 16 additions & 11 deletions pages/reference-sdk-react-hooks/useupdateowners/remove.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { Tabs } from "nextra/components"

# `remove`

- The react-query [`UseMutationResult`](https://tanstack.com/query/latest/docs/framework/react/reference/useMutation).
- The `mutate` and `mutateAsync` functions have been renamed to `removeOwner` and `removeOwnerAsync` respectively.
Executes a Safe transaction to remove an owner of the Safe connected to the [`SafeProvider`](./safeprovider.mdx) or sends it to the Safe Transaction Service if it isn't executable.

- If the `threshold` of the connected Safe is greater than `1`, it creates the Safe transaction and submits it to the Safe Transaction Service to collect the signatures from the Safe owners.
- If the `threshold` of the connected Safe is `1`, it executes the Safe transaction.

## Usage

Expand All @@ -12,24 +14,27 @@ import { Tabs } from "nextra/components"
<Tabs items={['App.tsx', 'main.tsx']}>
<Tabs.Tab>
```typescript
import { useUpdateOwners } from '@safe-global/safe-react-hooks'
import { useUpdateOwners, RemoveOwnerVariables } from '@safe-global/safe-react-hooks'

function App() {
const { remove } = useUpdateOwners()
const { removeOwner, data, error, isLoading } = swap

const ownerAddress = '0x...'

if (isLoading) return <>Loading...</>
const {
removeOwner,
data,
// ...
} = remove

if (error) return <>Error: {error.message}</>
const removeOwnerParams: RemoveOwnerVariables = {
ownerAddress: '0x...',
threshold: 1 // Optional
}

return (
<>
<button onClick={() => removeOwner({ ownerAddress })} disabled={isLoading}>
<button onClick={() => removeOwner(removeOwnerParams)}>
Remove Owner
</button>
{data && JSON.stringify(data, null, 2)}
{data && JSON.stringify(data)}
</>
)
}
Expand Down
27 changes: 16 additions & 11 deletions pages/reference-sdk-react-hooks/useupdateowners/swap.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { Tabs } from "nextra/components"

# `swap`

- The react-query [`UseMutationResult`](https://tanstack.com/query/latest/docs/framework/react/reference/useMutation).
- The `mutate` and `mutateAsync` functions have been renamed to `swapOwner` and `swapOwnerAsync` respectively.
Executes a Safe transaction to swap an owner of the Safe connected to the [`SafeProvider`](./safeprovider.mdx) or sends it to the Safe Transaction Service if it isn't executable.

- If the `threshold` of the connected Safe is greater than `1`, it creates the Safe transaction and submits it to the Safe Transaction Service to collect the signatures from the Safe owners.
- If the `threshold` of the connected Safe is `1`, it executes the Safe transaction.

## Usage

Expand All @@ -12,24 +14,27 @@ import { Tabs } from "nextra/components"
<Tabs items={['App.tsx', 'main.tsx']}>
<Tabs.Tab>
```typescript
import { useUpdateOwners } from '@safe-global/safe-react-hooks'
import { useUpdateOwners, SwapOwnerVariables } from '@safe-global/safe-react-hooks'

function App() {
const { swap } = useUpdateOwners()
const { swapOwner, data, error, isLoading } = swap

const ownerAddress = '0x...'

if (isLoading) return <>Loading...</>
const {
swapOwner,
data,
// ...
} = swap

if (error) return <>Error: {error.message}</>
const swapOwnerParams: SwapOwnerVariables = {
oldOwnerAddress: '0x...',
newOwnerAddress: '0x...'
}

return (
<>
<button onClick={() => swapOwner({ ownerAddress })} disabled={isLoading}>
<button onClick={() => swapOwner(swapOwnerParams)}>
Swap Owner
</button>
{data && JSON.stringify(data, null, 2)}
{data && JSON.stringify(data)}
</>
)
}
Expand Down

0 comments on commit 901c311

Please sign in to comment.