Skip to content

Commit 4841ff3

Browse files
committed
1 parent d580fe0 commit 4841ff3

File tree

2 files changed

+29
-16
lines changed

2 files changed

+29
-16
lines changed

apps/dashboard/src/components/contract-functions/contract-function.tsx

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"use client";
22

3+
import { CopyTextButton } from "@/components/ui/CopyTextButton";
4+
import { Badge } from "@/components/ui/badge";
35
import { Input } from "@/components/ui/input";
46
import { useDashboardRouter } from "@/lib/DashboardRouter";
57
import { cn } from "@/lib/utils";
@@ -34,7 +36,7 @@ import * as ERC721Ext from "thirdweb/extensions/erc721";
3436
import * as ERC1155Ext from "thirdweb/extensions/erc1155";
3537
import { useReadContract } from "thirdweb/react";
3638
import { toFunctionSelector } from "thirdweb/utils";
37-
import { Badge, Button, Card, Heading, Text } from "tw-components";
39+
import { Button, Card, Heading, Text } from "tw-components";
3840
import { useDebounce } from "use-debounce";
3941
import { useContractFunctionSelectors } from "../../contract-ui/hooks/useContractFunctionSelectors";
4042
import {
@@ -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 ? (

apps/dashboard/src/components/contract-functions/interactive-abi-function.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use client";
22

3+
import { Badge } from "@/components/ui/badge";
34
import { InlineCode } from "@/components/ui/inline-code";
45
import { ToolTipLabel } from "@/components/ui/tooltip";
56
import {
@@ -416,7 +417,15 @@ export const InteractiveAbiFunction: React.FC<InteractiveAbiFunctionProps> = ({
416417
) : formattedResponseData ? (
417418
<>
418419
<Divider />
419-
<Heading size="label.sm">Output</Heading>
420+
<div className="flex flex-row items-center gap-2">
421+
<Heading size="label.sm">Output</Heading>
422+
{/* Show the Solidity type of the function's output */}
423+
{abiFunction.outputs.length > 0 && (
424+
<Badge variant="default">
425+
{abiFunction.outputs[0]?.type}
426+
</Badge>
427+
)}
428+
</div>
420429
<CodeBlock
421430
w="full"
422431
position="relative"

0 commit comments

Comments
 (0)