Skip to content

Commit 7e75ee5

Browse files
basic tx detail view
1 parent 0c70b10 commit 7e75ee5

File tree

4 files changed

+96
-30
lines changed

4 files changed

+96
-30
lines changed

apps/dashboard/src/app/team/[team_slug]/[project_slug]/engine/analytics/tx-table/tx-table-ui.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,7 @@ export function TransactionsTableUI(props: {
136136
key={`${tx.id}${tx.chainId}`}
137137
className="cursor-pointer hover:bg-accent/50"
138138
onClick={() => {
139-
router.push(
140-
`/team/${props.project.teamId}/project/${props.project.id}/engine/tx/${tx.id}`,
141-
);
139+
router.push(`engine/tx/${tx.id}`);
142140
}}
143141
>
144142
{/* Queue ID */}

apps/dashboard/src/app/team/[team_slug]/[project_slug]/engine/lib/analytics.ts

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { Transaction } from "thirdweb/dist/types/insight/get-transactions";
12
import { THIRDWEB_ENGINE_CLOUD_URL } from "../../../../../../@/constants/env";
23
import type { TransactionStats } from "../../../../../../types/analytics";
34
import { getAuthToken } from "../../../../../api/lib/getAuthToken";
@@ -154,7 +155,7 @@ export async function getSingleTransaction({
154155
teamId: string;
155156
clientId: string;
156157
transactionId: string;
157-
}): Promise<TransactionStats[]> {
158+
}): Promise<Transaction | undefined> {
158159
const authToken = await getAuthToken();
159160

160161
const filters = {
@@ -168,7 +169,7 @@ export async function getSingleTransaction({
168169
};
169170

170171
const response = await fetch(
171-
`${THIRDWEB_ENGINE_CLOUD_URL}/project/transactions/analytics`,
172+
`${THIRDWEB_ENGINE_CLOUD_URL}/project/transactions/search`,
172173
{
173174
method: "POST",
174175
headers: {
@@ -183,7 +184,7 @@ export async function getSingleTransaction({
183184

184185
if (!response.ok) {
185186
if (response.status === 401) {
186-
return [];
187+
return undefined;
187188
}
188189

189190
// TODO - need to handle this error state, like we do with the connect charts
@@ -192,26 +193,54 @@ export async function getSingleTransaction({
192193
);
193194
}
194195

195-
type TransactionsChartResponse = {
196+
type TransactionParam = {
197+
to: string;
198+
data: string;
199+
value: string;
200+
};
201+
202+
type ExecutionParams = {
203+
type: string;
204+
signerAddress: string;
205+
entrypointAddress: string;
206+
smartAccountAddress: string;
207+
};
208+
209+
type ExecutionResult = {
210+
status: string;
211+
};
212+
213+
type Transaction = {
214+
id: string;
215+
batchIndex: number;
216+
chainId: string;
217+
from: string;
218+
transactionParams: TransactionParam[];
219+
transactionHash: string | null;
220+
confirmedAt: string | null;
221+
confirmedAtBlockNumber: number | null;
222+
enrichedData: unknown[];
223+
executionParams: ExecutionParams;
224+
executionResult: ExecutionResult;
225+
createdAt: string;
226+
errorMessage: string | null;
227+
cancelledAt: string | null;
228+
};
229+
230+
type Pagination = {
231+
totalCount: string;
232+
page: number;
233+
limit: number;
234+
};
235+
236+
type TransactionsSearchResponse = {
196237
result: {
197-
analytics: Array<{
198-
timeBucket: string;
199-
chainId: string;
200-
count: number;
201-
}>;
202-
metadata: {
203-
resolution: string;
204-
startDate: string;
205-
endDate: string;
206-
};
238+
transactions: Transaction[];
239+
pagination: Pagination;
207240
};
208241
};
209242

210-
const data = (await response.json()) as TransactionsChartResponse;
243+
const data = (await response.json()) as TransactionsSearchResponse;
211244

212-
return data.result.analytics.map((stat) => ({
213-
date: stat.timeBucket,
214-
chainId: Number(stat.chainId),
215-
count: stat.count,
216-
}));
245+
return data.result.transactions[0];
217246
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { ChevronLeft } from "lucide-react";
2+
import Link from "next/link";
3+
4+
export default function TransactionLayout({
5+
children,
6+
params,
7+
}: {
8+
children: React.ReactNode;
9+
params: { team_slug: string; project_slug: string };
10+
}) {
11+
return (
12+
<div className="flex flex-col gap-4">
13+
<div className="flex items-center gap-2">
14+
<Link
15+
href={`/team/${params.team_slug}/${params.project_slug}/engine`}
16+
className="flex items-center gap-1 text-muted-foreground text-sm hover:text-foreground"
17+
>
18+
<ChevronLeft className="h-4 w-4" />
19+
Back to Transactions
20+
</Link>
21+
</div>
22+
<div className="flex-1">{children}</div>
23+
</div>
24+
);
25+
}
Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,36 @@
1+
import { notFound, redirect } from "next/navigation";
2+
import { getProject } from "../../../../../../../@/api/projects";
3+
import { CodeServer } from "../../../../../../../@/components/ui/code/code.server";
14
import { getSingleTransaction } from "../../lib/analytics";
25

36
export default async function TransactionPage({
47
params,
58
}: {
6-
params: { team_slug: string; project_slug: string; id: string };
9+
params: Promise<{ team_slug: string; project_slug: string; id: string }>;
710
}) {
11+
const { team_slug, project_slug, id } = await params;
12+
13+
const project = await getProject(team_slug, project_slug);
14+
15+
if (!project) {
16+
redirect(`/team/${team_slug}`);
17+
}
18+
819
const transactionData = await getSingleTransaction({
9-
teamId: params.team_slug,
10-
clientId: params.project_slug,
11-
transactionId: params.id,
20+
teamId: project.teamId,
21+
clientId: project.publishableKey,
22+
transactionId: id,
1223
});
1324

25+
if (!transactionData) {
26+
notFound();
27+
}
28+
1429
return (
1530
<div className="p-4">
1631
<h1 className="mb-4 font-bold text-2xl">Transaction Details</h1>
17-
<pre className="overflow-auto rounded-lg bg-gray-100 p-4">
18-
{JSON.stringify(transactionData, null, 2)}
19-
</pre>
32+
{/* TODO: add transaction details UI */}
33+
<CodeServer lang="json" code={JSON.stringify(transactionData, null, 2)} />
2034
</div>
2135
);
2236
}

0 commit comments

Comments
 (0)