Skip to content

Commit

Permalink
refactor: cleanup contracts folder
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlc03 committed Dec 2, 2024
1 parent 38cbf66 commit 6382da6
Show file tree
Hide file tree
Showing 30 changed files with 60 additions and 64 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,5 @@ packages/cli/contractAddresses.old.json
packages/circuits/circom/test

**/ts/__benchmarks__/results/**

proofs
6 changes: 2 additions & 4 deletions packages/contracts/contracts/MACI.sol
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,11 @@ contract MACI is IMACI, DomainObjs, Params, Utilities {
// Get the user's voice credit balance.
uint256 voiceCreditBalance = initialVoiceCreditProxy.getVoiceCredits(msg.sender, _initialVoiceCreditProxyData);

uint256 timestamp = block.timestamp;

// Create a state leaf and insert it into the tree.
uint256 stateLeaf = hashStateLeaf(StateLeaf(_pubKey, voiceCreditBalance, timestamp));
uint256 stateLeaf = hashStateLeaf(StateLeaf(_pubKey, voiceCreditBalance, block.timestamp));
InternalLazyIMT._insert(lazyIMTData, stateLeaf);

emit SignUp(lazyIMTData.numberOfLeaves - 1, _pubKey.x, _pubKey.y, voiceCreditBalance, timestamp);
emit SignUp(lazyIMTData.numberOfLeaves - 1, _pubKey.x, _pubKey.y, voiceCreditBalance, block.timestamp);
}

/// @notice Deploy a new Poll contract.
Expand Down
5 changes: 1 addition & 4 deletions packages/contracts/contracts/Poll.sol
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,7 @@ contract Poll is Params, Utilities, SnarkCommon, IPoll {
/// @dev Can only be submitted before the voting deadline
/// @param _messages the messages
/// @param _encPubKeys the encrypted public keys
function publishMessageBatch(
Message[] calldata _messages,
PubKey[] calldata _encPubKeys
) public virtual isWithinVotingDeadline {
function publishMessageBatch(Message[] calldata _messages, PubKey[] calldata _encPubKeys) public virtual {

Check warning

Code scanning / Slither

Conformance to Solidity naming conventions Warning

Check warning

Code scanning / Slither

Conformance to Solidity naming conventions Warning

if (_messages.length != _encPubKeys.length) {
revert InvalidBatchLength();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/contracts/Tally.sol
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,10 @@ contract Tally is Ownable, SnarkCommon, CommonUtilities, Hasher, DomainObjs, ITa
TallyResult storage previous = tallyResults[_voteOptionIndex];

if (!previous.flag) {
previous.flag = true;
totalTallyResults++;
}

previous.flag = true;
previous.value = _tallyResult;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
pragma solidity ^0.8.20;

import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";

import { SignUpGatekeeper } from "./SignUpGatekeeper.sol";
import { IAnonAadhaar } from "../interfaces/IAnonAadhaar.sol";
import { IAnonAadhaar } from "./interfaces/IAnonAadhaar.sol";

/// @title AnonAadhaarGatekeeper
/// @notice A gatekeeper contract which allows users to sign up to MACI
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/contracts/gatekeepers/EASGatekeeper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.20;
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";

import { SignUpGatekeeper } from "./SignUpGatekeeper.sol";
import { IEAS } from "../interfaces/IEAS.sol";
import { IEAS } from "./interfaces/IEAS.sol";

/// @title EASGatekeeper
/// @notice A gatekeeper contract which allows users to sign up to MACI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.20;
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";

import { SignUpGatekeeper } from "./SignUpGatekeeper.sol";
import { IGitcoinPassportDecoder } from "../interfaces/IGitcoinPassportDecoder.sol";
import { IGitcoinPassportDecoder } from "./interfaces/IGitcoinPassportDecoder.sol";

/// @title GitcoinPassportGatekeeper
/// @notice A gatekeeper contract which allows users to sign up to MACI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.10;

import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";

import { IHats } from "../interfaces/IHats.sol";
import { IHats } from "./interfaces/IHats.sol";
import { SignUpGatekeeper } from "./SignUpGatekeeper.sol";

/// @title HatsGatekeeperBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.20;
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";

import { SignUpGatekeeper } from "./SignUpGatekeeper.sol";
import { ISemaphore } from "../interfaces/ISemaphore.sol";
import { ISemaphore } from "./interfaces/ISemaphore.sol";

/// @title SemaphoreGatekeeper
/// @notice A gatekeeper contract which allows users to sign up to MACI
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import { SnarkConstants } from "./SnarkConstants.sol";
import { SnarkCommon } from "./SnarkCommon.sol";
import { SnarkConstants } from "../crypto/SnarkConstants.sol";
import { SnarkCommon } from "../crypto/SnarkCommon.sol";
import { IVerifier } from "../interfaces/IVerifier.sol";

/// @title MockVerifier
Expand Down
16 changes: 7 additions & 9 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,19 @@
"test:tallyNonQv": "pnpm run test ./tests/TallyNonQv.test.ts",
"test:hasher": "pnpm run test ./tests/Hasher.test.ts",
"test:utilities": "pnpm run test ./tests/Utilities.test.ts",
"test:signupGatekeeper": "pnpm run test ./tests/SignUpGatekeeper.test.ts",
"test:signupGatekeeper": "pnpm run test ./tests/gatekeepers/SignUpGatekeeper.test.ts",
"test:verifier": "pnpm run test ./tests/Verifier.test.ts",
"test:accQueue": "pnpm run test ./tests/AccQueue.test.ts",
"test:accQueueBenchmark": "pnpm run test ./tests/AccQueueBenchmark.test.ts",
"test:hasherBenchmarks": "pnpm run test ./tests/HasherBenchmarks.test.ts",
"test:vkRegistry": "pnpm run test ./tests/VkRegistry.test.ts",
"test:pollFactory": "pnpm run test ./tests/PollFactory.test.ts",
"test:eas_gatekeeper": "pnpm run test ./tests/EASGatekeeper.test.ts",
"test:hats_gatekeeper": "pnpm run test ./tests/HatsGatekeeper.test.ts",
"test:gitcoin_gatekeeper": "pnpm run test ./tests/GitcoinPassportGatekeeper.test.ts",
"test:zupass_gatekeeper": "pnpm run test ./tests/ZupassGatekeeper.test.ts",
"test:semaphore_gatekeeper": "pnpm run test ./tests/SemaphoreGatekeeper.test.ts",
"test:anon_aadhaar_gatekeeper": "pnpm run test ./tests/AnonAadhaarGatekeeper.test.ts",
"test:simpleProjectRegistry": "pnpm run test ./tests/extensions/SimpleProjectRegistry.test.ts",
"test:simplePayout": "pnpm run test ./tests/extensions/SimplePayout.test.ts",
"test:eas_gatekeeper": "pnpm run test ./tests/gatekeepers/EASGatekeeper.test.ts",
"test:hats_gatekeeper": "pnpm run test ./tests/gatekeepers/HatsGatekeeper.test.ts",
"test:gitcoin_gatekeeper": "pnpm run test ./tests/gatekeepers/GitcoinPassportGatekeeper.test.ts",
"test:zupass_gatekeeper": "pnpm run test ./tests/gatekeepers/ZupassGatekeeper.test.ts",
"test:semaphore_gatekeeper": "pnpm run test ./tests/gatekeepers/SemaphoreGatekeeper.test.ts",
"test:anon_aadhaar_gatekeeper": "pnpm run test ./tests/gatekeepers/AnonAadhaarGatekeeper.test.ts",
"deploy": "hardhat deploy-full",
"deploy-poll": "hardhat deploy-poll",
"verify": "hardhat verify-full",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { expect } from "chai";
import { AbiCoder, Signer, ZeroAddress } from "ethers";
import { Keypair } from "maci-domainobjs";

import { deployAnonAadhaarGatekeeper, deployContract } from "../ts/deploy";
import { getDefaultSigner, getSigners } from "../ts/utils";
import { MACI, AnonAadhaarGatekeeper, MockAnonAadhaar } from "../typechain-types";
import { deployAnonAadhaarGatekeeper, deployContract } from "../../ts/deploy";
import { getDefaultSigner, getSigners } from "../../ts/utils";
import { MACI, AnonAadhaarGatekeeper, MockAnonAadhaar } from "../../typechain-types";

Check failure on line 7 in packages/contracts/tests/gatekeepers/AnonAadhaarGatekeeper.test.ts

View workflow job for this annotation

GitHub Actions / check (lint:ts)

There should be no empty line within import group

import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "./constants";
import { deployTestContracts } from "./utils";
import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "../constants";
import { deployTestContracts } from "../utils";

describe("AnonAadhaar Gatekeeper", () => {
let anonAadhaarGatekeeper: AnonAadhaarGatekeeper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { expect } from "chai";
import { AbiCoder, Signer, ZeroAddress, toBeArray } from "ethers";
import { Keypair } from "maci-domainobjs";

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

Check failure on line 7 in packages/contracts/tests/gatekeepers/EASGatekeeper.test.ts

View workflow job for this annotation

GitHub Actions / check (lint:ts)

There should be no empty line within import group

import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "./constants";
import { deployTestContracts } from "./utils";
import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "../constants";
import { deployTestContracts } from "../utils";

describe("EAS Gatekeeper", () => {
let easGatekeeper: EASGatekeeper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { expect } from "chai";
import { AbiCoder, Signer, ZeroAddress } from "ethers";
import { Keypair } from "maci-domainobjs";

import { deployContract, getDefaultSigner, getSigners } from "../ts";
import { GitcoinPassportGatekeeper, MACI, MockGitcoinPassportDecoder } from "../typechain-types";
import { deployContract, getDefaultSigner, getSigners } from "../../ts";
import { GitcoinPassportGatekeeper, MACI, MockGitcoinPassportDecoder } from "../../typechain-types";

Check failure on line 6 in packages/contracts/tests/gatekeepers/GitcoinPassportGatekeeper.test.ts

View workflow job for this annotation

GitHub Actions / check (lint:ts)

There should be no empty line within import group

import { initialVoiceCreditBalance, STATE_TREE_DEPTH } from "./constants";
import { deployTestContracts } from "./utils";
import { initialVoiceCreditBalance, STATE_TREE_DEPTH } from "../constants";
import { deployTestContracts } from "../utils";

describe("GitcoinPassport Gatekeeper", () => {
let gitcoinGatekeeper: GitcoinPassportGatekeeper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { expect } from "chai";
import { AbiCoder, Signer, ZeroAddress } from "ethers";
import { Keypair } from "maci-domainobjs";

import { deployContract } from "../ts/deploy";
import { getSigners } from "../ts/utils";
import { HatsGatekeeperMultiple, HatsGatekeeperSingle, MACI, MockHatsProtocol } from "../typechain-types";
import { deployContract } from "../../ts/deploy";
import { getSigners } from "../../ts/utils";
import { HatsGatekeeperMultiple, HatsGatekeeperSingle, MACI, MockHatsProtocol } from "../../typechain-types";

Check failure on line 7 in packages/contracts/tests/gatekeepers/HatsGatekeeper.test.ts

View workflow job for this annotation

GitHub Actions / check (lint:ts)

There should be no empty line within import group

import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "./constants";
import { deployTestContracts } from "./utils";
import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "../constants";
import { deployTestContracts } from "../utils";

describe("HatsProtocol Gatekeeper", () => {
let maciContract: MACI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { expect } from "chai";
import { AbiCoder, Signer, ZeroAddress, encodeBytes32String } from "ethers";
import { Keypair } from "maci-domainobjs";

import { deployContract } from "../ts/deploy";
import { getDefaultSigner, getSigners, generateMerkleTree } from "../ts/utils";
import { MerkleProofGatekeeper, MACI } from "../typechain-types";
import { deployContract } from "../../ts/deploy";
import { getDefaultSigner, getSigners, generateMerkleTree } from "../../ts/utils";
import { MerkleProofGatekeeper, MACI } from "../../typechain-types";

Check failure on line 8 in packages/contracts/tests/gatekeepers/MerkleProofGatekeeper.test.ts

View workflow job for this annotation

GitHub Actions / check (lint:ts)

There should be no empty line within import group

import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "./constants";
import { deployTestContracts } from "./utils";
import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "../constants";
import { deployTestContracts } from "../utils";

describe("MerkleProof Gatekeeper", () => {
let merkleProofGatekeeper: MerkleProofGatekeeper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { expect } from "chai";
import { AbiCoder, Signer, ZeroAddress } from "ethers";
import { Keypair } from "maci-domainobjs";

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

Check failure on line 7 in packages/contracts/tests/gatekeepers/SemaphoreGatekeeper.test.ts

View workflow job for this annotation

GitHub Actions / check (lint:ts)

There should be no empty line within import group

import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "./constants";
import { deployTestContracts } from "./utils";
import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "../constants";
import { deployTestContracts } from "../utils";

describe("Semaphore Gatekeeper", () => {
let semaphoreGatekeeper: SemaphoreGatekeeper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { expect } from "chai";
import { AbiCoder, ZeroAddress, Signer } from "ethers";
import { Keypair } from "maci-domainobjs";

import { deploySignupToken, deploySignupTokenGatekeeper, deployFreeForAllSignUpGatekeeper } from "../ts/deploy";
import { getDefaultSigner } from "../ts/utils";
import { FreeForAllGatekeeper, MACI, SignUpToken, SignUpTokenGatekeeper } from "../typechain-types";
import { deploySignupToken, deploySignupTokenGatekeeper, deployFreeForAllSignUpGatekeeper } from "../../ts/deploy";
import { getDefaultSigner } from "../../ts/utils";
import { FreeForAllGatekeeper, MACI, SignUpToken, SignUpTokenGatekeeper } from "../../typechain-types";

Check failure on line 7 in packages/contracts/tests/gatekeepers/SignUpGatekeeper.test.ts

View workflow job for this annotation

GitHub Actions / check (lint:ts)

There should be no empty line within import group

import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "./constants";
import { deployTestContracts } from "./utils";
import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "../constants";
import { deployTestContracts } from "../utils";

describe("SignUpGatekeeper", () => {
let signUpToken: SignUpToken;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { expect } from "chai";
import { AbiCoder, Signer, ZeroAddress } from "ethers";
import { Keypair } from "maci-domainobjs";

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

Check failure on line 7 in packages/contracts/tests/gatekeepers/ZupassGatekeeper.test.ts

View workflow job for this annotation

GitHub Actions / check (lint:ts)

There should be no empty line within import group

import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "./constants";
import { deployTestContracts } from "./utils";
import { STATE_TREE_DEPTH, initialVoiceCreditBalance } from "../constants";
import { deployTestContracts } from "../utils";

describe("Zupass Gatekeeper", () => {
let zupassGatekeeper: ZupassGatekeeper;
Expand Down

0 comments on commit 6382da6

Please sign in to comment.