From 79db31b4513a6303e8fc97a5eb001586cee9c7a7 Mon Sep 17 00:00:00 2001 From: Yashvardhan Jagnani <60016972+jagnani73@users.noreply.github.com> Date: Mon, 4 Nov 2024 22:17:38 +0530 Subject: [PATCH] misc fixes + raw logs component (#19) * misc fixes + raw logs component * nit --- .../[chain_id]/address/[address]/layout.tsx | 75 +++++++------------ .../address/[address]/nft-balances/page.tsx | 2 - .../address/[address]/token-balances/page.tsx | 2 - .../address/[address]/transactions/page.tsx | 6 -- .../[chain_id]/block/[block_height]/page.tsx | 6 -- app/(goldrush)/[chain_id]/blocks/page.tsx | 2 - app/(goldrush)/[chain_id]/page.tsx | 10 --- .../transaction/[tx_hash]/layout.tsx | 61 +++++++++++++++ .../[chain_id]/transaction/[tx_hash]/page.tsx | 73 +----------------- .../transaction/[tx_hash]/raw-logs/page.tsx | 12 +++ .../transaction/[tx_hash]/receipt/page.tsx | 12 +++ .../[chain_id]/transactions/page.tsx | 6 -- components/shared/index.tsx | 1 + components/shared/sub-nav.tsx | 27 +++++++ package-lock.json | 20 +++-- package.json | 4 +- utils/types/pages.types.ts | 8 ++ utils/types/shared.types.ts | 7 ++ 18 files changed, 167 insertions(+), 167 deletions(-) create mode 100644 app/(goldrush)/[chain_id]/transaction/[tx_hash]/layout.tsx create mode 100644 app/(goldrush)/[chain_id]/transaction/[tx_hash]/raw-logs/page.tsx create mode 100644 app/(goldrush)/[chain_id]/transaction/[tx_hash]/receipt/page.tsx create mode 100644 components/shared/sub-nav.tsx diff --git a/app/(goldrush)/[chain_id]/address/[address]/layout.tsx b/app/(goldrush)/[chain_id]/address/[address]/layout.tsx index a2bde29..a1ffd9d 100644 --- a/app/(goldrush)/[chain_id]/address/[address]/layout.tsx +++ b/app/(goldrush)/[chain_id]/address/[address]/layout.tsx @@ -1,47 +1,38 @@ "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 = ({ 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 (
@@ -49,21 +40,7 @@ const AddressLayout: React.FC = ({ - + {children}
diff --git a/app/(goldrush)/[chain_id]/address/[address]/nft-balances/page.tsx b/app/(goldrush)/[chain_id]/address/[address]/nft-balances/page.tsx index 5331e1d..6c3b07d 100644 --- a/app/(goldrush)/[chain_id]/address/[address]/nft-balances/page.tsx +++ b/app/(goldrush)/[chain_id]/address/[address]/nft-balances/page.tsx @@ -19,8 +19,6 @@ const AddressNFTBalancesPage: React.FC = ({ ({ parent: Link, parentProps: { diff --git a/app/(goldrush)/[chain_id]/address/[address]/token-balances/page.tsx b/app/(goldrush)/[chain_id]/address/[address]/token-balances/page.tsx index 29593ca..cc54545 100644 --- a/app/(goldrush)/[chain_id]/address/[address]/token-balances/page.tsx +++ b/app/(goldrush)/[chain_id]/address/[address]/token-balances/page.tsx @@ -11,8 +11,6 @@ const AddressTokenBalancesPage: React.FC = ({ ({ parent: Link, parentProps: { diff --git a/app/(goldrush)/[chain_id]/address/[address]/transactions/page.tsx b/app/(goldrush)/[chain_id]/address/[address]/transactions/page.tsx index f4d4bc6..587c180 100644 --- a/app/(goldrush)/[chain_id]/address/[address]/transactions/page.tsx +++ b/app/(goldrush)/[chain_id]/address/[address]/transactions/page.tsx @@ -11,8 +11,6 @@ const AddressTransactionsPage: React.FC = ({ ({ parent: Link, parentProps: { @@ -20,8 +18,6 @@ const AddressTransactionsPage: React.FC = ({ className: "hover:gbk-underline", }, })} - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-expect-error actionable_block={(block_height) => ({ parent: Link, parentProps: { @@ -29,8 +25,6 @@ const AddressTransactionsPage: React.FC = ({ className: "hover:gbk-underline", }, })} - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-expect-error actionable_transaction={(tx_hash) => ({ parent: Link, parentProps: { diff --git a/app/(goldrush)/[chain_id]/block/[block_height]/page.tsx b/app/(goldrush)/[chain_id]/block/[block_height]/page.tsx index 4af1a71..aaa0c55 100644 --- a/app/(goldrush)/[chain_id]/block/[block_height]/page.tsx +++ b/app/(goldrush)/[chain_id]/block/[block_height]/page.tsx @@ -14,8 +14,6 @@ const BlockPage: React.FC = ({ ({ parent: Link, parentProps: { @@ -23,8 +21,6 @@ const BlockPage: React.FC = ({ className: "hover:gbk-underline", }, })} - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-expect-error actionable_block={(block_height) => ({ parent: Link, parentProps: { @@ -32,8 +28,6 @@ const BlockPage: React.FC = ({ className: "hover:gbk-underline", }, })} - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-expect-error actionable_transaction={(tx_hash) => ({ parent: Link, parentProps: { diff --git a/app/(goldrush)/[chain_id]/blocks/page.tsx b/app/(goldrush)/[chain_id]/blocks/page.tsx index dcaea4a..f46dbe8 100644 --- a/app/(goldrush)/[chain_id]/blocks/page.tsx +++ b/app/(goldrush)/[chain_id]/blocks/page.tsx @@ -9,8 +9,6 @@ const BlocksPage: React.FC = ({ params: { chain_id } }) => {
({ parent: Link, parentProps: { diff --git a/app/(goldrush)/[chain_id]/page.tsx b/app/(goldrush)/[chain_id]/page.tsx index 64115b6..70c8024 100644 --- a/app/(goldrush)/[chain_id]/page.tsx +++ b/app/(goldrush)/[chain_id]/page.tsx @@ -40,8 +40,6 @@ const Home: React.FC = ({ params: { chain_id } }) => {
({ parent: Link, parentProps: { @@ -49,8 +47,6 @@ const Home: React.FC = ({ params: { chain_id } }) => { className: "hover:gbk-underline", }, })} - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-expect-error actionable_redirect={() => ({ parent: Link, parentProps: { @@ -68,8 +64,6 @@ const Home: React.FC = ({ params: { chain_id } }) => {
({ parent: Link, parentProps: { @@ -77,8 +71,6 @@ const Home: React.FC = ({ params: { chain_id } }) => { className: "hover:gbk-underline", }, })} - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-expect-error actionable_transaction={(tx_hash) => ({ parent: Link, parentProps: { @@ -86,8 +78,6 @@ const Home: React.FC = ({ params: { chain_id } }) => { className: "hover:gbk-underline", }, })} - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-expect-error actionable_redirect={() => ({ parent: Link, parentProps: { diff --git a/app/(goldrush)/[chain_id]/transaction/[tx_hash]/layout.tsx b/app/(goldrush)/[chain_id]/transaction/[tx_hash]/layout.tsx new file mode 100644 index 0000000..278fe64 --- /dev/null +++ b/app/(goldrush)/[chain_id]/transaction/[tx_hash]/layout.tsx @@ -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 = ({ + children, + params: { tx_hash, chain_id }, +}) => { + const routes: { + children: React.ReactNode; + href: string; + }[] = [ + { + children: "Receipt", + href: "receipt", + }, + { + children: "Raw Logs", + href: "raw-logs", + }, + ]; + + return ( +
+ ({ + 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", + }, + })} + /> + + + + {children} +
+ ); +}; + +export default TransactionLayout; diff --git a/app/(goldrush)/[chain_id]/transaction/[tx_hash]/page.tsx b/app/(goldrush)/[chain_id]/transaction/[tx_hash]/page.tsx index 25eeaf6..8c17e83 100644 --- a/app/(goldrush)/[chain_id]/transaction/[tx_hash]/page.tsx +++ b/app/(goldrush)/[chain_id]/transaction/[tx_hash]/page.tsx @@ -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 = ({ params: { tx_hash, chain_id }, }) => { - return ( -
- ({ - 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", - }, - })} - /> - ({ - 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", - }, - })} - /> -
- ); + redirect(`/${chain_id}/transaction/${tx_hash}/receipt`); }; export default TransactionPage; diff --git a/app/(goldrush)/[chain_id]/transaction/[tx_hash]/raw-logs/page.tsx b/app/(goldrush)/[chain_id]/transaction/[tx_hash]/raw-logs/page.tsx new file mode 100644 index 0000000..00346fb --- /dev/null +++ b/app/(goldrush)/[chain_id]/transaction/[tx_hash]/raw-logs/page.tsx @@ -0,0 +1,12 @@ +"use client"; + +import { type TransactionPageProps } from "@/utils/types/pages.types"; +import { TransactionRawLogs } from "@covalenthq/goldrush-kit"; + +const TransactionRawLogsPage: React.FC = ({ + params: { tx_hash, chain_id }, +}) => { + return ; +}; + +export default TransactionRawLogsPage; diff --git a/app/(goldrush)/[chain_id]/transaction/[tx_hash]/receipt/page.tsx b/app/(goldrush)/[chain_id]/transaction/[tx_hash]/receipt/page.tsx new file mode 100644 index 0000000..0607a2e --- /dev/null +++ b/app/(goldrush)/[chain_id]/transaction/[tx_hash]/receipt/page.tsx @@ -0,0 +1,12 @@ +"use client"; + +import { type TransactionPageProps } from "@/utils/types/pages.types"; +import { TransactionReceipt } from "@covalenthq/goldrush-kit"; + +const TransactionReceiptPage: React.FC = ({ + params: { tx_hash, chain_id }, +}) => { + return ; +}; + +export default TransactionReceiptPage; diff --git a/app/(goldrush)/[chain_id]/transactions/page.tsx b/app/(goldrush)/[chain_id]/transactions/page.tsx index 793fe07..e758a2b 100644 --- a/app/(goldrush)/[chain_id]/transactions/page.tsx +++ b/app/(goldrush)/[chain_id]/transactions/page.tsx @@ -11,8 +11,6 @@ const TransactionsPage: React.FC = ({
({ parent: Link, parentProps: { @@ -20,8 +18,6 @@ const TransactionsPage: React.FC = ({ className: "hover:gbk-underline", }, })} - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-expect-error actionable_block={(block_height) => ({ parent: Link, parentProps: { @@ -29,8 +25,6 @@ const TransactionsPage: React.FC = ({ className: "hover:gbk-underline", }, })} - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-expect-error actionable_transaction={(tx_hash) => ({ parent: Link, parentProps: { diff --git a/components/shared/index.tsx b/components/shared/index.tsx index c804389..717eef6 100644 --- a/components/shared/index.tsx +++ b/components/shared/index.tsx @@ -2,3 +2,4 @@ export { Footer } from "./footer"; export { Loader } from "./loader"; export { Navbar } from "./navbar"; export { PoweredByCovalent } from "./powered-by-covalent"; +export { SubNav } from "./sub-nav"; diff --git a/components/shared/sub-nav.tsx b/components/shared/sub-nav.tsx new file mode 100644 index 0000000..3dd5f34 --- /dev/null +++ b/components/shared/sub-nav.tsx @@ -0,0 +1,27 @@ +"use client"; + +import { type SubNavProps } from "@/utils/types/shared.types"; +import Link from "next/link"; +import { usePathname } from "next/navigation"; + +export const SubNav: React.FC = ({ routes }) => { + const path = usePathname().split("/").slice(-1)[0]; + + return ( + + ); +}; diff --git a/package-lock.json b/package-lock.json index 8cbacea..60a36d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.1.0", "license": "MIT", "dependencies": { - "@covalenthq/goldrush-kit": "^1.0.3", + "@covalenthq/goldrush-kit": "^1.0.5", "@next/third-parties": "^14.2.4", "next": "14.1.3", "react": "^18", @@ -17,7 +17,7 @@ "react-lottie": "^1.2.4" }, "devDependencies": { - "@covalenthq/client-sdk": "^2.1.1", + "@covalenthq/client-sdk": "^2.2.1", "@trivago/prettier-plugin-sort-imports": "^4.3.0", "@types/node": "^20", "@types/react": "^18", @@ -416,21 +416,19 @@ } }, "node_modules/@covalenthq/client-sdk": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@covalenthq/client-sdk/-/client-sdk-2.1.2.tgz", - "integrity": "sha512-PoWCTm2gp7sq19KBoTmpI3hKS52HW0gbBlHn8TM9XbBedaDFOEZG3rf3Pzhl0njFqQ1ikrU3vGOBE2/s9INUkQ==", - "license": "Apache-2.0", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@covalenthq/client-sdk/-/client-sdk-2.2.1.tgz", + "integrity": "sha512-lUfJw8Ce/aWHHHj+SQGUKQ5XmigR/HLycmYKh+/Go0Hg5BfQboGHFPcwEQjiEdH8z09NV2B0qloC9Tbe1/pxBA==", "dependencies": { "big.js": "^6.2.1" } }, "node_modules/@covalenthq/goldrush-kit": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@covalenthq/goldrush-kit/-/goldrush-kit-1.0.4.tgz", - "integrity": "sha512-+MeHfjMHPSMWxP9actpIwItIt4QMDoqwj0tUqQjKs/0NMOi8uf68yG5CmHey+ejOK8zwOtS/tDQzBJUF8Hs1wg==", - "license": "Apache-2.0", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@covalenthq/goldrush-kit/-/goldrush-kit-1.0.5.tgz", + "integrity": "sha512-q76L7IN3IC6I0GWDTBSPTUf41E4ZymRoycGb0ij4hDO8fiucjfYmaId+R5OWljPNfJ2Tum1eD5AEkNofgdxEPA==", "dependencies": { - "@covalenthq/client-sdk": "^2.1.2", + "@covalenthq/client-sdk": "^2.2.1", "@radix-ui/react-avatar": "^1.0.4", "@radix-ui/react-checkbox": "^1.0.4", "@radix-ui/react-dialog": "^1.0.5", diff --git a/package.json b/package.json index 1d18ac5..62147c9 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "pretty": "prettier . --write" }, "dependencies": { - "@covalenthq/goldrush-kit": "^1.0.3", + "@covalenthq/goldrush-kit": "^1.0.5", "@next/third-parties": "^14.2.4", "next": "14.1.3", "react": "^18", @@ -43,7 +43,7 @@ ], "license": "MIT", "devDependencies": { - "@covalenthq/client-sdk": "^2.1.1", + "@covalenthq/client-sdk": "^2.2.1", "@trivago/prettier-plugin-sort-imports": "^4.3.0", "@types/node": "^20", "@types/react": "^18", diff --git a/utils/types/pages.types.ts b/utils/types/pages.types.ts index d7989bb..77bd6ec 100644 --- a/utils/types/pages.types.ts +++ b/utils/types/pages.types.ts @@ -34,6 +34,14 @@ export interface BlocksPageProps { }; } +export interface TransactionLayoutProps { + children: React.ReactNode; + params: { + tx_hash: string; + chain_id: Chain; + }; +} + export interface TransactionPageProps { params: { tx_hash: string; diff --git a/utils/types/shared.types.ts b/utils/types/shared.types.ts index e16278d..32cc0d7 100644 --- a/utils/types/shared.types.ts +++ b/utils/types/shared.types.ts @@ -11,3 +11,10 @@ export interface GoldRushConfig { chains: Chain[]; gtag_id?: string | null; } + +export interface SubNavProps { + routes: { + children: React.ReactNode; + href: string; + }[]; +}