Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions dapp/src/components/page/dashboard/CreateProjectModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,12 @@ ${maintainerGithubs.map((gh) => `[[PRINCIPALS]]\ngithub="${gh}"`).join("\n\n")}
if (project && project.name && project.config && project.maintainers) {
setProject(project);

const { username, repoName } = getAuthorRepo(project.config.url);
if (username && repoName) {
const { descriptor, username, repoName } = getAuthorRepo(
project.config.url,
);
if (descriptor) {
setProjectRepoInfo(descriptor);
} else if (username && repoName) {
setProjectRepoInfo(username, repoName);
}

Expand Down
8 changes: 6 additions & 2 deletions dapp/src/components/page/dashboard/ProjectCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ const ProjectCard = ({ config }: { config: ProjectConfig }) => {
const project = await getProjectFromName(config.projectName);
if (project && project.name && project.config && project.maintainers) {
setProject(project);
const { username, repoName } = getAuthorRepo(project.config.url);
if (username && repoName) {
const { descriptor, username, repoName } = getAuthorRepo(
project.config.url,
);
if (descriptor) {
setProjectRepoInfo(descriptor);
} else if (username && repoName) {
setProjectRepoInfo(username, repoName);
}
const tomlData = await fetchTomlFromCid(project.config.ipfs);
Expand Down
11 changes: 10 additions & 1 deletion dapp/src/components/page/dashboard/ProjectList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from "../../../service/ReadContractService.ts";
import { loadConfigData } from "../../../service/StateService.ts";
import { convertGitHubLink } from "../../../utils/editLinkFunctions";
import { parseRepositoryUrl } from "../../../utils/repository";
import { projectCardModalOpen } from "../../../utils/store.ts";
import { extractConfigData } from "../../../utils/utils";
import CreateProjectModal from "./CreateProjectModal.tsx";
Expand Down Expand Up @@ -214,6 +215,7 @@ const ProjectList = () => {
const configData = extractConfigData(tomlData, project);
setConfigInfo(configData);
} else {
const repositoryDescriptor = parseRepositoryUrl(project.config.url);
const configData = {
projectName: project.name,
logoImageLink: undefined,
Expand All @@ -222,8 +224,15 @@ const ProjectList = () => {
organizationName: "",
officials: {
githubLink: project.config.url,
...(repositoryDescriptor
? { repository: repositoryDescriptor }
: {}),
},
socialLinks: {
twitter: "",
telegram: "",
discord: "",
},
socialLinks: {},
authorGithubNames: [],
maintainersAddresses: project.maintainers,
};
Expand Down
35 changes: 23 additions & 12 deletions dapp/src/components/page/project/CommitHistory.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useStore } from "@nanostores/react";
import { useEffect, useState } from "react";
import { getCommitHistory } from "../../../service/GithubService.ts";
import { getCommitHistory } from "../../../service/RepositoryService.ts";
import {
loadConfigData,
loadProjectRepoInfo,
Expand All @@ -18,24 +18,35 @@ const CommitHistory = () => {

const fetchCommitHistory = async (page = 1) => {
const projectRepoInfo = loadProjectRepoInfo();
if (projectRepoInfo?.author && projectRepoInfo?.repository) {
const history = await getCommitHistory(
if (!projectRepoInfo) {
return;
}

let history = null;
if (projectRepoInfo.descriptor) {
history = await getCommitHistory(
projectRepoInfo.descriptor,
undefined,
page,
);
} else if (projectRepoInfo.author && projectRepoInfo.repository) {
history = await getCommitHistory(
projectRepoInfo.author,
projectRepoInfo.repository,
page,
);
}

if (history) {
setCommitHistory(history);
setCurrentPage(page);
if (history) {
setCommitHistory(history);
setCurrentPage(page);

// Set the latest commit
if (history.length > 0 && history[0].commits.length > 0) {
latestCommit.set(history[0].commits[0].sha);
}
} else {
setCommitHistory([]);
// Set the latest commit
if (history.length > 0 && history[0].commits.length > 0) {
latestCommit.set(history[0].commits[0].sha);
}
} else {
setCommitHistory([]);
}
};

Expand Down
16 changes: 6 additions & 10 deletions dapp/src/components/page/project/ContributionMetrics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ import MonthlyActivityChart from "./MonthlyActivityChart";

interface ContributionMetricsProps {
projectName: string;
owner: string;
repo: string;
repositoryUrl: string;
}

const ContributionMetrics = ({
projectName,
owner,
repo,
repositoryUrl,
}: ContributionMetricsProps) => {
const [metrics, setMetrics] = useState<ContributionMetricsType | null>(null);
const [loading, setLoading] = useState(true);
Expand All @@ -28,10 +26,8 @@ const ContributionMetrics = ({
setLoading(true);
setError(null);

const metrics = await ContributionMetricsService.fetchMetrics(
owner,
repo,
);
const metrics =
await ContributionMetricsService.fetchMetrics(repositoryUrl);
setMetrics(metrics);

const configData = loadConfigData();
Expand All @@ -54,10 +50,10 @@ const ContributionMetrics = ({
}
};

if (projectName && owner && repo) {
if (projectName && repositoryUrl) {
fetchMetrics();
}
}, [projectName, owner, repo]);
}, [projectName, repositoryUrl]);

if (loading) {
return (
Expand Down
2 changes: 1 addition & 1 deletion dapp/src/components/page/project/LatestCommit.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useStore } from "@nanostores/react";
import { getLatestCommitData } from "@service/GithubService";
import { getLatestCommitData } from "@service/RepositoryService";
import { getProjectHash } from "@service/ReadContractService";
import { loadProjectInfo } from "@service/StateService";
import Tooltip from "components/utils/Tooltip";
Expand Down
42 changes: 26 additions & 16 deletions dapp/src/components/page/project/ProjectInfo.astro
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ import Button from "components/utils/Button";
<div id="read-more-modal-container"></div>

<script>
import { getLatestCommitData } from "@service/GithubService";
import { getLatestCommitData } from "@service/RepositoryService";
import { getIpfsBasicLink } from "utils/ipfsFunctions";
import { navigate } from "astro:transitions/client";
import type { ConfigData } from "types/projectConfig";
Expand Down Expand Up @@ -375,6 +375,11 @@ import Button from "components/utils/Button";
projectNameElement.textContent = projectInfo.name;
}
const configData = loadConfigData();
const repoDetails = projectInfo?.config?.url
? getAuthorRepo(projectInfo.config.url)
: undefined;
const repoHost = repoDetails?.descriptor?.host || "repository";
const repoDisplayName = repoHost.replace(/^www\./, "");

const projectThumbnail = document.getElementById(
"project-thumbnail",
Expand Down Expand Up @@ -428,6 +433,7 @@ import Button from "components/utils/Button";
);
}
} else {
// Fallback to repo URL if no explicit officials provided
addLinkButton(officialLinks, projectInfo.config.url, "github");
}
}
Expand Down Expand Up @@ -482,7 +488,9 @@ import Button from "components/utils/Button";
link.appendChild(icon);
link.appendChild(text);

syncStatusContainer.appendChild(link);
if (syncStatusContainer) {
syncStatusContainer.appendChild(link);
}

// Add commit badge
const latestSha = loadProjectLatestSha();
Expand Down Expand Up @@ -519,13 +527,11 @@ import Button from "components/utils/Button";
) {
commitIcon.src = "/icons/check.svg";
commitIcon.alt = "Check";
commitPopup.innerHTML =
'<p class="text-sm w-36 sm:w-max">Commit SHA on-chain exists on GitHub</p>';
commitPopup.innerHTML = `<p class="text-sm w-36 sm:w-max">Commit SHA on-chain exists on ${repoDisplayName}</p>`;
} else {
commitIcon.src = "/icons/check.svg";
commitIcon.alt = "Failed";
commitPopup.innerHTML =
'<p class="text-sm w-36 sm:w-max">Commit SHA on-chain cannot be found on GitHub</p>';
commitPopup.innerHTML = `<p class="text-sm w-36 sm:w-max">Commit SHA on-chain cannot be found on ${repoDisplayName}</p>`;
}
} else {
commitIcon.src = "/icons/failed.svg";
Expand All @@ -536,8 +542,7 @@ import Button from "components/utils/Button";
} catch (error) {
commitIcon.src = "/icons/failed.svg";
commitIcon.alt = "Failed";
commitPopup.innerHTML =
'<p class="text-sm w-36 sm:w-max">No commit SHA can be found on-chain or on GitHub</p>';
commitPopup.innerHTML = `<p class="text-sm w-36 sm:w-max">No commit SHA can be found on-chain or on ${repoDisplayName}</p>`;
}
}

Expand All @@ -549,8 +554,10 @@ import Button from "components/utils/Button";
logoImageLink: configData?.logoImageLink
? convertGitHubLink(configData.logoImageLink)
: "",
githubUrl:
configData?.officials?.githubLink || projectInfo.config.url,
repositoryUrl:
configData?.officials?.repository?.url ||
configData?.officials?.githubLink ||
projectInfo.config.url,
websiteUrl: configData?.officials?.websiteLink,
};

Expand Down Expand Up @@ -579,13 +586,15 @@ import Button from "components/utils/Button";
}

if (projectInfo?.name && projectInfo?.config?.url) {
const { username, repoName } = getAuthorRepo(projectInfo.config.url);
if (username && repoName) {
const repositoryUrl =
configData?.officials?.repository?.url ||
repoDetails?.descriptor?.url ||
projectInfo.config.url;
if (repositoryUrl) {
contributionMetricsRoot.render(
React.createElement(ContributionMetrics, {
projectName: projectInfo.name,
owner: username,
repo: repoName,
repositoryUrl,
}),
);
}
Expand All @@ -603,10 +612,11 @@ import Button from "components/utils/Button";
});

function addLinkButton(
container: HTMLElement,
container: HTMLElement | null,
url: string,
iconName: string,
) {
if (!container) return; // Defensive guard
const button = document.createElement("a");
button.href = url;
button.target = "_blank";
Expand Down Expand Up @@ -678,7 +688,7 @@ import Button from "components/utils/Button";
ul.appendChild(li);
});
secDiv.appendChild(ul);
contentDiv.appendChild(secDiv);
if (contentDiv) contentDiv.appendChild(secDiv);
}
});
} catch (e) {
Expand Down
24 changes: 12 additions & 12 deletions dapp/src/components/page/project/ReadMoreModal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useState, useCallback } from "react";
import type { FC } from "react";
import Modal from "components/utils/Modal";
import { fetchReadmeContentFromConfigUrl } from "../../../service/GithubService";
import { fetchReadmeContentFromConfigUrl } from "../../../service/RepositoryService";
import Markdown from "markdown-to-jsx";
import "github-markdown-css";

