Skip to content

Commit

Permalink
feat: do not show voters page when gatekeeper is not EAS
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlc03 committed Sep 2, 2024
1 parent f0ff7c2 commit 4a464f9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/interface/src/contexts/Maci.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ export const MaciProvider: React.FC<MaciProviderProps> = ({ children }: MaciProv
maciPubKey,
onSignup,
onVote,
gatekeeperTrait,
}),
[
isLoading,
Expand All @@ -441,6 +442,7 @@ export const MaciProvider: React.FC<MaciProviderProps> = ({ children }: MaciProv
maciPubKey,
onSignup,
onVote,
gatekeeperTrait,
],
);

Expand Down
3 changes: 2 additions & 1 deletion packages/interface/src/contexts/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type TallyData, type IGetPollData } from "maci-cli/sdk";
import { type TallyData, type IGetPollData, type GatekeeperTrait } from "maci-cli/sdk";
import { type ReactNode } from "react";

import type { Ballot, Vote } from "~/features/ballot/types";
Expand All @@ -20,6 +20,7 @@ export interface MaciContextType {
pollData?: IGetPollData;
tallyData?: TallyData;
maciPubKey?: string;
gatekeeperTrait?: GatekeeperTrait;
onSignup: (onError: () => void) => Promise<void>;
onVote: (
args: IVoteArgs[],
Expand Down
10 changes: 9 additions & 1 deletion packages/interface/src/layouts/DefaultLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { GatekeeperTrait } from "maci-cli/sdk";
import { type ReactNode, type PropsWithChildren, useMemo } from "react";
import { useAccount } from "wagmi";

Expand Down Expand Up @@ -25,7 +26,7 @@ export const Layout = ({ children = null, ...props }: ILayoutProps): JSX.Element
const { address } = useAccount();
const appState = useAppState();
const { ballot } = useBallot();
const { isRegistered } = useMaci();
const { isRegistered, gatekeeperTrait } = useMaci();

const navLinks = useMemo(() => {
const links = [
Expand Down Expand Up @@ -63,6 +64,13 @@ export const Layout = ({ children = null, ...props }: ILayoutProps): JSX.Element
href: "/applications",
children: "Applications",
},
],
);
}

if (config.admin === address! && gatekeeperTrait === GatekeeperTrait.EAS) {
links.push(
...[
{
href: "/voters",
children: "Voters",
Expand Down

0 comments on commit 4a464f9

Please sign in to comment.