11"use client" ;
22
3+ import { CopyTextButton } from "@/components/ui/CopyTextButton" ;
4+ import { Badge } from "@/components/ui/badge" ;
35import { Input } from "@/components/ui/input" ;
46import { useDashboardRouter } from "@/lib/DashboardRouter" ;
57import { cn } from "@/lib/utils" ;
@@ -34,7 +36,7 @@ import * as ERC721Ext from "thirdweb/extensions/erc721";
3436import * as ERC1155Ext from "thirdweb/extensions/erc1155" ;
3537import { useReadContract } from "thirdweb/react" ;
3638import { toFunctionSelector } from "thirdweb/utils" ;
37- import { Badge , Button , Card , Heading , Text } from "tw-components" ;
39+ import { Button , Card , Heading , Text } from "tw-components" ;
3840import { useDebounce } from "use-debounce" ;
3941import { useContractFunctionSelectors } from "../../contract-ui/hooks/useContractFunctionSelectors" ;
4042import {
@@ -85,6 +87,11 @@ function ContractFunctionInner({ contract, fn }: ContractFunctionProps) {
8587 return undefined ;
8688 } , [ isERC20 , isERC721Query . data , isERC1155Query . data ] ) ;
8789
90+ const functionSelector = useMemo (
91+ ( ) => ( fn ?. type === "function" ? toFunctionSelector ( fn ) : undefined ) ,
92+ [ fn ] ,
93+ ) ;
94+
8895 if ( ! fn ) {
8996 return null ;
9097 }
@@ -111,21 +118,22 @@ function ContractFunctionInner({ contract, fn }: ContractFunctionProps) {
111118
112119 return (
113120 < Flex direction = "column" gap = { 1.5 } >
114- < Flex
115- alignItems = { { base : "start" , md : "center" } }
116- gap = { 2 }
117- direction = { { base : "column" , md : "row" } }
118- >
121+ < Flex alignItems = "center" gap = { 2 } direction = "row" flexWrap = "wrap" >
119122 < Flex alignItems = "baseline" gap = { 1 } flexWrap = "wrap" >
120123 < Heading size = "subtitle.md" > { camelToTitle ( fn . name ) } </ Heading >
121124 < Heading size = "subtitle.sm" className = "text-muted-foreground" >
122125 ({ fn . name } )
123126 </ Heading >
124127 </ Flex >
125- { isFunction && (
126- < Badge size = "label.sm" variant = "subtle" colorScheme = "green" >
127- { fn . stateMutability }
128- </ Badge >
128+ { isFunction && < Badge variant = "success" > { fn . stateMutability } </ Badge > }
129+ { functionSelector && (
130+ < CopyTextButton
131+ textToCopy = { functionSelector }
132+ textToShow = { functionSelector }
133+ copyIconPosition = "right"
134+ tooltip = "The selector of this function"
135+ className = "ml-auto text-xs"
136+ />
129137 ) }
130138 </ Flex >
131139
@@ -173,11 +181,7 @@ function ContractFunctionInputs(props: {
173181 ({ fn . name } )
174182 </ Heading >
175183 </ Flex >
176- { isFunction && (
177- < Badge size = "label.sm" variant = "subtle" colorScheme = "green" >
178- { fn . stateMutability }
179- </ Badge >
180- ) }
184+ { isFunction && < Badge variant = "success" > { fn . stateMutability } </ Badge > }
181185 </ Flex >
182186
183187 { fn . inputs ?. length ? (
0 commit comments