}
/**
* Hook for checking if a user is authorized by a policy.
*
* @example
* ```tsx
* import { Hooks } from 'wagmi/tempo'
*
* function App() {
* const { data, isLoading } = Hooks.policy.useIsAuthorized({
* policyId: 2n,
* user: '0x...',
* })
*
* if (isLoading) return Loading...
* return Authorized: {data ? 'Yes' : 'No'}
* }
* ```
*
* @param parameters - Parameters.
* @returns Query result with authorization status.
*/
export function useIsAuthorized<
config extends Config = ResolvedRegister['config'],
selectData = Actions.policy.isAuthorized.ReturnValue,
>(
parameters: useIsAuthorized.Parameters = {},
): useIsAuthorized.ReturnValue {
const config = useConfig(parameters)
const chainId = useChainId({ config })
const options = Actions.policy.isAuthorized.queryOptions(config, {
...parameters,
chainId: parameters.chainId ?? chainId,
} as never)
return useQuery(options) as never
}
export declare namespace useIsAuthorized {
export type Parameters<
config extends Config = ResolvedRegister['config'],
selectData = Actions.policy.isAuthorized.ReturnValue,
> = ConfigParameter &
QueryParameter<
Actions.policy.isAuthorized.ReturnValue,
Actions.policy.isAuthorized.ErrorType,
selectData,
Actions.policy.isAuthorized.QueryKey
> &
ExactPartial>
export type ReturnValue<
selectData = Actions.policy.isAuthorized.ReturnValue,
> = UseQueryReturnType
}
/**
* Hook for watching policy creation events.
*
* @example
* ```tsx
* import { Hooks } from 'wagmi/tempo'
*
* function App() {
* Hooks.policy.useWatchCreate({
* onPolicyCreated(args) {
* console.log('Policy created:', args)
* },
* })
*
* return Watching for policy creation...
* }
* ```
*
* @param parameters - Parameters.
*/
export function useWatchCreate<
config extends Config = ResolvedRegister['config'],
>(parameters: useWatchCreate.Parameters = {}) {
const { enabled = true, onPolicyCreated, ...rest } = parameters
const config = useConfig({ config: parameters.config })
const configChainId = useChainId({ config })
const chainId = parameters.chainId ?? configChainId
// biome-ignore lint/correctness/useExhaustiveDependencies: rest.x is explicitly listed
useEffect(() => {
if (!enabled) return
if (!onPolicyCreated) return
return Actions.policy.watchCreate(config, {
...rest,
chainId,
onPolicyCreated,
})
}, [
config,
enabled,
chainId,
onPolicyCreated,
rest.fromBlock,
rest.onError,
rest.poll,
rest.pollingInterval,
])
}
export declare namespace useWatchCreate {
type Parameters = UnionCompute<
ExactPartial> &
ConfigParameter & { enabled?: boolean | undefined }
>
}
/**
* Hook for watching policy admin update events.
*
* @example
* ```tsx
* import { Hooks } from 'wagmi/tempo'
*
* function App() {
* Hooks.policy.useWatchAdminUpdated({
* onAdminUpdated(args) {
* console.log('Policy admin updated:', args)
* },
* })
*
* return Watching for admin updates...
* }
* ```
*
* @param parameters - Parameters.
*/
export function useWatchAdminUpdated<
config extends Config = ResolvedRegister['config'],
>(parameters: useWatchAdminUpdated.Parameters = {}) {
const { enabled = true, onAdminUpdated, ...rest } = parameters
const config = useConfig({ config: parameters.config })
const configChainId = useChainId({ config })
const chainId = parameters.chainId ?? configChainId
// biome-ignore lint/correctness/useExhaustiveDependencies: rest.x is explicitly listed
useEffect(() => {
if (!enabled) return
if (!onAdminUpdated) return
return Actions.policy.watchAdminUpdated(config, {
...rest,
chainId,
onAdminUpdated,
})
}, [
config,
enabled,
chainId,
onAdminUpdated,
rest.fromBlock,
rest.onError,
rest.poll,
rest.pollingInterval,
])
}
export declare namespace useWatchAdminUpdated {
type Parameters = UnionCompute<
ExactPartial> &
ConfigParameter & { enabled?: boolean | undefined }
>
}
/**
* Hook for watching whitelist update events.
*
* @example
* ```tsx
* import { Hooks } from 'wagmi/tempo'
*
* function App() {
* Hooks.policy.useWatchWhitelistUpdated({
* onWhitelistUpdated(args) {
* console.log('Whitelist updated:', args)
* },
* })
*
* return Watching for whitelist updates...
* }
* ```
*
* @param parameters - Parameters.
*/
export function useWatchWhitelistUpdated<
config extends Config = ResolvedRegister['config'],
>(parameters: useWatchWhitelistUpdated.Parameters = {}) {
const { enabled = true, onWhitelistUpdated, ...rest } = parameters
const config = useConfig({ config: parameters.config })
const configChainId = useChainId({ config })
const chainId = parameters.chainId ?? configChainId
// biome-ignore lint/correctness/useExhaustiveDependencies: rest.x is explicitly listed
useEffect(() => {
if (!enabled) return
if (!onWhitelistUpdated) return
return Actions.policy.watchWhitelistUpdated(config, {
...rest,
chainId,
onWhitelistUpdated,
})
}, [
config,
enabled,
chainId,
onWhitelistUpdated,
rest.fromBlock,
rest.onError,
rest.poll,
rest.pollingInterval,
])
}
export declare namespace useWatchWhitelistUpdated {
type Parameters = UnionCompute<
ExactPartial> &
ConfigParameter & { enabled?: boolean | undefined }
>
}
/**
* Hook for watching blacklist update events.
*
* @example
* ```tsx
* import { Hooks } from 'wagmi/tempo'
*
* function App() {
* Hooks.policy.useWatchBlacklistUpdated({
* onBlacklistUpdated(args) {
* console.log('Blacklist updated:', args)
* },
* })
*
* return Watching for blacklist updates...
* }
* ```
*
* @param parameters - Parameters.
*/
export function useWatchBlacklistUpdated<
config extends Config = ResolvedRegister['config'],
>(parameters: useWatchBlacklistUpdated.Parameters = {}) {
const { enabled = true, onBlacklistUpdated, ...rest } = parameters
const config = useConfig({ config: parameters.config })
const configChainId = useChainId({ config })
const chainId = parameters.chainId ?? configChainId
// biome-ignore lint/correctness/useExhaustiveDependencies: rest.x is explicitly listed
useEffect(() => {
if (!enabled) return
if (!onBlacklistUpdated) return
return Actions.policy.watchBlacklistUpdated(config, {
...rest,
chainId,
onBlacklistUpdated,
})
}, [
config,
enabled,
chainId,
onBlacklistUpdated,
rest.fromBlock,
rest.onError,
rest.poll,
rest.pollingInterval,
])
}
export declare namespace useWatchBlacklistUpdated {
type Parameters = UnionCompute<
ExactPartial> &
ConfigParameter & { enabled?: boolean | undefined }
>
}