From 76a796dc68e8b1d93320eba17c5584a60770a588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ti=E1=BA=BFn=20Nguy=E1=BB=85n=20Kh=E1=BA=AFc?= Date: Wed, 3 Jul 2024 21:58:28 +1200 Subject: [PATCH] refactor: add callback signer to options --- apps/docs/docs/getting-started/mutation.md | 2 +- packages/react/src/hooks/useMutation.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/docs/docs/getting-started/mutation.md b/apps/docs/docs/getting-started/mutation.md index cffa7592..e4ba7e24 100644 --- a/apps/docs/docs/getting-started/mutation.md +++ b/apps/docs/docs/getting-started/mutation.md @@ -50,7 +50,7 @@ const [clearIdentityState, clearIdentity] = useMutation((tx) => tx.Identity.clear_identity(), ); -clearIdentity(accounts.at(0)?.polkadotSigner); +clearIdentity({ signer: accounts.at(0)?.polkadotSigner }); ``` ## Submitting transaction diff --git a/packages/react/src/hooks/useMutation.ts b/packages/react/src/hooks/useMutation.ts index 6ab86066..5a482796 100644 --- a/packages/react/src/hooks/useMutation.ts +++ b/packages/react/src/hooks/useMutation.ts @@ -59,13 +59,14 @@ export function useMutation< const submit = useAtomCallback< void, - [from?: PolkadotSigner, options?: TxOptions>] + [options?: TxOptions> & { signer: PolkadotSigner }] >( useCallback( - async (get, _set, submitSigner, submitOptions) => { + async (get, _set, submitOptions) => { setState(PENDING); - const signer = submitSigner ?? options?.signer ?? contextSigner; + const signer = + submitOptions?.signer ?? options?.signer ?? contextSigner; if (signer === undefined) { throw new MutationError("No signer provided");