Skip to content

Commit

Permalink
feat(contracts): add deploySemaphoreGatekeeper()
Browse files Browse the repository at this point in the history
  • Loading branch information
baumstern committed Jul 4, 2024
1 parent 4e7f9eb commit 7252d0e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions contracts/tests/SemaphoreGatekeeper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect } from "chai";
import { AbiCoder, Signer, ZeroAddress } from "ethers";
import { Keypair } from "maci-domainobjs";

import { deployContract } from "../ts/deploy";
import { deploySemaphoreGatekeeper, deployContract } from "../ts/deploy";
import { getDefaultSigner, getSigners } from "../ts/utils";
import { MACI, SemaphoreGatekeeper, MockSemaphore } from "../typechain-types";

Expand Down Expand Up @@ -65,7 +65,7 @@ describe("Semaphore Gatekeeper", () => {
mockSemaphore = await deployContract("MockSemaphore", signer, true, validGroupId);
const mockSemaphoreAddress = await mockSemaphore.getAddress();
signerAddress = await signer.getAddress();
semaphoreGatekeeper = await deployContract("SemaphoreGatekeeper", signer, true, mockSemaphoreAddress, validGroupId);
semaphoreGatekeeper = await deploySemaphoreGatekeeper(mockSemaphoreAddress, validGroupId, signer, true);
});

describe("Deployment", () => {
Expand Down
17 changes: 17 additions & 0 deletions contracts/ts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
MessageProcessorFactory__factory as MessageProcessorFactoryFactory,
TallyFactory__factory as TallyFactoryFactory,
GitcoinPassportGatekeeper,
SemaphoreGatekeeper,
} from "../typechain-types";

import { log } from "./utils";
Expand Down Expand Up @@ -167,6 +168,22 @@ export const deployGitcoinPassportGatekeeper = async (
minimumScore.toString(),
);

/**
* Deploy a SemaphoreGatekeeper contract
* @param semaphoreAddress - the address of the Semaphore contract
* @param groupId - The group id of the semaphore group
* @param signer - the signer to use to deploy the contract
* @param quiet - whether to suppress console output
* @returns the deployed SemaphoreGatekeeper contract
*/
export const deploySemaphoreGatekeeper = async (
semaphoreAddress: string,
groupId: bigint,
signer?: Signer,
quiet = false,
): Promise<SemaphoreGatekeeper> =>
deployContract<SemaphoreGatekeeper>("SemaphoreGatekeeper", signer, quiet, semaphoreAddress, groupId.toString());

/**
* Deploy Poseidon contracts
* @param signer - the signer to use to deploy the contracts
Expand Down
1 change: 1 addition & 0 deletions contracts/ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export {
deployConstantInitialVoiceCreditProxy,
deployFreeForAllSignUpGatekeeper,
deployGitcoinPassportGatekeeper,
deploySemaphoreGatekeeper,
deployPollFactory,
createContractFactory,
deployPoseidonContracts,
Expand Down

0 comments on commit 7252d0e

Please sign in to comment.