From 6a6a9aaff19b5f68a846d4adab5a9149a093f153 Mon Sep 17 00:00:00 2001 From: Chirag <157453139+Chirag-S-Kotian@users.noreply.github.com> Date: Mon, 9 Dec 2024 23:13:06 +0530 Subject: [PATCH] feat(explorer): As a user, I want the Module page to display Portals leveraging it (#851) --- explorer/src/constants/columns/portal.tsx | 32 +++++++++++++++ explorer/src/constants/index.ts | 2 + explorer/src/interfaces/swr/enum.ts | 1 + .../pages/Issuer/components/Portals/index.tsx | 12 +++--- .../Module/components/ModulePortals/index.tsx | 39 +++++++++++++++++++ explorer/src/pages/Module/index.tsx | 2 + 6 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 explorer/src/pages/Module/components/ModulePortals/index.tsx diff --git a/explorer/src/constants/columns/portal.tsx b/explorer/src/constants/columns/portal.tsx index 980da05c..b96b5fb1 100644 --- a/explorer/src/constants/columns/portal.tsx +++ b/explorer/src/constants/columns/portal.tsx @@ -6,6 +6,8 @@ import { Chain } from "viem"; import { TdHandler } from "@/components/DataTable/components/TdHandler"; import { HelperIndicator } from "@/components/HelperIndicator"; import { Link } from "@/components/Link"; +import { EMPTY_STRING, ZERO, ZERO_ADDRESS } from "@/constants"; +import { ColumnsOptions } from "@/interfaces/components"; import { toPortalById } from "@/routes/constants"; import { getBlockExplorerLink } from "@/utils"; import { cropString } from "@/utils/stringUtils"; @@ -55,3 +57,33 @@ export const columns = ({ chain }: { chain: Chain }): ColumnDef[] => [ }, }, ]; + +export const portalColumnsOption: ColumnsOptions = { + 0: { + minWidth: 150, + maxWidth: 200, + isRandomWidth: true, + }, + 1: { + minWidth: 200, + maxWidth: 400, + isRandomWidth: true, + }, + 2: { + width: 150, + }, +}; + +export const skeletonPortals = (count: number) => + Array(count) + .fill(null) + .map(() => ({ + id: ZERO_ADDRESS, + name: EMPTY_STRING, + description: EMPTY_STRING, + ownerAddress: ZERO_ADDRESS, + ownerName: EMPTY_STRING, + modules: [], + isRevocable: false, + attestationCounter: ZERO, + })); diff --git a/explorer/src/constants/index.ts b/explorer/src/constants/index.ts index c839242f..dd6502d5 100644 --- a/explorer/src/constants/index.ts +++ b/explorer/src/constants/index.ts @@ -1,3 +1,4 @@ +import { Address } from "viem"; import { arbitrum, arbitrumSepolia, base, baseSepolia, bsc, bscTestnet, linea } from "wagmi/chains"; import { lineaSepolia } from "@/config"; @@ -10,6 +11,7 @@ export const DASH = "-"; export const ZERO_STRING = "0"; export const TEN = 10; export const ZERO = 0; +export const ZERO_ADDRESS: Address = "0x0000000000000000000000000000000000000000"; export const ITEMS_PER_PAGE_DEFAULT = 10; export const ITEMS_SEARCHED_DEFAULT = 100; export const CURRENT_PAGE_DEFAULT = 1; diff --git a/explorer/src/interfaces/swr/enum.ts b/explorer/src/interfaces/swr/enum.ts index f717d253..87afc72c 100644 --- a/explorer/src/interfaces/swr/enum.ts +++ b/explorer/src/interfaces/swr/enum.ts @@ -11,6 +11,7 @@ export enum SWRKeys { GET_RECENT_ATTESTATION_GLOBAL = "getRecentAttestations", GET_MODULE_LIST = "getModuleList", GET_MODULE_COUNT = "getModuleCount", + GET_MODULE_PORTAL_LIST = "getModulePortalList", SEARCH = "search", GET_PORTALS_BY_ISSUER = "getPortalsByIssuer", GET_PORTAL_BY_ID = "getPortalByID", diff --git a/explorer/src/pages/Issuer/components/Portals/index.tsx b/explorer/src/pages/Issuer/components/Portals/index.tsx index a65ffe51..3619ab6e 100644 --- a/explorer/src/pages/Issuer/components/Portals/index.tsx +++ b/explorer/src/pages/Issuer/components/Portals/index.tsx @@ -44,13 +44,13 @@ export const Portals: React.FC = ({ address }) => { - {portals.map(({ id, name, description, attestationCounter }) => ( - + {portals.map((portal) => ( +