Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tenscan] Frontend Updates #1932

Merged
merged 66 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
105ccd2
ui: public transaction details
Jennievon May 21, 2024
cdf8ab4
Update label for Batch Number to Batch Height
Jennievon May 21, 2024
d90f3ce
rollups:
Jennievon May 22, 2024
8864dab
Update rollup details component and add new API
Jennievon May 22, 2024
1752f6b
rearrange rollup details
Jennievon May 22, 2024
aa0fe11
- fetch batch by hash, sequence and height
Jennievon May 23, 2024
4bb5ebc
Remove batch actions column
Jennievon May 23, 2024
1cd99a4
Add icon to display encrypted Tx Blob
Jennievon May 23, 2024
b639dc4
Fix batch and transaction details display
Jennievon May 23, 2024
8e75920
feat: show/hide encrypted tx blob
Jennievon May 23, 2024
659f3dd
Update batch count message in index and rollup
Jennievon May 24, 2024
906df7f
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon May 24, 2024
f274c4b
Fix property names in Dashboard
Jennievon May 24, 2024
64fec98
Refactor `BatchDetailsComponent` to use updated
Jennievon May 24, 2024
b320bd4
separate batch hash and height components
Jennievon May 24, 2024
547ec3f
Refactor transaction hash display in
Jennievon May 24, 2024
e6cf45f
Fix case sensitivity in transfersTree property
Jennievon May 24, 2024
7809a5b
cleanup polling in pages
Jennievon May 24, 2024
75763df
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon May 24, 2024
a51c66c
update batch hash details component to handle
Jennievon May 24, 2024
2ba2983
Update transaction hash link path
Jennievon May 27, 2024
9201f78
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon May 27, 2024
c2385fe
Merge branch 'jennifer/2751-tenscan-ui-updates' of https://github.com…
Jennievon May 27, 2024
ef223c7
Fix `latestBatch` and `latest l1 rollup` property
Jennievon May 27, 2024
4d0815d
Remove unused code
Jennievon May 28, 2024
25df2cc
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon May 28, 2024
483fe09
Update rollup details labels
Jennievon May 28, 2024
36ebc13
- switch recent blocks to rollup
Jennievon May 31, 2024
ef09e6e
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon Jun 25, 2024
531fb76
update favicon path
Jennievon Jun 25, 2024
db22321
format terms text
Jennievon Jun 25, 2024
d7c312c
update discord links
Jennievon Jun 25, 2024
778d456
rm `Transfers Tree` from batch details
Jennievon Jun 26, 2024
51dd192
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon Jun 26, 2024
f8557c8
rm logs
Jennievon Jun 26, 2024
9f71d50
fix nav styles
Jennievon Jun 27, 2024
f4e542f
format gas text and txns' data table sorting
Jennievon Jun 27, 2024
23a7c68
rm total count for data tables
Jennievon Jun 27, 2024
7d49110
allow dynamic input of page number in pagination
Jennievon Jun 27, 2024
0c6a41c
Comment out total count feature
Jennievon Jun 27, 2024
cd67934
Uncomment total count feature in data tables
Jennievon Jun 27, 2024
8613086
rm pagination from batch txns
Jennievon Jul 1, 2024
4711cee
Add X icon to mobile menu
Jennievon Jul 1, 2024
66b5e8f
- fix pagination bug
Jennievon Jul 1, 2024
4432944
Fix pagination bug in DataTablePagination
Jennievon Jul 2, 2024
99c16f0
Update React and React-DOM versions to fix `fetchPriority` error
Jennievon Jul 2, 2024
a284ba6
Add .nvmrc file with version v20.11.0
Jennievon Jul 2, 2024
fc5c68f
- update batch hash in header object
Jennievon Jul 2, 2024
c72497a
Refactor link components in truncated address
Jennievon Jul 2, 2024
0f3c668
Fix batch and rollup details links
Jennievon Jul 3, 2024
bc79658
refactor dashboard data table headers to be sticky
Jennievon Jul 3, 2024
3949626
fix: failing build
Jennievon Jul 3, 2024
0dbdcc3
fix paginatioon bug
Jennievon Jul 4, 2024
46a8cff
update query key for rollups
Jennievon Jul 4, 2024
1f5c0da
Fix pagination button click event
Jennievon Jul 4, 2024
7454683
- refactor pagination logic
Jennievon Jul 5, 2024
b9598ab
Refactor DataTable component
Jennievon Jul 5, 2024
3291203
handle pagination and filter clearing
Jennievon Jul 5, 2024
5c092b9
update page index dynamically on page change
Jennievon Jul 5, 2024
23ba6f3
Merge branch 'main' of https://github.com/ten-protocol/go-ten into je…
Jennievon Jul 8, 2024
06b03f6
refactor code to use `getItem` in table desc
Jennievon Jul 8, 2024
5e9426d
Update noResultsWord to noResultsText in DataTable
Jennievon Jul 8, 2024
2b85ebb
Fix data table pagination row count
Jennievon Jul 8, 2024
337b6ed
rm unused imports and functions
Jennievon Jul 8, 2024
868a979
Remove "Blocks" link from NavLinks
Jennievon Jul 8, 2024
171181e
update column header title for `Gas Used`
Jennievon Jul 8, 2024
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
25 changes: 23 additions & 2 deletions tools/tenscan/frontend/api/batches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Batch,
BatchDetails,
BatchResponse,
LatestBatch,
} from "@/src/types/interfaces/BatchInterfaces";

