add calldata as part of the row details

Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
Uncle Fatso 2026-02-13 13:18:24 +03:00
parent 7457926952
commit da1cf93f34
Signed by: f4ts0
GPG Key ID: 565F4F2860226EBB
3 changed files with 29 additions and 2 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "ghost-dao-interface", "name": "ghost-dao-interface",
"private": true, "private": true,
"version": "0.5.12", "version": "0.5.13",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",

View File

@ -137,6 +137,7 @@ const NewProposal = ({ config, address, connect, chainId }) => {
<TableRow> <TableRow>
<TableCell align="center" style={{ padding: "8px 0" }}>Function</TableCell> <TableCell align="center" style={{ padding: "8px 0" }}>Function</TableCell>
<TableCell align="center" style={{ padding: "8px 0" }}>Target</TableCell> <TableCell align="center" style={{ padding: "8px 0" }}>Target</TableCell>
<TableCell align="center" style={{ padding: "8px 0" }}>Calldata</TableCell>
<TableCell align="center" style={{ padding: "8px 0" }}>Value</TableCell> <TableCell align="center" style={{ padding: "8px 0" }}>Value</TableCell>
</TableRow> </TableRow>
</TableHead> </TableHead>

View File

@ -1,6 +1,7 @@
import { useRef, useMemo } from "react"; import { useRef, useMemo, useState } from "react";
import { Box, Typography, Link, TableCell, TableRow, useTheme } from "@mui/material"; import { Box, Typography, Link, TableCell, TableRow, useTheme } from "@mui/material";
import { decodeFunctionData } from 'viem'; import { decodeFunctionData } from 'viem';
import toast from "react-hot-toast";
import { StyledInputBase } from "../../../../components/Swap/SwapCard"; import { StyledInputBase } from "../../../../components/Swap/SwapCard";
import { TertiaryButton } from "../../../../components/Button"; import { TertiaryButton } from "../../../../components/Button";
@ -56,6 +57,7 @@ export const parseFunctionCalldata = (metadata, index, chainId, nativeCoin, remo
return <AuditReservesParsed return <AuditReservesParsed
isTable isTable
key={index} key={index}
calldata={calldata}
label={label} label={label}
chainId={chainId} chainId={chainId}
remove={remove} remove={remove}
@ -69,6 +71,7 @@ export const parseFunctionCalldata = (metadata, index, chainId, nativeCoin, remo
isTable isTable
args={args} args={args}
key={index} key={index}
calldata={calldata}
label={label} label={label}
chainId={chainId} chainId={chainId}
remove={remove} remove={remove}
@ -82,6 +85,7 @@ export const parseFunctionCalldata = (metadata, index, chainId, nativeCoin, remo
isTable isTable
args={args} args={args}
key={index} key={index}
calldata={calldata}
label={label} label={label}
chainId={chainId} chainId={chainId}
remove={remove} remove={remove}
@ -94,6 +98,7 @@ export const parseFunctionCalldata = (metadata, index, chainId, nativeCoin, remo
return <ParsedCell return <ParsedCell
isTable isTable
key={index} key={index}
calldata={calldata}
label={label} label={label}
remove={remove} remove={remove}
nativeCoin={nativeCoin} nativeCoin={nativeCoin}
@ -247,6 +252,8 @@ export const ArgumentInput = ({
} }
export const ParsedCell = (props) => { export const ParsedCell = (props) => {
const [isCopied, setIsCopied] = useState(false);
const etherscanLink = useMemo(() => { const etherscanLink = useMemo(() => {
const client = config.getClient(); const client = config.getClient();
let url = client?.chain?.blockExplorers?.default?.url; let url = client?.chain?.blockExplorers?.default?.url;
@ -256,6 +263,19 @@ export const ParsedCell = (props) => {
return url; return url;
}, [props]); }, [props]);
const handleCalldataCopy = async () => {
try {
await navigator.clipboard.writeText(props.calldata);
setIsCopied(true);
toast.success("Calldata successfully copied to your clipboard.", { duration: 2000 });
setTimeout(() => setIsCopied(false), 2000);
} catch (err) {
toast.error("Could not copy calldata to clipboard, check logs for error details.", { duration: 5000 });
console.error(err);
}
};
return ( return (
<TableRow id={props.id + `--proposalFunction`} data-testid={props.id + `--proposalFunction`}> <TableRow id={props.id + `--proposalFunction`} data-testid={props.id + `--proposalFunction`}>
<TableCell align="center" style={{ padding: "8px 0" }}> <TableCell align="center" style={{ padding: "8px 0" }}>
@ -268,6 +288,12 @@ export const ParsedCell = (props) => {
</Link> </Link>
</TableCell> </TableCell>
<TableCell align="center" style={{ padding: "8px 0" }}>
<Link onClick={handleCalldataCopy} target="_blank" rel="noopener noreferrer">
<Typography>{shorten(props.calldata)}</Typography>
</Link>
</TableCell>
<TableCell align="center" style={{ padding: "8px 0" }}> <TableCell align="center" style={{ padding: "8px 0" }}>
<Typography>{formatCurrency(props.value, 2, props.nativeCoin)}</Typography> <Typography>{formatCurrency(props.value, 2, props.nativeCoin)}</Typography>
</TableCell> </TableCell>