From b5347f7cad85f5cddb1eb0c7f17d8835c5f696f4 Mon Sep 17 00:00:00 2001 From: Damian Martinelli Date: Mon, 30 Oct 2023 07:29:12 -0300 Subject: [PATCH] Add copy to clipboard to TxReceipt (#590) --- .../scaffold-eth/Contract/TxReceipt.tsx | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/packages/nextjs/components/scaffold-eth/Contract/TxReceipt.tsx b/packages/nextjs/components/scaffold-eth/Contract/TxReceipt.tsx index 12570b464..6308ed277 100644 --- a/packages/nextjs/components/scaffold-eth/Contract/TxReceipt.tsx +++ b/packages/nextjs/components/scaffold-eth/Contract/TxReceipt.tsx @@ -1,17 +1,47 @@ +import { useState } from "react"; +import { CopyToClipboard } from "react-copy-to-clipboard"; import { TransactionReceipt } from "viem"; +import { CheckCircleIcon, DocumentDuplicateIcon } from "@heroicons/react/24/outline"; import { displayTxResult } from "~~/components/scaffold-eth"; export const TxReceipt = ( txResult: string | number | bigint | Record | TransactionReceipt | undefined, ) => { + const [txResultCopied, setTxResultCopied] = useState(false); + return ( -
- -
- Transaction Receipt +
+
+ {txResultCopied ? ( +
-
-
{displayTxResult(txResult)}
+
+ +
+ Transaction Receipt +
+
+
{displayTxResult(txResult)}
+
);