export const fetchBatches = async (
Expand All @@ -20,8 +21,8 @@ export const fetchBatches = async (

export const fetchLatestBatch = async (
payload?: Record<string, any>
): Promise<ResponseDataInterface<Batch>> => {
return await httpRequest<ResponseDataInterface<Batch>>({
): Promise<ResponseDataInterface<LatestBatch>> => {
return await httpRequest<ResponseDataInterface<LatestBatch>>({
method: "get",
url: pathToUrl(apiRoutes.getLatestBatch),
searchParams: payload,
Expand All @@ -36,3 +37,23 @@ export const fetchBatchByHash = async (
url: pathToUrl(apiRoutes.getBatchByHash, { hash }),
});
};

export const fetchBatchByHeight = async (
height: string
): Promise<ResponseDataInterface<Batch>> => {
return await httpRequest<ResponseDataInterface<Batch>>({
method: "get",
url: pathToUrl(apiRoutes.getBatchByHeight, { height }),
});
};

export const fetchBatchTransactions = async (
fullHash: string,
options?: Record<string, any>
): Promise<ResponseDataInterface<any>> => {
return await httpRequest<ResponseDataInterface<any>>({
method: "get",
url: pathToUrl(apiRoutes.getBatchTransactions, { fullHash }),
searchParams: options,
});
};
47 changes: 46 additions & 1 deletion tools/tenscan/frontend/api/rollups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ import { httpRequest } from ".";
import { apiRoutes } from "@/src/routes";
import { pathToUrl } from "@/src/routes/router";
import { ResponseDataInterface } from "@/src/types/interfaces";
import { Batch, BatchResponse } from "@/src/types/interfaces/BatchInterfaces";
import {
Rollup,
RollupsResponse,
} from "@/src/types/interfaces/RollupInterfaces";

export const fetchRollups = async (
export const fetchLatestRollups = async (
payload?: Record<string, any>
): Promise<ResponseDataInterface<any>> => {
return await httpRequest<ResponseDataInterface<any>>({
Expand All @@ -13,6 +18,15 @@ export const fetchRollups = async (
});
};

export const fetchRollups = async (): Promise<
ResponseDataInterface<RollupsResponse>
> => {
return await httpRequest<ResponseDataInterface<RollupsResponse>>({
method: "get",
url: pathToUrl(apiRoutes.getRollups),
});
};

export const decryptEncryptedRollup = async ({
StrData,
}: {
Expand All @@ -24,3 +38,34 @@ export const decryptEncryptedRollup = async ({
data: { StrData },
});
};

export const fetchRollupByHash = async (
hash: string
): Promise<ResponseDataInterface<Rollup>> => {
return await httpRequest<ResponseDataInterface<Rollup>>({
method: "get",
url: pathToUrl(apiRoutes.getRollupByHash, { hash }),
});
};

export const fetchRollupByBatchSequence = async (
seq: string
): Promise<ResponseDataInterface<Rollup>> => {
const res = await httpRequest<ResponseDataInterface<Rollup>>({
method: "get",
url: pathToUrl(apiRoutes.getRollupByBatchSequence, { seq }),
});
console.log(res);
return res;
};

export const fetchBatchesInRollups = async (
hash: string,
options: Record<string, any>
): Promise<ResponseDataInterface<BatchResponse>> => {
return await httpRequest<ResponseDataInterface<BatchResponse>>({
method: "get",
url: pathToUrl(apiRoutes.getBatchesInRollup, { hash }),
searchParams: options,
});
};
10 changes: 10 additions & 0 deletions tools/tenscan/frontend/api/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
TransactionCount,
Price,
TransactionResponse,
Transaction,
} from "@/src/types/interfaces/TransactionInterfaces";

export const fetchTransactions = async (
Expand All @@ -31,3 +32,12 @@ export const fetchEtherPrice = async (): Promise<Price> => {
url: apiRoutes.getEtherPrice,
});
};

export const fetchTransactionByHash = async (
hash: string
): Promise<ResponseDataInterface<Transaction>> => {
return await httpRequest<ResponseDataInterface<Transaction>>({
method: "get",
url: pathToUrl(apiRoutes.getTransactionByHash, { hash }),
});
};
6 changes: 6 additions & 0 deletions tools/tenscan/frontend/pages/address/[address].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ const AddressDetails = () => {
};

export default AddressDetails;

export async function getServerSideProps(context: any) {
return {
props: {},
};
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fetchBatchByHash } from "@/api/batches";
import Layout from "@/src/components/layouts/default-layout";
import { BatchDetailsComponent } from "@/src/components/modules/batches/batch-details";
import { BatchHashDetailsComponent } from "@/src/components/modules/batches/batch-hash-details";
import {
Card,
CardHeader,
Expand Down Expand Up @@ -36,7 +36,7 @@ export default function Batch() {
</CardDescription>
</CardHeader>
<CardContent>
<BatchDetailsComponent batchDetails={batchDetails} />
<BatchHashDetailsComponent batchDetails={batchDetails} />
</CardContent>
</Card>
) : (
Expand All @@ -45,3 +45,9 @@ export default function Batch() {
</Layout>
);
}

export async function getServerSideProps(context: any) {
return {
props: {},
};
}
53 changes: 53 additions & 0 deletions tools/tenscan/frontend/pages/batch/height/[height].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { fetchBatchByHeight } from "@/api/batches";
import Layout from "@/src/components/layouts/default-layout";
import { BatchHeightDetailsComponent } from "@/src/components/modules/batches/batch-height-details";
import {
Card,
CardHeader,
CardTitle,
CardContent,
CardDescription,
} from "@/src/components/ui/card";
import { Skeleton } from "@/src/components/ui/skeleton";
import { useQuery } from "@tanstack/react-query";
import { useRouter } from "next/router";

export default function Batch() {
const router = useRouter();
const { height } = router.query;

const { data, isLoading } = useQuery({
queryKey: ["batchHeight", height],
queryFn: () => fetchBatchByHeight(height as string),
});

const batchDetails = data?.item;

return (
<Layout>
{isLoading ? (
<Skeleton className="h-6 w-24" />
) : batchDetails ? (
<Card className="col-span-3">
<CardHeader>
<CardTitle>Batch #{Number(batchDetails?.header?.number)}</CardTitle>
<CardDescription>
Overview of the batch #{Number(batchDetails?.header?.number)}
</CardDescription>
</CardHeader>
<CardContent>
<BatchHeightDetailsComponent batchDetails={batchDetails} />
</CardContent>
</Card>
) : (
<div>Batch not found</div>
)}
</Layout>
);
}

export async function getServerSideProps(context: any) {
return {
props: {},
};
}
67 changes: 67 additions & 0 deletions tools/tenscan/frontend/pages/batch/txs/[fullHash].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { fetchBatchTransactions } from "@/api/batches";
import Layout from "@/src/components/layouts/default-layout";
import { DataTable } from "@/src/components/modules/common/data-table/data-table";
import EmptyState from "@/src/components/modules/common/empty-state";
import { columns } from "@/src/components/modules/batches/transaction-columns";
import {
Card,
CardHeader,
CardTitle,
CardContent,
CardDescription,
} from "@/src/components/ui/card";
import { useQuery } from "@tanstack/react-query";
import { useRouter } from "next/router";
import { getOptions } from "@/src/lib/constants";

export default function BatchTransactions() {
const router = useRouter();
const { fullHash } = router.query;
const options = getOptions(router.query);

const { data, isLoading, refetch } = useQuery({
queryKey: ["batchTransactions", { fullHash, options }],
queryFn: () => fetchBatchTransactions(fullHash as string, options),
});

const { TransactionsData, Total } = data?.result || {
TransactionsData: [],
Total: 0,
};

return (
<Layout>
{TransactionsData ? (
<Card className="col-span-3">
<CardHeader>
<CardTitle>Transactions</CardTitle>
<CardDescription>
Overview of transactions at batch{" "}
{"#" + TransactionsData[0]?.BatchHeight}
</CardDescription>
</CardHeader>
<CardContent>
<DataTable
columns={columns}
data={TransactionsData}
refetch={refetch}
total={+Total}
isLoading={isLoading}
/>
</CardContent>
</Card>
) : (
<EmptyState
title="No transactions found"
description="There are no transactions in this batch."
/>
)}
</Layout>
);
}

export async function getServerSideProps(context: any) {
return {
props: {},
};
}
6 changes: 5 additions & 1 deletion tools/tenscan/frontend/pages/batches/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export default function Batches() {

React.useEffect(() => {
setNoPolling(true);

return () => {
setNoPolling(false);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

Expand All @@ -30,7 +34,7 @@ export default function Batches() {
<div>
<h2 className="text-2xl font-bold tracking-tight">Batches</h2>
<p className="text-sm text-muted-foreground">
{formatNumber(Total)} Batches found.
{formatNumber(Total)} Batch(es) found.
</p>
</div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion tools/tenscan/frontend/pages/blocks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export const metadata: Metadata = {
};

export default function Blocks() {
const { blocks, setNoPolling, refetchBlocks } = useBlocksService();
const { blocks, setNoPolling, refetchBlocks, isBlocksLoading } =
useBlocksService();
const { BlocksData, Total } = blocks?.result || {
BlocksData: [],
Total: 0,
Expand Down Expand Up @@ -41,6 +42,7 @@ export default function Blocks() {
data={BlocksData}
total={+Total}
refetch={refetchBlocks}
isLoading={isBlocksLoading}
/>
) : (
<p>Loading...</p>
Expand Down
6 changes: 6 additions & 0 deletions tools/tenscan/frontend/pages/docs/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,9 @@ const Document = () => {
};

export default Document;

export async function getServerSideProps(context: any) {
return {
props: {},
};
}
54 changes: 54 additions & 0 deletions tools/tenscan/frontend/pages/rollup/[hash]/batches.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React from "react";
import { columns } from "@/src/components/modules/batches/columns";
import { DataTable } from "@/src/components/modules/common/data-table/data-table";
import Layout from "@/src/components/layouts/default-layout";
import { Metadata } from "next";
import { formatNumber } from "@/src/lib/utils";
import { useRollupsService } from "@/src/services/useRollupsService";

export const metadata: Metadata = {
title: "Batches",
description: "A table of Batches.",
};

export default function RollupBatches() {
const { rollupBatches, isRollupBatchesLoading, refetchRollupBatches } =
useRollupsService();

const { BatchesData, Total } = rollupBatches?.result || {
BatchesData: [],
Total: 0,
};

return (
<Layout>
<div className="h-full flex-1 flex-col space-y-8 md:flex">
<div className="flex items-center justify-between space-y-2">
<div>
<h2 className="text-2xl font-bold tracking-tight">Batches</h2>
<p className="text-sm text-muted-foreground">
{formatNumber(Total)} Batch(es) found in this rollup.
</p>
</div>
</div>
{BatchesData ? (
<DataTable
columns={columns}
data={BatchesData}
refetch={refetchRollupBatches}
total={+Total}
isLoading={isRollupBatchesLoading}
/>
) : (
<p>Loading...</p>
)}
</div>
</Layout>
);
}

export async function getServerSideProps(context: any) {
return {
props: {},
};
}
Loading
Loading