Skip to content

Commit

Permalink
Refactor portal constants and ModulePortals component to use EMPTY_0X…
Browse files Browse the repository at this point in the history
…_STRING, EMPTY_STRING, and ZERO constants; optimize portal filtering in ModulePortals
  • Loading branch information
Chirag-S-Kotian committed Dec 3, 2024
1 parent c8718d9 commit a67eede
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
11 changes: 6 additions & 5 deletions explorer/src/constants/columns/portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Chain } from "viem";
import { TdHandler } from "@/components/DataTable/components/TdHandler";
import { HelperIndicator } from "@/components/HelperIndicator";
import { Link } from "@/components/Link";
import { EMPTY_0X_STRING, EMPTY_STRING, ZERO } from "@/constants";
import { toPortalById } from "@/routes/constants";
import { getBlockExplorerLink } from "@/utils";
import { cropString } from "@/utils/stringUtils";
Expand Down Expand Up @@ -73,11 +74,11 @@ export const skeletonPortals = (count: number) =>
.fill(null)
.map((_, index) => ({
id: `0x${index.toString(16).padStart(40, "0")}` as `0x${string}`,
name: "",
description: "",
ownerAddress: "0x0000000000000000000000000000000000000000" as `0x${string}`,
ownerName: "",
name: EMPTY_STRING,
description: EMPTY_STRING,
ownerAddress: `${EMPTY_0X_STRING}${"0".repeat(40)}` as `0x${string}`,
ownerName: EMPTY_STRING,
modules: [] as `0x${string}`[],
isRevocable: false,
attestationCounter: 0,
attestationCounter: ZERO,
}));
5 changes: 2 additions & 3 deletions explorer/src/pages/Module/components/ModulePortals/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ export const ModulePortals: React.FC<{ moduleId: Address }> = ({ moduleId }) =>
const { data: portals, isLoading } = useSWR(
`${SWRKeys.GET_MODULE_PORTAL_LIST}/${moduleId}/${chain.id}`,
async () => {
const allPortals = await sdk.portal.findBy(100, 0);
const portalList = allPortals.filter((portal) => portal.modules.includes(moduleId));
return portalList.slice(0, 5).map((portal) => ({
const portalList = await sdk.portal.findBy(5, 0, { modules_contains: [moduleId] }, "attestationCounter", "desc");
return portalList.map((portal) => ({
...portal,
id: portal.id as `0x${string}`,
}));
Expand Down

0 comments on commit a67eede

Please sign in to comment.