Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 49 additions & 4 deletions src/app/transactions/[hash]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { CircleCheck, CircleX } from "lucide-react";
import { CircleCheck, CircleX, ChevronDown } from "lucide-react";
import { useCallback, useEffect, useState } from "react";
import { useParams } from "next/navigation";
import TimeAgo from "react-timeago";
Expand All @@ -14,6 +14,7 @@ interface Transaction {
sender: string;
methodId: string;
nonce: string;
argsFields: string[];
executionResult: {
status: boolean;
statusMessage?: string;
Expand All @@ -38,6 +39,7 @@ export default function TransactionDetail() {
const params = useParams<{ hash: string }>();
const [data, setData] = useState<GetTransactionQueryResponse["data"]>();
const [loading, setLoading] = useState(true);
const [argsExpanded, setArgsExpanded] = useState(false);
const query = useCallback(async () => {
setLoading(true);
const queryStr = `query GetTransaction($hash: String!) {
Expand All @@ -46,6 +48,7 @@ export default function TransactionDetail() {
methodId
sender
nonce
argsFields
executionResult {
status
statusMessage
Expand Down Expand Up @@ -81,6 +84,38 @@ export default function TransactionDetail() {
void query();
}, []);

const ArgsFieldsDisplay = () => {
if (
!data?.transaction?.argsFields ||
data.transaction.argsFields.length === 0
) {
return "—";
}

return (
<div className="w-full space-y-2\">
<button
onClick={() => setArgsExpanded(!argsExpanded)}
className="flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors"
>
<ChevronDown
className={`w-4 h-4 transition-transform ${
argsExpanded ? "rotate-180" : ""
}`}
/>
<span className="font-mono text-xs">
{argsExpanded ? "Hide args" : "Show args"}
</span>
</button>
{argsExpanded && (
<pre className="text-xs bg-muted p-3 rounded overflow-auto max-h-64 font-mono border border-border w-full">
{JSON.stringify(data.transaction.argsFields, null, 2)}
</pre>
)}
</div>
);
};

const getStatus = (tx: Transaction | undefined) => {
const batch = tx?.executionResult?.block?.batch;

Expand Down Expand Up @@ -135,9 +170,19 @@ export default function TransactionDetail() {
},
{
label: "Created",
value: data?.transaction?.executionResult?.block?.createdAt
? <TimeAgo date={data.transaction.executionResult.block.createdAt} minPeriod={30} />
: "—",
value: data?.transaction?.executionResult?.block?.createdAt ? (
<TimeAgo
date={data.transaction.executionResult.block.createdAt}
minPeriod={30}
/>
) : (
"—"
),
},
{
label: "Args Fields",
value: <ArgsFieldsDisplay />,
fullWidth: true,
},
];

Expand Down
3 changes: 2 additions & 1 deletion src/components/details/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface DetailsLayoutProps {
label: string;
value: string | JSX.Element;
link?: string;
fullWidth?: boolean;
}[];
loading: boolean;
}
Expand All @@ -39,7 +40,7 @@ export function DetailsLayout({
{/* Details */}
<div className="flex justify-start w-full mb-2 mt-6 flex-wrap">
{details.map((detail, i) => (
<div className="min-w-[50px] mr-12 mb-6" key={detail.label}>
<div className={cn("min-w-[50px] mr-12 mb-6", { "w-full mr-0": detail.fullWidth })} key={detail.label}>
<Link
href={detail.link ?? ""}
className={cn({
Expand Down