From c102e70195846ae7273a2704b2ce512502b9ab53 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 15 Sep 2025 21:23:41 +0000 Subject: [PATCH 1/4] feat: Add EIP-7702 support detection to live stats Co-authored-by: joaquim.verges --- .../components/client/live-stats.tsx | 83 ++++++++++++++++--- 1 file changed, 72 insertions(+), 11 deletions(-) diff --git a/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/live-stats.tsx b/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/live-stats.tsx index 7199c3145ff..22898d07990 100644 --- a/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/live-stats.tsx +++ b/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/live-stats.tsx @@ -2,6 +2,7 @@ import { useQuery } from "@tanstack/react-query"; import { CircleCheckIcon, XIcon } from "lucide-react"; +import { Badge } from "@/components/ui/badge"; import { CopyTextButton } from "@/components/ui/CopyTextButton"; import { Skeleton } from "@/components/ui/skeleton"; import { ToolTipLabel } from "@/components/ui/tooltip"; @@ -43,9 +44,7 @@ function useChainStatswithRPC(_rpcUrl: string) { const latency = (performance.now() - startTimeStamp).toFixed(0); const blockNumber = Number.parseInt(json.result.number, 16); - const blockGasLimit = Number.parseInt(json.result.gasLimit, 16); return { - blockGasLimit, blockNumber, latency, }; @@ -61,8 +60,70 @@ function useChainStatswithRPC(_rpcUrl: string) { }); } +function useEIP7702Support(_rpcUrl: string) { + let rpcUrl = _rpcUrl.replace( + // eslint-disable-next-line no-template-curly-in-string + // biome-ignore lint/suspicious/noTemplateCurlyInString: this is expected in this case + "${THIRDWEB_API_KEY}", + NEXT_PUBLIC_DASHBOARD_CLIENT_ID, + ); + + // based on the environment hit dev or production + if (hostnameEndsWith(rpcUrl, "rpc.thirdweb.com")) { + if (!isProd) { + rpcUrl = rpcUrl.replace("rpc.thirdweb.com", "rpc.thirdweb-dev.com"); + } + } + + return useQuery({ + enabled: !!rpcUrl, + queryFn: async () => { + try { + const res = await fetch(rpcUrl, { + body: JSON.stringify({ + id: 1, + jsonrpc: "2.0", + method: "eth_estimateGas", + params: [ + { + from: "0xdeadbeef00000000000000000000000000000000", + to: "0xdeadbeef00000000000000000000000000000000", + data: "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + value: "0x0" + }, + "latest", + { + "0xdeadbeef00000000000000000000000000000000": { + code: "0xef01000000000000000000000000000000000000000001" + } + } + ], + }), + method: "POST", + }); + + const json = await res.json(); + + // If the response has a valid result object, EIP-7702 is enabled + return { + isSupported: !!json.result, + }; + } catch { + // If the request fails or errors, EIP-7702 is not supported + return { + isSupported: false, + }; + } + }, + queryKey: ["eip-7702-support", { rpcUrl }], + refetchInterval: false, // Don't refetch this as it's unlikely to change + refetchOnWindowFocus: false, + }); +} + export function ChainLiveStats(props: { rpc: string }) { const stats = useChainStatswithRPC(props.rpc); + const eip7702Support = useEIP7702Support(props.rpc); return ( <> @@ -120,16 +181,16 @@ export function ChainLiveStats(props: { rpc: string }) { )} - {/* Block Gas Limit */} - }> - {stats.isError ? ( -

N/A

- ) : stats.data ? ( -

- {stats.data.blockGasLimit ?? "N/A"} -

+ {/* EIP-7702 Support */} + + {eip7702Support.isError ? ( + Disabled + ) : eip7702Support.data ? ( + + {eip7702Support.data.isSupported ? "Enabled" : "Disabled"} + ) : ( -
+
)} From e761f820c215425b500bfae61cd8349cf0b0a0ae Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 15 Sep 2025 23:42:05 +0000 Subject: [PATCH 2/4] Refactor: Update live stats component labels Co-authored-by: joaquim.verges --- .../(chainPage)/components/client/live-stats.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/live-stats.tsx b/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/live-stats.tsx index 22898d07990..e2e2b6360a8 100644 --- a/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/live-stats.tsx +++ b/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/live-stats.tsx @@ -168,8 +168,8 @@ export function ChainLiveStats(props: { rpc: string }) { )} - {/* Block Height */} - }> + {/* Latest Block */} + }> {stats.isError ? (

N/A

) : stats.data ? ( @@ -181,8 +181,8 @@ export function ChainLiveStats(props: { rpc: string }) { )}
- {/* EIP-7702 Support */} - + {/* EIP-7702 */} + {eip7702Support.isError ? ( Disabled ) : eip7702Support.data ? ( From 3261dec572aa50009c979a708db291b64fdd4b0d Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Tue, 16 Sep 2025 12:24:11 +1200 Subject: [PATCH 3/4] lint --- .../(chainPage)/components/client/live-stats.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/live-stats.tsx b/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/live-stats.tsx index e2e2b6360a8..99b261337fa 100644 --- a/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/live-stats.tsx +++ b/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/live-stats.tsx @@ -89,21 +89,21 @@ function useEIP7702Support(_rpcUrl: string) { from: "0xdeadbeef00000000000000000000000000000000", to: "0xdeadbeef00000000000000000000000000000000", data: "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - value: "0x0" + value: "0x0", }, "latest", { "0xdeadbeef00000000000000000000000000000000": { - code: "0xef01000000000000000000000000000000000000000001" - } - } + code: "0xef01000000000000000000000000000000000000000001", + }, + }, ], }), method: "POST", }); const json = await res.json(); - + // If the response has a valid result object, EIP-7702 is enabled return { isSupported: !!json.result, @@ -186,7 +186,11 @@ export function ChainLiveStats(props: { rpc: string }) { {eip7702Support.isError ? ( Disabled ) : eip7702Support.data ? ( - + {eip7702Support.data.isSupported ? "Enabled" : "Disabled"} ) : ( From 4bf256fd321b8a76df361cae9c692a9e6316a7cb Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Tue, 16 Sep 2025 12:31:18 +1200 Subject: [PATCH 4/4] style --- .../components/client/live-stats.tsx | 40 +++++++++++++------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/live-stats.tsx b/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/live-stats.tsx index 99b261337fa..ef969f1f6aa 100644 --- a/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/live-stats.tsx +++ b/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/live-stats.tsx @@ -2,7 +2,6 @@ import { useQuery } from "@tanstack/react-query"; import { CircleCheckIcon, XIcon } from "lucide-react"; -import { Badge } from "@/components/ui/badge"; import { CopyTextButton } from "@/components/ui/CopyTextButton"; import { Skeleton } from "@/components/ui/skeleton"; import { ToolTipLabel } from "@/components/ui/tooltip"; @@ -182,17 +181,34 @@ export function ChainLiveStats(props: { rpc: string }) { {/* EIP-7702 */} - - {eip7702Support.isError ? ( - Disabled - ) : eip7702Support.data ? ( - - {eip7702Support.data.isSupported ? "Enabled" : "Disabled"} - + + + + ) : ( + + + + ) + ) : eip7702Support.isError ? ( + + + + ) : null + } + > + {eip7702Support.data ? ( + eip7702Support.data.isSupported ? ( + "Enabled" + ) : ( + "Disabled" + ) + ) : eip7702Support.isError ? ( + "Disabled" ) : (