Skip to content

Commit

Permalink
Minor adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
joYyHack committed Aug 26, 2024
1 parent 5142f62 commit 83933b1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 77 deletions.
69 changes: 12 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,63 +1,18 @@
# Hardhat template
# Basic Implementation of ZK Multisig Smart Contracts

Template hardhat repository for ad-hoc smart contracts development.
This project consists of a basic implementation of ZK (Zero-Knowledge) multisig smart contracts.

### How to use
The contracts are divided into two parts:

The template works out of the box. To clean up the repo, you may need to delete the mock contracts, tests and migration files.
- **ZK Multisig Factory** - Manages and deploys multisig contracts.
- **ZK Multisig** - The implementation of the multisig contract itself.

#### Compilation
For more details, refer to the documentation: [Link to Documentation]

To compile the contracts, use the next script:
## Steps to Build the Project

```bash
npm run compile
```

#### Test

To run the tests, execute the following command:

```bash
npm run test
```

Or to see the coverage, run:

```bash
npm run coverage
```

#### Local deployment

To deploy the contracts locally, run the following commands (in the different terminals):

```bash
npm run private-network
npm run deploy-localhost
```

#### Bindings

The command to generate the bindings is as follows:

```bash
npm run generate-types
```

> See the full list of available commands in the `package.json` file.
### Integrated plugins

- Hardhat official `ethers` + `ethers-v6`
- [`Typechain`](https://www.npmjs.com/package/@typechain/hardhat)
- [`hardhat-migrate`](https://www.npmjs.com/package/@solarity/hardhat-migrate), [`hardhat-markup`](https://www.npmjs.com/package/@solarity/hardhat-markup), [`hardhat-gobind`](https://www.npmjs.com/package/@solarity/hardhat-gobind)
- [`hardhat-contract-sizer`](https://www.npmjs.com/package/hardhat-contract-sizer)
- [`hardhat-gas-reporter`](https://www.npmjs.com/package/hardhat-gas-reporter)
- [`solidity-coverage`](https://www.npmjs.com/package/solidity-coverage)

### Other niceties

- The template comes with presetup `prettier` and `solhint` that lint the project via `husky` before compilation hook.
- The `.env.example` file is provided to check what is required as ENVs
- Preinstalled `@openzeppelin/contracts` and `@solarity/solidity-lib`
1. Compile the contracts:
```bash
npm run compile
npm run test
```
20 changes: 8 additions & 12 deletions contracts/ZKMultisig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -188,20 +188,16 @@ contract ZKMultisig is UUPSUpgradeable, IZKMultisig {

function getProposalChallenge(uint256 proposalId_) public view returns (uint256) {
return
uint256(
PoseidonUnit1L.poseidon(
[
uint256(
uint248(
uint256(
keccak256(
abi.encode(block.chainid, address(this), proposalId_)
)
)
PoseidonUnit1L.poseidon(
[
uint256(
uint248(
uint256(
keccak256(abi.encode(block.chainid, address(this), proposalId_))
)
)
]
)
)
]
);
}

Expand Down
5 changes: 1 addition & 4 deletions contracts/ZKMultisigFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ contract ZKMultisigFactory is EIP712, IZKMultisigFactory {
address participantVerifier_
) EIP712("ZKMultisigFactory", "1") {
require(
zkMultisigImplementation_ != address(0) &&
zkMultisigImplementation_.code.length > 0 &&
participantVerifier_ != address(0) &&
participantVerifier_.code.length > 0,
zkMultisigImplementation_.code.length > 0 && participantVerifier_.code.length > 0,
"ZKMultisigFactory: Invalid implementation or verifier address"
);

Expand Down
2 changes: 1 addition & 1 deletion test/ZKMultisig.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe("ZKMultisig", () => {

await zkMultisigImpl.waitForDeployment();

var zkMultisigFactory__factory = await ethers.getContractFactory("ZKMultisigFactory");
const zkMultisigFactory__factory = await ethers.getContractFactory("ZKMultisigFactory");
zkMultisigFactory = await zkMultisigFactory__factory.deploy(
await zkMultisigImpl.getAddress(),
await positiveParticipantVerifier.getAddress(),
Expand Down
6 changes: 3 additions & 3 deletions test/ZKMultisigFactory.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ describe("ZKMultisig Factory", () => {
before(async () => {
[alice] = await ethers.getSigners();

var verifier__factory = await ethers.getContractFactory("PositiveVerifierMock");
const verifier__factory = await ethers.getContractFactory("PositiveVerifierMock");
participantVerifier = await verifier__factory.deploy();

await participantVerifier.waitForDeployment();

var zkMultisig__factory = await ethers.getContractFactory("ZKMultisig", {
const zkMultisig__factory = await ethers.getContractFactory("ZKMultisig", {
libraries: {
PoseidonUnit1L: await (await getPoseidon(1)).getAddress(),
},
Expand All @@ -46,7 +46,7 @@ describe("ZKMultisig Factory", () => {

await zkMultisig.waitForDeployment();

var zkMultisigFactory__factory = await ethers.getContractFactory("ZKMultisigFactory");
const zkMultisigFactory__factory = await ethers.getContractFactory("ZKMultisigFactory");
zkMultisigFactory = await zkMultisigFactory__factory.deploy(
await zkMultisig.getAddress(),
await participantVerifier.getAddress(),
Expand Down

0 comments on commit 83933b1

Please sign in to comment.