diff --git a/.changeset/witty-seals-punch.md b/.changeset/witty-seals-punch.md new file mode 100644 index 00000000..f371d9d5 --- /dev/null +++ b/.changeset/witty-seals-punch.md @@ -0,0 +1,5 @@ +--- +"@reactive-dot/react": minor +--- + +Add hook for getting all configured chain IDs. diff --git a/packages/react/src/hooks/use-chain-id.ts b/packages/react/src/hooks/use-chain-id.ts index db4aeace..f25267a1 100644 --- a/packages/react/src/hooks/use-chain-id.ts +++ b/packages/react/src/hooks/use-chain-id.ts @@ -1,13 +1,24 @@ import { ChainIdContext } from "../contexts/index.js"; +import { chainConfigsAtom } from "../stores/config.js"; import type { ChainHookOptions } from "./types.js"; import { type ChainId, ReDotError } from "@reactive-dot/core"; +import { useAtomValue } from "jotai"; import { useContext } from "react"; +/** + * Hook for getting all configured chain IDs. + * + * @returns All configured chain IDs + */ +export function useChainIds() { + return Object.keys(useAtomValue(chainConfigsAtom)) as ChainId[]; +} + /** * Hook for getting the current chain ID. * * @param options - Additional options - * @returns + * @returns The current chain ID */ export function useChainId< const TAllowList extends ChainId[],