Skip to content

Commit

Permalink
chore: rename functions and file structure, update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kittybest committed Jan 31, 2025
1 parent c3de9da commit aea5e0f
Show file tree
Hide file tree
Showing 44 changed files with 369 additions and 405 deletions.
9 changes: 5 additions & 4 deletions docs/01_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ pnpm initPoll:NETWORK --poll [poll-id]

The `.env.example` file in the `packages/interface/` folder contains instructions for most of these steps.

At the very minimum you need to configure a **subgraph**, **admin address**, **MACI address**, the **EAS Schema** and the **application registration periods** under App Configuration.
At the very minimum you need to configure a **subgraph**, **admin address**, and **MACI address** under App Configuration.
If you're using EAS Gatekeeper, add **EAS Schema** as well.

### Subgraph

Expand Down Expand Up @@ -197,7 +198,7 @@ cd ../../packages/subgraph/

The default configuration is Optimism Sepolia for development and Optimism for production.

You can find supported networks on the EAS documentation website: https://docs.attest.sh/docs/quick--start/contracts
For using EAS Gatekeeper, you can find supported networks on the EAS documentation website: https://docs.attest.sh/docs/quick--start/contracts

#### App

Expand All @@ -215,9 +216,9 @@ To create your own round you need to do the following:

#### EAS

If you are running on a different network than Optimism Sepolia, just change the `NEXT_PUBLIC_CHAIN_NAME` to your network. Please head to `src/config.ts` to see which networks are available in the config file. The EAS addresses are used to create attestations for either voters or projects.
If you are running on a different network than Optimism Sepolia, just change the `NEXT_PUBLIC_CHAIN_NAME` to your network. Please head to `src/config.ts` to see which networks are available in the config file. The EAS addresses are used to create attestations for either voters if you're using EAS Gatekeeper.

If using EAS, it is required to create a schema on the network you choose to use. Once it's created, you can add the IDs to `NEXT_PUBLIC_APPROVAL_SCHEMA` and `NEXT_PUBLIC_METADATA_SCHEMA`. Please note that the schema IDs in the `.env.example` file work on Optimism Sepolia only.
When using EAS, it is required to create a schema on the network you choose to use. Once it's created, you can add the IDs to `NEXT_PUBLIC_APPROVAL_SCHEMA`. Please note that the schema IDs in the `.env.example` file work on Optimism Sepolia only.

You can also configure your own schemas here if you wish to, or deploy the EAS contracts to a network that doesn't have them.

Expand Down
21 changes: 9 additions & 12 deletions docs/02_adding_projects.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Adding projects

- Navigate to https://maci-platform.vercel.app/applications/new (replace the domain with your deployment)
- Navigate to https://maci-platform.vercel.app/rounds/:roundId/requests/new (replace the domain with your deployment)
- Fill out profile fields with name, profile image and banner image
- Fill out application fields
- **name** - the name to be displayed
Expand All @@ -11,21 +11,18 @@
- **contributionLinks** - links to contributions
- **fundingSources** - list your funding sources

This will create an Attestation with the Metadata schema and populate the fields:
This will create a request with the Metadata to the registry contract.

- `type: "application"`
- `roundId: NEXT_PUBLIC_ROUND_ID`
## Reviewing and approving requests

## Reviewing and approving applications

- Navigate to https://maci-platform.vercel.app/applications (replace the domain with your deployment)
- Navigate to https://maci-platform.vercel.app/rounds/:roundId/requests (replace the domain with your deployment)
- Make sure you have configured `NEXT_PUBLIC_ADMIN_ADDRESS` with the address you connect your wallet with
- You will see a list of submitted applications
- Press each of them to open the application
- Select the applications you want to approve
- Press Approve button to create attestations for these projects (send transaction to confirm)
- You will see a list of submitted requests
- Press each of them to check the request detail
- Select the requests you want to approve
- Press Approve button to submit approval on registry contract for these projects (send transaction to confirm)

