|
1 | 1 | import { AccountId, AccountWalletClient } from '@abstract-money/core' |
2 | 2 | import { DeliverTxResponse } from '@cosmjs/stargate' |
3 | | -import { UseMutationOptions, useMutation } from '@tanstack/react-query' |
4 | | -import { useConfig } from '../../../contexts' |
| 3 | +import { |
| 4 | + UseMutationOptions, |
| 5 | + UseMutationResult, |
| 6 | + useMutation, |
| 7 | +} from '@tanstack/react-query' |
| 8 | +import { useAccountId, useConfig } from '../../../contexts' |
| 9 | +import { parseParameters } from '../utils' |
5 | 10 |
|
6 | 11 | type WithdrawMutation = Parameters<AccountWalletClient['withdraw']>[0] |
7 | 12 |
|
| 13 | +export function useWithdraw( |
| 14 | + { accountId }: { accountId: AccountId | undefined }, |
| 15 | + options?: Omit< |
| 16 | + UseMutationOptions<DeliverTxResponse, unknown, WithdrawMutation>, |
| 17 | + 'mutationFn' |
| 18 | + >, |
| 19 | +): UseMutationResult<DeliverTxResponse, unknown, WithdrawMutation> |
| 20 | +export function useWithdraw( |
| 21 | + options?: Omit< |
| 22 | + UseMutationOptions<DeliverTxResponse, unknown, WithdrawMutation>, |
| 23 | + 'mutationFn' |
| 24 | + >, |
| 25 | +): UseMutationResult<DeliverTxResponse, unknown, WithdrawMutation> |
8 | 26 | /** |
9 | 27 | * Hook to withdraw to an Account. |
10 | 28 | * @param options withdraw options. |
11 | 29 | */ |
12 | 30 | export function useWithdraw( |
13 | | - { accountId }: { accountId: AccountId | undefined }, |
14 | | - options?: UseMutationOptions<DeliverTxResponse, unknown, WithdrawMutation>, |
| 31 | + arg1?: |
| 32 | + | { accountId: AccountId | undefined } |
| 33 | + | Omit< |
| 34 | + UseMutationOptions<DeliverTxResponse, unknown, WithdrawMutation>, |
| 35 | + 'mutationFn' |
| 36 | + >, |
| 37 | + arg2?: Omit< |
| 38 | + UseMutationOptions<DeliverTxResponse, unknown, WithdrawMutation>, |
| 39 | + 'mutationFn' |
| 40 | + >, |
15 | 41 | ) { |
| 42 | + const { accountId: accountIdParameter, options } = parseParameters(arg1, arg2) |
| 43 | + const { accountId } = useAccountId({ accountId: accountIdParameter }) |
16 | 44 | const config = useConfig() |
17 | 45 | const accountWalletClient = config.useAccountWalletClient({ |
18 | 46 | chainName: accountId?.chainName, |
|
0 commit comments