@safe-global/safe-react-hooks
Version:
A collection of React Hooks that facilitates the interaction of React apps with Safe Smart Accounts
24 lines • 1.04 kB
JavaScript
import { useIsDeployed } from '../hooks/useSafeInfo/useIsDeployed.js';
import { usePublicClientQuery } from '../hooks/usePublicClientQuery.js';
import { QueryKey } from '../constants.js';
/**
* Hook to get all pending transactions for the connected Safe.
* @param params Parameters to customize the hook behavior.
* @param params.config SafeConfig to use instead of the one provided by `SafeProvider`.
* @returns Query result object containing the list of pending transactions.
*/
export function usePendingTransactions(params = {}) {
const { data: isDeployed } = useIsDeployed({ config: params.config });
return usePublicClientQuery({
...params,
querySafeClientFn: async (safeClient) => {
if (!isDeployed) {
throw new Error('Safe is not deployed');
}
const { results } = await safeClient.getPendingTransactions();
return results;
},
queryKey: [QueryKey.PendingTransactions]
});
}
//# sourceMappingURL=usePendingTransactions.js.map