> It can take 10 minutes for the applications to be approved in the UI
> It can take 10 minutes for the requests to be approved in the UI
[<img width="100%" src="https://cdn.loom.com/sessions/thumbnails/cfe9bb7ad0b44aaca4d26a446006386a-with-play.gif" width="50%">](https://www.loom.com/embed/cfe9bb7ad0b44aaca4d26a446006386a?sid=a3765630-b097-41bb-aa8b-7600b6901fe4)

Expand Down
6 changes: 3 additions & 3 deletions docs/04_voting.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ Once applications have been approved and the voters' addresses have been added,

- Navigate to https://maci-platform.vercel.app/signup
- Click `Join` button to signup and wait for transaction confirmation
- After signing up, you could navigate to https://maci-platform.vercel.app/projects and click the `Add` button on the project card or add your vote amount in the project details page (https://maci-platform.vercel.app/projects/:projectId)
- Click `Ballot` on the navbar to navigate to the ballot page (https://maci-platform.vercel.app/ballot)
- After signing up, you could navigate to https://maci-platform.vercel.app/rounds/:roundId and click the `Add` button on the project card or add your vote amount in the project details page (https://maci-platform.vercel.app/rounds/:roundId/:projectId)
- Click `Ballot` on the navbar to navigate to the ballot page (https://maci-platform.vercel.app/rounds/:roundId/ballot)
- Adjust the allocation
- Click `Submit` and send the transaction
- If you change your mind, just modify them and press submit again

As a coordinator, you need to tally the poll results and publish them using CDN (see `NEXT_PUBLIC_TALLY_URL` env variable). See [maci docs](https://maci.pse.dev/docs/integrating#poll-finalization) for more information.
As a coordinator, you need to tally the poll results and publish them using command `submitOnChain`. See [maci docs](https://maci.pse.dev/docs/integrating#poll-finalization) for more information.

:::info
Please be advised that due to the block gas limit for most EVM networks, the number of votes that can be sent in one batch has been limited to 50. The effort to increase the limit is tracked [here](https://github.com/privacy-scaling-explorations/maci-platform/issues/31). For a list of supported networks and maximum number of votes per batch, please refer to [MACI docs](https://maci.pse.dev/docs/developers-references/smart-contracts/SupportedNetworks).
Expand Down
10 changes: 2 additions & 8 deletions docs/05_results.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
# Results

Once the voting has ended you can view the results. There's an env variable `NEXT_PUBLIC_TALLY_URL`. As a coordinator you need to upload `tally-{pollId}.json` file. Make sure the poll id in the file name is the same as current one.
Once the voting has ended you can view the results. As a coordinator you need to run `submitOnChain:network` in the `contracts` package.

- https://maci-platform.vercel.app/projects/results
- https://maci-platform.vercel.app/rounds/:roundId/results

![](./images/voting_ended_sidebar.png)

You can also see statistics of the round:

- https://maci-platform.vercel.app/stats

![](./images/stats.png)
6 changes: 3 additions & 3 deletions packages/interface/src/components/EligibilityDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,18 @@ export const EligibilityDialog = ({ pollId = "" }: IEligibilityDialogProps): JSX
}, [disconnect]);

const handleGoToCreateApp = useCallback(() => {
router.push(`/rounds/${pollId}/applications/new`);
router.push(`/rounds/${pollId}/requests/new`);
}, [router, pollId]);

if (roundState === ERoundState.APPLICATION) {
return (
<Dialog
button="secondary"
buttonAction={handleGoToCreateApp}
buttonName="Create Application"
buttonName="Create Project Request"
description={
<div className="flex flex-col gap-4">
<p>Start creating your own application now!</p>
<p>Start creating your own project now!</p>
</div>
}
isOpen={openDialog}
Expand Down
2 changes: 1 addition & 1 deletion packages/interface/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const Header = ({ navLinks, pollId = "" }: IHeaderProps) => {

// the URI of round index page looks like: /rounds/:pollId, without anything else, which is the reason why the length is 3
const isRoundProjectPage = useMemo(
() => asPath.includes("rounds") && !asPath.includes("applications") && !asPath.includes("ballot"),
() => asPath.includes("rounds") && !asPath.includes("requests") && !asPath.includes("ballot"),
[asPath],
);

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { createElement } from "react";

import { Heading } from "~/components/ui/Heading";
import { Markdown } from "~/components/ui/Markdown";
import { type Application } from "~/features/applications/types";
import { type Metadata } from "~/features/requests/types";

import { LinkBox } from "./LinkBox";

interface IProjectContributionsProps {
isLoading: boolean;
project?: Application;
project?: Metadata;
}

const ProjectContributions = ({ isLoading, project = undefined }: IProjectContributionsProps): JSX.Element => (
Expand Down
6 changes: 3 additions & 3 deletions packages/interface/src/features/projects/hooks/useProjects.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Chain, Hex } from "viem";

import { type Application } from "~/features/applications/types";
import { type Metadata } from "~/features/requests/types";
import { useMetadata } from "~/hooks/useMetadata";
import { api } from "~/utils/api";

Expand Down Expand Up @@ -33,8 +33,8 @@ export function useSearchProjects({
);
}

export function useProjectMetadata(metadataPtr?: string): UseTRPCQueryResult<Application, unknown> {
return useMetadata<Application>(metadataPtr);
export function useProjectMetadata(metadataPtr?: string): UseTRPCQueryResult<Metadata, unknown> {
return useMetadata<Metadata>(metadataPtr);
}

export function useProjectCount({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Button } from "~/components/ui/Button";
import { useIsAdmin } from "~/hooks/useIsAdmin";
import { useIsCorrectNetwork } from "~/hooks/useIsCorrectNetwork";

import type { TApplicationsToApprove } from "../types";
import type { TRequestsToApprove } from "../types";

interface IApproveButtonProps {
isLoading?: boolean;
Expand All @@ -13,10 +13,10 @@ interface IApproveButtonProps {
export const ApproveButton = ({ isLoading = false }: IApproveButtonProps): JSX.Element => {
const isAdmin = useIsAdmin();
const { isCorrectNetwork, correctNetwork } = useIsCorrectNetwork();
const form = useFormContext<TApplicationsToApprove>();
const form = useFormContext<TRequestsToApprove>();
const selectedCount = Object.values(form.watch("selected")).filter(Boolean).length;

const text = isAdmin ? `Approve ${selectedCount} applications` : "You must be an admin";
const text = isAdmin ? `Approve ${selectedCount} requests` : "You must be an admin";

return (
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { ErrorMessage, Label } from "~/components/ui/Form";
import { Tag } from "~/components/ui/Tag";
import { impactCategories } from "~/config";

import { ApplicationSchema } from "../types";
import { MetadataSchema } from "../types";

export const ImpactTags = (): JSX.Element => {
const { control, watch, formState } = useFormContext<z.infer<typeof ApplicationSchema>>();
const { control, watch, formState } = useFormContext<z.infer<typeof MetadataSchema>>();
const { field } = useController({
name: "impactCategory",
control,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,37 @@ import { Dialog } from "~/components/ui/Dialog";
import { Spinner } from "~/components/ui/Spinner";
import { useIsCorrectNetwork } from "~/hooks/useIsCorrectNetwork";

import type { Application } from "../types";
import type { Metadata } from "../types";
import type { ImpactMetrix, ContributionLink, FundingSource } from "~/features/projects/types";

export enum EApplicationStep {
export enum EMetadataStep {
PROFILE,
ADVANCED,
REVIEW,
}

interface IApplicationButtonsProps {
step: EApplicationStep;
interface IMetadataButtonsProps {
step: EMetadataStep;
isUploading: boolean;
isPending: boolean;
onNextStep: () => void;
onBackStep: () => void;
}

export const ApplicationButtons = ({
export const MetadataButtons = ({
step,
isUploading,
isPending,
onNextStep,
onBackStep,
}: IApplicationButtonsProps): JSX.Element => {
}: IMetadataButtonsProps): JSX.Element => {
const { isCorrectNetwork } = useIsCorrectNetwork();

const { address } = useAccount();

const [showDialog, setShowDialog] = useState<boolean>(false);

const form = useFormContext<Application>();
const form = useFormContext<Metadata>();

const [
name,
Expand Down Expand Up @@ -75,7 +75,7 @@ export const ApplicationButtons = ({
links === undefined || links.every((link) => link.description !== undefined && link.description.length > 0);

const checkStepComplete = (): boolean => {
if (step === EApplicationStep.PROFILE) {
if (step === EMetadataStep.PROFILE) {
return (
bannerImageUrl !== undefined &&
profileImageUrl !== undefined &&
Expand All @@ -86,7 +86,7 @@ export const ApplicationButtons = ({
);
}

if (step === EApplicationStep.ADVANCED) {
if (step === EMetadataStep.ADVANCED) {
return (
impactCategory !== undefined &&
impactCategory.length > 0 &&
Expand Down Expand Up @@ -135,19 +135,19 @@ export const ApplicationButtons = ({
onOpenChange={handleOnOpenChange}
/>

{step !== EApplicationStep.PROFILE && (
{step !== EMetadataStep.PROFILE && (
<Button className="text-gray-300 underline" size="auto" variant="ghost" onClick={handleOnClickBackStep}>
Back
</Button>
)}

{step !== EApplicationStep.REVIEW && (
{step !== EMetadataStep.REVIEW && (
<Button size="auto" variant="primary" onClick={handleOnClickNextStep}>
Next
</Button>
)}

{step === EApplicationStep.REVIEW && (
{step === EMetadataStep.REVIEW && (
<IconButton
disabled={isPending || !address || !isCorrectNetwork}
icon={isPending ? Spinner : null}
Expand Down
Loading

0 comments on commit aea5e0f

Please sign in to comment.