(projectId: string)
| 251 | } |
| 252 | |
| 253 | async function fetchProject(projectId: string): Promise<Project | null> { |
| 254 | const { owner, dtag } = parseProjectRouteId(projectId); |
| 255 | const events = await relayClient.fetchEvents({ |
| 256 | kinds: [KIND_REPO_ANNOUNCEMENT], |
| 257 | ...(owner ? { authors: [owner] } : {}), |
| 258 | "#d": [dtag], |
| 259 | limit: 10, |
| 260 | }); |
| 261 | |
| 262 | const deduped = dedup(events).filter( |
| 263 | (event) => !owner || event.pubkey.toLowerCase() === owner, |
| 264 | ); |
| 265 | const project = deduped.length > 0 ? eventToProject(deduped[0]) : null; |
| 266 | if (!project) { |
| 267 | return null; |
| 268 | } |
| 269 | |
| 270 | const deletionEvents = await relayClient.fetchEvents({ |
| 271 | kinds: [KIND_DELETION], |
| 272 | authors: [project.owner], |
| 273 | "#a": [project.repoAddress], |
| 274 | limit: 10, |
| 275 | }); |
| 276 | |
| 277 | return isDeletedByA(project, deletionEvents) ? null : project; |
| 278 | } |
| 279 | |
| 280 | function eventToRepoState(event: RelayEvent): RepoState { |
| 281 | const branches: RepoState["branches"] = []; |
no test coverage detected