Skip to content

Commit

Permalink
Merge pull request #29 from penumbra-zone/#6-cleaning-up-naming
Browse files Browse the repository at this point in the history
cleaned up project naming conventions (routes, components, endpoints):
- tx -> transaction
- ht -> block
- BlockEvent -> Block
- TransactionEvent -> Transaction
  • Loading branch information
ejmg authored Dec 13, 2023
2 parents 4310c61 + 1837498 commit ad6d8d8
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/app/api/ht/route.ts → src/app/api/block/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { z } from "zod";
export const dynamic = "force-dynamic";

export async function GET(req: Request) {
console.log("Sucess: GET /api/ht");
console.log("Sucess: GET /api/block");
try {
const url = new URL(req.url);
const queryParam = url.searchParams.get("q")?.trim() ?? "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { z } from "zod";
export const dynamic = "force-dynamic";

export async function GET(req: Request) {
console.log("Success: GET /api/tx");
console.log("Success: GET /api/transaction");
try {
const url = new URL(req.url);
const queryParam = url.searchParams.get("q")?.trim() ?? "";
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions src/app/block/[ht]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { type FC } from "react";
import { useQuery } from "@tanstack/react-query";
import axios from "axios";
import { BlockResult } from "@/lib/validators/search";
import BlockEvent from "@/components/BlockEvent";
import Block from "@/components/Block";

interface PageProps {
params: {
Expand All @@ -17,8 +17,8 @@ const Page : FC<PageProps> = ({ params }) => {

const { data: blockData , isFetched, isError } = useQuery({
queryFn: async () => {
console.log(`Fetching: GET /api/ht?q=${ht}`);
const { data } = await axios.get(`/api/ht?q=${ht}`);
console.log(`Fetching: GET /api/block?q=${ht}`);
const { data } = await axios.get(`/api/block?q=${ht}`);
console.log("Fetching result:", data);
const result = BlockResult.safeParse(data);
console.log(result);
Expand Down Expand Up @@ -51,7 +51,7 @@ const Page : FC<PageProps> = ({ params }) => {
{blockData ? (
<div className="flex flex-col justify-center w-full">
<h1 className="text-3xl mx-auto py-5 font-semibold">Block Summary</h1>
<BlockEvent blockPayload={blockData}/>
<Block blockPayload={blockData}/>
</div>
) : (
<div>
Expand Down
8 changes: 4 additions & 4 deletions src/app/transaction/[hash]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { type FC } from "react";
import { useQuery } from "@tanstack/react-query";
import { TransactionResult } from "@/lib/validators/search";
import axios from "axios";
import TransactionEvent from "@/components/TransactionEvent";
import Transaction from "@/components/Transaction";

interface PageProps {
params: {
Expand All @@ -18,8 +18,8 @@ const Page : FC<PageProps> = ({ params }) => {

const { data: txData , isFetched, isError } = useQuery({
queryFn: async () => {
console.log(`Fetching: GET /api/tx?q=${hash}`);
const { data } = await axios.get(`/api/tx?q=${hash}`);
console.log(`Fetching: GET /api/transaction?q=${hash}`);
const { data } = await axios.get(`/api/transaction?q=${hash}`);
console.log("Fetched result:", data);
const result = TransactionResult.safeParse(data);
if (result.success) {
Expand Down Expand Up @@ -52,7 +52,7 @@ const Page : FC<PageProps> = ({ params }) => {
{txData ? (
<div className="flex flex-col justify-center w-full">
<h1 className="text-3xl mx-auto py-5 font-semibold">Transaction Event Summary</h1>
<TransactionEvent txPayload={txData} />
<Transaction txPayload={txData} />
</div>
) : (
<p>No results</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface BlockEventProps {
// re-write the rendering for BlockEvent. What I'm assuming is that there's meaningful info (and lack-of) to tease out from Blocks
// and providing for that will eventually happen here; otherwise, just re-using the same component will make sense instead of mostly
// duplicate ui code that shows the exact same information.
const BlockEvent : FC<BlockEventProps> = ({ blockPayload }) => {
const Block : FC<BlockEventProps> = ({ blockPayload }) => {
const [blockEvent, penumbraTx] = blockPayload;

return (
Expand Down Expand Up @@ -67,4 +67,4 @@ const BlockEvent : FC<BlockEventProps> = ({ blockPayload }) => {
);
};

export default BlockEvent;
export default Block;
2 changes: 1 addition & 1 deletion src/components/Searchbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const SearchBar : FC = () => {
const hashResult = HashResultValidator.safeParse(input);
const blockResult = BlockHeightValidator.safeParse(input);
if (hashResult.success) {
searchCmd("tx");
searchCmd("transaction");
} else if (blockResult.success) {
searchCmd("block");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { type TransactionResultPayload } from "@/lib/validators/search";
import ReactJson from "@microlink/react-json-view";
import { type FC } from "react";

interface TransactionEventProps {
interface TransactionProps {
txPayload: TransactionResultPayload
}

const TransactionEvent : FC<TransactionEventProps> = ({ txPayload }) => {
const Transaction : FC<TransactionProps> = ({ txPayload }) => {
const [txEvent, penumbraTx] = txPayload;
return (
<div className="bg-white rounded-sm">
Expand Down Expand Up @@ -67,4 +67,4 @@ const TransactionEvent : FC<TransactionEventProps> = ({ txPayload }) => {
);
};

export default TransactionEvent;
export default Transaction;
2 changes: 1 addition & 1 deletion src/components/TransactionsTable/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const columns : Array<ColumnDef<EventColumns>> = [
header: () => <div className="font-semibold text-gray-800 text-center">Hash</div>,
cell: ({ row }) => {
const tx : Array<{ tx_hash: string }>= row.getValue("tx_results");
return <Link href={`/tx/${tx[0].tx_hash}`} className="underline"><pre className="text-center">{tx[0].tx_hash}</pre></Link>;
return <Link href={`/transaction/${tx[0].tx_hash}`} className="underline"><pre className="text-center">{tx[0].tx_hash}</pre></Link>;
},
},
];
2 changes: 1 addition & 1 deletion src/components/TransactionsTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const TransactionsTable = async () => {
pageSize: 10,
};

const endpoint = "/api/events";
const endpoint = "/api/transactions";
const queryKey: TableQueryKey = ["TransactionsTable", defaultQueryOptions];

await queryClient.prefetchQuery({
Expand Down
4 changes: 2 additions & 2 deletions src/lib/validators/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const BlockHeightValidator = z.bigint().nonnegative({ message: "Block hei
export type HashResultQuery = z.infer<typeof HashResultValidator>;
export type BlockHeightQuery = z.infer<typeof BlockHeightValidator>;

// zod schema equivalent to the /parsed/ JSON data returned by prisma in GET /api/tx?q=<hash>
// zod schema equivalent to the /parsed/ JSON data returned by prisma in GET /api/transaction?q=<hash>
export const TransactionResult = z.tuple([
z.object({
tx_hash: z.string(),
Expand All @@ -47,7 +47,7 @@ export const TransactionResult = z.tuple([
}),
]);

// zod schema equivalent to the /parsed/ JSON data returned by prisma in GET /api/ht?q=<height>
// zod schema equivalent to the /parsed/ JSON data returned by prisma in GET /api/block?q=<height>
// NOTE: This definition is meaningfully different from TransactionResult in that the Transaction value may not exist at all.
export const BlockResult = z.tuple([
z.object({
Expand Down

0 comments on commit ad6d8d8

Please sign in to comment.