ReadHookQueryOptions#
The /fhe-airdrop read hooks took a query option first. The /fhe-vesting, /fhe-disperse and /testnet-faucet read hooks now take the same option, typed ReadHookQueryOptions and exported from each of those react subpaths.
import type { UseQueryOptions } from "@tanstack/react-query";
interface ReadHookQueryOptions<TData = unknown> {
/** TanStack Query options for this read, minus queryKey and queryFn. */
query?: Omit<UseQueryOptions<TData, Error>, "queryKey" | "queryFn">;
}queryKey and queryFn stay owned by the hook, so cache identity never drifts from what was fetched. Everything else (staleTime, gcTime, refetchInterval, placeholderData and so on) passes through.
import { useIsRegistered } from "@tokenops/sdk/fhe-disperse/react";
const { data: isRegistered } = useIsRegistered({
user,
query: {
refetchInterval: 10_000,
enabled: panelOpen, // can turn a ready query off, never an unready one on
},
});enabled is combined, not replaced#
Each hook has its own readiness: a resolved client, a connected public client, the arguments it needs. query.enabled is combined with that readiness. It can turn a ready query off; it can never turn an unready one on, so enabled: truedoes not make a hook fetch without its address. The caller's value is passed through rather than coerced, so TanStack's function form of enabled keeps working.
select keeps the result type#
query.select is typed (data: TData) => TData on every product, so the hook result stays TData. Use it to normalize a value; derive a different shape from data at the call site rather than casting a reshaping selector.
import { getAddress } from "viem";
import { useManagerToken } from "@tokenops/sdk/fhe-vesting/react";
// select is (data: Address) => Address here: normalize, do not reshape.
const { data: token } = useManagerToken({
address: manager,
query: { select: (t) => getAddress(t) },
});
const label = token ? shortAddress(token) : undefined; // derive other shapes hereReads that default to staleTime: Infinity#
Reads of values baked into bytecode or fixed at create time default to staleTime: Infinity. Pass query: { staleTime: 0 } to opt out. The list below is taken from the hook code itself, not the TSDoc, checked against the installed 2.0.0-rc.1 build. Every other read defaults to staleTime: 0.
| Subpath | Read hooks | Default staleTime: Infinity | Infinity once positive |
|---|---|---|---|
@tokenops/sdk/fhe-vesting/react | 29 | useManagerToken, useManagerFeeType, useManagerFee, useManagerFeeInfo, useManagerDeploymentBlockNumber, useManagerIsSplitEnabled, useManagerIsPausable, useRoleConstants | none |
@tokenops/sdk/fhe-vesting/advanced/react | 1 | none | none |
@tokenops/sdk/fhe-airdrop/react | 33 | useAirdropConfig, useAirdropDeploymentMode, useAirdropRoleAdmin, useAirdropRoleConstants, useComplianceRoleConstants, useDedupMode, useEcdsaDomain, useIsMerkleRootMutable, useUnwrapRequest | useIsAirdrop, useComplianceManagerOf, useTokenOf |
@tokenops/sdk/fhe-airdrop/advanced/react | 12 | useFactoryRoleConstants | none |
@tokenops/sdk/fhe-disperse/react | 13 | useDeploymentBlockNumber, useWalletImplementation | none |
@tokenops/sdk/testnet-faucet/react | 9 | useFaucetRate, useFaucetDecimals, useUnderlyingDecimals, useUnderlyingTokenAddress, useMaxTotalSupply, useFaucetMetadata | none |
useIsOperator is the exception#
useIsOperator lives in /fhe/react and is re-exported by the vesting and disperse react subpaths. It takes a plain enabled and chainId, not a query object.