From 901c31126d7c64e35382c6047d5babd002dd666b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Wed, 16 Oct 2024 17:00:14 +0100 Subject: [PATCH] Update owners management descriptions and code snippets --- .../useupdateowners/add.mdx | 27 +++++++++++-------- .../useupdateowners/remove.mdx | 27 +++++++++++-------- .../useupdateowners/swap.mdx | 27 +++++++++++-------- 3 files changed, 48 insertions(+), 33 deletions(-) diff --git a/pages/reference-sdk-react-hooks/useupdateowners/add.mdx b/pages/reference-sdk-react-hooks/useupdateowners/add.mdx index 21d1c49d9..57b0f9567 100644 --- a/pages/reference-sdk-react-hooks/useupdateowners/add.mdx +++ b/pages/reference-sdk-react-hooks/useupdateowners/add.mdx @@ -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 @@ -12,24 +14,27 @@ import { Tabs } from "nextra/components" ```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 ( <> - - {data && JSON.stringify(data, null, 2)} + {data && JSON.stringify(data)} ) } diff --git a/pages/reference-sdk-react-hooks/useupdateowners/remove.mdx b/pages/reference-sdk-react-hooks/useupdateowners/remove.mdx index bfa02bb85..978984350 100644 --- a/pages/reference-sdk-react-hooks/useupdateowners/remove.mdx +++ b/pages/reference-sdk-react-hooks/useupdateowners/remove.mdx @@ -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 @@ -12,24 +14,27 @@ import { Tabs } from "nextra/components" ```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 ( <> - - {data && JSON.stringify(data, null, 2)} + {data && JSON.stringify(data)} ) } diff --git a/pages/reference-sdk-react-hooks/useupdateowners/swap.mdx b/pages/reference-sdk-react-hooks/useupdateowners/swap.mdx index c06600bde..12c7c23d2 100644 --- a/pages/reference-sdk-react-hooks/useupdateowners/swap.mdx +++ b/pages/reference-sdk-react-hooks/useupdateowners/swap.mdx @@ -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 @@ -12,24 +14,27 @@ import { Tabs } from "nextra/components" ```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 ( <> - - {data && JSON.stringify(data, null, 2)} + {data && JSON.stringify(data)} ) }