Skip to content

Commit

Permalink
refactor: add callback signer to options
Browse files Browse the repository at this point in the history
  • Loading branch information
tien committed Jul 3, 2024
1 parent 439f3c1 commit 76a796d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apps/docs/docs/getting-started/mutation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions packages/react/src/hooks/useMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ export function useMutation<

const submit = useAtomCallback<
void,
[from?: PolkadotSigner, options?: TxOptions<ReturnType<TAction>>]
[options?: TxOptions<ReturnType<TAction>> & { 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");
Expand Down

0 comments on commit 76a796d

Please sign in to comment.