Skip to content

Commit 7abbd73

Browse files
committed
feat: enhance ProjectCard to display network type and update useProjectList for manifest retrieval
1 parent c02edf0 commit 7abbd73

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/components/ProjectCard/ProjectCard.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import * as React from 'react';
5-
import { IndexerName } from '@components/IndexerDetails/IndexerName';
65
import { Manifest } from '@hooks/useGetDeploymentManifest';
76
import { Address, Typography } from '@subql/components';
87
import { ProjectFieldsFragment, ProjectType } from '@subql/network-query';
@@ -12,6 +11,7 @@ import BigNumber from 'bignumber.js';
1211
import dayjs from 'dayjs';
1312
import { toSvg } from 'jdenticon';
1413

14+
import { ETH_TYPE_DICTION, NETWORK_TYPE_DICTION } from 'src/const/const';
1515
import { ProjectMetadata } from 'src/models';
1616

1717
import IPFSImage from '../IPFSImage';
@@ -49,6 +49,21 @@ const ProjectCard: React.FC<Props> = ({ project, href, onClick }) => {
4949
);
5050
}, [project?.deployments?.nodes]);
5151

52+
const networkVal = React.useMemo(() => {
53+
if (project.type === ProjectType.RPC && project.manifest?.rpcFamily) {
54+
return project.manifest.rpcFamily[0];
55+
}
56+
57+
const chainId =
58+
project.type === ProjectType.SUBQUERY ? project.manifest?.network?.chainId : project.manifest?.dataSources?.[0]?.network;
59+
if (!chainId) return '-';
60+
61+
const polkadotName = NETWORK_TYPE_DICTION[chainId];
62+
const ethName = ETH_TYPE_DICTION[chainId];
63+
64+
return polkadotName || ethName || chainId;
65+
}, [project.type, project.manifest]);
66+
5267
return (
5368
<a
5469
href={href ? href : `${PROJECT_NAV}/${project.id}`}
@@ -76,7 +91,9 @@ const ProjectCard: React.FC<Props> = ({ project, href, onClick }) => {
7691
</div>
7792

7893
{project.type === ProjectType.SUBQUERY || project.type === ProjectType.SUBGRAPH ? (
79-
<IndexerName address={project.owner} size="tiny" />
94+
<Typography variant="small" style={{ textTransform: 'uppercase' }}>
95+
{networkVal}
96+
</Typography>
8097
) : (
8198
<Typography variant="small" style={{ textTransform: 'uppercase' }}>
8299
{project.manifest?.rpcFamily?.[0]}

src/hooks/useProjectList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const ProjectItem: React.FC<{
2626
onClick?: () => void;
2727
}> = ({ project, makeRedirectHref, onClick }) => {
2828
const { getMetadataFromCid } = useProjectMetadata();
29-
const { manifest } = useGetDeploymentManifest(project.type === ProjectType.RPC ? project.deploymentId : '');
29+
const { manifest } = useGetDeploymentManifest(project.deploymentId);
3030

3131
const { data: metadata } = useAsyncMemo(() => getMetadataFromCid(project.metadata), [project]);
3232

0 commit comments

Comments
 (0)