1
1
"use client" ;
2
2
3
+ import { CopyTextButton } from "@/components/ui/CopyTextButton" ;
4
+ import { Badge } from "@/components/ui/badge" ;
3
5
import { Input } from "@/components/ui/input" ;
4
6
import { useDashboardRouter } from "@/lib/DashboardRouter" ;
5
7
import { cn } from "@/lib/utils" ;
@@ -34,7 +36,7 @@ import * as ERC721Ext from "thirdweb/extensions/erc721";
34
36
import * as ERC1155Ext from "thirdweb/extensions/erc1155" ;
35
37
import { useReadContract } from "thirdweb/react" ;
36
38
import { toFunctionSelector } from "thirdweb/utils" ;
37
- import { Badge , Button , Card , Heading , Text } from "tw-components" ;
39
+ import { Button , Card , Heading , Text } from "tw-components" ;
38
40
import { useDebounce } from "use-debounce" ;
39
41
import { useContractFunctionSelectors } from "../../contract-ui/hooks/useContractFunctionSelectors" ;
40
42
import {
@@ -85,6 +87,11 @@ function ContractFunctionInner({ contract, fn }: ContractFunctionProps) {
85
87
return undefined ;
86
88
} , [ isERC20 , isERC721Query . data , isERC1155Query . data ] ) ;
87
89
90
+ const functionSelector = useMemo (
91
+ ( ) => ( fn ?. type === "function" ? toFunctionSelector ( fn ) : undefined ) ,
92
+ [ fn ] ,
93
+ ) ;
94
+
88
95
if ( ! fn ) {
89
96
return null ;
90
97
}
@@ -111,21 +118,22 @@ function ContractFunctionInner({ contract, fn }: ContractFunctionProps) {
111
118
112
119
return (
113
120
< 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" >
119
122
< Flex alignItems = "baseline" gap = { 1 } flexWrap = "wrap" >
120
123
< Heading size = "subtitle.md" > { camelToTitle ( fn . name ) } </ Heading >
121
124
< Heading size = "subtitle.sm" className = "text-muted-foreground" >
122
125
({ fn . name } )
123
126
</ Heading >
124
127
</ 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
+ />
129
137
) }
130
138
</ Flex >
131
139
@@ -173,11 +181,7 @@ function ContractFunctionInputs(props: {
173
181
({ fn . name } )
174
182
</ Heading >
175
183
</ 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 > }
181
185
</ Flex >
182
186
183
187
{ fn . inputs ?. length ? (
0 commit comments