Skip to content
This repository has been archived by the owner on Nov 28, 2024. It is now read-only.

refactor: bump semaphore pkg version #8

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 6 additions & 8 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@ import Header from "@/components/Header";
import Logo from "@/components/ui/Logo";
import { GroupWithNetwork } from "@/lib/types";
import { extractPresentNetworks } from "@/lib/utils";
import {
SemaphoreSubgraph,
getSupportedNetworks,
} from "@semaphore-protocol/data";
import { SemaphoreSubgraph } from "@semaphore-protocol/data";
import { supportedNetworks } from "@semaphore-protocol/utils";
import { cache } from "react";

const getGroupSubgraphData = async (network: string) => {
const semaphoreSubgraph = new SemaphoreSubgraph();
const semaphoreSubgraph = new SemaphoreSubgraph(network);
try {
const groupData = await semaphoreSubgraph.getGroups({
members: true,
verifiedProofs: true,
validatedProofs: true,
});
const groupsWithNetwork = groupData.map((group) => {
return { ...group, network };
Expand All @@ -28,14 +26,14 @@ const getGroupSubgraphData = async (network: string) => {
};

const getGroupsFromSubgraph = cache(async () => {
const networks = getSupportedNetworks();
const networks = Object.keys(supportedNetworks);
const data: GroupWithNetwork[] = [];

console.log(networks);
for (const network of networks) {
try {
const groupData = await getGroupSubgraphData(network);
console.log(groupData);

if (groupData) {
data.push(...groupData);
console.log(`Got ${groupData.length} groups from ${network}`);
Expand Down
4 changes: 2 additions & 2 deletions components/Dashboard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GroupResponse, SemaphoreSubgraph } from "@semaphore-protocol/data";
import { GroupResponse } from "@semaphore-protocol/data";
import StatCard from "../StatCard";

export default function Dashboard({ groups }: { groups?: GroupResponse[] }) {
Expand All @@ -19,7 +19,7 @@ export default function Dashboard({ groups }: { groups?: GroupResponse[] }) {
<StatCard
title="total proofs"
value={`${groups.reduce((proofCount, currGroup) => {
return (proofCount += currGroup?.verifiedProofs?.length || 0);
return (proofCount += currGroup?.validatedProofs?.length || 0);
}, 0)}`}
/>
</>
Expand Down
18 changes: 9 additions & 9 deletions components/Groups/details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { GroupResponse } from "@semaphore-protocol/data";
import { motion } from "framer-motion";
import { useEffect, useState } from "react";
import { VerifiedProof } from "../ui/VerifiedProof";
import { ValidatedProof } from "../ui/ValidatedProof";
import Copy from "../ui/copy";
interface GroupAndRefProps {
group?: GroupWithNetwork;
Expand All @@ -23,10 +23,10 @@ export const Details = ({ group, forwardRef }: GroupAndRefProps) => {

const groupProofsByTimestamp = (group: GroupWithNetwork | undefined) => {
if (!group) return;
if (!group?.verifiedProofs) return;
if (!group?.validatedProofs) return;

const value = group.verifiedProofs.reduce(
(acc: Record<string, GroupResponse["verifiedProofs"]>, proof: any) => {
const value = group.validatedProofs.reduce(
(acc: Record<string, GroupResponse["validatedProofs"]>, proof: any) => {
if (!proof) return acc;
const tDate = formatDate(proof.timestamp);
if (!acc[tDate]) {
Expand Down Expand Up @@ -98,18 +98,18 @@ export const Details = ({ group, forwardRef }: GroupAndRefProps) => {
</motion.div>
))}
</motion.div>
<p className="text-slate-400">Verified Proofs</p>
<p className="text-slate-400">Validated Proofs</p>
<motion.div
className="flex max-h-screen flex-col gap-3 overflow-y-auto overflow-x-hidden p-2"
variants={staggerChildren}
>
{!group.verifiedProofs?.length && (
{!group.validatedProofs?.length && (
<p className="text-sm text-slate-600 dark:text-slate-400">
We couldn&apos;t find any verified proofs
We couldn&apos;t find any validated proofs
</p>
)}
{group.verifiedProofs && (
<VerifiedProof records={groupedTimestamps} />
{group.validatedProofs && (
<ValidatedProof records={groupedTimestamps} />
)}
</motion.div>
</>
Expand Down
6 changes: 3 additions & 3 deletions components/ui/GroupCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export default function GroupCard({ group, onClick }: GroupAndClickProps) {
<p className="text-slate-400">|</p>
<p>
✅{" "}
{group.verifiedProofs?.length === 1
? "1 verified proof"
: `${group.verifiedProofs?.length} verified proofs`}
{group.validatedProofs?.length === 1
? "1 validated proof"
: `${group.validatedProofs?.length} validated proofs`}
</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
AccordionTrigger,
} from "./Accordion";
interface Props {
records: Record<string, GroupResponse["verifiedProofs"]> | undefined;
records: Record<string, GroupResponse["validatedProofs"]> | undefined;
}

export const VerifiedProof = ({ records }: Props) => {
export const ValidatedProof = ({ records }: Props) => {
if (!records) return null;
return (
<>
Expand All @@ -29,20 +29,20 @@ export const VerifiedProof = ({ records }: Props) => {
<AccordionContent key={index}>
<div className="flex flex-col items-start">
<article>
<h6 className="text-slate-400">External Nullifier</h6>
<p>{proof?.externalNullifier}</p>
<h6 className="text-slate-400">Scope</h6>
<p>{proof?.scope}</p>
</article>
<article>
<h6 className="text-slate-400">Merkle Tree Root</h6>
<p>{truncateHash(proof.merkleTreeRoot)}</p>
</article>
<article>
<h6 className="text-slate-400">Nullifier Hash</h6>
<p>{truncateHash(proof.nullifierHash)}</p>
<h6 className="text-slate-400">Nullifier</h6>
<p>{truncateHash(proof.nullifier)}</p>
</article>
<article>
<h6 className="text-slate-400">Signal</h6>
<p>{truncateHash(proof.signal)}</p>
<h6 className="text-slate-400">Message</h6>
<p>{truncateHash(proof.message)}</p>
</article>
</div>
</AccordionContent>
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"@radix-ui/react-accordion": "^1.1.1",
"@radix-ui/react-label": "^2.0.1",
"@radix-ui/react-select": "^1.2.1",
"@semaphore-protocol/data": "^3.9.0",
"@semaphore-protocol/data": "4.2.0",
"@semaphore-protocol/utils": "4.2.0",
"@types/node": "18.15.11",
"@types/react": "18.0.35",
"@types/react-dom": "18.0.11",
Expand Down
Loading
Loading