From 2f8d51514c7d641a0a58e22bb78c62087131dfa9 Mon Sep 17 00:00:00 2001 From: Yos Riady Date: Fri, 6 Mar 2026 15:33:55 +0700 Subject: [PATCH] Clean up builder codes UI --- .../contract/WriteOnlyFunctionForm.tsx | 21 +----- .../packages/nextjs/app/page.tsx | 5 -- .../nextjs/components/SendTransaction.tsx | 74 ------------------- .../packages/nextjs/package.json | 1 - 4 files changed, 1 insertion(+), 100 deletions(-) delete mode 100644 with-next-app-router/packages/nextjs/components/SendTransaction.tsx diff --git a/with-next-app-router/packages/nextjs/app/debug/_components/contract/WriteOnlyFunctionForm.tsx b/with-next-app-router/packages/nextjs/app/debug/_components/contract/WriteOnlyFunctionForm.tsx index 36fedcc..4829a3c 100644 --- a/with-next-app-router/packages/nextjs/app/debug/_components/contract/WriteOnlyFunctionForm.tsx +++ b/with-next-app-router/packages/nextjs/app/debug/_components/contract/WriteOnlyFunctionForm.tsx @@ -1,6 +1,5 @@ "use client"; -import { Attribution } from "ox/erc8021"; import { useEffect, useState } from "react"; import { InheritanceTooltip } from "./InheritanceTooltip"; import { Abi, AbiFunction } from "abitype"; @@ -35,7 +34,6 @@ export const WriteOnlyFunctionForm = ({ }: WriteOnlyFunctionFormProps) => { const [form, setForm] = useState>(() => getInitialFormState(abiFunction)); const [txValue, setTxValue] = useState(""); - const [builderCode, setBuilderCode] = useState(""); const { chain } = useAccount(); const writeTxn = useTransactor(); const { targetNetwork } = useTargetNetwork(); @@ -53,7 +51,6 @@ export const WriteOnlyFunctionForm = ({ abi: abi, args: getParsedContractFunctionArgs(form), value: txValue ? BigInt(txValue) : BigInt(0), - ...(builderCode ? { dataSuffix: Attribution.toDataSuffix({ codes: [builderCode] }) } : {}), }); await writeTxn(makeWriteWithParams); onChange(); @@ -88,8 +85,7 @@ export const WriteOnlyFunctionForm = ({ /> ); }); - // Builder code block is always rendered, so use column layout for consistent UX - const zeroInputs = false; + const zeroInputs = inputs.length === 0 && abiFunction.stateMutability !== "payable"; return (
@@ -115,21 +111,6 @@ export const WriteOnlyFunctionForm = ({ />
) : null} -
-
- builder code - ERC-8021 (optional) -
- { - setDisplayedTxResult(undefined); - setBuilderCode(e.target.value); - }} - /> -
{!zeroInputs && (
diff --git a/with-next-app-router/packages/nextjs/app/page.tsx b/with-next-app-router/packages/nextjs/app/page.tsx index 4263241..492ba99 100644 --- a/with-next-app-router/packages/nextjs/app/page.tsx +++ b/with-next-app-router/packages/nextjs/app/page.tsx @@ -6,7 +6,6 @@ import { useFormo } from "@formo/analytics"; import type { NextPage } from "next"; import { useAccount } from "wagmi"; import { BugAntIcon, MagnifyingGlassIcon } from "@heroicons/react/24/outline"; -import { SendTransaction } from "~~/components/SendTransaction"; import { SignMessage } from "~~/components/SignMessage"; import { SignTypedData } from "~~/components/SignTypedData"; import { Address } from "~~/components/scaffold-eth"; @@ -154,10 +153,6 @@ const Home: NextPage = (): JSX.Element => {
-
- -
-
diff --git a/with-next-app-router/packages/nextjs/components/SendTransaction.tsx b/with-next-app-router/packages/nextjs/components/SendTransaction.tsx deleted file mode 100644 index 139c145..0000000 --- a/with-next-app-router/packages/nextjs/components/SendTransaction.tsx +++ /dev/null @@ -1,74 +0,0 @@ -import { Attribution } from "ox/erc8021"; -import * as React from "react"; -import { useAccount, useSendTransaction, useWaitForTransactionReceipt } from "wagmi"; - -export function SendTransaction() { - const { address } = useAccount(); - const { data: hash, error, isPending, sendTransaction } = useSendTransaction(); - const [builderCode, setBuilderCode] = React.useState("test_builder"); - const dataSuffix = React.useMemo( - () => (builderCode ? Attribution.toDataSuffix({ codes: [builderCode] }) : undefined), - [builderCode], - ); - - const { isLoading: isConfirming, isSuccess: isConfirmed } = useWaitForTransactionReceipt({ - hash, - }); - - const handleSubmit = async (event: React.FormEvent) => { - event.preventDefault(); - if (address) { - // useSendTransaction has no dataSuffix param; for this test tx the only calldata - // is the ERC-8021 suffix, so passing it as data is correct and indexers will parse it. - sendTransaction({ - to: "0x000000000000000000000000000000000000dEaD", - value: BigInt(0), - ...(dataSuffix ? { data: dataSuffix } : {}), - }); - } - }; - - return ( - -
- - setBuilderCode(e.target.value)} - className="w-full p-2 border rounded-md" - required - /> -
-

ERC-8021 Builder Code: "{builderCode}"

-

dataSuffix: {dataSuffix ?? "—"}

-
-
- - - - {hash && ( -
-
- Transaction Hash: {hash} -
- {isConfirming &&
Waiting for confirmation...
} - {isConfirmed &&
Transaction confirmed!
} -
- )} - - {error &&
{error.message}
} - - ); -} diff --git a/with-next-app-router/packages/nextjs/package.json b/with-next-app-router/packages/nextjs/package.json index 360a4c2..2a02a11 100644 --- a/with-next-app-router/packages/nextjs/package.json +++ b/with-next-app-router/packages/nextjs/package.json @@ -25,7 +25,6 @@ "next": "~14.2.11", "next-nprogress-bar": "~2.3.13", "next-themes": "~0.3.0", - "ox": "^0.14.0", "qrcode.react": "~3.1.0", "react": "~18.3.1", "react-copy-to-clipboard": "~5.1.0",