Skip to content

Commit

Permalink
Refactor portal columns and constants, update portal components to us…
Browse files Browse the repository at this point in the history
…e new constants and column definitions
  • Loading branch information
Chirag-S-Kotian committed Dec 5, 2024
1 parent a67eede commit 9b79dfa
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 24 deletions.
10 changes: 5 additions & 5 deletions explorer/src/constants/columns/portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +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 { EMPTY_STRING, ZERO, ZERO_ADDRESS } from "@/constants";
import { toPortalById } from "@/routes/constants";
import { getBlockExplorerLink } from "@/utils";
import { cropString } from "@/utils/stringUtils";
Expand Down Expand Up @@ -72,13 +72,13 @@ export const portalColumnsOption = {
export const skeletonPortals = (count: number) =>
Array(count)
.fill(null)
.map((_, index) => ({
id: `0x${index.toString(16).padStart(40, "0")}` as `0x${string}`,
.map(() => ({
id: ZERO_ADDRESS,
name: EMPTY_STRING,
description: EMPTY_STRING,
ownerAddress: `${EMPTY_0X_STRING}${"0".repeat(40)}` as `0x${string}`,
ownerAddress: ZERO_ADDRESS,
ownerName: EMPTY_STRING,
modules: [] as `0x${string}`[],
modules: [],
isRevocable: false,
attestationCounter: ZERO,
}));
1 change: 1 addition & 0 deletions explorer/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const DASH = "-";
export const ZERO_STRING = "0";
export const TEN = 10;
export const ZERO = 0;
export const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000" as `0x${string}`;
export const ITEMS_PER_PAGE_DEFAULT = 10;
export const ITEMS_SEARCHED_DEFAULT = 100;
export const CURRENT_PAGE_DEFAULT = 1;
Expand Down
19 changes: 7 additions & 12 deletions explorer/src/pages/Issuer/components/Portals/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ export const Portals: React.FC<IPortalProps> = ({ address }) => {
const location = useLocation();

const { data: portals } = useSWR(`${SWRKeys.GET_PORTALS_BY_ISSUER}/${address}`, () =>
sdk.portal.findBy(undefined, undefined, { ownerAddress: address }).then((portalList) =>
portalList.map((portal) => ({
...portal,
id: portal.id as `0x${string}`,
})),
),
sdk.portal.findBy(undefined, undefined, { ownerAddress: address }),
);

if (!portals) return null;
Expand All @@ -49,22 +44,22 @@ export const Portals: React.FC<IPortalProps> = ({ address }) => {
</tr>
</thead>
<tbody className="divide-y">
{portals.map(({ id, name, description, attestationCounter }) => (
<tr key={id}>
{portals.map((portal) => (
<tr key={portal.id}>
<td className="px-6 py-4 whitespace-nowrap text-xs font-medium">
<Button
name={name}
name={portal.name}
handler={() =>
navigate(toPortalById(id).replace(CHAIN_ID_ROUTE, network), {
navigate(toPortalById(portal.id).replace(CHAIN_ID_ROUTE, network), {
state: { from: location.pathname },
})
}
buttonType={EButtonType.TRANSPARENT}
iconRight={<ArrowRight />}
/>
</td>
<td className="px-6 py-4 whitespace-nowrap text-xs">{description}</td>
<td className="px-6 py-4 whitespace-nowrap text-xs font-medium">{attestationCounter}</td>
<td className="px-6 py-4 whitespace-nowrap text-xs">{portal.description}</td>
<td className="px-6 py-4 whitespace-nowrap text-xs font-medium">{portal.attestationCounter}</td>
</tr>
))}
</tbody>
Expand Down
8 changes: 1 addition & 7 deletions explorer/src/pages/Module/components/ModulePortals/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@ export const ModulePortals: React.FC<{ moduleId: Address }> = ({ moduleId }) =>

const { data: portals, isLoading } = useSWR(
`${SWRKeys.GET_MODULE_PORTAL_LIST}/${moduleId}/${chain.id}`,
async () => {
const portalList = await sdk.portal.findBy(5, 0, { modules_contains: [moduleId] }, "attestationCounter", "desc");
return portalList.map((portal) => ({
...portal,
id: portal.id as `0x${string}`,
}));
},
async () => sdk.portal.findBy(undefined, undefined, { modules_contains: [moduleId] }),
{
shouldRetryOnError: false,
},
Expand Down

0 comments on commit 9b79dfa

Please sign in to comment.