Expand All @@ -15,7 +15,7 @@ interface ReadMoreModalProps {
description: string;
organization: string;
logoImageLink: string;
githubUrl: string;
repositoryUrl: string;
websiteUrl?: string;
};
}
Expand Down Expand Up @@ -62,10 +62,10 @@ const ReadMoreModal: FC<ReadMoreModalProps> = ({

useEffect(() => {
const loadReadme = async () => {
if (isOpen && projectData?.githubUrl) {
if (isOpen && projectData?.repositoryUrl) {
try {
const content = await fetchReadmeContentFromConfigUrl(
projectData.githubUrl,
projectData.repositoryUrl,
);
if (content) {
setReadmeContent(content);
Expand All @@ -87,13 +87,13 @@ const ReadMoreModal: FC<ReadMoreModalProps> = ({
setReadmeContent("");
}
};
}, [isOpen, projectData?.githubUrl]);
}, [isOpen, projectData?.repositoryUrl]);

const handleGoToReleases = useCallback(() => {
if (projectData?.githubUrl) {
window.open(`${projectData.githubUrl}/releases`, "_blank");
if (projectData?.repositoryUrl) {
window.open(`${projectData.repositoryUrl}/releases`, "_blank");
}
}, [projectData?.githubUrl]);
}, [projectData?.repositoryUrl]);

if (!isOpen) return null;

Expand All @@ -115,9 +115,9 @@ const ReadMoreModal: FC<ReadMoreModalProps> = ({
{projectData?.name || ""}
</p>
<div className="flex items-center gap-3">
{projectData?.githubUrl && (
{projectData?.repositoryUrl && (
<a
href={projectData.githubUrl}
href={projectData.repositoryUrl}
target="_blank"
rel="noopener noreferrer"
>
Expand Down Expand Up @@ -154,8 +154,8 @@ const ReadMoreModal: FC<ReadMoreModalProps> = ({
<div className="flex items-center gap-2 w-full sm:w-auto">
<CopyButton
textToCopy={
projectData?.githubUrl
? `git clone ${projectData.githubUrl}`
projectData?.repositoryUrl
? `git clone ${projectData.repositoryUrl}`
: ""
}
showText={true}
Expand Down
2 changes: 1 addition & 1 deletion dapp/src/components/page/project/ReadmeViewer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useStore } from "@nanostores/react";
import Markdown from "markdown-to-jsx";
import { useEffect, useState } from "react";
import { fetchReadmeContentFromConfigUrl } from "../../../service/GithubService";
import { fetchReadmeContentFromConfigUrl } from "../../../service/RepositoryService";
import { loadProjectInfo } from "../../../service/StateService";
import { projectInfoLoaded } from "../../../utils/store";
import DOMPurify from "dompurify";
Expand Down
2 changes: 1 addition & 1 deletion dapp/src/components/page/project/UpdateHashModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useStore } from "@nanostores/react";
import { getLatestCommitHash } from "@service/GithubService";
import { getLatestCommitHash } from "@service/RepositoryService";
import { getProject } from "@service/ReadContractService";
import { loadProjectInfo, setProject } from "@service/StateService";
import { loadedPublicKey } from "@service/walletService";
Expand Down
8 changes: 5 additions & 3 deletions dapp/src/pages/project/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ import ProjectInfoTitle from "../../components/page/project/ProjectInfoTitle.ast
const project = await getProjectFromName(projectName);
if (project && project.name && project.config && project.maintainers) {
setProject(project);
const { username, repoName } = getAuthorRepo(project.config.url);
if (username && repoName) {
setProjectRepoInfo(username, repoName);
const { descriptor } = getAuthorRepo(project.config.url);
if (descriptor) {
setProjectRepoInfo(descriptor);
} else {
setProjectRepoInfo(project.config.url);
}
const tomlData = await fetchTomlFromCid(project.config.ipfs);
if (tomlData) {
Expand Down
Loading
Loading