From c36c3df44b061d7993fe129b10efdc252c200b41 Mon Sep 17 00:00:00 2001 From: Bartek Date: Wed, 8 Jul 2026 17:01:12 +0200 Subject: [PATCH] feat(wallet-react-ui): transaction signing with user confirmation --- apps/zerodev-signer-demo/next-env.d.ts | 1 + .../src/app/dashboard/page.tsx | 45 ++- .../wallet-react-ui/src/connector.test.ts | 364 +++++++++--------- packages/wallet-react-ui/src/connector.ts | 16 +- packages/wallet-react-ui/src/index.ts | 14 +- packages/wallet-react-ui/tsconfig.build.json | 1 - 6 files changed, 240 insertions(+), 201 deletions(-) diff --git a/apps/zerodev-signer-demo/next-env.d.ts b/apps/zerodev-signer-demo/next-env.d.ts index 1b3be084..830fb594 100644 --- a/apps/zerodev-signer-demo/next-env.d.ts +++ b/apps/zerodev-signer-demo/next-env.d.ts @@ -1,5 +1,6 @@ /// /// +/// // NOTE: This file should not be edited // see https://nextjs.org/docs/app/api-reference/config/typescript for more information. diff --git a/apps/zerodev-signer-demo/src/app/dashboard/page.tsx b/apps/zerodev-signer-demo/src/app/dashboard/page.tsx index 1fea4eed..6a042209 100644 --- a/apps/zerodev-signer-demo/src/app/dashboard/page.tsx +++ b/apps/zerodev-signer-demo/src/app/dashboard/page.tsx @@ -2,6 +2,7 @@ import { useQuery } from "@tanstack/react-query"; import { useAuthenticators } from "@zerodev/wallet-react"; +import { SignatureRequest } from "@zerodev/wallet-react-ui"; import { Check, Copy, @@ -107,6 +108,21 @@ export default function DashboardPage() { const [isLoggingOut, setIsLoggingOut] = useState(false); const [isBalanceRefreshing, setIsBalanceRefreshing] = useState(false); + // Toggle for whether SignatureRequest is mounted. When mounted, the kit + // gates signing calls on user confirmation; when not, calls go through + // silently (background mode). Default off; persisted in localStorage. + const [confirmationEnabled, setConfirmationEnabled] = useState(() => { + if (typeof window === "undefined") return false; + return localStorage.getItem("zd:signingConfirmation") === "true"; + }); + + useEffect(() => { + localStorage.setItem( + "zd:signingConfirmation", + String(confirmationEnabled), + ); + }, [confirmationEnabled]); + // Wagmi hooks const { address, status, chain, } = useAccount(); const publicClient = usePublicClient({ chainId: chain?.id }); @@ -241,6 +257,9 @@ export default function DashboardPage() { return ( <> setShowExportModal(false)} /> + {confirmationEnabled && ( + + )}
@@ -256,7 +275,7 @@ export default function DashboardPage() { Created with {authMethodLabel}
-
+
+