From 510dd4b3930695d8936ec749cd6b0358431e29af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ti=E1=BA=BFn=20Nguy=E1=BB=85n=20Kh=E1=BA=AFc?= Date: Wed, 21 Aug 2024 23:50:08 +1200 Subject: [PATCH] feat: hook for getting the current signer (#132) --- .changeset/friendly-carrots-melt.md | 5 +++++ packages/react/src/hooks/use-signer.ts | 11 +++++++++++ packages/react/src/index.ts | 1 + 3 files changed, 17 insertions(+) create mode 100644 .changeset/friendly-carrots-melt.md create mode 100644 packages/react/src/hooks/use-signer.ts diff --git a/.changeset/friendly-carrots-melt.md b/.changeset/friendly-carrots-melt.md new file mode 100644 index 00000000..ea036e0d --- /dev/null +++ b/.changeset/friendly-carrots-melt.md @@ -0,0 +1,5 @@ +--- +"@reactive-dot/react": minor +--- + +Added hook for getting the current signer. diff --git a/packages/react/src/hooks/use-signer.ts b/packages/react/src/hooks/use-signer.ts new file mode 100644 index 00000000..c8457acb --- /dev/null +++ b/packages/react/src/hooks/use-signer.ts @@ -0,0 +1,11 @@ +import { SignerContext } from "../contexts/signer.js"; +import { useContext } from "react"; + +/** + * Hook for getting the current signer. + * + * @returns The current signer + */ +export function useSigner() { + return useContext(SignerContext); +} diff --git a/packages/react/src/index.ts b/packages/react/src/index.ts index 9c55cc99..46b3f56d 100644 --- a/packages/react/src/index.ts +++ b/packages/react/src/index.ts @@ -26,6 +26,7 @@ export { useLazyLoadQueryWithRefresh, useQueryRefresher, } from "./hooks/use-query.js"; +export { useSigner } from "./hooks/use-signer.js"; export { useTypedApi } from "./hooks/use-typed-api.js"; export { useWalletConnector } from "./hooks/use-wallet-connector.js"; export { useWalletDisconnector } from "./hooks/use-wallet-disconnector.js";