Skip to content

Commit

Permalink
misc fixes + raw logs component (#19)
Browse files Browse the repository at this point in the history
* misc fixes + raw logs component

* nit
  • Loading branch information
jagnani73 authored Nov 4, 2024
1 parent 80966bc commit 79db31b
Show file tree
Hide file tree
Showing 18 changed files with 167 additions and 167 deletions.
75 changes: 26 additions & 49 deletions app/(goldrush)/[chain_id]/address/[address]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,69 +1,46 @@
"use client";

import { SubNav } from "@/components/shared";
import { type AddressLayoutProps } from "@/utils/types/pages.types";
import { AddressCard, AddressDetails } from "@covalenthq/goldrush-kit";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { useMemo } from "react";

const AddressLayout: React.FC<AddressLayoutProps> = ({
children,
params: { address, chain_id },
}) => {
const path = usePathname().split("/").slice(-1)[0];

const routes = useMemo<
const routes: {
children: React.ReactNode;
href: string;
}[] = [
{
children: React.ReactNode;
href: string;
}[]
>(
() => [
{
children: "Transactions",
href: "transactions",
},
{
children: "Activity",
href: "activity",
},
{
children: "Token Balances",
href: "token-balances",
},
{
children: "NFT Balances",
href: "nft-balances",
},
{
children: "NFT Collection",
href: "nft-collection",
},
],
[]
);
children: "Transactions",
href: "transactions",
},
{
children: "Activity",
href: "activity",
},
{
children: "Token Balances",
href: "token-balances",
},
{
children: "NFT Balances",
href: "nft-balances",
},
{
children: "NFT Collection",
href: "nft-collection",
},
];

return (
<main className="gbk-flex gbk-w-full gbk-flex-col gbk-gap-4">
<AddressCard address={address} avatar={{}} />

<AddressDetails address={address} chain_name={chain_id} />

<nav className="flex gap-4 gbk-my-4">
{routes.map(({ children, href }) => (
<Link
key={href}
href={href}
className={`gbk-transition-all hover:gbk-underline ${
path === href
? "text-primary-light dark:text-primary-dark gbk-underline"
: "text-secondary-light dark:text-secondary-dark"
}`}
>
{children}
</Link>
))}
</nav>
<SubNav routes={routes} />

{children}
</main>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ const AddressNFTBalancesPage: React.FC<AddressPageProps> = ({
<NFTWalletCollectionList
address={address}
chain_name={chain_id}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
actionable_contract={(address) => ({
parent: Link,
parentProps: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ const AddressTokenBalancesPage: React.FC<AddressPageProps> = ({
<TokenBalancesList
address={address}
chain_names={[chain_id]}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
actionable_token={(address) => ({
parent: Link,
parentProps: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,20 @@ const AddressTransactionsPage: React.FC<AddressPageProps> = ({
<AddressTransactions
address={address}
chain_name={chain_id}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
actionable_address={(address) => ({
parent: Link,
parentProps: {
href: `/${chain_id}/address/${address}`,
className: "hover:gbk-underline",
},
})}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
actionable_block={(block_height) => ({
parent: Link,
parentProps: {
href: `/${chain_id}/block/${block_height}`,
className: "hover:gbk-underline",
},
})}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
actionable_transaction={(tx_hash) => ({
parent: Link,
parentProps: {
Expand Down
6 changes: 0 additions & 6 deletions app/(goldrush)/[chain_id]/block/[block_height]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,20 @@ const BlockPage: React.FC<BlockPageProps> = ({
<BlockTransactions
block_height={+block_height}
chain_name={chain_id}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
actionable_address={(address) => ({
parent: Link,
parentProps: {
href: `/${chain_id}/address/${address}`,
className: "hover:gbk-underline",
},
})}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
actionable_block={(block_height) => ({
parent: Link,
parentProps: {
href: `/${chain_id}/block/${block_height}`,
className: "hover:gbk-underline",
},
})}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
actionable_transaction={(tx_hash) => ({
parent: Link,
parentProps: {
Expand Down
2 changes: 0 additions & 2 deletions app/(goldrush)/[chain_id]/blocks/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ const BlocksPage: React.FC<BlocksPageProps> = ({ params: { chain_id } }) => {
<main className="gbk-flex gbk-w-full gbk-flex-col gbk-gap-4">
<BlocksList
chain_name={chain_id}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
actionable_block={(block) => ({
parent: Link,
parentProps: {
Expand Down
10 changes: 0 additions & 10 deletions app/(goldrush)/[chain_id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,13 @@ const Home: React.FC<HomePageProps> = ({ params: { chain_id } }) => {
<div className="gbk-flex gbk-justify-between gbk-gap-x-4">
<LatestBlocks
chain_name={chain_id}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
actionable_block={(block) => ({
parent: Link,
parentProps: {
href: `/${chain_id}/block/${block}`,
className: "hover:gbk-underline",
},
})}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
actionable_redirect={() => ({
parent: Link,
parentProps: {
Expand All @@ -68,26 +64,20 @@ const Home: React.FC<HomePageProps> = ({ params: { chain_id } }) => {
<div className="gbk-flex gbk-justify-between gbk-gap-x-4">
<LatestTransactions
chain_name={chain_id}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
actionable_address={(address) => ({
parent: Link,
parentProps: {
href: `/${chain_id}/address/${address}`,
className: "hover:gbk-underline",
},
})}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
actionable_transaction={(tx_hash) => ({
parent: Link,
parentProps: {
href: `/${chain_id}/transaction/${tx_hash}`,
className: "hover:gbk-underline",
},
})}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
actionable_redirect={() => ({
parent: Link,
parentProps: {
Expand Down
61 changes: 61 additions & 0 deletions app/(goldrush)/[chain_id]/transaction/[tx_hash]/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"use client";

import { SubNav } from "@/components/shared";
import { type TransactionLayoutProps } from "@/utils/types/pages.types";
import { TransactionDetails } from "@covalenthq/goldrush-kit";
import Link from "next/link";

const TransactionLayout: React.FC<TransactionLayoutProps> = ({
children,
params: { tx_hash, chain_id },
}) => {
const routes: {
children: React.ReactNode;
href: string;
}[] = [
{
children: "Receipt",
href: "receipt",
},
{
children: "Raw Logs",
href: "raw-logs",
},
];

return (
<main className="gbk-flex gbk-w-full gbk-flex-col gbk-gap-4">
<TransactionDetails
chain_name={chain_id}
tx_hash={tx_hash}
actionable_from={(from_address) => ({
parent: Link,
parentProps: {
href: `/${chain_id}/address/${from_address}`,
className: "hover:gbk-underline",
},
})}
actionable_to={(to_address) => ({
parent: Link,
parentProps: {
href: `/${chain_id}/address/${to_address}`,
className: "hover:gbk-underline",
},
})}
actionable_block={(block_height) => ({
parent: Link,
parentProps: {
href: `/${chain_id}/block/${block_height}`,
className: "hover:gbk-underline",
},
})}
/>

<SubNav routes={routes} />

{children}
</main>
);
};

export default TransactionLayout;
73 changes: 2 additions & 71 deletions app/(goldrush)/[chain_id]/transaction/[tx_hash]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,81 +1,12 @@
"use client";

import { type TransactionPageProps } from "@/utils/types/pages.types";
import {
TransactionDetails,
TransactionReceipt,
} from "@covalenthq/goldrush-kit";
import Link from "next/link";
import { redirect } from "next/navigation";

const TransactionPage: React.FC<TransactionPageProps> = ({
params: { tx_hash, chain_id },
}) => {
return (
<main className="gbk-flex gbk-w-full gbk-flex-col gbk-gap-4">
<TransactionDetails
chain_name={chain_id}
tx_hash={tx_hash}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
actionable_from={(from_address) => ({
parent: Link,
parentProps: {
href: `/${chain_id}/address/${from_address}`,
className: "hover:gbk-underline",
},
})}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
actionable_to={(to_address) => ({
parent: Link,
parentProps: {
href: `/${chain_id}/address/${to_address}`,
className: "hover:gbk-underline",
},
})}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
actionable_block={(block_height) => ({
parent: Link,
parentProps: {
href: `/${chain_id}/block/${block_height}`,
className: "hover:gbk-underline",
},
})}
/>
<TransactionReceipt
chain_name={"eth-mainnet"}
tx_hash={tx_hash}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
actionable_from={(from_address) => ({
parent: Link,
parentProps: {
href: `/${chain_id}/address/${from_address}`,
className: "hover:gbk-underline",
},
})}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
actionable_to={(to_address) => ({
parent: Link,
parentProps: {
href: `/${chain_id}/address/${to_address}`,
className: "hover:gbk-underline",
},
})}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
actionable_block={(block_height) => ({
parent: Link,
parentProps: {
href: `/${chain_id}/block/${block_height}`,
className: "hover:gbk-underline",
},
})}
/>
</main>
);
redirect(`/${chain_id}/transaction/${tx_hash}/receipt`);
};

export default TransactionPage;
12 changes: 12 additions & 0 deletions app/(goldrush)/[chain_id]/transaction/[tx_hash]/raw-logs/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"use client";

import { type TransactionPageProps } from "@/utils/types/pages.types";
import { TransactionRawLogs } from "@covalenthq/goldrush-kit";

const TransactionRawLogsPage: React.FC<TransactionPageProps> = ({
params: { tx_hash, chain_id },
}) => {
return <TransactionRawLogs chain_name={chain_id} tx_hash={tx_hash} />;
};

export default TransactionRawLogsPage;
12 changes: 12 additions & 0 deletions app/(goldrush)/[chain_id]/transaction/[tx_hash]/receipt/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"use client";

import { type TransactionPageProps } from "@/utils/types/pages.types";
import { TransactionReceipt } from "@covalenthq/goldrush-kit";

const TransactionReceiptPage: React.FC<TransactionPageProps> = ({
params: { tx_hash, chain_id },
}) => {
return <TransactionReceipt chain_name={chain_id} tx_hash={tx_hash} />;
};

export default TransactionReceiptPage;
Loading

0 comments on commit 79db31b

Please sign in to comment.