Skip to content

Commit

Permalink
feat(cli): add sdk command to get eas gatekeeper data (privacy-scalin…
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlc03 authored Jul 26, 2024
1 parent e7aa4dd commit bd894d8
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 30 deletions.
1 change: 1 addition & 0 deletions cli/ts/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export {
getGatekeeperTrait,
getSemaphoreGatekeeperData,
getZupassGatekeeperData,
getEASGatekeeperData,
} from "./signup";
export { verify } from "./verify";
export { genProofs } from "./genProofs";
Expand Down
30 changes: 30 additions & 0 deletions cli/ts/commands/signup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
SignUpGatekeeper__factory as SignUpGatekeeperFactory,
SemaphoreGatekeeper__factory as SemaphoreGatekeeperFactory,
ZupassGatekeeper__factory as ZupassGatekeeperFactory,
EASGatekeeper__factory as EASGatekeeperFactory,
} from "maci-contracts/typechain-types";
import { PubKey } from "maci-domainobjs";

Expand All @@ -16,6 +17,7 @@ import type {
IGetGatekeeperDataArgs,
ISemaphoreGatekeeperData,
IZupassGatekeeperData,
IEASGatekeeperData,
} from "../utils/interfaces";

import { banner } from "../utils/banner";
Expand Down Expand Up @@ -241,3 +243,31 @@ export const getZupassGatekeeperData = async ({
signer2: validSigner2.toString(),
};
};

/**
* Get the EAS gatekeeper data
* @param IGetGatekeeperDataArgs - The arguments for the get eas gatekeeper data command
* @returns The eas gatekeeper data
*/
export const getEASGatekeeperData = async ({
maciAddress,
signer,
}: IGetGatekeeperDataArgs): Promise<IEASGatekeeperData> => {
const maciContract = MACIFactory.connect(maciAddress, signer);

const gatekeeperContractAddress = await maciContract.signUpGatekeeper();

const gatekeeperContract = EASGatekeeperFactory.connect(gatekeeperContractAddress, signer);

const [eas, schema, attester] = await Promise.all([
gatekeeperContract.eas(),
gatekeeperContract.schema(),
gatekeeperContract.attester(),
]);

return {
eas: eas.toString(),
schema: schema.toString(),
attester: attester.toString(),
};
};
2 changes: 2 additions & 0 deletions cli/ts/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
getGatekeeperTrait,
getSemaphoreGatekeeperData,
getZupassGatekeeperData,
getEASGatekeeperData,
} from "../commands/signup";
import { verify } from "../commands/verify";

Expand All @@ -29,6 +30,7 @@ export {
getGatekeeperTrait,
getSemaphoreGatekeeperData,
getZupassGatekeeperData,
getEASGatekeeperData,
};

export type { ISnarkJSVerificationKey } from "maci-circuits";
Expand Down
1 change: 1 addition & 0 deletions cli/ts/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export type {
ISemaphoreGatekeeperData,
IGetGatekeeperDataArgs,
IZupassGatekeeperData,
IEASGatekeeperData,
} from "./interfaces";
export { GatekeeperTrait } from "./interfaces";
export { compareVks } from "./vks";
Expand Down
23 changes: 23 additions & 0 deletions cli/ts/utils/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,9 @@ export interface ISemaphoreGatekeeperData {
groupId: string;
}

/**
* Interface for the zupass gatekeeper data
*/
export interface IZupassGatekeeperData {
/**
* The event ID
Expand All @@ -1192,3 +1195,23 @@ export interface IZupassGatekeeperData {
*/
signer2: string;
}

/**
* Interface for the EAS gatekeeper data
*/
export interface IEASGatekeeperData {
/**
* The EAS
*/
eas: string;

/**
* The schema
*/
schema: string;

/**
* The attester
*/
attester: string;
}
30 changes: 0 additions & 30 deletions contracts/contracts/trees/EmptyBallotRoots.sol

This file was deleted.

0 comments on commit bd894d8

Please sign in to comment.