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

Commit d1fb26a

Browse files
authored
Merge pull request #8 from semaphore-protocol/refactor/semaphore-v4
refactor: bump semaphore pkg version
2 parents 19061a8 + 10aaf8c commit d1fb26a

File tree

7 files changed

+139
-325
lines changed

7 files changed

+139
-325
lines changed

app/page.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@ import Header from "@/components/Header";
44
import Logo from "@/components/ui/Logo";
55
import { GroupWithNetwork } from "@/lib/types";
66
import { extractPresentNetworks } from "@/lib/utils";
7-
import {
8-
SemaphoreSubgraph,
9-
getSupportedNetworks,
10-
} from "@semaphore-protocol/data";
7+
import { SemaphoreSubgraph } from "@semaphore-protocol/data";
8+
import { supportedNetworks } from "@semaphore-protocol/utils";
119
import { cache } from "react";
1210

1311
const getGroupSubgraphData = async (network: string) => {
14-
const semaphoreSubgraph = new SemaphoreSubgraph();
12+
const semaphoreSubgraph = new SemaphoreSubgraph(network);
1513
try {
1614
const groupData = await semaphoreSubgraph.getGroups({
1715
members: true,
18-
verifiedProofs: true,
16+
validatedProofs: true,
1917
});
2018
const groupsWithNetwork = groupData.map((group) => {
2119
return { ...group, network };
@@ -28,14 +26,14 @@ const getGroupSubgraphData = async (network: string) => {
2826
};
2927

3028
const getGroupsFromSubgraph = cache(async () => {
31-
const networks = getSupportedNetworks();
29+
const networks = Object.keys(supportedNetworks);
3230
const data: GroupWithNetwork[] = [];
3331

3432
console.log(networks);
3533
for (const network of networks) {
3634
try {
3735
const groupData = await getGroupSubgraphData(network);
38-
console.log(groupData);
36+
3937
if (groupData) {
4038
data.push(...groupData);
4139
console.log(`Got ${groupData.length} groups from ${network}`);

components/Dashboard/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { GroupResponse, SemaphoreSubgraph } from "@semaphore-protocol/data";
1+
import { GroupResponse } from "@semaphore-protocol/data";
22
import StatCard from "../StatCard";
33

44
export default function Dashboard({ groups }: { groups?: GroupResponse[] }) {
@@ -19,7 +19,7 @@ export default function Dashboard({ groups }: { groups?: GroupResponse[] }) {
1919
<StatCard
2020
title="total proofs"
2121
value={`${groups.reduce((proofCount, currGroup) => {
22-
return (proofCount += currGroup?.verifiedProofs?.length || 0);
22+
return (proofCount += currGroup?.validatedProofs?.length || 0);
2323
}, 0)}`}
2424
/>
2525
</>

components/Groups/details.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import { GroupResponse } from "@semaphore-protocol/data";
1111
import { motion } from "framer-motion";
1212
import { useEffect, useState } from "react";
13-
import { VerifiedProof } from "../ui/VerifiedProof";
13+
import { ValidatedProof } from "../ui/ValidatedProof";
1414
import Copy from "../ui/copy";
1515
interface GroupAndRefProps {
1616
group?: GroupWithNetwork;
@@ -23,10 +23,10 @@ export const Details = ({ group, forwardRef }: GroupAndRefProps) => {
2323

2424
const groupProofsByTimestamp = (group: GroupWithNetwork | undefined) => {
2525
if (!group) return;
26-
if (!group?.verifiedProofs) return;
26+
if (!group?.validatedProofs) return;
2727

28-
const value = group.verifiedProofs.reduce(
29-
(acc: Record<string, GroupResponse["verifiedProofs"]>, proof: any) => {
28+
const value = group.validatedProofs.reduce(
29+
(acc: Record<string, GroupResponse["validatedProofs"]>, proof: any) => {
3030
if (!proof) return acc;
3131
const tDate = formatDate(proof.timestamp);
3232
if (!acc[tDate]) {
@@ -98,18 +98,18 @@ export const Details = ({ group, forwardRef }: GroupAndRefProps) => {
9898
</motion.div>
9999
))}
100100
</motion.div>
101-
<p className="text-slate-400">Verified Proofs</p>
101+
<p className="text-slate-400">Validated Proofs</p>
102102
<motion.div
103103
className="flex max-h-screen flex-col gap-3 overflow-y-auto overflow-x-hidden p-2"
104104
variants={staggerChildren}
105105
>
106-
{!group.verifiedProofs?.length && (
106+
{!group.validatedProofs?.length && (
107107
<p className="text-sm text-slate-600 dark:text-slate-400">
108-
We couldn&apos;t find any verified proofs
108+
We couldn&apos;t find any validated proofs
109109
</p>
110110
)}
111-
{group.verifiedProofs && (
112-
<VerifiedProof records={groupedTimestamps} />
111+
{group.validatedProofs && (
112+
<ValidatedProof records={groupedTimestamps} />
113113
)}
114114
</motion.div>
115115
</>

components/ui/GroupCard.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ export default function GroupCard({ group, onClick }: GroupAndClickProps) {
3030
<p className="text-slate-400">|</p>
3131
<p>
3232
{" "}
33-
{group.verifiedProofs?.length === 1
34-
? "1 verified proof"
35-
: `${group.verifiedProofs?.length} verified proofs`}
33+
{group.validatedProofs?.length === 1
34+
? "1 validated proof"
35+
: `${group.validatedProofs?.length} validated proofs`}
3636
</p>
3737
</div>
3838
</div>
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import {
77
AccordionTrigger,
88
} from "./Accordion";
99
interface Props {
10-
records: Record<string, GroupResponse["verifiedProofs"]> | undefined;
10+
records: Record<string, GroupResponse["validatedProofs"]> | undefined;
1111
}
1212

13-
export const VerifiedProof = ({ records }: Props) => {
13+
export const ValidatedProof = ({ records }: Props) => {
1414
if (!records) return null;
1515
return (
1616
<>
@@ -29,20 +29,20 @@ export const VerifiedProof = ({ records }: Props) => {
2929
<AccordionContent key={index}>
3030
<div className="flex flex-col items-start">
3131
<article>
32-
<h6 className="text-slate-400">External Nullifier</h6>
33-
<p>{proof?.externalNullifier}</p>
32+
<h6 className="text-slate-400">Scope</h6>
33+
<p>{proof?.scope}</p>
3434
</article>
3535
<article>
3636
<h6 className="text-slate-400">Merkle Tree Root</h6>
3737
<p>{truncateHash(proof.merkleTreeRoot)}</p>
3838
</article>
3939
<article>
40-
<h6 className="text-slate-400">Nullifier Hash</h6>
41-
<p>{truncateHash(proof.nullifierHash)}</p>
40+
<h6 className="text-slate-400">Nullifier</h6>
41+
<p>{truncateHash(proof.nullifier)}</p>
4242
</article>
4343
<article>
44-
<h6 className="text-slate-400">Signal</h6>
45-
<p>{truncateHash(proof.signal)}</p>
44+
<h6 className="text-slate-400">Message</h6>
45+
<p>{truncateHash(proof.message)}</p>
4646
</article>
4747
</div>
4848
</AccordionContent>

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"@radix-ui/react-accordion": "^1.1.1",
2020
"@radix-ui/react-label": "^2.0.1",
2121
"@radix-ui/react-select": "^1.2.1",
22-
"@semaphore-protocol/data": "^3.9.0",
22+
"@semaphore-protocol/data": "4.3.0",
23+
"@semaphore-protocol/utils": "4.3.0",
2324
"@types/node": "18.15.11",
2425
"@types/react": "18.0.35",
2526
"@types/react-dom": "18.0.11",

0 commit comments

Comments
 (0)